Skip to content

Commit

Permalink
Added estimated record time field to both the IMU datalogging forms. …
Browse files Browse the repository at this point in the history
…This field uses the measured data ready frequency and the number of requested samples to estimate the capture duration
  • Loading branch information
ajn96 committed Jul 19, 2022
1 parent de6e179 commit 18a00b2
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 30 deletions.
45 changes: 35 additions & 10 deletions src/IMUStreamingGUI.designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 33 additions & 3 deletions src/IMUStreamingGUI.vb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Public Class IMUStreamingGUI
Private WithEvents fileManager As Logger
Private manager As BurstManager
Private initialized As Boolean = False
Private totalDRCaptures As Integer = 0
Private measuredDrFreq As Double = Double.PositiveInfinity

''' <summary>
''' Load the application
Expand Down Expand Up @@ -136,7 +138,7 @@ Public Class IMUStreamingGUI
fileManager.RegList = manager.BurstRegisters
fileManager.FileBaseName = m_TopGUI.SelectedPersonality + "_Burst" + timeString
fileManager.FilePath = savePath
fileManager.Buffers = Convert.ToUInt32(text_numSamples.Text)
fileManager.Buffers = totalDRCaptures
fileManager.Captures = 1 'Number of times to read each register in the reg map
fileManager.FileMaxDataRows = 1000000 'Keep this under 1M samples to open in Excel
fileManager.BufferTimeoutSeconds = 10 'Timeout in seconds
Expand Down Expand Up @@ -201,7 +203,7 @@ Public Class IMUStreamingGUI
''' <param name="sender"></param>
''' <param name="e"></param>
Private Sub MeasureDR_Click(sender As Object, e As EventArgs) Handles btn_measureDR.Click
label_measuredFreq.Text = FormatNumber(m_TopGUI.FX3.ReadDRFreq(m_TopGUI.FX3.DrPin, 1, 2000), 3).ToString + " Hz"
MeasureDrFreq(2000)
End Sub

''' <summary>
Expand Down Expand Up @@ -242,6 +244,11 @@ Public Class IMUStreamingGUI
''' <param name="e"></param>
Private Sub check_drActive_CheckedChanged(sender As Object, e As EventArgs) Handles check_drActive.CheckedChanged
m_TopGUI.FX3.DrActive = check_drActive.Checked
If check_drActive.Checked Then
MeasureDrFreq(500)
Else
UpdateRecordTimeEstimate()
End If
End Sub

''' <summary>
Expand All @@ -252,11 +259,13 @@ Public Class IMUStreamingGUI
Private Sub text_numSamples_TextChanged(sender As Object, e As EventArgs) Handles text_numSamples.TextChanged
'Check DR capture input
Try
Convert.ToInt32(text_numSamples.Text)
totalDRCaptures = Convert.ToInt32(text_numSamples.Text)
Catch ex As Exception
MsgBox("ERROR: Invalid Input")
text_numSamples.Text = "10000"
totalDRCaptures = 10000
End Try
UpdateRecordTimeEstimate()
End Sub

''' <summary>
Expand All @@ -269,6 +278,12 @@ Public Class IMUStreamingGUI

#Region "Helper Functions"

Private Sub MeasureDrFreq(timeout As Integer)
measuredDrFreq = m_TopGUI.FX3.ReadDRFreq(m_TopGUI.FX3.DrPin, 1, 2000)
label_measuredFreq.Text = FormatNumber(measuredDrFreq, 3).ToString + " Hz"
UpdateRecordTimeEstimate()
End Sub

