📄 frmdi.frm
字号:
bRet = DAQDI1.EnableBitScan(False)
If bRet Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
cmdSelectDevice.Enabled = True
cmdBitScan.Enabled = True
cmdByteScan.Enabled = True
cmdEventScan.Enabled = True
cmdExit.Enabled = True
bRet = DAQDI1.CloseDevice
If bRet Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
End Sub
Private Sub cmdByteRead_Click()
bRet = DAQDI1.OpenDevice
If bRet Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
DAQDI1.Port = cmbPort.ListIndex
Text1.Text = Hex(DAQDI1.ByteInput)
bRet = DAQDI1.CloseDevice
If bRet Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
End Sub
Private Sub cmdByteScan_Click()
bRet = DAQDI1.OpenDevice
If bRet Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
cmdByteScan.Enabled = False
cmdBitScan.Enabled = False
cmdEventScan.Enabled = False
DAQDI1.Port = cmbPort.ListIndex
' leon.jin add
Text1.Text = Hex(DAQDI1.ByteInput)
' end leon.jin
bRet = DAQDI1.EnableByteScan(True)
If bRet Then
cmdByteScan.Enabled = True
cmdBitScan.Enabled = True
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
cmdSelectDevice.Enabled = False
cmdByteStop.Enabled = True
cmdBitStop.Enabled = False
cmdEventScan.Enabled = False
cmdExit.Enabled = False
End Sub
Private Sub cmdByteStop_Click()
cmdByteStop.Enabled = False
bRet = DAQDI1.EnableByteScan(False)
If bRet Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
cmdSelectDevice.Enabled = True
cmdByteScan.Enabled = True
cmdBitScan.Enabled = True
cmdEventScan.Enabled = True
cmdExit.Enabled = True
bRet = DAQDI1.CloseDevice
If bRet Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
End Sub
Private Sub cmdEventScan_Click()
bRet = DAQDI1.OpenDevice
If bRet Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
DAQDI1.Port = cmbPort.ListIndex
DAQDI1.Bit = cmbBit.ListIndex
bRet = DAQDI1.EnableEvent(True)
If bRet Then
cmdBitScan.Enabled = True
cmdByteScan.Enabled = True
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
cmdSelectDevice.Enabled = False
cmdBitScan.Enabled = False
cmdByteScan.Enabled = False
cmdEventScan.Enabled = False
cmdEventStop.Enabled = True
cmdBitStop.Enabled = False
cmdByteStop.Enabled = False
cmdExit.Enabled = False
End Sub
Private Sub cmdEventStop_Click()
cmdEventStop.Enabled = False
bRet = DAQDI1.EnableEvent(False)
If bRet Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
cmdSelectDevice.Enabled = True
cmdByteScan.Enabled = True
cmdBitScan.Enabled = True
cmdEventScan.Enabled = True
cmdExit.Enabled = True
glMatchCount = 0
glEventCount = 0
bRet = DAQDI1.CloseDevice
If bRet Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
End Sub
' End add
Private Sub cmdExit_Click()
Unload Me
End
End Sub
Private Sub cmdSelectDevice_Click()
Dim i As Integer
Dim Ret As Long
' Select Device from installed list
Ret = DAQDI1.SelectDevice
txtDeviceNum.Text = DAQDI1.DeviceNumber
txtDeviceName.Text = DAQDI1.DeviceName
DAQDI1.DeviceNumber = DAQDI1.DeviceNumber
DAQDI1.DeviceName = DAQDI1.DeviceName
' Open Device
If DAQDI1.OpenDevice Then
MsgBox DAQDI1.ErrorMessage, vbOKOnly
Exit Sub
End If
If DAQDI1.MaxPortNumber = 0 Then
MsgBox "Function Not Supported", vbOKOnly
Unload Me
End
End If
' Add Port number to list box
cmbPort.Clear
For i = 0 To DAQDI1.MaxPortNumber - 1
cmbPort.AddItem (Str(i))
Next i
If DAQDI1.MaxPortNumber Then
cmbPort.ListIndex = DAQDI1.Port
End If
End Sub
Private Sub DAQDI1_OnBitScan(ByVal Data As Boolean)
Text1.Text = Data
End Sub
Public Sub DAQDI1_OnByte()
Dim lData As Long
lData = DAQDI1.PatternMatchEnabled
'Text1.Text = "byte" + Hex(lData)
End Sub
Private Sub DAQDI1_OnByteScan(ByVal Data As Integer)
Dim lData As Long
lData = DAQDI1.ByteScanValue
Text1.Text = Hex(lData)
End Sub
Private Sub DAQDI1_OnEvent()
glEventCount = glEventCount + 1
txtEventNum.Text = glEventCount
End Sub
Private Sub DAQDI1_OnEventPatternMatch()
glMatchCount = glMatchCount + 1
If (glMatchCount Mod 9) = 0 Then
txtMatchNum.Text = glMatchCount
End If
End Sub
' End add
Private Sub Form_Load()
'Select Default Device
Call cmdSelectDevice_Click
glEventCount = 0
glMatchCount = 0
txtScanTime.Text = DAQDI1.ScanTime
txtDeviceNum.Text = DAQDI1.DeviceNumber
txtDeviceName.Text = DAQDI1.DeviceName
cmdByteStop.Enabled = False
cmdBitStop.Enabled = False
cmbPort.ListIndex = DAQDI1.Port
cmbBit.ListIndex = DAQDI1.Bit
' Init compare array
nTemp(0) = 1
nTemp(1) = 2
nTemp(2) = 4
nTemp(3) = 8
nTemp(4) = 16
nTemp(5) = 32
nTemp(6) = 64
nTemp(7) = 128
txtFilter.Text = DAQDI1.PatternMatchFilter
txtData.Text = DAQDI1.PatternMatchData
If DAQDI1.PatternMatchEnabled = True Then
chkMatchEnabled.Value = Checked
Else
chkMatchEnabled.Value = Unchecked
End If
txtEventNum.Text = glEventCount
txtMatchNum.Text = glMatchCount
DisplayPattern
DisplayPattern
' End Add
End Sub
Private Sub Form_Unload(Cancel As Integer)
DAQDI1.EnableEvent (False)
DAQDI1.CloseDevice
End Sub
Private Sub radHBit_Click(Index As Integer)
checkData Index, True
End Sub
Private Sub radLBit_Click(Index As Integer)
checkData Index, False
End Sub
Private Sub txtDeviceNum_Change()
DAQDI1.DeviceNumber = Val(txtDeviceNum.Text)
txtDeviceName.Text = DAQDI1.DeviceName
End Sub
Private Sub txtScanTime_Change()
DAQDI1.ScanTime = Val(txtScanTime.Text)
End Sub
Private Sub DisplayPattern()
Dim i As Integer
Dim nFilter As Integer
Dim nData As Integer
nFilter = DAQDI1.PatternMatchFilter
nData = DAQDI1.PatternMatchData
nFilter = nFilter And 255
nData = nData And 255
If chkMatchEnabled.Value = Checked Then
DAQDI1.PatternMatchEnabled = True
Else
DAQDI1.PatternMatchEnabled = False
End If
If DAQDI1.PatternMatchEnabled = True Then
For i = 0 To 7
chkBit(i).Enabled = True
If (nFilter And nTemp(i)) = nTemp(i) Then
chkBit(i).Value = Checked
radHBit(i).Enabled = True
radLBit(i).Enabled = True
Else
chkBit(i).Value = Unchecked
radHBit(i).Enabled = False
radLBit(i).Enabled = False
End If
Next
Else
For i = 0 To 7
chkBit(i).Enabled = False
radHBit(i).Enabled = False
radLBit(i).Enabled = False
If (nFilter And nTemp(i)) = nTemp(i) Then
chkBit(i).Value = Checked
Else
chkBit(i).Value = Unchecked
End If
Next
End If
For i = 0 To 7
If (nData And nTemp(i)) = nTemp(i) Then
radHBit(i).Value = True
radLBit(i).Value = False
Else
radHBit(i).Value = False
radLBit(i).Value = True
End If
Next
End Sub
Private Sub CheckFilter(nIndex As Integer)
Dim nFilter As Integer
nFilter = DAQDI1.PatternMatchFilter
nFilter = nFilter And 255
If chkBit(nIndex).Value = Checked Then
nFilter = nFilter Or nTemp(nIndex)
radHBit(nIndex).Enabled = True
radLBit(nIndex).Enabled = True
Else
nFilter = nFilter And (Not (nTemp(nIndex)))
radHBit(nIndex).Enabled = False
radLBit(nIndex).Enabled = False
End If
nFilter = nFilter And 255
DAQDI1.PatternMatchFilter = nFilter
txtFilter.Text = nFilter
End Sub
Private Sub checkData(nIndex As Integer, bHighBit As Boolean)
Dim nData As Integer
nData = DAQDI1.PatternMatchData
nData = nData And 255
If bHighBit = True Then
If radHBit(nIndex).Value = True Then
radLBit(nIndex).Value = False
nData = nData Or nTemp(nIndex)
Else
radLBit(nIndex).Value = True
nData = nData And (Not nTemp(nIndex))
End If
Else
If radLBit(nIndex).Value = True Then
radHBit(nIndex).Value = False
nData = nData And (Not nTemp(nIndex))
Else
radHBit(nIndex).Value = True
nData = nData Or nTemp(nIndex)
End If
End If
nData = nData And 255
DAQDI1.PatternMatchData = nData
txtData.Text = nData
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -