unit AIOENet;

interface

{$IFDEF VER130}  // Delphi 5
type
	UInt64 = Int64;
{$ENDIF}

type
	TUInt8      = Byte    ; TPUInt8      = ^TUInt8     ;
	TUInt16     = Word    ; TPUInt16     = ^TUInt16    ;
	TUInt32     = LongWord; TPUInt32     = ^TUInt32    ;
	TUInt64     = UInt64  ; TPUInt64     = ^TUInt64    ;
	TUIntNative = Cardinal; TPUIntNative = ^TUIntNative;
	TSInt8      = ShortInt; TPSInt8      = ^TSInt8     ;
	TSInt16     = SmallInt; TPSInt16     = ^TSInt16    ;
	TSInt32     = LongInt ; TPSInt32     = ^TSInt32    ;
	TSInt64     = Int64   ; TPSInt64     = ^Int64      ;
	TSIntNative = Integer ; TPSIntNative = ^TSIntNative;
	TSingle     = Single  ; TPSingle     = ^TSingle    ;
	TDouble     = Double  ; TPDouble     = ^TDouble    ;

{$IFDEF VER130}  // Delphi 5
type
	UCS4Char = TUInt32;
{$ENDIF}

type
	TAnsiChar = AnsiChar; TPAnsiChar = ^TAnsiChar;
	TWideChar = WideChar; TPWideChar = ^TWideChar;
	TUCS4Char = UCS4Char; TPUCS4Char = ^TUCS4Char;

type
	TWinErrCode = TUInt32;
	TPWinErrCode = ^TWinErrCode;

type
	TChannelIndex = TUInt32;
const
	ciAll = TChannelIndex(-1);

type
	TRangeCode = TUInt32;
	TPRangeCode = ^TRangeCode;
const
	rcNoChange     = TRangeCode(-1);
	rcUnipolar10   = TRangeCode($30313055); //FourCC('U010');
	rcUnipolar5    = TRangeCode($35303055); //FourCC('U005');
	rcUnipolar2    = TRangeCode($32303055); //FourCC('U002');
	rcUnipolar1    = TRangeCode($31303055); //FourCC('U001');
	rcBipolar24    = TRangeCode($3432E142); //FourCC('B±24');
	rcBipolar20    = TRangeCode($3032E142); //FourCC('B±20');
	rcBipolar12    = TRangeCode($3231E142); //FourCC('B±12');
	rcBipolar10    = TRangeCode($3031E142); //FourCC('B±10');
	rcBipolar5     = TRangeCode($3530E142); //FourCC('B±05');
	rcBipolar2_5   = TRangeCode($BD32E142); //FourCC('B±2½');
	rcBipolar2     = TRangeCode($3230E142); //FourCC('B±02');
	rcBipolar1_25  = TRangeCode($BC31E142); //FourCC('B±1¼');
	rcBipolar1     = TRangeCode($3130E142); //FourCC('B±01');
	rcBipolar_625  = TRangeCode($3835E142); //FourCC('B±58');
	rcBipolar_3125  = TRangeCode($3331E142); //FourCC('B±13');
	//rcCurrent420   = TRangeCode($30323449); //FourCC('I420'); // mA
	rcRangeCode0   = TRangeCode(0);
	rcRangeCode1   = TRangeCode(1);
	rcRangeCode2   = TRangeCode(2);
	rcRangeCode3   = TRangeCode(3);
	rcRangeCode4   = TRangeCode(4);
	rcRangeCode5   = TRangeCode(5);
	rcRangeCode6   = TRangeCode(6);
	rcRangeCode7   = TRangeCode(7);

type
	TCalMode = TUInt32;
	TPCalMode = TPUInt32;
const
	cmRealData	= TCalMode(0);
	cmUnipolarGround	= TCalMode(1);
	cmUnipolarReference	= TCalMode(3);
	cmBipolarGround	= TCalMode(5);
	cmBipolarReference	= TCalMode(7);

type
	TClientRef = Pointer;

