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

	'===============================================================================================
	'  API-DIG(WDM) Definition file
	'===============================================================================================

	'-----------------------------------------------------------------------------------------------
	'  API-PAC(W32) Common constant
	'-----------------------------------------------------------------------------------------------
	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

	'-----------------------------------------------------------------------------------------------
	'  Constant
	'-----------------------------------------------------------------------------------------------
	' Destination signal
	Public Const DIG_ECU_DEST_SYNC1 As Short = 104                   	' Synchronous bus signal line 1
	Public Const DIG_ECU_DEST_SYNC2 As Short = 105                   	' Synchronous bus signal line 2
	Public Const DIG_ECU_DEST_SYNC3 As Short = 106                   	' Synchronous bus signal line 3
	Public Const DIG_ECU_DEST_SYNC_MSTHALT As Short = 107            	' Master device stop request
	Public Const DIG_ECU_DEST_SYNC_SLVHALT As Short = 108            	' Slave device stop request
	Public Const DIG_ECU_DEST_DIO0 As Short = 112                    	' External I/O terminal 0
	Public Const DIG_ECU_DEST_DIO1 As Short = 113                    	' External I/O terminal 1

	' Source signal
	Public Const DIG_ECU_SRC_NC As Short = 0                         	' Not connected
	Public Const DIG_ECU_SRC_CLOCK As Short = 4                      	' Internal clock on digitizer board
	Public Const DIG_ECU_SRC_PLLCLOCK As Short = 10003               	' PLL reference clock
	Public Const DIG_ECU_SRC_RECORD As Short = 10000                 	' Trigger of 1 record sampling completion
	Public Const DIG_ECU_SRC_STOP As Short = 19                      	' Trigger of digitizer operation completion
	Public Const DIG_ECU_SRC_PRETRG As Short = 10001                 	' Trigger of pre-trigger satisfaction
	Public Const DIG_ECU_SRC_POSTTRG As Short = 10002                	' Trigger of post-trigger satisfaction
	Public Const DIG_ECU_SRC_DIO0 As Short = 128                     	' External I/O terminal 0
	Public Const DIG_ECU_SRC_DIO1 As Short = 129                     	' External I/O terminal 1
	Public Const DIG_ECU_SRC_SYNC1 As Short = 136                    	' Slave signal line 1
	Public Const DIG_ECU_SRC_SYNC2 As Short = 137                    	' Slave signal line 2
	Public Const DIG_ECU_SRC_SYNC3 As Short = 138                    	' Slave signal line 3
	Public Const DIG_ECU_SRC_HALT As Short = 432                     	' Trigger of digitizer abnormally halt

	' Acquisition mode
	Public Const DIG_MODE_OSCILLO As Short = 0                       	' Oscilloscope mode
	Public Const DIG_MODE_DIGITIZER As Short = 1                     	' Digitizer mode
	Public Const DIG_MODE_LOGGER As Short = 2                        	' Data logger mode
	Public Const DIG_MODE_JUDGE As Short = 3                         	' Waveform judgment instrument mode

	' Emergency halt factor
	Public Const DIG_HALT_CLOCK_ERROR As Integer = &H1                 	' Sampling clock error
	Public Const DIG_HALT_JUDGE_COUNT As Integer = &H40                	' Waveform judgment count match
	Public Const DIG_HALT_OVERRANGE_CH0 As Integer = &H100             	' Channel 0 over range
	Public Const DIG_HALT_OVERRANGE_CH1 As Integer = &H200             	' Channel 1 over range
	Public Const DIG_HALT_DEVMEM_OVERFLOW As Integer = &H10000000      	' Device memory overflow
	Public Const DIG_HALT_DRVMEM_OVERFLOW As Integer = &H80000000      	' Driver memory overflow

	' Event factor
	Public Const DIG_EVENT_STOP As Integer = &H1						' Digitizer operation halt
	' Message number
	Public Const DIG_MESSAGE_STOP As Integer = &H2000					' Digitizer operation halt

	' Sampling mode
	Public Const DIG_SAMPLEMODE_REALTIME As Short = 0                	' Realtime sampling mode
	Public Const DIG_SAMPLEMODE_INTERLEAVE As Short = 1              	' Interleave sampling mode
	Public Const DIG_SAMPLEMODE_EQUIVALENT As Short = 2              	' Equivalent sampling mode

	' Channel number
	Public Const DIG_CHANNEL0 As Short = 0                           	' Channel 0
	Public Const DIG_CHANNEL1 As Short = 1                           	' Channel 1

	' Enable/Disable
	Public Const DIG_ENABLE As Short = 1                             	' Enable
	Public Const DIG_DISABLE As Short = 0                            	' Disable

	' Input range
	Public Const DIG_RANGE_40VPP As Single = 40#                      	' +/-20V
	Public Const DIG_RANGE_20VPP As Single = 20#                      	' +/-10V
	Public Const DIG_RANGE_10VPP As Single = 10#                      	' +/-5V
	Public Const DIG_RANGE_4VPP As Single = 4#                        	' +/-2V
	Public Const DIG_RANGE_2VPP As Single = 2#                       	' +/-1V
	Public Const DIG_RANGE_1VPP As Single = 1#                        	' +/-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

	' Input impedance
	Public Const DIG_IMPEDANCE_1M As Single = 1000000                	' 1M ohm
	Public Const DIG_IMPEDANCE_50 As Single = 50                     	' 50 ohm

	' Input coupling method
	Public Const DIG_COUPLING_DC As Short = 0                       	' DC coupling
	Public Const DIG_COUPLING_AC As Short = 1                       	' AC coupling
	Public Const DIG_COUPLING_GND As Short = 2                      	' GND coupling

	' Band-width
	Public Const DIG_BANDWIDTH_FULL As Single = 0                    	' Full band-width
	Public Const DIG_BANDWIDTH_20MHZ As Single = 20000000            	' Below 20MHz

	' Probe attenuation rate
	Public Const DIG_PROBE_X1 As Single = 1                          	' 1:1
	Public Const DIG_PROBE_X10 As Single = 10                        	' 10:1
	Public Const DIG_PROBE_X100 As Single = 100                      	' 100:1
	Public Const DIG_PROBE_X1000 As Single = 1000                    	' 1000:1

	' Trigger condition
	Public Const DIG_TRIGGERTYPE_AUTO As Short = 0                  	' Auto
	Public Const DIG_TRIGGERTYPE_DIEDGE As Short = 1                	' Digital edge trigger
	Public Const DIG_TRIGGERTYPE_DIWINDOW As Short = 2              	' Digital window trigger
	Public Const DIG_TRIGGERTYPE_AIEDGE As Short = 3                	' Analog edge trigger
	Public Const DIG_TRIGGERTYPE_AIWINDOW As Short = 4              	' Analog window trigger
	Public Const DIG_TRIGGERTYPE_SOFT As Short = 5                  	' Software trigger

	' Trigger direction
	Public Const DIG_TRIGGER_SLOPE_RISE As Short = 0                	' Rising edge
	Public Const DIG_TRIGGER_SLOPE_FALL As Short = 1                	' Falling edge
	Public Const DIG_TRIGGER_SLOPE_BOTH As Short = 2                	' Both edge

	' Window trigger condition
	Public Const DIG_TRIGGER_WINDOW_ENTER As Short = 0              	' Entered window
	Public Const DIG_TRIGGER_WINDOW_LEAVE As Short = 1              	' Left window

	' Option for generating mask data
	Public Const DIG_AUTOMASK_NEW As Short = 0                      	' New
	Public Const DIG_AUTOMASK_AND As Short = 1                      	' Logical and with existing data
	Public Const DIG_AUTOMASK_OR As Short = 2                       	' Logical or with existing data

	' Waveform judgment data
	Public Const DIG_JUDGE_OK As Short = 0                          	' OK record
	Public Const DIG_JUDGE_NG As Short = 1                          	' NG record


	' Type of outputting digital signal
	Public Const DIG_JUDGE_OUT_LIMIT As Short = 0       				' Count value reaches limit
	Public Const DIG_JUDGE_OUT_OK As Short = 1          				' Each OK judgment result
	Public Const DIG_JUDGE_OUT_NG As Short = 2          				' Each NG judgment result

	' Output signal shape
	Public Const DIG_DO_LEVEL As Short = 0                          	' Level
	Public Const DIG_DO_PULSE As Short = 1                          	' Pulse

	' Output logic
	Public Const DIG_DO_LOGIC_POSITIVE As Short = 0                 	' Positive logic
	Public Const DIG_DO_LOGIC_NEGATIVE As Short = 1                 	' Negative logic

	' Trigger object
	Public Const DIG_PRETRIGGER As Short = 0                        	' Pre-trigger
	Public Const DIG_POSTTRIGGER As Short = 1                       	' Post-trigger

	' Status
	Public Const DIG_STATUS_BUSY As Integer = &H1                     	' Digitizer is in operation
	Public Const DIG_STATUS_PRETRG_WAIT As Integer = &H10             	' Waiting for pre-trigger
	Public Const DIG_STATUS_POSTTRG_WAIT As Integer = &H20            	' Waiting for post-triger
	Public Const DIG_STATUS_OVERRANGE_CH0 As Integer = &H100          	' Channel 0 is overrange
	Public Const DIG_STATUS_OVERRANGE_CH1 As Integer = &H200          	' Channel 1 is overrange
	Public Const DIG_STATUS_IMPEDANCE_CHANGE_CH0 As Integer = &H400   	' Channel 0 changes impedance automatically
	Public Const DIG_STATUS_IMPEDANCE_CHANGE_CH1 As Integer = &H800   	' Channel 1 changes impedance automatically
	Public Const DIG_STATUS_MASTER_HALT_REQUEST As Integer = &H1000   	' Stop request from master device
	Public Const DIG_STATUS_SLAVE_HALT_REQUEST As Integer = &H2000    	' Stop request from slave device
	Public Const DIG_STATUS_DRVMEM_OVERFLOW As Integer = &H10000      	' Driver memory overflows
	Public Const DIG_STATUS_DDRMEM_OVERFLOW As Integer = &H20000      	' DDR memory overflows
	Public Const DIG_STATUS_PREMEM_OVERFLOW As Integer = &H40000      	' Memory used for pre-trigger sample overflows
	Public Const DIG_STATUS_POSTMEM_OVERFLOW As Integer = &H80000     	' Memory used for post-trigger sample overflows
	Public Const DIG_STATUS_CLOCK_ERROR As Integer = &H100000         	' Sampling clock error

	' Record acquisition option 
	Public Const DIG_RECORD_DATA As Integer = 1                         ' Record data
	Public Const DIG_RECORD_JUDGE As Integer = 2                        ' Summary of waveform judgment result
	Public Const DIG_RECORD_DETAIL As Integer = 4                       ' Detail of waveform judgment result
	Public Const DIG_RECORD_ALL As Integer = 7                          ' All the data

	' Detail of waveform judgment result
	Public Const DIG_JUDGE_INRANGE As Short = 0                     	' Within the range of mask data
	Public Const DIG_JUDGE_UNDERRANGE As Short = 1                  	' Exceeds the lower bound value
	Public Const DIG_JUDGE_OVERRANGE As Short = 2                   	' Exceeds the upper bound value

	' Filter time
	Public Const DIG_FILTER_NONE As Short = 0                       	' No filter
	Public Const DIG_FILTER_25 As Short = 25                        	' 25usec

	' Calibration type
	Public Const DIG_CALIB_ADCOFFSET As Short = 0                   	' ADC offset
	Public Const DIG_CALIB_ADCGAIN As Short = 1                     	' ADC gain
	Public Const DIG_CALIB_DACGAIN As Short = 2                     	' DAC gain

	' I/O address
	Public Const DIG_ADDRESS_LOCAL As Short = 0                     	' Local address
	Public Const DIG_ADDRESS_MASTER As Short = 1                    	' Bus master address
	'----------------------------------------------------------------------------------------------
	' Error code
	'----------------------------------------------------------------------------------------------
	Public Const DIG_ERR_SUCCESS As Integer = 0                       	' Normal completed
	Public Const DIG_ERR_INI_RESOURCE As Integer = 1                  	' Invalid resource reference specified
	Public Const DIG_ERR_INI_INTERRUPT As Integer = 2                 	' Invalid interrupt routine registered
	Public Const DIG_ERR_INI_MEMORY As Integer = 3                    	' Invalid memory allocated
	Public Const DIG_ERR_INI_REGISTRY As Integer = 4                  	' Invalid registry access
	Public Const DIG_ERR_INI_BM_ADDRESS As Integer = 5                	' The value of address is unusual at the time of bus master registration
	Public Const DIG_ERR_INI_CREATE_ADAPTER As Integer = 6            	' Failed in creating an adapter object
	Public Const DIG_ERR_SYS_RECOVERED_FROM_STANDBY As Integer = 7    	' Execute DigResetDevice function because the device has recovered from standby mode
	Public Const DIG_ERR_INI_NOT_FOUND_SYS_FILE As Integer = 8        	' Because the cdig.sys file is not found, it is not possible to initialize it
	Public Const DIG_ERR_INI_DLL_FILE_VERSION As Integer = 9          	' Because version information on the cdig.dll file cannot be acquired, it is not possible to initialize it
	Public Const DIG_ERR_INI_SYS_FILE_VERSION As Integer = 10         	' Because version information on the cdig.sys file cannot be acquired, it is not possible to initialize it
	Public Const DIG_ERR_INI_NO_MATCH_DRV_VERSION As Integer = 11     	' Because version information on cdig.dll and cdig.sys is different, it is not possible to initialize it

	Public Const DIG_ERR_DLL_DEVICE_NAME As Integer = 10000           	' Invalid device name specified
	Public Const DIG_ERR_DLL_INVALID_ID As Integer = 10001            	' Invalid ID specified
	Public Const DIG_ERR_DLL_CALL_DRIVER As Integer = 10002           	' Not call the driver (Failure on DEVICE I/O CONTROL)
	Public Const DIG_ERR_DLL_CREATE_FILE As Integer = 10003           	' Not create the file (Failure on CreateFile)
	Public Const DIG_ERR_DLL_CLOSE_FILE As Integer = 10004            	' Not close the file (Failure on CloseFile)
	Public Const DIG_ERR_DLL_CREATE_THREAD As Integer = 10005         	' Not create the thread (Failure on CreateThread)
	Public Const DIG_ERR_DLL_DEVICE_NOT_FOUND As Integer = 10006      	' Not find devices
	Public Const DIG_ERR_DLL_DEVICETYPE_NOT_FOUND As Integer = 10013  	' Not find the device type
	Public Const DIG_ERR_XML_MASTER_NOT_FOUND As Integer = 10060      	' There is no master config file
	Public Const DIG_ERR_XML_ROOT_NOT_FOUND_IN_MST As Integer = 10061 	' There is no root element in master config file
	Public Const DIG_ERR_XML_LIST_NOT_FOUND_IN_MST As Integer = 10062 	' There is no device list in master config file
	Public Const DIG_ERR_XML_NODE_NOT_FOUND_IN_MST As Integer = 10063 	' There is no device node in master config file
	Public Const DIG_ERR_XML_USER_NOT_FOUND As Integer = 10064        	' There is no user config file
	Public Const DIG_ERR_XML_ROOT_NOT_FOUND_IN_USR As Integer = 10065 	' There is no root element in user config file
	Public Const DIG_ERR_XML_NODE_NOT_FOUND_IN_USR As Integer = 10066 	' There is no device node in user config file
	Public Const DIG_ERR_XML_CREATE_CLONE As Integer = 10067          	' Failed in creating a clone node
	Public Const DIG_ERR_XML_SAVE As Integer = 10068                  	' Failed in saving the user config file
	Public Const DIG_ERR_XML_INVALID_DEVICE As Integer = 10069        	' XML file for different devices
	Public Const DIG_ERR_XML_UNKNOWN_VERSION As Integer = 10070       	' Unknown master config file version
	Public Const DIG_ERR_XML_INVALID_VERSION As Integer = 10071       	' The version of master config file does not match

	Public Const DIG_ERR_DLL_PARAM1_RANGE As Integer = 10100          	' The value of parameter1 beyond the limit
	Public Const DIG_ERR_DLL_PARAM2_RANGE As Integer = 10101          	' The value of parameter2 beyond the limit
	Public Const DIG_ERR_DLL_PARAM3_RANGE As Integer = 10102          	' The value of parameter3 beyond the limit
	Public Const DIG_ERR_DLL_PARAM4_RANGE As Integer = 10103          	' The value of parameter4 beyond the limit
	Public Const DIG_ERR_DLL_PARAM5_RANGE As Integer = 10104          	' The value of parameter5 beyond the limit
	Public Const DIG_ERR_DLL_PARAM6_RANGE As Integer = 10105          	' The value of parameter6 beyond the limit
	Public Const DIG_ERR_DLL_PARAM7_RANGE As Integer = 10106          	' The value of parameter7 beyond the limit
	Public Const DIG_ERR_DLL_PARAM8_RANGE As Integer = 10107          	' The value of parameter8 beyond the limit
	Public Const DIG_ERR_DLL_PARAM1_NULL As Integer = 10110           	' Invalid value of parameter1 specified
	Public Const DIG_ERR_DLL_PARAM2_NULL As Integer = 10111           	' Invalid value of parameter2 specified
	Public Const DIG_ERR_DLL_PARAM3_NULL As Integer = 10112           	' Invalid value of parameter3 specified
	Public Const DIG_ERR_DLL_PARAM4_NULL As Integer = 10113           	' Invalid value of parameter4 specified
	Public Const DIG_ERR_DLL_PARAM5_NULL As Integer = 10114          	' Invalid value of parameter5 specified
	Public Const DIG_ERR_DLL_MEMORY_OVERFLOW As Integer = 10120      	' Driver memory overflow error occurred
	Public Const DIG_ERR_DLL_RECORD_NUMBER As Integer = 10121        	' There is not the data of the specified record number
	Public Const DIG_ERR_DLL_TIMEOUT As Integer = 10122              	' Timeout occurred
	Public Const DIG_ERR_DLL_DEVICE_BUSY As Integer = 10123          	' Can not use while digitizer is working
	Public Const DIG_ERR_DLL_DAQMODE As Integer = 10124              	' Can not use at this operation mode
	Public Const DIG_ERR_DLL_DATA_EMPTY As Integer = 10125           	' There is no converted data
	Public Const DIG_ERR_DLL_RECORDS_NOT_ENOUGH As Integer = 10126   	' Record data is not enough
	Public Const DIG_ERR_DLL_INVALID_MASKSIZE As Integer = 10127     	' The previous mask data does not match the size
	Public Const DIG_ERR_DLL_CALIB_ACCURACY1 As Integer = 10128      	' The accuracy of external DC voltage generator is insufficient(Variability)
	Public Const DIG_ERR_DLL_CALIB_ACCURACY2 As Integer = 10129      	' The accuracy of external DC voltage generator is insufficient(Average)
	Public Const DIG_ERR_DLL_CALIB_50OHM As Integer = 10130             ' Can not switch the input impedance to 50 ohm
	Public Const DIG_ERR_DLL_OPEN_FILE As Integer = 10131               ' Failed in loading file

	Public Const DIG_ERR_SYS_MEMORY As Integer = 20000               	' Not secure memory
	Public Const DIG_ERR_SYS_NOT_SUPPORTED As Integer = 20001        	' This board couldn't use this function
	Public Const DIG_ERR_SYS_BOARD_EXECUTING As Integer = 20002      	' Board is behaving, not execute
	Public Const DIG_ERR_SYS_USING_OTHER_PROCESS As Integer = 20003  	' Other process is using the device, not execute
	Public Const DIG_ERR_SYS_NOT_FOUND_PROCESS_DATA As Integer = 20004 	' Process information is not found

	Public Const DIG_ERR_SYS_EEPROM_BUSY As Integer = 20120           	' EEPROM operates abnormally
	Public Const DIG_ERR_SYS_PLL_BUSY As Integer = 20121              	' PLL(Phase-locked loop) operates abnormally
	Public Const DIG_ERR_SYS_RELAY_BUSY As Integer = 20122            	' Relay loop operates abnormally
	Public Const DIG_ERR_SYS_CALIB_BUSY As Integer = 20123            	' Calibration operates abnormally
	Public Const DIG_ERR_SYS_PLL_DETECT As Integer = 20124            	' Can not detect the PLL basis clock signal
	Public Const DIG_ERR_BM_BUFFER As Integer = 21100                 	' Can not ensure the enough buffer for bus master transfer setting
	Public Const DIG_ERR_BM_LOCK_MEMORY As Integer = 21101            	' Can not lock memory for bus master transfer setting
	Public Const DIG_ERR_BM_PARAM As Integer = 21102                  	' Parameter error occurred when setting the bus master transfer
	Public Const DIG_ERR_BM_SEQUENCE As Integer = 21103               	' Execution procedure error occurred when setting the bus master transfer

	'-----------------------------------------------------------------------------------------------
	' cdig.dll export method
	'-----------------------------------------------------------------------------------------------
	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
