//==============================================================================================
// API-DIG(WDM) Definition File
//==============================================================================================

using System;
using System.Runtime.InteropServices;

namespace CdigCs
{
    unsafe public class Cdig
    {
		//----------------------------------------------------------------------------------------------
		// API-PAC(W32) Common Constant
		//----------------------------------------------------------------------------------------------
		// Bus type
		public const short DEVICE_TYPE_ISA				= 0;		// ISA
		public const short DIG_BUSTYPE_PCI				= 1;		// PCI
		public const short DEVICE_TYPE_PCMCIA			= 2;		// PCMCIA
		public const short DIG_BUSTYPE_USB				= 3;		// USB
		public const short DEVICE_TYPE_FIT				= 4;		// FIT
		public const short DEVICE_TYPE_CARDBUS			= 5;		// CardBus
		public const short DEVICE_TYPE_DEMO				= 6;		// Demo
		public const short DEVICE_TYPE_EZUSB			= 10;		// EZ-USB

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

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

		// Acquisition mode
        public const short DIG_MODE_OSCILLO				= 0;			// Oscilloscope mode
        public const short DIG_MODE_DIGITIZER			= 1;			// Digitizer mode
        public const short DIG_MODE_LOGGER				= 2;			// Data logger mode
        public const short DIG_MODE_JUDGE				= 3;			// Waveform judgment instrument mode

		// Emergency halt factor
        public const uint DIG_HALT_CLOCK_ERROR			= 0x00000001;	// Sampling clock error
        public const uint DIG_HALT_JUDGE_COUNT			= 0x00000040;	// Waveform judgment count match
        public const uint DIG_HALT_OVERRANGE_CH0		= 0x00000100;	// Channel 0 over range
        public const uint DIG_HALT_OVERRANGE_CH1		= 0x00000200;	// Channel 1 over range
        public const uint DIG_HALT_DEVMEM_OVERFLOW		= 0x10000000;	// Device memory overflow
        public const uint DIG_HALT_DRVMEM_OVERFLOW		= 0x80000000;	// Driver memory overflow

		// Event factor
		public const uint DIG_EVENT_STOP				= 0x00000001;	// Digitizer operation halt
		// Message number
		public const int DIG_MESSAGE_STOP				= 0x2000;		// Digitizer operation halt

		// Sampling mode
        public const short DIG_SAMPLEMODE_REALTIME		= 0;			// Realtime sampling mode
        public const short DIG_SAMPLEMODE_INTERLEAVE	= 1;			// Interleave sampling mode
        public const short DIG_SAMPLEMODE_EQUIVALENT	= 2;			// Equivalent sampling mode

		// Channel number
        public const short DIG_CHANNEL0					= 0;			// Channel 0
        public const short DIG_CHANNEL1					= 1;			// Channel 1

		// Enable/Disable
        public const short DIG_ENABLE					= 1;			// Enable
        public const short DIG_DISABLE					= 0;			// Disable

		// Input range
        public const float DIG_RANGE_40VPP				= 40.0F;		// +/-20V
        public const float DIG_RANGE_20VPP				= 20.0F;		// +/-10V
        public const float DIG_RANGE_10VPP				= 10.0F;		// +/-5V
        public const float DIG_RANGE_4VPP				= 4.0F;			// +/-2V
        public const float DIG_RANGE_2VPP				= 2.0F;			// +/-1V
        public const float DIG_RANGE_1VPP				= 1.0F;			// +/-0.5V
        public const float DIG_RANGE_400MVPP			= 0.4F;			// +/-0.2V
        public const float DIG_RANGE_200MVPP			= 0.2F;			// +/-0.1V
        public const float DIG_RANGE_100MVPP			= 0.1F;			// +/-0.05V
        public const float DIG_RANGE_40MVPP				= 0.04F;		// +/-0.02V

		// Input impedance
        public const float DIG_IMPEDANCE_1M				= 1000000;		// 1M ohm
        public const float DIG_IMPEDANCE_50				= 50;			// 50 ohm

		// Input coupling method
        public const short DIG_COUPLING_DC				= 0;			// DC coupling
        public const short DIG_COUPLING_AC				= 1;			// AC coupling
        public const short DIG_COUPLING_GND				= 2;			// GND coupling

		// Band-width
        public const float DIG_BANDWIDTH_FULL			= 0;			// Full band-width
        public const float DIG_BANDWIDTH_20MHZ			= 20000000;		// Below 20MHz

		// Probe attenuation rate
        public const float DIG_PROBE_X1					= 1;			// 1:1
        public const float DIG_PROBE_X10				= 10;			// 10:1
        public const float DIG_PROBE_X100				= 100;			// 100:1
        public const float DIG_PROBE_X1000				= 1000;			// 1000:1

		// Trigger condition
		public const short DIG_TRIGGERTYPE_AUTO			= 0;			// Auto
		public const short DIG_TRIGGERTYPE_DIEDGE		= 1;			// Digital edge trigger
		public const short DIG_TRIGGERTYPE_DIWINDOW		= 2;			// Digital window trigger
		public const short DIG_TRIGGERTYPE_AIEDGE		= 3;			// Analog edge trigger
		public const short DIG_TRIGGERTYPE_AIWINDOW		= 4;			// Analog window trigger
		public const short DIG_TRIGGERTYPE_SOFT			= 5;			// Software trigger

		// Trigger direction
        public const short DIG_TRIGGER_SLOPE_RISE		= 0;			// Rising edge
        public const short DIG_TRIGGER_SLOPE_FALL		= 1;			// Falling edge
        public const short DIG_TRIGGER_SLOPE_BOTH		= 2;			// Both edge

		// Window trigger condition
        public const short DIG_TRIGGER_WINDOW_ENTER		= 0;			// Entered window
        public const short DIG_TRIGGER_WINDOW_LEAVE		= 1;			// Left window

		// Option for generating mask data
        public const short DIG_AUTOMASK_NEW				= 0;			// New
        public const short DIG_AUTOMASK_AND				= 1;			// Logical and with existing data
        public const short DIG_AUTOMASK_OR				= 2;			// Logical or with existing data

		// Waveform judgment data
        public const short DIG_JUDGE_OK					= 0;			// OK record
        public const short DIG_JUDGE_NG					= 1;			// NG record

		// Type of outputting digital signal
        public const short DIG_JUDGE_OUT_LIMIT			= 0;			// Count value reaches limit
        public const short DIG_JUDGE_OUT_OK				= 1;			// Each OK judgment result
        public const short DIG_JUDGE_OUT_NG				= 2;			// Each NG judgment result

		// Output signal shape
        public const short DIG_DO_LEVEL					= 0;			// Level
        public const short DIG_DO_PULSE					= 1;			// Pulse

		// Output logic
        public const short DIG_DO_LOGIC_POSITIVE		= 0;			// Positive logic
        public const short DIG_DO_LOGIC_NEGATIVE		= 1;			// Negative logic

		// Trigger object
		public const short DIG_PRETRIGGER				= 0;			// Pre-trigger
		public const short DIG_POSTTRIGGER				= 1;			// Post-trigger

		// Status
		public const uint DIG_STATUS_BUSY				= 0x00000001;	// Digitizer is in operation
		public const uint DIG_STATUS_PRETRG_WAIT		= 0x00000010;	// Waiting for pre-trigger
		public const uint DIG_STATUS_POSTTRG_WAIT		= 0x00000020;	// Waiting for post-triger
		public const uint DIG_STATUS_OVERRANGE_CH0		= 0x00000100;	// Channel 0 is overrange
		public const uint DIG_STATUS_OVERRANGE_CH1		= 0x00000200;	// Channel 1 is overrange
		public const uint DIG_STATUS_IMPEDANCE_CHANGE_CH0	= 0x00000400;	// Channel 0 changes impedance automatically
		public const uint DIG_STATUS_IMPEDANCE_CHANGE_CH1	= 0x00000800;	// Channel 1 changes impedance automatically
		public const uint DIG_STATUS_MASTER_HALT_REQUEST= 0x00001000;	// Stop request from master device
		public const uint DIG_STATUS_SLAVE_HALT_REQUEST	= 0x00002000;	// Stop request from slave device
		public const uint DIG_STATUS_DRVMEM_OVERFLOW	= 0x00010000;	// Driver memory overflows
		public const uint DIG_STATUS_DDRMEM_OVERFLOW	= 0x00020000;	// DDR memory overflows
		public const uint DIG_STATUS_PREMEM_OVERFLOW	= 0x00040000;	// Memory used for pre-trigger sample overflows
		public const uint DIG_STATUS_POSTMEM_OVERFLOW	= 0x00080000;	// Memory used for post-trigger sample overflows
		public const uint DIG_STATUS_CLOCK_ERROR		= 0x00100000;	// Sampling clock error