//System(nil) functions.
function ScanForDevices(NameListChAvailable: TUInt32; pNameList: TPAnsiChar; out NameListCh: TUInt32): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'ScanForDevicesA';
function ScanForDevices(NameListChAvailable: TUInt32; pNameList: TPWideChar; out NameListCh: TUInt32): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'ScanForDevicesW';
function ScanForDevices(NameListChAvailable: TUInt32; pNameList: TPUCS4Char; out NameListCh: TUInt32): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'ScanForDevicesU';
function ScanForDevicesA(NameListChAvailable: TUInt32; pNameList: TPAnsiChar; out NameListCh: TUInt32): TWinErrCode; cdecl; external 'AIOENet.dll';
function ScanForDevicesW(NameListChAvailable: TUInt32; pNameList: TPWideChar; out NameListCh: TUInt32): TWinErrCode; cdecl; external 'AIOENet.dll';
function ScanForDevicesU(NameListChAvailable: TUInt32; pNameList: TPUCS4Char; out NameListCh: TUInt32): TWinErrCode; cdecl; external 'AIOENet.dll';

function Connect(Host: TPAnsiChar; Index: TUInt32 = 0): TClientRef; cdecl; overload; external 'AIOENet.dll' name 'ConnectA';
function Connect(Host: TPWideChar; Index: TUInt32 = 0): TClientRef; cdecl; overload; external 'AIOENet.dll' name 'ConnectW';
function Connect(Host: TPUCS4Char; Index: TUInt32 = 0): TClientRef; cdecl; overload; external 'AIOENet.dll' name 'ConnectU';
function ConnectA(Host: TPAnsiChar; Index: TUInt32 = 0): TClientRef; cdecl; external 'AIOENet.dll';
function ConnectW(Host: TPWideChar; Index: TUInt32 = 0): TClientRef; cdecl; external 'AIOENet.dll';
function ConnectU(Host: TPUCS4Char; Index: TUInt32 = 0): TClientRef; cdecl; external 'AIOENet.dll';

function Disconnect(uClientRef: TClientRef): TWinErrCode; cdecl; external 'AIOENet.dll';

function GetDeviceFeatures(uClientRef: TClientRef; FeatureBytes: TUInt32; pFeatures: TPUInt8): TWinErrCode; cdecl; external 'AIOENet.dll';

function SetTimeout(uClientRef: TClientRef; TimeoutMS: TSInt32): TWinErrCode; cdecl; external 'AIOENet.dll';

//DIO functions.
function DIO_Configure(uClientRef: TClientRef; pDataBytes: TPUInt32; pData: TPUInt8; pDirection: TPUInt8): TWinErrCode; cdecl; external 'AIOENet.dll';
function DIO_ReadDirection(uClientRef: TClientRef; pDataBytes: TPUInt32; pData: TPUInt8): TWinErrCode; cdecl; external 'AIOENet.dll';
function DIO_WriteAll(uClientRef: TClientRef; pDataBytes: TPUInt32; pData: TPUInt8): TWinErrCode; cdecl; external 'AIOENet.dll';
function DIO_ReadAll(uClientRef: TClientRef; pDataBytes: TPUInt32; pData: TPUInt8): TWinErrCode; cdecl; external 'AIOENet.dll';

//A/D(ADC) functions.
function ADC_Reset(uClientRef: TClientRef): TWinErrCode; cdecl; external 'AIOENet.dll';

function ADC_SetRange(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; RangeCode: TRangeCode): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_SetDifferential(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; bDifferential: ByteBool): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_SetChScan(uClientRef: TClientRef; FirstCh, LastCh: TChannelIndex): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_SetOversample(uClientRef: TClientRef; Oversample: TUInt32): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_SetCalMode(uClientRef: TClientRef; CalMode: TCalMode = cmRealData): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_SetRangeCal(uClientRef: TClientRef; RangeCode: TRangeCode; ScaleFactor: TDouble = 1; OffsetCounts: TDouble = 0): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_SetRate(uClientRef: TClientRef; Rate: TDouble): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_GetRate(uClientRef: TClientRef; out Rate: TDouble): TWinErrCode; cdecl; external 'AIOENet.dll';

