📄 global.bas
字号:
Attribute VB_Name = "Module2"
Option Explicit
Const MaxEntries = 255
Public Const MaxChannels = 64 - 1
Global DeviceHandle As Long
Global ptDevGetFeatures As PT_DeviceGetFeatures
Global lpDevFeatures As DEVFEATURES
Global devicelist(0 To MaxEntries) As PT_DEVLIST
Global SubDevicelist(0 To MaxEntries) As PT_DEVLIST
Global ErrCde As Long
Global szErrMsg As String * 80
Global lpAIConfig As PT_AIConfig
Global AiVolIn As PT_AIVoltageIn
Global ptAIGetConfig As PT_AIGetConfig
Global AiCtrMode As Integer
Global wGainCode(0 To MaxChannels) As Integer
Global iGainIndex(0 To MaxChannels) As Integer
Global gwMaxLogChanNum As Integer
Global dfCurDevice As DEVCONFIG_AI
Global lpDEVCONFIG_AI As DEVCONFIG_AI
Global lpAIGetConfig As PT_AIGetConfig
Global ptEnableEvent As PT_EnableEvent ' Enable event
Global gnNumOfSubdevices As Integer
Global gwEvtFlag As Integer 'event enable(0)
Global gwFifoSize As Integer 'Fifo Size
Global gwFifoEnable As Integer ' Fifo
Global Response As Integer
Global lBuffer() As Long
Global ptAiStart As PT_FAIIntScanStart
Global dwDeviceNum As Long
Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Public Const GMEM_FIXED = &H0
Public Const GMEM_ZEROINIT = &H40
Public Const GPTR = (GMEM_FIXED Or GMEM_ZEROINIT)
Public Const LVS_EX_GRIDLINES = &H1
Public Const LVS_EX_FULLROWSELECT = &H20
Public Const LVM_FIRST As Long = &H1000
Public Const LVM_SETEXTENDEDLISTVIEWSTYLE As Long = (LVM_FIRST + 54)
Public Const LVM_GETEXTENDEDLISTVIEWSTYLE As Long = (LVM_FIRST + 55)
Public Declare Function SendMessageLong Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Function ChkErr(ByVal lErrCde As Long) As Long
If (lErrCde <> 0) Then
DRV_GetErrorMessage lErrCde, szErrMsg
Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
ChkErr = 1
Else
ChkErr = 0
End If
End Function
Public Function GainCodeFilling()
Dim i As Integer
For i = 0 To MaxChannels
iGainIndex(i) = frmSelDev.ListGain.ListIndex
Next i
End Function
Public Function Min(ByVal a As Long, ByVal b As Long) As Long
If a < b Then
Min = a
Else
Min = b
End If
End Function
Public Function SHL(OPR As Long, n As Integer) As Long
Dim BD As Long
Dim i As Integer
If n = 31 Then
SHL = &H80000000
Exit Function
End If
BD = OPR
For i = 1 To n - 1
BD = (BD And &H7FFFFFFF) * 2 'mask and shift left the D31 bit to avoid byte overflow
Next i
SHL = (BD And &H7FFFFFFF) * 2
End Function
Public Function PhyChanToLogChan(byDevCfg As DEVCONFIG_AI, ByVal byPhyChan As Long) As Long
Dim i As Integer
PhyChanToLogChan = 0
If byDevCfg.ulChanConfig = 1 Then
PhyChanToLogChan = byPhyChan
Exit Function
End If
For i = 0 To Min(byPhyChan, 31)
If (byDevCfg.ulChanConfig And SHL(1, i)) Then
i = i + 1
End If
PhyChanToLogChan = PhyChanToLogChan + 1
Next i
If (byPhyChan >= 32) Then
For i = 32 To byPhyChan
If (byDevCfg.ulChanConfigEx(0) And SHL(1, (i - 32))) Then
i = i + 1
End If
PhyChanToLogChan = PhyChanToLogChan + 1
Next
End If
PhyChanToLogChan = PhyChanToLogChan - 1
End Function
Public Function GetMaxLogChanNum(DevCfg As DEVCONFIG_AI, DevFeature As DEVFEATURES) As Long
Dim i As Integer
GetMaxLogChanNum = 0
If DevCfg.ulChanConfig = 1 Then
GetMaxLogChanNum = DevFeature.usMaxAIDiffChl
Exit Function
End If
For i = 0 To DevFeature.usMaxAISiglChl - 1
If (i < 32) Then
If (DevCfg.ulChanConfig And SHL(1, i)) Then
i = i + 1
End If
Else
If (DevCfg.ulChanConfig And SHL(1, i - 32)) Then
i = i + 1
End If
End If
GetMaxLogChanNum = GetMaxLogChanNum + 1
Next i
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -