📄 signalfrm.frm
字号:
ReceivedSignal.Data = 0
Next i
End Sub
Private Function Transmit_Signal() As Long
'#######################################################################
' This fuction is called by the procedure, tmr_MethodDispatch_Timer().
' It's job is to generate a sine wave signal of a specified sample size
' and display it on the transmitted signal chart. Afterwards, the
' function attempts to transmit the signal to the target. The status of
' the method call, Write(), is returned to tmr_MethodDispatch().
'#######################################################################
Dim i As Integer ' index variable for loop
Dim samples(0 To (SAMPLE_SIZE - 1)) As Long ' array of 32-bit integer
' samples
Dim bufferstate As Long ' buffer State
' Gather samples and update "transmitted signal chart"
For i = LBound(samples) To UBound(samples)
samples(i) = Int(Sin(i * (Pi / 8)) * 100) ' generate sample
TransmittedSignal.Row = i + 1 ' set focus to row number i + 1
TransmittedSignal.Data = samples(i) ' clear data at row
Next i
status = toDSP.Write(CVar(samples), bufferstate) ' write array to target
Transmit_Signal = status ' return status
End Function
Private Function Receive_Signal() As Long
'#######################################################################
' This function is called by the procedure, tmr_MethodDispatch_Timer().
' It's job is to read a signal from the target (DSP) and display it on
' the signal reception chart. The status of the method call, ReadSAI4,
' is returned to tmr_MethodDispatch().
'#######################################################################
Dim parray As Variant ' pointer to SAFEARRAY
Dim i As Long ' index variable for loop
status = fromDSP.ReadSAI4(parray) ' read data back from target
If (status = SUCCESS) Then
' Update "received signal chart"
For i = LBound(parray) To UBound(parray)
ReceivedSignal.Row = i + 1 ' set focus to row number i + 1
ReceivedSignal.Data = parray(i) ' clear data at row
Next i
End If
ReceiveSignal = status ' return status
End Function
Private Sub cmd_Toggle_Click()
'#######################################################################
' This procedure is a handler for the command button control. Its job
' is either to start or stop the test.
'#######################################################################
' Test caption for starting or stopping test
If (cmd_Toggle.Caption = START_CAPTION) Then
BoardProc_frm.Show 1
Test_ON ' start test
Else
Test_OFF 'stop test
End If
End Sub
Private Sub Form_Load()
'#######################################################################
' This procedure is immediately called when the application is invoked
' or runned under the Visual Basic IDE. Its job is to set up the
' display for running.
'#######################################################################
' Set form location
Left = (Screen.Width - Width) / 2
Top = (Screen.Height - Height) / 2
' Set the number of rows
TransmittedSignal.RowCount = SAMPLE_SIZE
ReceivedSignal.RowCount = SAMPLE_SIZE
' Set caption on toggle button
cmd_Toggle.Caption = START_CAPTION
' Clear charts
Clear_Charts
End Sub
Private Sub Form_Resize()
'#######################################################################
' This procedure is called if the form size if modifed. It's job is to
' re-size and re-position the Active-X controls according to scale.
'#######################################################################
' To resize controls:
'
' current control [width/height] = ( current control [width/height] *
' original control [width/height]) /
' forms original [width/height]
' Grow/Shrink Controls
TransmittedSignal.Width = (signalfrm.Width * _
TRANSMITTED_CHART_START_WIDTH) / _
FORM_START_WIDTH
TransmittedSignal.Height = (signalfrm.Height * _
TRANSMITTED_CHART_START_HEIGHT) / _
FORM_START_HEIGHT
ReceivedSignal.Width = (signalfrm.Width * _
RECEIVED_CHART_START_WIDTH) / _
FORM_START_WIDTH
ReceivedSignal.Height = (signalfrm.Height * _
RECEIVED_CHART_START_HEIGHT) / _
FORM_START_HEIGHT
cmd_Toggle.Width = (signalfrm.Width * _
TOGGLE_BUTTON_START_WIDTH) / _
FORM_START_WIDTH
cmd_Toggle.Height = (signalfrm.Height * _
TOGGLE_BUTTON_START_HEIGHT) / _
FORM_START_HEIGHT
' To re-position controls:
'
' current control [left/top] = ( original control [left/top] /
' original control [width/height] ) *
' current control [width/height]
' Note: However, we will multiply the original [left/top] position
' by the inverse of the original start [width/height] to
' protect us against division by zero.
' Re-position Controls
TransmittedSignal.Left = (TRANSMITTED_CHART_START_LEFT * _
(1 / TRANSMITTED_CHART_START_WIDTH)) * _
TransmittedSignal.Width
TransmittedSignal.Top = (TRANSMITTED_CHART_START_TOP * _
(1 / TRANSMITTED_CHART_START_HEIGHT)) * _
TransmittedSignal.Height
ReceivedSignal.Left = (RECEIVED_CHART_START_LEFT * _
(1 / RECEIVED_CHART_START_WIDTH)) * _
ReceivedSignal.Width
ReceivedSignal.Top = (RECEIVED_CHART_START_TOP * _
(1 / RECEIVED_CHART_START_HEIGHT)) * _
ReceivedSignal.Height
cmd_Toggle.Left = (TOGGLE_BUTTON_START_LEFT * _
(1 / TOGGLE_BUTTON_START_WIDTH)) * _
cmd_Toggle.Width
cmd_Toggle.Top = (TOGGLE_BUTTON_START_TOP * _
(1 / TOGGLE_BUTTON_START_WIDTH)) * _
cmd_Toggle.Height
End Sub
Private Sub Form_Unload(Cancel As Integer)
If (tmr_MethodDispatch.Enabled = True) Then
Test_OFF
End If
Unload BoardProc_frm
End Sub
Private Sub ReceivedSignal_ChartSelected(MouseFlags As Integer, Cancel As Integer)
' No handler is required
' The program is not configured to accept user input from the charts
End Sub
Private Sub tmr_MethodDispatch_Timer()
'#######################################################################
' This procedure is enabled(called repeatedly) when the user starts the
' the test. It acts as a task and is not halted until the user disables
' the timer (i.e. tmr_MethodDispatch.Enable = "False"). This
' procedure's job is to call Transmit_Signal() and Receive_Signal()
'#######################################################################
Dim func_status As Long ' status of function call
Dim response As Integer ' variable for response from messagebox
Dim lBufferState As Long
' Call StatusOfWrite() to make sure that the target application has
' requested data. This is needed for host to target synchronization.
If (toDSP.StatusOfWrite(lBufferState) <> SUCCESS) Then
Exit Sub
End If
If (lBufferState >= 0) Then
Exit Sub
End If
func_status = Transmit_Signal ' attempt to transmit signal to target
If (func_status <> SUCCESS) Then ' if attempt was not successful
response = MsgBox("Error: Signal not transmitted to target, " + _
"Do you wish to continue?", _
vbcrtical + vbYesNo)
If (response <> vbYes) Then
Test_OFF ' stop test
End If
Else
func_status = Receive_Signal ' attempt to read signal from target
Select Case (func_status)
Case SUCCESS ' Success full read, continue
' execution
Case EEndOfLogFile ' No more data will be available
response = MsgBox("End Of Log File has been reached", _
vbInformation)
Test_OFF
Case ENoDataAvailable ' No data is currently available,
' data may be available in the
' future
response = MsgBox("No data is currently available " + _
"Do you wish to continue program?", _
vbInformation + vbYesNo)
If (response <> vbYes) Then
Test_OFF
End If
Case FAIL ' Read failure
response = MsgBox("Error: Signal not received from target, " + _
"Do you wish to continue?", _
vbCritical + vbYesNo)
If (response <> vbYes) Then
Test_OFF
End If
Case Else ' Unknown return from debugger
response = MsgBox("Error: Unexpected return from debugger, " + _
"Application is terminated", vbCritical)
End Select
End If
End Sub
Private Sub TransmittedSignal_ChartSelected(MouseFlags As Integer, Cancel As Integer)
' No handler is required
' The program is not configured to accept user input from the charts
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -