📄 driver.bas
字号:
Attribute VB_Name = "Module1"
'***************************************************************************
' Module Name: DRIVER.BAS
' Purpose: the declaration of functions, data structures, status codes,
' constants, and messages
' Version: 3.01
' Date: 04/16/1998
' Copyright (c) 1996 Advantech Corp. Ltd.
' All rights reserved.
'****************************************************************************
'****************************************************************************
' Constant Definition
'****************************************************************************
Global Const MaxDev = 255 ' max. # of devices
Global Const MaxDevNameLen = 49 ' original is 64; max lenght of device name
Global Const MaxGroup = 6
Global Const MaxPort = 3
Global Const MaxszErrMsgLen = 80
Global Const MAX_DEVICE_NAME_LEN = 64
Global Const MAX_DRIVER_NAME_LEN = 16
Global Const MAX_DAUGHTER_NUM = 16
Global Const MAX_DIO_PORT = 48
Global Const MAX_AO_RANGE = 16
'***************************************************************************
' Define board vendor ID
'***************************************************************************
Global Const AAC = &H0 'Advantech
Global Const MB = &H1000 'Keithley/MetraByte
Global Const BB = &H2000 'Burr Brown
Global Const GRAYHILL = &H3000 'Grayhill
Global Const KGS = &H4000
Global Const BD_PCL836 = AAC Or &H54 ' PCL-836
'****************************************************************************
' Define subsection identifier
'****************************************************************************
Global Const DAS_AISECTION = &H1 ' A/D subsection
Global Const DAS_AOSECTION = &H2 ' D/A sbusection
Global Const DAS_DISECTION = &H3 ' Digital input subsection
Global Const DAS_DOSECTION = &H4 ' Digital output sbusection
Global Const DAS_TEMPSECTION = &H5 ' thermocouple section
Global Const DAS_ECSECTION = &H6 ' Event count subsection
Global Const DAS_FMSECTION = &H7 ' frequency measurement section
Global Const DAS_POSECTION = &H8 ' pulse output section
Global Const DAS_ALSECTION = &H9 ' alarm section
Global Const MT_AISECTION = &HA ' monitoring A/D subsection
Global Const MT_DISECTION = &HB ' monitoring D/I subsection
'**************************************************************************
' Define Status Code
'**************************************************************************
Global Const SUCCESS = 0
Global Const DrvErrorCode = 1
Global Const InvalidChannel = (DrvErrorCode + 6)
'****************************************************************************
' define gate mode
'****************************************************************************
Global Const GATE_DISABLED = 0 ' no gating
Global Const GATE_HIGHLEVEL = 1 ' active high level
Global Const GATE_LOWLEVEL = 2 ' active low level
Global Const GATE_HIGHEDGE = 3 ' active high edge
Global Const GATE_LOWEDGE = 4 ' active low edge
'*************************************************************************
' define gain listing
'************************************************************************
Type GainList
usGainCde As Integer
fMaxGainVal As Single
fMinGainVal As Single
szGainStr(0 To 15) As Byte
End Type
'*************************************************************************
' Define hardware board(device) features.
'
' Note: definition for dwPermutaion member
'
' Bit 0: Software AI
' Bit 1: DMA AI
' Bit 2: Interrupt AI
' Bit 3: Condition AI
' Bit 4: Software AO
' Bit 5: DMA AO
' Bit 6: Interrupt AO
' Bit 7: Condition AO
' Bit 8: Software DI
' Bit 9: DMA DI
' Bit 10: Interrupt DI
' Bit 11: Condition DI
' Bit 12: Software DO
' Bit 13: DMA DO
' Bit 14: Interrupt DO
' Bit 15: Condition DO
' Bit 16: High Gain
' Bit 17: Auto Channel Scan
' Bit 18: Pacer Trigger
' Bit 19: External Trigger
' Bit 20: Down Counter
' Bit 21: Dual DMA
' Bit 22: Monitoring
' Bit 23: QCounter
'
'***********************************************************************
Type DEVFEATURES
szDriverVer(0 To 7) As Byte ' device driver version
szDriverName(0 To (MAX_DRIVER_NAME_LEN - 1)) As Byte ' device driver name
dwBoardID As Long ' board ID
usMaxAIDiffChl As Integer ' Max. number of differential channel
usMaxAISiglChl As Integer ' Max. number of single-end channel
usMaxAOChl As Integer ' Max. number of D/A channel
usMaxDOChl As Integer ' Max. number of digital out channel
usMaxDIChl As Integer ' Max. number of digital input channel
usDIOPort As Integer ' specifies if programmable or not
usMaxTimerChl As Integer ' Max. number of Counter/Timer channel
usMaxAlarmChl As Integer ' Max number of alram channel
End Type
'*************************************************************************
' DaughterSet Definition
'*************************************************************************
Type DAUGHTERSET
dwBoardID As Long ' expansion board ID
usNum As Integer ' available expansion channels
fGain As Single ' gain for expansion channel
usCards As Integer ' number of expansion cards
End Type
'**************************************************************************
' TRIGLEVEL Definition
'**************************************************************************
Type PT_DEVLIST
dwDeviceNum As Long
szDeviceName(0 To 49) As Byte
nNumOfSubdevices As Integer
End Type
Type PT_DeviceGetFeatures
buffer As Long ' LPDEVFEATURES
size As Integer
End Type
Type PT_CounterEventStart
counter As Integer
GateMode As Integer
End Type
Type PT_CounterEventRead
counter As Integer
overflow As Long ' USHORT far *overflow
count As Long ' ULONG far *count
End Type
Type PT_CounterFreqStart
counter As Integer
GatePeriod As Integer
GateMode As Integer
End Type
Type PT_CounterFreqRead
counter As Integer
freq As Long 'FLOAT far *freq
End Type
Type PT_CounterPulseStart
counter As Integer
Period As Single
UpCycle As Single
GateMode As Integer
End Type
'**************************************************************************
' Function Declaration for ADSAPI32
'**************************************************************************
Declare Function DRV_SelectDevice Lib "adsapi32.dll" (ByVal hCaller As Long, ByVal GetModule As Boolean, DeviceNum As Long, ByVal Description As String) As Long
Declare Function DRV_DeviceGetNumOfList Lib "adsapi32.dll" (NumOfDevices As Integer) As Long
Declare Function DRV_DeviceGetList Lib "adsapi32.dll" (ByVal DeviceList As Long, ByVal MaxEntries As Integer, nOutEntries As Integer) As Long
Declare Function DRV_DeviceGetSubList Lib "adsapi32.dll" (ByVal DeviceNum As Long, ByVal SubDevList As Long, ByVal MaxEntries As Integer, nOutEntries As Integer) As Long
Declare Function DRV_DeviceOpen Lib "adsapi32.dll" (ByVal DeviceNum As Long, DriverHandle As Long) As Long
Declare Function DRV_DeviceClose Lib "adsapi32.dll" (DriverHandle As Long) As Long
Declare Function DRV_DeviceGetFeatures Lib "adsapi32.dll" (ByVal DriverHandle As Long, lpDevFeatures As PT_DeviceGetFeatures) As Long
Declare Function DRV_BoardTypeMapBoardName Lib "adsapi32.dll" (ByVal BoardID As Long, ByVal ExpName As String) As Long
Declare Sub DRV_GetErrorMessage Lib "adsapi32.dll" (ByVal lError As Long, ByVal lpszszErrMsg As String)
Declare Function DRV_CounterEventStart Lib "adsapi32.dll" (ByVal DriverHandle As Long, CounterEventStart As PT_CounterEventStart) As Long
Declare Function DRV_CounterEventRead Lib "adsapi32.dll" (ByVal DriverHandle As Long, CounterEventRead As PT_CounterEventRead) As Long
Declare Function DRV_CounterFreqStart Lib "adsapi32.dll" (ByVal DriverHandle As Long, CounterFreqStart As PT_CounterFreqStart) As Long
Declare Function DRV_CounterFreqRead Lib "adsapi32.dll" (ByVal DriverHandle As Long, CounterFreqRead As PT_CounterFreqRead) As Long
Declare Function DRV_CounterPulseStart Lib "adsapi32.dll" (ByVal DriverHandle As Long, CounterPulseStart As PT_CounterPulseStart) As Long
Declare Function DRV_CounterReset Lib "adsapi32.dll" (ByVal DriverHandle As Long, ByVal counter As Integer) As Long
Declare Function DRV_GetAddress Lib "adsapi32.dll" (lpVoid As Any) As Long
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -