Attribute VB_Name = "AIOWDM"
Module AIOWDM

    Public Const WDG_ACTION_IGNORE As UInt32 = 0
    Public Const WDG_ACTION_DISABLE As UInt32 = 1
    Public Const WDG_ACTION_SOFT_RESTART As UInt32 = 2
    Public Const WDG_ACTION_MOSTLY_SOFT_RESTART As UInt32 = 4
    Public Const PCI_WDG_CSM_RATE As Double = 2.08333
    Public Const P104_WDG_CSM_RATE As Double = 2.08333
    Public Const ISA_WDG_CSM_RATE As Double = 0.894886

    ' BAR constants
    Public Const BAR0 As Byte = &H80
    Public Const BAR1 As Byte = &H81
    Public Const BAR2 As Byte = &H82
    Public Const BAR3 As Byte = &H83
    Public Const BAR4 As Byte = &H84
    Public Const BAR5 As Byte = &H85

    ' DAC Range Constants
    Public Const rcNoChange As UInt32 = &HFFFFFFFF
    Public Const rcUnipolar10 As UInt32 = &H30313055  ' "U010"
    Public Const rcUnipolar5 As UInt32 = &H35303055   ' "U005"
    Public Const rcBipolar10 As UInt32 = &H3031E142   ' "B±10"
    Public Const rcBipolar5 As UInt32 = &H3530E142    ' "B±05"
    Public Const rcBipolar2_5 As UInt32 = &HBD32E142  ' "B±2½"
    Public Const rcCurrent420 As UInt32 = &H30323449  ' "I420"
    Public Const rcCurrent020 As UInt32 = &H30323049  ' "I020"
    Public Const rcCurrent024 As UInt32 = &H34323049  ' "I024"
    Public Const rcCode0 As UInt32 = 0
    Public Const rcCode1 As UInt32 = 1
    Public Const rcCode2 As UInt32 = 2
    Public Const rcCode3 As UInt32 = 3
    Public Const rcCode4 As UInt32 = 4
    Public Const rcCode5 As UInt32 = 5
    Public Const rcCode6 As UInt32 = 6
    Public Const rcCode7 As UInt32 = 7
    Public Const rcCode8 As UInt32 = 8
    Public Const rcCode9 As UInt32 = 9
    Public Const rcCode10 As UInt32 = 10

    ' Additional Constants
    Public Const bUpdate As UInt32 = 1
    Public Const bSimultaneous As UInt32 = 1
    Public Const bRestricted As UInt32 = 1

    ' Function declarations for the AIOWDM driver
    Public Declare Function GetNumCards Lib "AIOWDM" Alias "VBGetNumCards" () As UInt32
    Public Declare Function QueryCardInfo Lib "AIOWDM" Alias "VBQueryCardInfo" (ByVal CardNum As Int32, ByRef pDeviceID As UInt32, ByRef pBase As UInt32, ByRef pNameSize As UInt32, ByVal pName As String) As UInt32
    Public Declare Function QueryBARBase Lib "AIOWDM.dll" Alias "VBQueryBARBase" (ByVal CardNum As Int32, ByVal BARIndex As UInt32, ByRef pBase As UInt32) As UInt32
    Public Declare Function WaitForIRQ Lib "AIOWDM" Alias "VBWaitForIRQ" (ByVal CardNum As Int32) As UInt32
    Public Declare Function AbortRequest Lib "AIOWDM" Alias "VBAbortRequest" (ByVal CardNum As Int32) As UInt32
    Public Declare Function CloseCard Lib "AIOWDM" Alias "VBCloseCard" (ByVal CardNum As Int32) As UInt32
    Public Declare Function COSWaitForIRQ Lib "AIOWDM" Alias "VBCOSWaitForIRQ" (ByVal CardNum As Int32, ByVal PPIs As UInt32, ByRef pData As Byte) As UInt32
    Public Declare Function SetCOSScheme Lib "AIOWDM" Alias "VBSetCOSScheme" (ByVal CardNum As Int32, ByVal COSScheme As UInt32) As UInt32
    Public Declare Function PollForIRQ Lib "AIOWDM.dll" Alias "VBPollForIRQ" (ByVal CardNum As Int32) As UInt32
    Public Declare Function WDGInit Lib "AIOWDM" Alias "VBWDGInit" (ByVal CardNum As Int32) As UInt32
    Public Declare Function WDGHandleIRQ Lib "AIOWDM" Alias "VBWDGHandleIRQ" (ByVal CardNum As Int32, Action As UInt32) As UInt32
    Public Declare Function WDGSetTimeout Lib "AIOWDM" Alias "VBWDGSetTimeout" (ByVal CardNum As Int32, ByVal Milliseconds As Double, ByVal MHzClockRate As Double) As Double
    Public Declare Function WDGPet Lib "AIOWDM" Alias "VBWDGPet" (ByVal CardNum As Int32) As UInt32
    Public Declare Function WDGReadTemp Lib "AIOWDM" Alias "VBWDGReadTemp" (ByVal CardNum As Int32) As Double
    Public Declare Function WDGReadStatus Lib "AIOWDM" Alias "VBWDGReadStatus" (ByVal CardNum As Int32) As UInt32
    Public Declare Function WDGStart Lib "AIOWDM" Alias "VBWDGStart" (ByVal CardNum As Int32) As UInt32
    Public Declare Function WDGStop Lib "AIOWDM" Alias "VBWDGStop" (ByVal CardNum As Int32) As UInt32
    Public Declare Function EmergencyReboot Lib "AIOWDM" Alias "VBEmergencyReboot" () As UInt32
    Public Declare Function WDGSetResetDuration Lib "AIOWDM" Alias "VBWDGSetResetDuration" (ByVal CardNum As Int32, ByVal Milliseconds As Double, ByVal MHzClockRate As Double) As Double

    '8-bit Relative
    Public Declare Function RelInPortB Lib "AIOWDM" Alias "VBRelInPortB" (ByVal Cardnum As Long, ByVal Port As Long) As Integer
    Public Declare Function RelOutPortB Lib "AIOWDM" Alias "VBRelOutPortB" (ByVal Cardnum As Long, ByVal Port As Long, ByVal Value As Byte) As Integer
    Public Declare Function InBAR8 Lib "AIOWDM" Alias "VBInBAR8" (ByVal CardNum As Long, ByVal BAR As Byte, ByVal Offset As Long) As Byte
    Public Declare Function OutBAR8 Lib "AIOWDM" Alias "VBOutBAR8" (ByVal CardNum As Long, ByVal BAR As Byte, ByVal Offset As Long, ByVal Value As Byte) As Byte
    Public Declare Function RelINSB Lib "AIOWDM" Alias "VBRelINSB" (ByVal CardNum As Long, ByVal Offset As Long, ByVal Count As Long, ByRef pBuf As Byte) As Long

    '16-bit Relative
    Public Declare Function RelInPort Lib "AIOWDM" Alias "VBRelInPort" (ByVal Cardnum As Long, ByVal Port As Long) As Integer
    Public Declare Function RelOutPort Lib "AIOWDM" Alias "VBRelOutPort" (ByVal Cardnum As Long, ByVal Port As Long, ByVal Value As Integer) As Integer
    Public Declare Function InBAR16 Lib "AIOWDM" Alias "VBInBAR16" (ByVal CardNum As Long, ByVal BAR As Byte, ByVal Offset As Long) As Integer
    Public Declare Function OutBAR16 Lib "AIOWDM" Alias "VBOutBAR16" (ByVal CardNum As Long, ByVal BAR As Byte, ByVal Offset As Long, ByVal Value As Integer) As Integer
    Public Declare Function RelINSW Lib "AIOWDM" Alias "VBRelINSW" (ByVal CardNum As Long, ByVal Offset As Long, ByVal Count As Long, ByRef pBuf As Integer) As Long

    '32-bit Relative
    Public Declare Function RelInPortL Lib "AIOWDM" Alias "VBRelInPortL" (ByVal Cardnum As Long, ByVal Port As Long) As Long
    Public Declare Function RelOutPortL Lib "AIOWDM" Alias "VBRelOutPortL" (ByVal Cardnum As Long, ByVal Port As Long, ByVal Value As Long) As Integer
    Public Declare Function InBAR32 Lib "AIOWDM" Alias "VBInBAR32" (ByVal CardNum As Long, ByVal BAR As Byte, ByVal Offset As Long) As Long
    Public Declare Function OutBAR32 Lib "AIOWDM" Alias "VBOutBAR32" (ByVal CardNum As Long, ByVal BAR As Byte, ByVal Offset As Long, ByVal Value As Long) As Long
    Public Declare Function RelINSL Lib "AIOWDM" Alias "VBRelINSL" (ByVal CardNum As Long, ByVal Offset As Long, ByVal Count As Long, ByRef pBuf As Long) As Long
    Public Declare Function RelInPortDWord Lib "AIOWDM" Alias "VBRelInPortDWord" (ByVal Cardnum As Long, ByVal Port As Long) As Long
    Public Declare Function RelOutPortDWord Lib "AIOWDM" Alias "VBRelOutPortDWord" (ByVal Cardnum As Long, ByVal Port As Long, ByVal Value As Long) As Integer

    '8-bit Absolute
    Public Declare Function InPortB Lib "AIOWDM" Alias "VBInPortB" (ByVal Port As Long) As Integer
    Public Declare Function OutPortB Lib "AIOWDM" Alias "VBOutPortB" (ByVal Port As Long, ByVal Value As Byte) As Integer
    Public Declare Function INSB Lib "AIOWDM" Alias "VBINSB" (Addr As Long, ByVal Count As Long, ByRef pBuf As Byte) As Long

    '16-bit Absolute
    Public Declare Function InPort Lib "AIOWDM" Alias "VBInPort" (ByVal Port As Long) As Integer
    Public Declare Function OutPort Lib "AIOWDM" Alias "VBOutPort" (ByVal Port As Long, ByVal Value As Integer) As Integer
    Public Declare Function INSW Lib "AIOWDM" Alias "VBINSW" (Addr As Long, ByVal Count As Long, ByRef pBuf As Integer) As Long

    '32-bit Absolute
    Public Declare Function InPortL Lib "AIOWDM" Alias "VBInPortL" (ByVal Port As Long) As Long
    Public Declare Function OutPortL Lib "AIOWDM" Alias "VBOutPortL" (ByVal Port As Long, ByVal Value As Long) As Integer
    Public Declare Function INSL Lib "AIOWDM" Alias "VBINSL" (Addr As Long, ByVal Count As Long, ByRef pBuf As Long) As Long
    Public Declare Function InPortDWord Lib "AIOWDM" Alias "VBInPortDWord" (ByVal Port As Long) As Long
    Public Declare Function OutPortDWord Lib "AIOWDM" Alias "VBOutPortDWord" (ByVal Port As Long, ByVal Value As Long) As Integer

	' Digital Integration Features API Functions
	Public Declare Function DIF_ConfigurePulseClock Lib "AIOWDM.dll" Alias "VBDIF_ConfigurePulseClock" (ByVal CardNum As UInt32, ByRef clockHz As Double) As UInt32
	Public Declare Function DIF_Measure Lib "AIOWDM.dll" Alias "VBDIF_Measure" (ByVal CardNum As UInt32, ByVal iBit As UInt32, ByRef LoSide As Double, ByRef HiSide As Double, ByRef DutyCycle As Double, ByRef Frequency As Double) As UInt32
	Public Declare Function DIF_Generate Lib "AIOWDM.dll" Alias "VBDIF_Generate" (ByVal CardNum As UInt32, ByVal iBit As UInt32, ByVal ActiveSide As Double, ByVal InactiveSide As Double, ByVal PulseCount As UInt16) As UInt32
	Public Declare Function DIF_ConfigureGeneration Lib "AIOWDM.dll" Alias "VBDIF_ConfigureGeneration" (ByVal CardNum As UInt32, ByVal iBit As UInt32, ByVal ActiveSide As Double, ByVal InactiveSide As Double, ByVal PulseCount As UInt16) As UInt32
	Public Declare Function DIF_ConfigureCounting Lib "AIOWDM.dll" Alias "VBDIF_ConfigureCounting" (ByVal CardNum As UInt32, ByVal iBit As UInt32, ByVal bCountFalling As Boolean, ByVal bCountRising As Boolean) As UInt32
	Public Declare Function DIF_Count Lib "AIOWDM.dll" Alias "VBDIF_Count" (ByVal CardNum As UInt32, ByVal iBit As UInt32, ByRef Count As UInt32) As UInt32
	Public Declare Function DIF_CountOverflowIRQEnable Lib "AIOWDM.dll" Alias "VBDIF_CountOverflowIRQEnable" (ByVal CardNum As UInt32, ByVal iBit As UInt32, ByVal bEnabled As Boolean) As UInt32
	Public Declare Function DIF_IRQEdgeEnable Lib "AIOWDM.dll" Alias "VBDIF_IRQEdgeEnable" (ByVal CardNum As UInt32, ByVal iBit As UInt32, ByVal bFallingIRQ As Boolean, ByVal bRisingIRQ As Boolean) As UInt32

    ' DAC Functions
    Public Declare Function DAC_GetNumDacs Lib "AIOWDM" Alias "VBDAC_GetNumDacs" (ByVal CardNum As Int32, ByRef numDacs As UInt16) As UInt32
    Public Declare Function DAC_GetMaxCounts Lib "AIOWDM" Alias "VBDAC_GetMaxCounts" (ByVal CardNum As Int32, ByRef maxCounts As UInt32) As UInt32
    Public Declare Function DAC_Output Lib "AIOWDM" Alias "VBDAC_Output" (ByVal CardNum As Int32, ByVal iDac As UInt16, ByVal Value As Double) As UInt32
    Public Declare Function DAC_Outputs Lib "AIOWDM" Alias "VBDAC_Outputs" (ByVal CardNum As Int32, ByVal NumValues As UInt16, ByRef Values As Double) As UInt32
    Public Declare Function DAC_SetRange Lib "AIOWDM" Alias "VBDAC_SetRange" (ByVal CardNum As Int32, ByVal iDac As UInt16, ByVal RangeCode As UInt32) As UInt32
    Public Declare Function DAC_SetRanges Lib "AIOWDM" Alias "VBDAC_SetRanges" (ByVal CardNum As Int32, ByVal numRangeCodes As UInt16, ByRef RangeCodes As UInt32) As UInt32
    Public Declare Function DAC_GetRange Lib "AIOWDM" Alias "VBDAC_GetRange" (ByVal CardNum As Int32, ByVal iDac As UInt16, ByRef RangeCode As UInt32) As UInt32
    Public Declare Function DAC_GetRanges Lib "AIOWDM" Alias "VBDAC_GetRanges" (ByVal CardNum As Int32, ByRef pNumRangeCodes As UInt16, ByRef RangeCodes As UInt32) As UInt32
    Public Declare Function DAC_ValueFromCounts Lib "AIOWDM" Alias "VBDAC_ValueFromCounts" (ByVal CardNum As Int32, ByVal iDac As UInt16, ByVal Counts As UInt32, ByRef Value As Double) As UInt32
    Public Declare Function DAC_OutputCount Lib "AIOWDM" Alias "VBDAC_OutputCount" (ByVal CardNum As Int32, ByVal iDac As UInt16, ByVal Counts As UInt32) As UInt32
    Public Declare Function DAC_OutputCounts Lib "AIOWDM" Alias "VBDAC_OutputCounts" (ByVal CardNum As Int32, ByVal numCounts As UInt16, ByRef Counts As UInt32) As UInt32
    Public Declare Function DAC_ReloadCalibrationData Lib "AIOWDM" Alias "VBDAC_ReloadCalibrationData" (ByVal CardNum As Int32) As UInt32
    Public Declare Function DAC_EnableCalibration Lib "AIOWDM" Alias "VBDAC_EnableCalibration" (ByVal CardNum As Int32, ByVal Enable As UInt16) As UInt32
    Public Declare Function DAC_GetCalibrationData Lib "AIOWDM" Alias "VBDAC_GetCalibrationData" (ByVal CardNum As Int32, ByRef pBufLength As UInt16, ByRef pBuf As Double) As UInt32
    Public Declare Function DAC_WriteCalibrationData Lib "AIOWDM" Alias "VBDAC_WriteCalibrationData" (ByVal CardNum As Int32, ByRef pBufLength As UInt16, ByRef pBuf As Byte, ByVal bToEEPROM As UInt16) As UInt32
    Public Declare Function DAC_ConfigureSimultaneousMode Lib "AIOWDM" Alias "VBDAC_ConfigureSimultaneousMode" (ByVal CardNum As Int32, ByVal bSimultaneous As Int32, ByVal bUpdate As Int32) As UInt32
    Public Declare Function DAC_ConfigureVoltageRestrictMode Lib "AIOWDM" Alias "VBDAC_ConfigureVoltageRestrictMode" (ByVal CardNum As Int32, ByVal bRestricted As Int32) As UInt32

End Module