		// Record acquisition option
		public const int DIG_RECORD_DATA				= 1;			// Record data
		public const int DIG_RECORD_JUDGE				= 2;			// Summary of waveform judgment result
		public const int DIG_RECORD_DETAIL				= 4;			// Detail of waveform judgment result
		public const int DIG_RECORD_ALL					= 7;			// All the data

		// Detail of waveform judgment result
		public const short DIG_JUDGE_INRANGE			= 0;			// Within the range of mask data
		public const short DIG_JUDGE_UNDERRANGE			= 1;			// Exceeds the lower bound value
		public const short DIG_JUDGE_OVERRANGE			= 2;			// Exceeds the upper bound value

		// Filter time
		public const short DIG_FILTER_NONE				= 0;			// No filter
		public const short DIG_FILTER_25				= 25;			// 25usec

		// Calibration type
		public const short DIG_CALIB_ADCOFFSET			= 0;			// ADC offset
		public const short DIG_CALIB_ADCGAIN			= 1;			// ADC gain
		public const short DIG_CALIB_DACGAIN			= 2;			// DAC gain

		// I/O address
		public const short DIG_ADDRESS_LOCAL			= 0;			// Local address
		public const short DIG_ADDRESS_MASTER			= 1;			// Bus master address

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

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

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

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

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

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

