Option Strict Off
Option Explicit On
Imports System.Runtime.InteropServices
Imports System.Text
Module DIG

    '===============================================================================================
    '  API-DIG(WDM)p`t@C
    '===============================================================================================

    '-----------------------------------------------------------------------------------------------
    '  API-PAC(W32)ʒ萔
    '-----------------------------------------------------------------------------------------------
    Public Const DEVICE_TYPE_ISA As Short = 0                           ' ISA
    Public Const DIG_BUSTYPE_PCI As Short = 1                           ' PCI
    Public Const DEVICE_TYPE_PCMCIA As Short = 2                         ' PCMCIA
    Public Const DIG_BUSTYPE_USB As Short = 3                            ' USB
    Public Const DEVICE_TYPE_FIT As Short = 4                            ' FIT
    Public Const DEVICE_TYPE_CARDBUS As Short = 5                        ' CARDBUS
    Public Const DEVICE_TYPE_DEMO As Short = 6                           ' DEMO
    Public Const DEVICE_TYPE_EZUSB As Short = 10                        ' EZUSB

    '-----------------------------------------------------------------------------------------------
    '  萔
    '-----------------------------------------------------------------------------------------------
    ' ڑM
    Public Const DIG_ECU_DEST_SYNC1 As Short = 104                      ' oXM1
    Public Const DIG_ECU_DEST_SYNC2 As Short = 105                      ' oXM2
    Public Const DIG_ECU_DEST_SYNC3 As Short = 106                      ' oXM3
    Public Const DIG_ECU_DEST_SYNC_MSTHALT As Short = 107               ' }X^foCX~v
    Public Const DIG_ECU_DEST_SYNC_SLVHALT As Short = 108               ' X[ufoCX~v
    Public Const DIG_ECU_DEST_DIO0 As Short = 112                       ' Oo͒[q0
    Public Const DIG_ECU_DEST_DIO1 As Short = 113                       ' Oo͒[q1

    ' ڑM
    Public Const DIG_ECU_SRC_NC As Short = 0                            ' ڑ
    Public Const DIG_ECU_SRC_CLOCK As Short = 4                         ' fW^CUNbN
    Public Const DIG_ECU_SRC_PLLCLOCK As Short = 10003                  ' PLLNbN
    Public Const DIG_ECU_SRC_RECORD As Short = 10000                    ' 1R[hTvOIgK
    Public Const DIG_ECU_SRC_STOP As Short = 19                         ' fW^CU슮gK
    Public Const DIG_ECU_SRC_PRETRG As Short = 10001                    ' vgKgK
    Public Const DIG_ECU_SRC_POSTTRG As Short = 10002                   ' |XggKgK
    Public Const DIG_ECU_SRC_DIO0 As Short = 128                        ' Oo͒[q0
    Public Const DIG_ECU_SRC_DIO1 As Short = 129                        ' Oo͒[q1
    Public Const DIG_ECU_SRC_SYNC1 As Short = 136                       ' X[uM1
    Public Const DIG_ECU_SRC_SYNC2 As Short = 137                       ' X[uM2
    Public Const DIG_ECU_SRC_SYNC3 As Short = 138                       ' X[uM3
    Public Const DIG_ECU_SRC_HALT As Short = 432                        ' fW^CUُ~gK

    ' W[h
    Public Const DIG_MODE_OSCILLO As Short = 0                          ' IVXR[v[h
    Public Const DIG_MODE_DIGITIZER As Short = 1                        ' fW^CU[h
    Public Const DIG_MODE_LOGGER As Short = 2                           ' f[^K[[h
    Public Const DIG_MODE_JUDGE As Short = 3                            ' g`@[h

    ' ~v
    Public Const DIG_HALT_CLOCK_ERROR As Integer = &H1                  ' TvONbNG[
    Public Const DIG_HALT_JUDGE_COUNT As Integer = &H40                 ' g`JEgv
    Public Const DIG_HALT_OVERRANGE_CH0 As Integer = &H100              ' `l0I[o[W
    Public Const DIG_HALT_OVERRANGE_CH1 As Integer = &H200              ' `l1I[o[W
    Public Const DIG_HALT_DEVMEM_OVERFLOW As Integer = &H10000000       ' foCXI[o[t[
    Public Const DIG_HALT_DRVMEM_OVERFLOW As Integer = &H80000000       ' hCoI[o[t[

    ' Cxgv
    Public Const DIG_EVENT_STOP As Integer = &H1                           ' fW^CU̓~
    ' bZ[Wԍ
    Public Const DIG_MESSAGE_STOP As Integer = &H2000                     ' fW^CU̓~

    ' TvO[h
    Public Const DIG_SAMPLEMODE_REALTIME As Short = 0                   ' A^CTvO
    Public Const DIG_SAMPLEMODE_INTERLEAVE As Short = 1                 ' {TvO
    Public Const DIG_SAMPLEMODE_EQUIVALENT As Short = 2                 ' TvO

    ' `lԍ
    Public Const DIG_CHANNEL0 As Short = 0                              ' `l0
    Public Const DIG_CHANNEL1 As Short = 1                              ' `l1

    ' L/
    Public Const DIG_ENABLE As Short = 1                                ' L
    Public Const DIG_DISABLE As Short = 0                               ' 

    ' ̓W
    Public Const DIG_RANGE_40VPP As Single = 40.0#                        ' }20V
    Public Const DIG_RANGE_20VPP As Single = 20.0#                        ' }10V
    Public Const DIG_RANGE_10VPP As Single = 10.0#                        ' }5V
    Public Const DIG_RANGE_4VPP As Single = 4.0#                          ' }2V
    Public Const DIG_RANGE_2VPP As Single = 2.0#                          ' }1V
    Public Const DIG_RANGE_1VPP As Single = 1.0#                          ' }0.5V
    Public Const DIG_RANGE_400MVPP As Single = 0.4                      ' }0.2V
    Public Const DIG_RANGE_200MVPP As Single = 0.2                      ' }0.1V
    Public Const DIG_RANGE_100MVPP As Single = 0.1                      ' }0.05V
    Public Const DIG_RANGE_40MVPP As Single = 0.04                      ' }0.02V

    ' ̓Cs[_X
    Public Const DIG_IMPEDANCE_1M As Single = 1000000                   ' 1M
    Public Const DIG_IMPEDANCE_50 As Single = 50                        ' 50

    ' ̓JbvO
    Public Const DIG_COUPLING_DC As Short = 0                           ' DCJbvO
    Public Const DIG_COUPLING_AC As Short = 1                           ' ACJbvO
    Public Const DIG_COUPLING_GND As Short = 2                          ' GNDJbvO

    ' oh
    Public Const DIG_BANDWIDTH_FULL As Single = 0                       ' Sш敝
    Public Const DIG_BANDWIDTH_20MHZ As Single = 20000000               ' 20MHzȉ

    ' 
    Public Const DIG_PROBE_X1 As Single = 1                             ' 1F1
    Public Const DIG_PROBE_X10 As Single = 10                           ' 10F1
    Public Const DIG_PROBE_X100 As Single = 100                         ' 100F1
    Public Const DIG_PROBE_X1000 As Single = 1000                       ' 1000F1

    ' gK
    Public Const DIG_TRIGGERTYPE_AUTO As Short = 0                      ' 
    Public Const DIG_TRIGGERTYPE_DIEDGE As Short = 1                    ' fW^GbWgK
    Public Const DIG_TRIGGERTYPE_DIWINDOW As Short = 2                  ' fW^EBhEgK
    Public Const DIG_TRIGGERTYPE_AIEDGE As Short = 3                    ' AiOGbWgK
    Public Const DIG_TRIGGERTYPE_AIWINDOW As Short = 4                  ' AiOEBhEgK
    Public Const DIG_TRIGGERTYPE_SOFT As Short = 5                      ' \tgEFAgK

    ' gK
    Public Const DIG_TRIGGER_SLOPE_RISE As Short = 0                    ' オGbW
    Public Const DIG_TRIGGER_SLOPE_FALL As Short = 1                    ' GbW
    Public Const DIG_TRIGGER_SLOPE_BOTH As Short = 2                    ' GbW

    ' EBhEgK
    Public Const DIG_TRIGGER_WINDOW_ENTER As Short = 0                  ' EBhE֓
    Public Const DIG_TRIGGER_WINDOW_LEAVE As Short = 1                  ' EBhEO֊Oꂽ

    ' }XNf[^쐬IvV
    Public Const DIG_AUTOMASK_NEW As Short = 0                          ' VK쐬
    Public Const DIG_AUTOMASK_AND As Short = 1                          ' f[^Ƃ̘_
    Public Const DIG_AUTOMASK_OR As Short = 2                           ' f[^Ƃ̘_a

    ' g`f[^
    Public Const DIG_JUDGE_OK As Short = 0                              ' OKʂ̃R[h
    Public Const DIG_JUDGE_NG As Short = 1                              ' NGʂ̃R[h

    ' fW^Mo͕
    Public Const DIG_JUDGE_OUT_LIMIT As Short = 0                       ' JEgl~bg
    Public Const DIG_JUDGE_OUT_OK As Short = 1                          ' OK茋ʖ
    Public Const DIG_JUDGE_OUT_NG As Short = 2                          ' NG茋ʖ

    ' o͐M`
    Public Const DIG_DO_LEVEL As Short = 0                              ' x
    Public Const DIG_DO_PULSE As Short = 1                              ' pX

    ' o͘_
    Public Const DIG_DO_LOGIC_POSITIVE As Short = 0                     ' _
    Public Const DIG_DO_LOGIC_NEGATIVE As Short = 1                     ' s_

    ' gKΏ
    Public Const DIG_PRETRIGGER As Short = 0                            ' vgK
    Public Const DIG_POSTTRIGGER As Short = 1                           ' |XggK

    ' Xe[^X
    Public Const DIG_STATUS_BUSY As Integer = &H1                       ' fW^CU쒆
    Public Const DIG_STATUS_PRETRG_WAIT As Integer = &H10               ' vgK҂
    Public Const DIG_STATUS_POSTTRG_WAIT As Integer = &H20              ' |XggK҂
    Public Const DIG_STATUS_OVERRANGE_CH0 As Integer = &H100            ' `l0I[o[W
    Public Const DIG_STATUS_OVERRANGE_CH1 As Integer = &H200            ' `l1I[o[W
    Public Const DIG_STATUS_IMPEDANCE_CHANGE_CH0 As Integer = &H400     ' `l0I[o[W
    Public Const DIG_STATUS_IMPEDANCE_CHANGE_CH1 As Integer = &H800     ' `l1I[o[W
    Public Const DIG_STATUS_MASTER_HALT_REQUEST As Integer = &H1000     ' }X^foCX̒~v
    Public Const DIG_STATUS_SLAVE_HALT_REQUEST As Integer = &H2000      ' X[ufoCX̒~v
    Public Const DIG_STATUS_DRVMEM_OVERFLOW As Integer = &H10000        ' hCoI[o[t[
    Public Const DIG_STATUS_DDRMEM_OVERFLOW As Integer = &H20000        ' DDRI[o[t[
    Public Const DIG_STATUS_PREMEM_OVERFLOW As Integer = &H40000        ' vgKTvpI[o[t[
    Public Const DIG_STATUS_POSTMEM_OVERFLOW As Integer = &H80000       ' |XggKTvpI[o[t[
    Public Const DIG_STATUS_CLOCK_ERROR As Integer = &H100000           ' TvONbNG[

    ' R[h擾IvV
    Public Const DIG_RECORD_DATA As Integer = 1                         ' R[hf[^
    Public Const DIG_RECORD_JUDGE As Integer = 2                        ' g`茋ʊTv
    Public Const DIG_RECORD_DETAIL As Integer = 4                       ' g`茋ʏڍ
    Public Const DIG_RECORD_ALL As Integer = 7                          ' ׂẴf[^

    ' g`茋ʏڍ
    Public Const DIG_JUDGE_INRANGE As Short = 0                         ' }XNf[^͈͓̔
    Public Const DIG_JUDGE_UNDERRANGE As Short = 1                      ' lI[o[
    Public Const DIG_JUDGE_OVERRANGE As Short = 2                       ' lI[o[

    ' tB^
    Public Const DIG_FILTER_NONE As Short = 0                           ' tB^Ȃ
    Public Const DIG_FILTER_25 As Short = 25                            ' 25usec

    ' Lu[V
    Public Const DIG_CALIB_ADCOFFSET As Short = 0                       ' ADCItZbg
    Public Const DIG_CALIB_ADCGAIN As Short = 1                         ' ADCQC
    Public Const DIG_CALIB_DACGAIN As Short = 2                         ' DACQC

    ' I/OAhX
    Public Const DIG_ADDRESS_LOCAL As Short = 0                         ' [J
    Public Const DIG_ADDRESS_MASTER As Short = 1                        ' oX}X^
    '----------------------------------------------------------------------------------------------
    ' G[R[h
    '----------------------------------------------------------------------------------------------
    Public Const DIG_ERR_SUCCESS As Integer = 0                         ' I
    Public Const DIG_ERR_INI_RESOURCE As Integer = 1                    ' \[X̎擾Ɏs܂
    Public Const DIG_ERR_INI_INTERRUPT As Integer = 2                   ' 荞݃[`̓o^Ɏs܂
    Public Const DIG_ERR_INI_MEMORY As Integer = 3                      ' ̊蓖ĂɎs܂
    Public Const DIG_ERR_INI_REGISTRY As Integer = 4                    ' WXg̃ANZXɎs܂
    Public Const DIG_ERR_INI_BM_ADDRESS As Integer = 5                  ' oX}X^o^ɐݒ肷AhX̒lُł
    Public Const DIG_ERR_INI_CREATE_ADAPTER As Integer = 6              ' A_v^IuWFNg̐Ɏs܂
    Public Const DIG_ERR_SYS_RECOVERED_FROM_STANDBY As Integer = 7      ' X^oC[h畜A߁ADigResetDevice֐sĂ
    Public Const DIG_ERR_INI_NOT_FOUND_SYS_FILE As Integer = 8          ' cdig.syst@CȂߏł܂
    Public Const DIG_ERR_INI_DLL_FILE_VERSION As Integer = 9            ' cdig.dllt@C̃o[W񂪎擾łȂߏł܂
    Public Const DIG_ERR_INI_SYS_FILE_VERSION As Integer = 10           ' cdig.syst@C̃o[W񂪎擾łȂߏł܂
    Public Const DIG_ERR_INI_NO_MATCH_DRV_VERSION As Integer = 11       ' cdig.dllcdig.sys̃o[W񂪈vȂߏł܂

    Public Const DIG_ERR_DLL_DEVICE_NAME As Integer = 10000             ' ݒt@Cɓo^ĂȂfoCXw肳܂
    Public Const DIG_ERR_DLL_INVALID_ID As Integer = 10001              ' IDw肳܂
    Public Const DIG_ERR_DLL_CALL_DRIVER As Integer = 10002             ' hCoĂяo܂(ioctlɎs)
    Public Const DIG_ERR_DLL_CREATE_FILE As Integer = 10003             ' t@C̍쐬Ɏs܂(opens)
    Public Const DIG_ERR_DLL_CLOSE_FILE As Integer = 10004              ' t@C̃N[YɎs܂(closes)
    Public Const DIG_ERR_DLL_CREATE_THREAD As Integer = 10005           ' Xbh̍쐬Ɏs܂
    Public Const DIG_ERR_DLL_DEVICE_NOT_FOUND As Integer = 10006        ' foCXt܂
    Public Const DIG_ERR_DLL_DEVICETYPE_NOT_FOUND As Integer = 10013    ' foCX^Cvt܂
    Public Const DIG_ERR_XML_MASTER_NOT_FOUND As Integer = 10060        ' }X^RtBOt@C݂܂
    Public Const DIG_ERR_XML_ROOT_NOT_FOUND_IN_MST As Integer = 10061   ' }X^RtBOt@CɃ[gGg݂܂
    Public Const DIG_ERR_XML_LIST_NOT_FOUND_IN_MST As Integer = 10062   ' }X^RtBOt@CɃfoCXXg݂܂
    Public Const DIG_ERR_XML_NODE_NOT_FOUND_IN_MST As Integer = 10063   ' }X^RtBOt@CɃfoCXm[h݂܂
    Public Const DIG_ERR_XML_USER_NOT_FOUND As Integer = 10064          ' [U[RtBOt@C݂܂
    Public Const DIG_ERR_XML_ROOT_NOT_FOUND_IN_USR As Integer = 10065   ' [U[RtBOt@CɃ[gGg݂܂
    Public Const DIG_ERR_XML_NODE_NOT_FOUND_IN_USR As Integer = 10066   ' [U[RtBOt@CɃfoCXm[h݂܂
    Public Const DIG_ERR_XML_CREATE_CLONE As Integer = 10067            ' N[m[h̍쐬Ɏs܂
    Public Const DIG_ERR_XML_SAVE As Integer = 10068                    ' [U[RtBOt@C̕ۑɎs܂
    Public Const DIG_ERR_XML_INVALID_DEVICE As Integer = 10069          ' قȂfoCXXMLt@Cł
    Public Const DIG_ERR_XML_UNKNOWN_VERSION As Integer = 10070         ' }X^RtBOt@C̃o[Wsł
    Public Const DIG_ERR_XML_INVALID_VERSION As Integer = 10071         ' }X^RtBOt@C̃o[Wv܂

    Public Const DIG_ERR_DLL_PARAM1_RANGE As Integer = 10100            ' p[^1͈͊Oł
    Public Const DIG_ERR_DLL_PARAM2_RANGE As Integer = 10101            ' p[^2͈͊Oł
    Public Const DIG_ERR_DLL_PARAM3_RANGE As Integer = 10102            ' p[^3͈͊Oł
    Public Const DIG_ERR_DLL_PARAM4_RANGE As Integer = 10103            ' p[^4͈͊Oł
    Public Const DIG_ERR_DLL_PARAM5_RANGE As Integer = 10104            ' p[^5͈͊Oł
    Public Const DIG_ERR_DLL_PARAM6_RANGE As Integer = 10105            ' p[^6͈͊Oł
    Public Const DIG_ERR_DLL_PARAM7_RANGE As Integer = 10106            ' p[^7͈͊Oł
    Public Const DIG_ERR_DLL_PARAM8_RANGE As Integer = 10107            ' p[^8͈͊Oł
    Public Const DIG_ERR_DLL_PARAM1_NULL As Integer = 10110             ' p[^1ُlł
    Public Const DIG_ERR_DLL_PARAM2_NULL As Integer = 10111             ' p[^2ُlł
    Public Const DIG_ERR_DLL_PARAM3_NULL As Integer = 10112             ' p[^3ُlł
    Public Const DIG_ERR_DLL_PARAM4_NULL As Integer = 10113             ' p[^4ُlł
    Public Const DIG_ERR_DLL_PARAM5_NULL As Integer = 10114             ' p[^5ُlł
    Public Const DIG_ERR_DLL_MEMORY_OVERFLOW As Integer = 10120         ' hCoI[o[t[Ă܂
    Public Const DIG_ERR_DLL_RECORD_NUMBER As Integer = 10121           ' w肵R[h̃f[^݂܂
    Public Const DIG_ERR_DLL_TIMEOUT As Integer = 10122                 ' ^CAEg܂
    Public Const DIG_ERR_DLL_DEVICE_BUSY As Integer = 10123             ' fW^CU쒆ł
    Public Const DIG_ERR_DLL_DAQMODE As Integer = 10124                 ' ̓샂[hł͎gpł܂
    Public Const DIG_ERR_DLL_DATA_EMPTY As Integer = 10125              ' ϊꂽf[^݂܂
    Public Const DIG_ERR_DLL_RECORDS_NOT_ENOUGH As Integer = 10126      ' R[hf[^sĂ܂
    Public Const DIG_ERR_DLL_INVALID_MASKSIZE As Integer = 10127        ' Õ}XNf[^ƃTCYv܂
    Public Const DIG_ERR_DLL_CALIB_ACCURACY1 As Integer = 10128         ' Od̐xs\ł(΂)
    Public Const DIG_ERR_DLL_CALIB_ACCURACY2 As Integer = 10129         ' Od̐xs\ł()
    Public Const DIG_ERR_DLL_CALIB_50OHM As Integer = 10130             ' ̓Cs[_X50ɐ؂ւ邱Ƃł܂
    Public Const DIG_ERR_DLL_OPEN_FILE As Integer = 10131               ' t@C̓ǂݍ݂Ɏs܂

    Public Const DIG_ERR_SYS_MEMORY As Integer = 20000                  ' ̊mۂɎs܂
    Public Const DIG_ERR_SYS_NOT_SUPPORTED As Integer = 20001           ' ̃foCXł͂̊֐͎gpł܂
    Public Const DIG_ERR_SYS_BOARD_EXECUTING As Integer = 20002         ' foCX쒆̂ߎsł܂
    Public Const DIG_ERR_SYS_USING_OTHER_PROCESS As Integer = 20003     ' ̃vZXfoCXgpĂ邽߁Asł܂
    Public Const DIG_ERR_SYS_NOT_FOUND_PROCESS_DATA As Integer = 20004  ' vZX񂪌܂

    Public Const DIG_ERR_SYS_EEPROM_BUSY As Integer = 20120             ' EEPROMُł
    Public Const DIG_ERR_SYS_PLL_BUSY As Integer = 20121                ' PLLHُł
    Public Const DIG_ERR_SYS_RELAY_BUSY As Integer = 20122              ' [Hُł
    Public Const DIG_ERR_SYS_CALIB_BUSY As Integer = 20123              ' Lu[Vُł
    Public Const DIG_ERR_SYS_PLL_DETECT As Integer = 20124              ' PLLNbNMo܂
    Public Const DIG_ERR_BM_BUFFER As Integer = 21100                   ' oX}X^]ݒŃobt@傫Ċmۂł܂ł
    Public Const DIG_ERR_BM_LOCK_MEMORY As Integer = 21101              ' oX}X^]ݒŃbNł܂ł
    Public Const DIG_ERR_BM_PARAM As Integer = 21102                    ' oX}X^]ݒŃp[^G[܂
    Public Const DIG_ERR_BM_SEQUENCE As Integer = 21103                 ' oX}X^]ݒŎs菇G[܂

    '-----------------------------------------------------------------------------------------------
    ' cdig.dllGNX|[g֐
    '-----------------------------------------------------------------------------------------------
    Declare Function DigInit Lib "CDIG.DLL" (ByVal DeviceName As String, ByRef Id As Short) As Integer
    Declare Function DigExit Lib "CDIG.DLL" (ByVal Id As Short) As Integer
    Declare Function DigResetProcess Lib "CDIG.DLL" (ByVal DeviceName As String) As Integer
    Declare Function DigResetDevice Lib "CDIG.DLL" (ByVal Id As Short) As Integer
    Declare Function DigSetEcuSignal Lib "CDIG.DLL" (ByVal Id As Short, ByVal Destination As Integer, ByVal Source As Integer) As Integer
    Declare Function DigGetEcuSignal Lib "CDIG.DLL" (ByVal Id As Short, ByVal Destination As Integer, ByRef Source As Integer) As Integer
    Declare Function DigAutoSetup Lib "CDIG.DLL" (ByVal Id As Short) As Integer
    Declare Function DigLoadConfig Lib "CDIG.DLL" (ByVal Id As Short, ByVal FilePath As String) As Integer
    Declare Function DigSaveConfig Lib "CDIG.DLL" (ByVal Id As Short, ByVal FilePath As String) As Integer
    Declare Function DigSetDigitizerMode Lib "CDIG.DLL" (ByVal Id As Short, ByVal Mode As Short) As Integer
    Declare Function DigSetHaltCondition Lib "CDIG.DLL" (ByVal Id As Short, ByVal Condition As Integer) As Integer
    Declare Function DigSetEvent Lib "CDIG.DLL" (ByVal Id As Short, ByVal hWnd As Integer, ByVal Factor As Integer) As Integer
    Declare Function DigSetReferenceClock Lib "CDIG.DLL" (ByVal Id As Short, ByVal ClockSource As Short) As Integer
    Declare Function DigSetClockSource Lib "CDIG.DLL" (ByVal Id As Short, ByVal ClockSource As Short) As Integer
    Declare Function DigSetSampleRate Lib "CDIG.DLL" (ByVal Id As Short, ByVal SampleRate As Single) As Integer
    Declare Function DigSetSampleClock Lib "CDIG.DLL" (ByVal Id As Short, ByVal SampleClock As Integer) As Integer
    Declare Function DigSetRecordLength Lib "CDIG.DLL" (ByVal Id As Short, ByVal RecordLength As Integer) As Integer
    Declare Function DigSetDutyCycle Lib "CDIG.DLL" (ByVal Id As Short, ByVal DutyCycle As Single) As Integer
    Declare Function DigSetPreSampleTimes Lib "CDIG.DLL" (ByVal Id As Short, ByVal SampleTimes As Integer) As Integer
    Declare Function DigSetPostSampleTimes Lib "CDIG.DLL" (ByVal Id As Short, ByVal SampleTimes As Integer) As Integer
    Declare Function DigSetRecordNumber Lib "CDIG.DLL" (ByVal Id As Short, ByVal RecordNumber As Integer) As Integer
    Declare Function DigSetMaxDriverMemorySize Lib "CDIG.DLL" (ByVal Id As Short, ByVal Size As Integer) As Integer
    Declare Function DigGetSampleRate Lib "CDIG.DLL" (ByVal Id As Short, ByRef SampleRate As Single) As Integer
    Declare Function DigGetSampleClock Lib "CDIG.DLL" (ByVal Id As Short, ByRef SampleClock As Integer) As Integer
    Declare Function DigGetRecordLength Lib "CDIG.DLL" (ByVal Id As Short, ByRef RecordLength As Integer) As Integer
    Declare Function DigGetRecordNumber Lib "CDIG.DLL" (ByVal Id As Short, ByRef RecordNumber As Integer) As Integer
    Declare Function DigGetDutyCycle Lib "CDIG.DLL" (ByVal Id As Short, ByRef DutyCycle As Single) As Integer
    Declare Function DigGetPreSampleTimes Lib "CDIG.DLL" (ByVal Id As Short, ByRef SampleTimes As Integer) As Integer
    Declare Function DigGetPostSampleTimes Lib "CDIG.DLL" (ByVal Id As Short, ByRef SampleTimes As Integer) As Integer
    Declare Function DigGetMaxDriverMemorySize Lib "CDIG.DLL" (ByVal Id As Short, ByRef Size As Integer) As Integer
    Declare Function DigGetMaxDriverMemoryRecords Lib "CDIG.DLL" (ByVal Id As Short, ByRef Records As Integer) As Integer
    Declare Function DigGetMaxDriverMemorySamples Lib "CDIG.DLL" (ByVal Id As Short, ByRef Samples As Integer) As Integer
    Declare Function DigSetChannel Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal Enable As Short) As Integer
    Declare Function DigSetRange Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal Range As Single) As Integer
    Declare Function DigSetOffset Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal Offset As Single) As Integer
    Declare Function DigSetImpedance Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal Impedance As Single) As Integer
    Declare Function DigSetCoupling Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal Coupling As Short) As Integer
    Declare Function DigSetBandWidth Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal BandWidth As Single) As Integer
    Declare Function DigSetProbeAttenuation Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal Attenuation As Single) As Integer
    Declare Function DigSetAutoLimitRange Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal Enable As Short) As Integer
    Declare Function DigGetChannel Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByRef Enable As Short) As Integer
    Declare Function DigGetChannels Lib "CDIG.DLL" (ByVal Id As Short, ByRef Channels As Short) As Integer
    Declare Function DigGetRange Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByRef Range As Single) As Integer
    Declare Function DigGetImpedance Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByRef Impedance As Single) As Integer
    Declare Function DigSetPreTriggerType Lib "CDIG.DLL" (ByVal Id As Short, ByVal TriggerType As Short) As Integer
    Declare Function DigSetPreTriggerDiEdge Lib "CDIG.DLL" (ByVal Id As Short, ByVal TriggerSource As Short, ByVal Slope As Short, ByVal TriggerCount As Integer) As Integer
    Declare Function DigSetPreTriggerAiEdge Lib "CDIG.DLL" (ByVal Id As Short, ByVal TriggerSource As Short, ByVal Level As Single, ByVal Slope As Short, ByVal TriggerCount As Integer) As Integer
    Declare Function DigSetPreTriggerAiEdgeHysterisis Lib "CDIG.DLL" (ByVal Id As Short, ByVal TriggerSource As Short, ByVal Hysterisis As Single) As Integer
    Declare Function DigSetPreTriggerAiWindow Lib "CDIG.DLL" (ByVal Id As Short, ByVal TriggerSource As Short, ByVal EnterOrLeave As Short, ByVal HighLevel As Single, ByVal LowLevel As Single, ByVal StateType As Short, ByVal State1 As Short, ByVal State2 As Short) As Integer
    Declare Function DigSetPostTriggerType Lib "CDIG.DLL" (ByVal Id As Short, ByVal TriggerType As Short) As Integer
    Declare Function DigSetPostTriggerDiEdge Lib "CDIG.DLL" (ByVal Id As Short, ByVal TriggerSource As Short, ByVal Slope As Short, ByVal TriggerCount As Integer) As Integer
    Declare Function DigSetPostTriggerAiEdge Lib "CDIG.DLL" (ByVal Id As Short, ByVal TriggerSource As Short, ByVal Level As Single, ByVal Slope As Short, ByVal TriggerCount As Integer) As Integer
    Declare Function DigSetPostTriggerAiEdgeHysterisis Lib "CDIG.DLL" (ByVal Id As Short, ByVal TriggerSource As Short, ByVal Hysterisis As Single) As Integer
    Declare Function DigSetPostTriggerAiWindow Lib "CDIG.DLL" (ByVal Id As Short, ByVal TriggerSource As Short, ByVal EnterOrLeave As Short, ByVal HighLevel As Single, ByVal LowLevel As Single, ByVal StateType As Short, ByVal State1 As Short, ByVal State2 As Short) As Integer
    Declare Function DigGetPostTriggerType Lib "CDIG.DLL" (ByVal Id As Short, ByRef TriggerType As Short) As Integer
    Declare Function DigGetPostTriggerAiEdge Lib "CDIG.DLL" (ByVal Id As Short, ByRef TriggerSource As Short, ByRef Level As Single, ByRef Slope As Short, ByRef TriggerCount As Integer) As Integer
    Declare Function DigSetJudgeChannel Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal Enable As Short) As Integer
    Declare Function DigSetAutoMask Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal Hmargin As Integer, ByVal Vmargin As Integer, ByVal Opt As Short) As Integer
    Declare Function DigSetJudgeData Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal DataSize As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal UpperData() As Single, <MarshalAs(UnmanagedType.LPArray)> ByVal LowerData() As Single) As Integer
    Declare Function DigSetJudgeData32 Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal DataSize As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal UpperData() As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal LowerData() As Integer) As Integer
    Declare Function DigGetJudgeData Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal DataSize As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal UpperData() As Single, <MarshalAs(UnmanagedType.LPArray)> ByVal LowerData() As Single) As Integer
    Declare Function DigGetJudgeData32 Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal DataSize As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal UpperData() As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal LowerData() As Integer) As Integer
    Declare Function DigSetJudgeCountLimit Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal Condition As Short, ByVal Limit As Integer) As Integer
    Declare Function DigSetJudgeSignalOut Lib "CDIG.DLL" (ByVal Id As Short, ByVal Channel As Short, ByVal Mode As Short, ByVal Signal As Short, ByVal Logic As Short, ByVal Destination As Short, ByVal PulseWidth As Single) As Integer
    Declare Function DigStart Lib "CDIG.DLL" (ByVal Id As Short) As Integer
    Declare Function DigStartSync Lib "CDIG.DLL" (ByVal Id As Short, ByVal Timeout As Single) As Integer
    Declare Function DigSoftTrigger Lib "CDIG.DLL" (ByVal Id As Short, ByVal TriggerType As Short) As Integer
    Declare Function DigStop Lib "CDIG.DLL" (ByVal Id As Short) As Integer
    Declare Function DigGetStatus Lib "CDIG.DLL" (ByVal Id As Short, ByRef Status As Integer) As Integer
    Declare Function DigGetDigitizedSamples Lib "CDIG.DLL" (ByVal Id As Short, ByRef Samples As Integer) As Integer
    Declare Function DigGetAcquiredSamples Lib "CDIG.DLL" (ByVal Id As Short, ByRef Samples As Integer) As Integer
    Declare Function DigGetDriverMemorySamples Lib "CDIG.DLL" (ByVal Id As Short, ByRef Samples As Integer) As Integer
    Declare Function DigGetDigitizedRecords Lib "CDIG.DLL" (ByVal Id As Short, ByRef Records As Integer) As Integer
    Declare Function DigGetAcquiredRecords Lib "CDIG.DLL" (ByVal Id As Short, ByRef Records As Integer) As Integer
    Declare Function DigGetDriverMemoryRecords Lib "CDIG.DLL" (ByVal Id As Short, ByRef Records As Integer) As Integer
    Declare Function DigGetJudgeCount Lib "CDIG.DLL" (ByVal Id As Short, ByRef JudgeCount As Integer) As Integer
    Declare Function DigReadEarliestRecords Lib "CDIG.DLL" (ByVal Id As Short, ByVal Opt As Integer, ByVal RecordNum As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal RecordData() As Single, <MarshalAs(UnmanagedType.LPArray)> ByVal Judge() As Short, ByRef JudgeDetail As Short) As Integer
    Declare Function DigReadEarliestRecords32 Lib "CDIG.DLL" (ByVal Id As Short, ByVal Opt As Integer, ByVal RecordNum As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal RecordData() As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal Judge() As Short, ByRef JudgeDetail As Short) As Integer
    Declare Function DigReadLatestRecords Lib "CDIG.DLL" (ByVal Id As Short, ByVal Opt As Integer, ByVal RecordNum As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal RecordData() As Single, <MarshalAs(UnmanagedType.LPArray)> ByVal Judge() As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal JudgeDetail() As Short) As Integer
    Declare Function DigReadLatestRecords32 Lib "CDIG.DLL" (ByVal Id As Short, ByVal Opt As Integer, ByVal RecordNum As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal RecordData() As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal Judge() As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal JudgeDetail() As Short) As Integer
    Declare Function DigReadSamples32 Lib "CDIG.DLL" (ByVal Id As Short, ByRef Samples As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal SampleData() As Integer, ByRef TriggerPoint As Integer) As Integer
    Declare Function DigReadSamples Lib "CDIG.DLL" (ByVal Id As Short, ByRef Samples As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal SampleData() As Single, ByRef TriggerPoint As Integer) As Integer
    Declare Function DigReadSingleData Lib "CDIG.DLL" (ByVal Id As Short, ByVal DataSize As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal Data() As Single) As Integer
    Declare Function DigReadSingleData32 Lib "CDIG.DLL" (ByVal Id As Short, ByVal DataSize As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal Data() As Integer) As Integer
    Declare Function DigSetControlFilter Lib "CDIG.DLL" (ByVal Id As Short, ByVal Signal As Short, ByVal Value As Single) As Integer
    Declare Function DigGetTemperature Lib "CDIG.DLL" (ByVal Id As Short, ByRef Temperature As Single) As Integer
    Declare Function DigGetErrorString Lib "CDIG.DLL" (ByVal ErrorCode As Integer, ByVal ErrorString As StringBuilder) As Integer
    Declare Function DigQueryDeviceName Lib "CDIG.DLL" (ByVal Index As Short, ByVal DeviceName As StringBuilder, ByVal Device As StringBuilder) As Integer
    Declare Function DigGetDeviceType Lib "CDIG.DLL" (ByVal Device As String, ByRef DeviceType As Short) As Integer
End Module