function ADC_ImmediateGetData(uClientRef: TClientRef; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'ADC_ImmediateGetScanV';
function ADC_ImmediateGetData(uClientRef: TClientRef; pDataRaw: TPUInt32): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'ADC_ImmediateGetScanRaw';
function ADC_ImmediateGetData(uClientRef: TClientRef; Ch: TChannelIndex; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'ADC_ImmediateGetSampleV';
function ADC_ImmediateGetData(uClientRef: TClientRef; Ch: TChannelIndex; pDataRaw: TPUInt32): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'ADC_ImmediateGetSampleRaw';
function ADC_ImmediateGetScanV(uClientRef: TClientRef; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_ImmediateGetScanRaw(uClientRef: TClientRef; pDataRaw: TPUInt32): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_ImmediateGetSampleV(uClientRef: TClientRef; Ch: TChannelIndex; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_ImmediateGetSampleRaw(uClientRef: TClientRef; Ch: TChannelIndex; pDataRaw: TPUInt32): TWinErrCode; cdecl; external 'AIOENet.dll';

function ADC_AcquireBegin(uClientRef: TClientRef; TriggerMode: TUInt8 = $15): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_AcquireEnd(uClientRef: TClientRef): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_AcquireGetData(uClientRef: TClientRef; pDataSamples: TPUInt32; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'ADC_AcquireGetDataV';
function ADC_AcquireGetData(uClientRef: TClientRef; pDataSamples: TPUInt32; pDataRaw: TPUInt32): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'ADC_AcquireGetDataRaw';
function ADC_AcquireGetDataV(uClientRef: TClientRef; pDataSamples: TPUInt32; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; cdecl; external 'AIOENet.dll';
function ADC_AcquireGetDataRaw(uClientRef: TClientRef; pDataSamples: TPUInt32; pDataRaw: TPUInt32): TWinErrCode; cdecl; external 'AIOENet.dll';

//D/A(DAC) functions.
function DAC_GetRange(uClientRef: TClientRef; Ch: TChannelIndex; pRange: TPRangeCode = nil; pLowV: TPDouble = nil; pHighV: TPDouble = nil): TWinErrCode; cdecl; external 'AIOENet.dll';
function DAC_Enable(uClientRef: TClientRef): TWinErrCode; cdecl; external 'AIOENet.dll';
function DAC_Disable(uClientRef: TClientRef): TWinErrCode; cdecl; external 'AIOENet.dll';

function DAC_Output(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; V: TDouble): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'DAC_OutputV';
function DAC_Output(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; Counts: TUInt16): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'DAC_OutputCounts';
function DAC_Output(uClientRef: TClientRef; Channels: TUInt32; pV: TPDouble): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'DAC_OutputNV';
function DAC_Output(uClientRef: TClientRef; Channels: TUInt32; pCounts: TPUInt16): TWinErrCode; cdecl; overload; external 'AIOENet.dll' name 'DAC_OutputNCounts';
function DAC_OutputV(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; V: TDouble): TWinErrCode; cdecl; external 'AIOENet.dll';
function DAC_OutputCounts(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; Counts: TUInt16): TWinErrCode; cdecl; external 'AIOENet.dll';
function DAC_OutputFrac(uClientRef: TClientRef; Ch: TChannelIndex {= ciAll}; Frac: TDouble): TWinErrCode; cdecl; external 'AIOENet.dll';
function DAC_OutputNV(uClientRef: TClientRef; Channels: TUInt32; pV: TPDouble): TWinErrCode; cdecl; external 'AIOENet.dll';
function DAC_OutputNCounts(uClientRef: TClientRef; Channels: TUInt32; pCounts: TPUInt16): TWinErrCode; cdecl; external 'AIOENet.dll';
function DAC_OutputNFrac(uClientRef: TClientRef; Channels: TUInt32; pFrac: TPDouble): TWinErrCode; cdecl; external 'AIOENet.dll';

function DAC_SetChCal(uClientRef: TClientRef; Ch: TChannelIndex; ScaleFactor: TDouble = 1; OffsetCounts: TDouble = 0): TWinErrCode; cdecl; external 'AIOENet.dll';
function DAC_SetAllCal(uClientRef: TClientRef; pScaleFactor: TPDouble = nil; pOffsetCounts: TPDouble = nil): TWinErrCode; cdecl; external 'AIOENet.dll';

implementation

end.