		//----------------------------------------------------------------------------------------------
		// Method prototype
		//----------------------------------------------------------------------------------------------
        public Cdig()
        {
        }
        public int Init(string DeviceName, out short Id)
        {
            Id = 0;
            return DigInit(DeviceName, ref Id);
        }
        public int Exit(short Id)
        {
            return DigExit(Id);
        }
        public int ResetProcess(string DeviceName)
        {
            return DigResetProcess(DeviceName);
        }
        public int ResetDevice(short Id)
        {
            return DigResetDevice(Id);
        }
		public int SetEcuSignal(short Id, short Destination, short Source)
		{
			return DigSetEcuSignal(Id, Destination, Source);
		}
		public int GetEcuSignal(short Id, short Destination, out short Source)
		{
			Source = 0;
			return DigGetEcuSignal(Id, Destination, ref Source);
		}
        public int AutoSetup(short Id)
        {
            return DigAutoSetup(Id);
        }
        public int LoadConfig(short Id, string FilePath)
        {
			return DigLoadConfig(Id, FilePath);
		}
        public int SaveConfig(short Id, string FilePath)
        {
			return DigSaveConfig(Id, FilePath);
		}
        public int SetDigitizerMode(short Id, short Mode)
        {
            return DigSetDigitizerMode(Id, Mode);
        }
        public int SetHaltCondition(short Id, uint Condition)
        {
            return DigSetHaltCondition(Id, (int)Condition);
        }
        public int SetEvent(short Id, int hWnd, uint Factor)
        {
            return DigSetEvent(Id, hWnd, (int)Factor);
		}
        public int SetReferenceClock(short Id, short ClockSource)
        {
            return DigSetReferenceClock(Id, ClockSource);
        }
        public int SetClockSource(short Id, short ClockSource)
        {
            return DigSetClockSource(Id, ClockSource);
        }
        public int SetSampleRate(short Id, float SampleRate)
        {
            return DigSetSampleRate(Id, SampleRate);
        }
        public int SetSampleClock(short Id, int SampleClock)
        {
            return DigSetSampleClock(Id, SampleClock);
        }
        public int SetRecordLength(short Id, int RecordLength)
        {
            return DigSetRecordLength(Id, RecordLength);
        }
        public int SetDutyCycle(short Id, float DutyCycle)
        {
            return DigSetDutyCycle(Id, DutyCycle);
        }
        public int SetPreSampleTimes(short Id, int SampleTimes)
        {
            return DigSetPreSampleTimes(Id, SampleTimes);
        }
        public int SetPostSampleTimes(short Id, int SampleTimes)
        {
            return DigSetPostSampleTimes(Id, SampleTimes);
        }
        public int SetRecordNumber(short Id, int RecordNumber)
        {
            return DigSetRecordNumber(Id, RecordNumber);
        }
        public int GetSampleRate(short Id, out float SampleRate)
        {
            SampleRate = 0;
            return DigGetSampleRate(Id, ref SampleRate);
        }
        public int GetSampleClock(short Id, out int SampleClock)
        {
            SampleClock = 0;
            return DigGetSampleClock(Id, ref SampleClock);
        }
        public int GetRecordLength(short Id, out int RecordLength)
        {
            RecordLength = 0;
            return DigGetRecordLength(Id, ref RecordLength);
        }
        public int GetRecordNumber(short Id, out int RecordNumber)
        {
            RecordNumber = 0;
            return DigGetRecordNumber(Id, ref RecordNumber);
        }
        public int GetDutyCycle(short Id, out float DutyCycle)
        {
            DutyCycle = 0;
            return DigGetDutyCycle(Id, ref DutyCycle);
        }
        public int GetPreSampleTimes(short Id, out int SampleTimes)
        {
            SampleTimes = 0;
            return DigGetPreSampleTimes(Id, ref SampleTimes);
        }
        public int GetPostSampleTimes(short Id, out int SampleTimes)
        {
            SampleTimes = 0;
            return DigGetPostSampleTimes(Id, ref SampleTimes);
        }
        public int GetMaxDriverMemorySize(short Id, out int Size)
        {
            Size = 0;
            return DigGetMaxDriverMemorySize(Id, ref Size);
        }
        public int GetMaxDriverMemoryRecords(short Id, out int Records)
        {
            Records = 0;
            return DigGetMaxDriverMemoryRecords(Id, ref Records);
        }
        public int GetMaxDriverMemorySamples(short Id, out int Samples)
        {
            Samples = 0;
            return DigGetMaxDriverMemorySamples(Id, ref Samples);
        }
        public int SetChannel(short Id, short Channel, short Enable)
        {
            return DigSetChannel(Id, Channel, Enable);
        }
        public int SetRange(short Id, short Channel, float Range)
        {
            return DigSetRange(Id, Channel, Range);
        }
        public int SetOffset(short Id, short Channel, float Offset)
        {
            return DigSetOffset(Id, Channel, Offset);
        }
        public int SetImpedance(short Id, short Channel, float Impedance)
        {
            return DigSetImpedance(Id, Channel, Impedance);
        }
        public int SetCoupling(short Id, short Channel, short Coupling)
        {
            return DigSetCoupling(Id, Channel, Coupling);
        }
        public int SetBandWidth(short Id, short Channel, float BandWidth)
        {
            return DigSetBandWidth(Id, Channel, BandWidth);
        }
        public int SetProbeAttenuation(short Id, short Channel, float Attenuation)
        {
            return DigSetProbeAttenuation(Id, Channel, Attenuation);
        }
        public int SetAutoLimitRange(short Id, short Channel, short Enable)
        {
            return DigSetAutoLimitRange(Id, Channel, Enable);
        }
        public int GetChannel(short Id, short Channel, out short Enable)
        {
			Enable = 0;
			return DigGetChannel(Id, Channel, ref Enable);
		}
        public int GetChannels(short Id, out short Channels)
        {
            Channels = 0;
            return DigGetChannels(Id, ref Channels);
        }
        public int GetRange(short Id, short Channel, out float Range)
        {
			Range = 0;
			return DigGetRange(Id, Channel, ref Range);
		}
        public int GetImpedance(short Id, short Channel, out float Impedance)
        {
			Impedance = 0;
			return DigGetImpedance(Id, Channel, ref Impedance);
		}
        public int SetPreTriggerType(short Id, short TriggerType)
        {
            return DigSetPreTriggerType(Id, TriggerType);
        }
        public int SetPreTriggerDiEdge(short Id, short TriggerSource, short Slope, int TriggerCount)
        {
            return DigSetPreTriggerDiEdge(Id, TriggerSource, Slope, TriggerCount);
        }
        public int SetPreTriggerAiEdge(short Id, short TriggerSource, float Level, short Slope, int TriggerCount)
        {
            return DigSetPreTriggerAiEdge(Id, TriggerSource, Level, Slope, TriggerCount);
        }
        public int SetPreTriggerAiEdgeHysterisis(short Id, short TriggerSource, float Hysterisis)
        {
            return DigSetPreTriggerAiEdgeHysterisis(Id, TriggerSource, Hysterisis);
        }
        public int SetPreTriggerAiWindow(short Id, short TriggerSource, short EnterOrLeave,
            float HighLevel, float LowLevel, short StateType, int State1, int State2)
        {
            return DigSetPreTriggerAiWindow(Id, TriggerSource, EnterOrLeave, HighLevel, LowLevel, StateType, State1, State2);
        }
        public int SetPostTriggerType(short Id, short TriggerType)
        {
            return DigSetPostTriggerType(Id, TriggerType);
        }
        public int SetPostTriggerDiEdge(short Id, short TriggerSource, short Slope, int TriggerCount)
        {
            return DigSetPostTriggerDiEdge(Id, TriggerSource, Slope, TriggerCount);
        }
        public int SetPostTriggerAiEdge(short Id, short TriggerSource, float Level, short Slope, int TriggerCount)
        {
            return DigSetPostTriggerAiEdge(Id, TriggerSource, Level, Slope, TriggerCount);
        }
        public int SetPostTriggerAiEdgeHysterisis(short Id, short TriggerSource, float Hysterisis)
        {
            return DigSetPostTriggerAiEdgeHysterisis(Id, TriggerSource, Hysterisis);
        }
        public int SetPostTriggerAiWindow(short Id, short TriggerSource, short EnterOrLeave,
            float HighLevel, float LowLevel, short StateType, int State1, int State2)
        {
            return DigSetPostTriggerAiWindow(Id, TriggerSource, EnterOrLeave, HighLevel, LowLevel, StateType, State1, State2);
        }
        public int GetPostTriggerType(short Id, out short TriggerType)
        {
			TriggerType = 0;
			return DigGetPostTriggerType(Id, ref TriggerType);
		}
        public int GetPostTriggerAiEdge(short Id, out short TriggerSource, out float Level, out short Slope, out int TriggerCount)
        {
			TriggerSource = 0;
			Level = 0;
			Slope = 0;
			TriggerCount = 0;
			return DigGetPostTriggerAiEdge(Id, ref TriggerSource, ref Level, ref Slope, ref TriggerCount);
		}
        public int SetJudgeChannel(short Id, short Channel, short Enable)
        {
            return DigSetJudgeChannel(Id, Channel, Enable);
        }
        public int SetAutoMask(short Id, short Channel, int Hmargin, int Vmargin, short Option)
        {
            return DigSetAutoMask(Id, Channel, Hmargin, Vmargin, Option);
        }
        public int SetJudgeData(short Id, short Channel, int DataSize, float[] UpperData, float[] LowerData)
        {
            return DigSetJudgeData(Id, Channel, DataSize, UpperData, LowerData);
        }
        public int SetJudgeData32(short Id, short Channel, int DataSize, int[] UpperData, int[] LowerData)
        {
            return DigSetJudgeData32(Id, Channel, DataSize, UpperData, LowerData);
        }
        public int GetJudgeData(short Id, short Channel, int DataSize, ref float[] UpperData, ref float[] LowerData)
        {
            return DigGetJudgeData(Id, Channel, DataSize, UpperData, LowerData);
        }
        public int GetJudgeData32(short Id, short Channel, int DataSize, ref int[] UpperData, ref int[] LowerData)
        {
            return DigGetJudgeData32(Id, Channel, DataSize, UpperData, LowerData);
        }
        public int SetJudgeCountLimit(short Id, short Channel, short Condition, int Limit)
        {
            return DigSetJudgeCountLimit(Id, Channel, Condition, Limit);
        }
        public int SetJudgeSignalOut(short Id, short Channel, short Mode, short Signal, short Logic, short Destination, float PulseWidth)
        {
            return DigSetJudgeSignalOut(Id, Channel, Mode, Signal, Logic, Destination, PulseWidth);
        }
        public int Start(short Id)
        {
            return DigStart(Id);
        }
        public int StartSync(short Id, float Timeout)
        {
            return DigStartSync(Id, Timeout);
        }
        public int SoftTrigger(short Id, short TriggerType)
        {
            return DigSoftTrigger(Id, TriggerType);
        }
        public int Stop(short Id)
        {
            return DigStop(Id);
        }
        public int GetStatus(short Id, out int Status)
        {
            Status = 0;
            return DigGetStatus(Id, ref Status);
        }
        public int GetDigitizedSamples(short Id, out int Samples)
        {
            Samples = 0;
            return DigGetDigitizedSamples(Id, ref Samples);
        }
        public int GetAcquiredSamples(short Id, out int Samples)
        {
            Samples = 0;
            return DigGetAcquiredSamples(Id, ref Samples);
        }
        public int GetDriverMemorySamples(short Id, out int Samples)
        {
            Samples = 0;
            return DigGetDriverMemorySamples(Id, ref Samples);
        }
        public int GetDigitizedRecords(short Id, out int Records)
        {
            Records = 0;
            return DigGetDigitizedRecords(Id, ref Records);
        }
        public int GetAcquiredRecords(short Id, out int Records)
        {
            Records = 0;
            return DigGetAcquiredRecords(Id, ref Records);
        }
        public int GetDriverMemoryRecords(short Id, out int Records)
        {
            Records = 0;
            return DigGetDriverMemoryRecords(Id, ref Records);
        }
        public int GetJudgeCount(short Id, out int JudgeCount)
        {
            JudgeCount = 0;
            return DigGetJudgeCount(Id, ref JudgeCount);
        }
		// Overriding type of the last seven types
		public int ReadEarliestRecords(short Id, int Option, int RecordNum,
        	ref float[] RecordData, ref short[] Judge, ref short[] JudgeDetail)
        {
            return DigReadEarliestRecords(Id, Option, RecordNum, RecordData, Judge, JudgeDetail);
        }
		public int ReadEarliestRecords(short Id, int Option, int RecordNum,
			ref float[] RecordData, ref short[] Judge, int Null1)
		{
			short[] temp1 = new short[1];
			return DigReadEarliestRecords(Id, Option, RecordNum, RecordData, Judge, temp1);
		}
		public int ReadEarliestRecords(short Id, int Option, int RecordNum,
			ref float[] RecordData, int Null1, ref short[] JudgeDetail)
		{
			short[] temp1 = new short[1];
			return DigReadEarliestRecords(Id, Option, RecordNum, RecordData, temp1, JudgeDetail);
		}
		public int ReadEarliestRecords(short Id, int Option, int RecordNum,
			int Null1, ref short[] Judge, ref short[] JudgeDetail)
		{
			float[] temp1 = new float[1];
			return DigReadEarliestRecords(Id, Option, RecordNum, temp1, Judge, JudgeDetail);
		}
		public int ReadEarliestRecords(short Id, int Option, int RecordNum,
			ref float[] RecordData, int Null1, int Null2)
		{
			short[] temp1 = new short[1];
			short[] temp2 = new short[1];
			return DigReadEarliestRecords(Id, Option, RecordNum, RecordData, temp1, temp2);
		}
		public int ReadEarliestRecords(short Id, int Option, int RecordNum,
			int Null1, ref short[] Judge, int Null2)
		{
			float[] temp1 = new float[1];
			short[] temp2 = new short[1];
			return DigReadEarliestRecords(Id, Option, RecordNum, temp1, Judge, temp2);
		}
		public int ReadEarliestRecords(short Id, int Option, int RecordNum,
			int Null1, int Null2, ref short[] JudgeDetail)
		{
			float[] temp1 = new float[1];
			short[] temp2 = new short[1];
			return DigReadEarliestRecords(Id, Option, RecordNum, temp1, temp2, JudgeDetail);
		}
		// Overriding type of the last seven types
		public int ReadEarliestRecords32(short Id, int Option, int RecordNum,
			ref int[] RecordData, ref short[] Judge, ref short[] JudgeDetail)
		{
			return DigReadEarliestRecords32(Id, Option, RecordNum, RecordData, Judge, JudgeDetail);
		}
		public int ReadEarliestRecords32(short Id, int Option, int RecordNum,
			ref int[] RecordData, ref short[] Judge, int Null1)
		{
			short[] temp1 = new short[1];
			return DigReadEarliestRecords32(Id, Option, RecordNum, RecordData, Judge, temp1);
		}
		public int ReadEarliestRecords32(short Id, int Option, int RecordNum,
			ref int[] RecordData, int Null1, ref short[] JudgeDetail)
		{
			short[] temp1 = new short[1];
			return DigReadEarliestRecords32(Id, Option, RecordNum, RecordData, temp1, JudgeDetail);
		}
		public int ReadEarliestRecords32(short Id, int Option, int RecordNum,
			int Null1, ref short[] Judge, ref short[] JudgeDetail)
		{
			int[] temp1 = new int[1];
			return DigReadEarliestRecords32(Id, Option, RecordNum, temp1, Judge, JudgeDetail);
		}
		public int ReadEarliestRecords32(short Id, int Option, int RecordNum,
			ref int[] RecordData, int Null1, int Null2)
		{
			short[] temp1 = new short[1];
			short[] temp2 = new short[1];
			return DigReadEarliestRecords32(Id, Option, RecordNum, RecordData, temp1, temp2);
		}
		public int ReadEarliestRecords32(short Id, int Option, int RecordNum,
			int Null1, ref short[] Judge, int Null2)
		{
			int[] temp1 = new int[1];
			short[] temp2 = new short[1];
			return DigReadEarliestRecords32(Id, Option, RecordNum, temp1, Judge, temp2);
		}
		public int ReadEarliestRecords32(short Id, int Option, int RecordNum,
			int Null1, int Null2, ref short[] JudgeDetail)
		{
			int[] temp1 = new int[1];
			short[] temp2 = new short[1];
			return DigReadEarliestRecords32(Id, Option, RecordNum, temp1, temp2, JudgeDetail);
		}
		// Overriding type of the last seven types
		public int ReadLatestRecords(short Id, int Option, int RecordNum,
        	ref float[] RecordData, ref short[] Judge, ref short[] JudgeDetail)
        {
            return DigReadLatestRecords(Id, Option, RecordNum, RecordData, Judge, JudgeDetail);
        }
		public int ReadLatestRecords(short Id, int Option, int RecordNum,
			ref float[] RecordData, ref short[] Judge, int Null1)
		{
			short[] temp1 = new short[1];
			return DigReadLatestRecords(Id, Option, RecordNum, RecordData, Judge, temp1);
		}
		public int ReadLatestRecords(short Id, int Option, int RecordNum,
			ref float[] RecordData, int Null1, ref short[] JudgeDetail)
		{
			short[] temp1 = new short[1];
			return DigReadLatestRecords(Id, Option, RecordNum, RecordData, temp1, JudgeDetail);
		}
		public int ReadLatestRecords(short Id, int Option, int RecordNum,
			int Null1, ref short[] Judge, ref short[] JudgeDetail)
		{
			float[] temp1 = new float[1];
			return DigReadLatestRecords(Id, Option, RecordNum, temp1, Judge, JudgeDetail);
		}
		public int ReadLatestRecords(short Id, int Option, int RecordNum,
			ref float[] RecordData, int Null1, int Null2)
		{
			short[] temp1 = new short[1];
			short[] temp2 = new short[1];
			return DigReadLatestRecords(Id, Option, RecordNum, RecordData, temp1, temp2);
		}
		public int ReadLatestRecords(short Id, int Option, int RecordNum,
			int Null1, ref short[] Judge, int Null2)
		{
			float[] temp1 = new float[1];
			short[] temp2 = new short[1];
			return DigReadLatestRecords(Id, Option, RecordNum, temp1, Judge, temp2);
		}
		public int ReadLatestRecords(short Id, int Option, int RecordNum,
			int Null1, int Null2, ref short[] JudgeDetail)
		{
			float[] temp1 = new float[1];
			short[] temp2 = new short[1];
			return DigReadLatestRecords(Id, Option, RecordNum, temp1, temp2, JudgeDetail);
		}
		// Overriding type of the last seven types
        public int ReadLatestRecords32(short Id, int Option, int RecordNum,
        	ref int[] RecordData, ref short[] Judge, ref short[] JudgeDetail)
        {
            return DigReadLatestRecords32(Id, Option, RecordNum, RecordData, Judge, JudgeDetail);
        }
		public int ReadLatestRecords32(short Id, int Option, int RecordNum,
			ref int[] RecordData, ref short[] Judge, int Null1)
		{
			short[] temp1 = new short[1];
			return DigReadLatestRecords32(Id, Option, RecordNum, RecordData, Judge, temp1);
		}
		public int ReadLatestRecords32(short Id, int Option, int RecordNum,
			ref int[] RecordData, int Null1, ref short[] JudgeDetail)
		{
			short[] temp1 = new short[1];
			return DigReadLatestRecords32(Id, Option, RecordNum, RecordData, temp1, JudgeDetail);
		}
		public int ReadLatestRecords32(short Id, int Option, int RecordNum,
			int Null1, ref short[] Judge, ref short[] JudgeDetail)
		{
			int[] temp1 = new int[1];
			return DigReadLatestRecords32(Id, Option, RecordNum, temp1, Judge, JudgeDetail);
		}
		public int ReadLatestRecords32(short Id, int Option, int RecordNum,
			ref int[] RecordData, int Null1, int Null2)
		{
			short[] temp1 = new short[1];
			short[] temp2 = new short[1];
			return DigReadLatestRecords32(Id, Option, RecordNum, RecordData, temp1, temp2);
		}
		public int ReadLatestRecords32(short Id, int Option, int RecordNum,
			int Null1, ref short[] Judge, int Null2)
		{
			int[] temp1 = new int[1];
			short[] temp2 = new short[1];
			return DigReadLatestRecords32(Id, Option, RecordNum, temp1, Judge, temp2);
		}
		public int ReadLatestRecords32(short Id, int Option, int RecordNum,
			int Null1, int Null2, ref short[] JudgeDetail)
		{
			int[] temp1 = new int[1];
			short[] temp2 = new short[1];
			return DigReadLatestRecords32(Id, Option, RecordNum, temp1, temp2, JudgeDetail);
		}
        public int ReadSamples32(short Id, ref int Samples, ref int[] SampleData, out int TriggerPoint)
        {
            TriggerPoint = 0;
            return DigReadSamples32(Id, ref Samples, SampleData, ref TriggerPoint);
        }
        public int ReadSamples(short Id, ref int Samples, ref float[] SampleData, out int TriggerPoint)
        {
            TriggerPoint = 0;
            return DigReadSamples(Id, ref Samples, SampleData, ref TriggerPoint);
        }
        public int ReadSingleData(short Id, short DataSize, ref float[] Data)
        {
            return DigReadSingleData(Id, DataSize, Data);
        }
        public int ReadSingleData32(short Id, short DataSize, ref int[] Data)
        {
            return DigReadSingleData32(Id, DataSize, Data);
        }
        public int SetControlFilter(short Id, short Signal, float Value)
        {
            return DigSetControlFilter(Id, Signal, Value);
        }
        public int GetTemperature(short Id, out float Temperature)
        {
            Temperature = 0;
            return DigGetTemperature(Id, ref Temperature);
        }
        public int GetErrorString(int ErrorCode, out string ErrorString)
        {
            ErrorString = new String('0', 1);
            System.Text.StringBuilder errorstring = new System.Text.StringBuilder(256);
            int ret = DigGetErrorString(ErrorCode, errorstring);
            if (ret == 0)
            {
                ErrorString = errorstring.ToString();
            }
            return ret;
        }
        public int QueryDeviceName(short Index, out string DeviceName, out string Device)
        {
            DeviceName = new String('0', 1);
            Device = new String('0', 1);
            System.Text.StringBuilder devicename = new System.Text.StringBuilder(256);
            System.Text.StringBuilder device = new System.Text.StringBuilder(256);
            int ret = DigQueryDeviceName(Index, devicename, device);
            if (ret == 0)
            {
                DeviceName = devicename.ToString();
                Device = device.ToString();
            }
            return ret;
        }
        public int GetDeviceType(string Device, out short DeviceType)
        {
            DeviceType = 0;
            return DigGetDeviceType(Device, ref DeviceType);
        }
    }
}