''' <summary>
''' Clean up after a burst read capture has completed
''' </summary>
Expand Down Expand Up @@ -322,6 +337,21 @@ Public Class IMUStreamingGUI
Next
End Sub

Private Sub UpdateRecordTimeEstimate()
If check_drActive.Checked Then
If Not Double.IsPositiveInfinity(measuredDrFreq) Then
Dim seconds As Integer = 0
seconds = totalDRCaptures / measuredDrFreq
Dim span As TimeSpan = TimeSpan.FromSeconds(seconds)
lab_recTime.Text = New DateTime(span.Ticks).ToString("HH:mm:ss")
Else
lab_recTime.Text = "No data ready detected"
End If
Else
lab_recTime.Text = "Async Capture"
End If
End Sub

#End Region

End Class
25 changes: 25 additions & 0 deletions src/RegisterBulkReadGUI.designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 35 additions & 17 deletions src/RegisterBulkReadGUI.vb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Public Class RegisterBulkReadGUI

Private WithEvents fileManager As Logger
Private totalDRCaptures As Integer = 0
Private measuredDrFreq As Double = Double.PositiveInfinity

Public Sub FormSetup() Handles Me.Load

Expand Down Expand Up @@ -153,13 +154,9 @@ Public Class RegisterBulkReadGUI
Private Sub MainButton_Click(sender As Object, e As EventArgs) Handles MainButton.Click

Dim savePath As String
Dim MeasuredFreq As Double = Double.PositiveInfinity
Dim timeString As String = "_" + DateTime.Now().ToString("s")
timeString = timeString.Replace(":", "-")

'Update the data ready pin and measurement
UpdateDRPin()

'Check whether user selected registers to stream
If selectedRegview.Items.Count <= 0 Then
MessageBox.Show("Please select registers to stream before starting", "No registers selected!", MessageBoxButtons.OK)
Expand All @@ -175,10 +172,9 @@ Public Class RegisterBulkReadGUI
'Check whether the measured DR is valid
If m_TopGUI.FX3.DrActive And ValidateDR.Checked Then
'measure data ready frequency
MeasuredFreq = m_TopGUI.FX3.MeasurePinFreq(m_TopGUI.FX3.DrPin, 1, 10000, 2)
DrFreq.Text = FormatNumber(MeasuredFreq, 3).ToString() + "Hz"
MeasureDrFreq(10000)
'allow a freq up to 16KHz
If MeasuredFreq > 16000 Or MeasuredFreq = Double.PositiveInfinity Then
If measuredDrFreq > 16000 Or measuredDrFreq = Double.PositiveInfinity Then
If MessageBox.Show("Data ready frequency measured invalid. Continue?", "Invalid Data Ready!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) <> DialogResult.OK Then
Exit Sub
End If
Expand All @@ -193,7 +189,7 @@ Public Class RegisterBulkReadGUI

'Check the time it will take to capture each frame and ask the user if it exceeds the DR period
If m_TopGUI.FX3.DrActive And ValidateDR.Checked Then
Dim drPeriod As Double = 1 / MeasuredFreq
Dim drPeriod As Double = 1 / measuredDrFreq
Dim num16bitregs As Integer = 0
For Each reg In regList
If reg.NumBytes = 1 Or reg.NumBytes = 2 Then
Expand Down Expand Up @@ -306,8 +302,7 @@ Public Class RegisterBulkReadGUI
End Sub

Private Sub MeasureDR_Click(sender As Object, e As EventArgs) Handles MeasureDR.Click
UpdateDRPin()
DrFreq.Text = FormatNumber(m_TopGUI.FX3.MeasurePinFreq(m_TopGUI.FX3.DrPin, 1, 5000, 2), 3).ToString + " Hz"
MeasureDrFreq(5000)
End Sub

Private Sub UpdateDRPin()
Expand Down Expand Up @@ -335,7 +330,7 @@ Public Class RegisterBulkReadGUI
End If
End Sub

Private Sub UpdateGUI()
Private Sub NumberDRToCapture_TextChanged(sender As Object, e As EventArgs) Handles NumberDRToCapture.TextChanged
'Check DR capture input
If NumberDRToCapture.Text = "" Then
NumberDRToCapture.Text = 0
Expand All @@ -346,17 +341,18 @@ Public Class RegisterBulkReadGUI
MsgBox("ERROR: Invalid Input")
Exit Sub
End Try
End Sub

Private Sub NumberDRToCapture_TextChanged(sender As Object, e As EventArgs) Handles NumberDRToCapture.TextChanged
UpdateGUI()
UpdateRecordTimeEstimate()
End Sub

Private Sub DrActiveBox_CheckedChanged(sender As Object, e As EventArgs) Handles DrActiveBox.CheckedChanged
m_TopGUI.FX3.DrActive = DrActiveBox.Checked
MeasureDR.Enabled = m_TopGUI.FX3.DrActive
ValidateDR.Enabled = m_TopGUI.FX3.DrActive
MeasureDR.Enabled = DrActiveBox.Checked
ValidateDR.Enabled = DrActiveBox.Checked
ValidateDR.Checked = DrActiveBox.Checked
If DrActiveBox.Checked Then
MeasureDrFreq(500)
End If
UpdateRecordTimeEstimate()
End Sub

Private Sub btn_loadregs_Click(sender As Object, e As EventArgs) Handles btn_loadregs.Click
Expand Down Expand Up @@ -405,4 +401,26 @@ Public Class RegisterBulkReadGUI

End Sub

Private Sub MeasureDrFreq(timeout As Integer)
UpdateDRPin()
measuredDrFreq = m_TopGUI.FX3.MeasurePinFreq(m_TopGUI.FX3.DrPin, 1, timeout, 2)
DrFreq.Text = FormatNumber(measuredDrFreq, 3).ToString + " Hz"
UpdateRecordTimeEstimate()
End Sub

Private Sub UpdateRecordTimeEstimate()
If DrActiveBox.Checked Then
If Not Double.IsPositiveInfinity(measuredDrFreq) Then
Dim seconds As Integer = 0
seconds = totalDRCaptures / measuredDrFreq
Dim span As TimeSpan = TimeSpan.FromSeconds(seconds)
label_recTime.Text = New DateTime(span.Ticks).ToString("HH:mm:ss")
Else
label_recTime.Text = "No data ready detected"
End If
Else
label_recTime.Text = "Async Capture"
End If
End Sub

End Class

0 comments on commit 18a00b2

Please sign in to comment.