library AIOAIO;

uses
	Winapi.Windows,
	Core in 'Core.pas',
	//LogThreads in 'LogThreads.pas',
	CoreExports in 'CoreExports.pas',
	PIOExports in 'PIOExports.pas',
	ADCExports in 'ADCExports.pas',
	ADCStreamExports in 'ADCStreamExports.pas',
	DACExports in 'DACExports.pas';

{$R *.res}



function VBBRD_GetHighestBoardIndex: TBoardIndex; stdcall;
begin
	Result := BRD_GetHighestBoardIndex;
end;

function VBBRD_GetDeviceID(iBoard: TBoardIndex; pDeviceID: TPUInt32): TWinErrCode; stdcall;
begin
	Result := BRD_GetDeviceID(iBoard, pDeviceID);
end;

function VBBRD_GetNameA(iBoard: TBoardIndex; BufLen: TUInt32; pNameBuf: TPAnsiChar = nil; pNameLen: TPUInt32 = nil): TWinErrCode; stdcall;
begin
	Result := BRD_GetNameA(iBoard, BufLen, pNameBuf, pNameLen);
end;

function VBBRD_GetNameW(iBoard: TBoardIndex; BufLen: TUInt32; pNameBuf: TPWideChar = nil; pNameLen: TPUInt32 = nil): TWinErrCode; stdcall;
begin
	Result := BRD_GetNameW(iBoard, BufLen, pNameBuf, pNameLen);
end;

function VBBRD_GetSerialNumber(iBoard: TBoardIndex; pSN: TPSerialNumber): TWinErrCode; stdcall;
begin
	Result := BRD_GetSerialNumber(iBoard, pSN);
end;

function VBBRD_Reset(iBoard: TBoardIndex): TWinErrCode; stdcall;
begin
	Result := BRD_Reset(iBoard);
end;



function VBDAC_SetRange1(iBoard: TBoardIndex; Ch: TChannelIndex = ciAll; Range: TRangeCode = rcBipolar10): TWinErrCode; stdcall;
begin
	Result := DAC_SetRange1(iBoard, Ch, Range);
end;

function VBDAC_SetRangeAll(iBoard: TBoardIndex; RangeCt: TUInt32; pRange: TPRangeCode): TWinErrCode; stdcall;
begin
	Result := DAC_SetRangeAll(iBoard, RangeCt, pRange);
end;

function VBDAC_OutputCounts(iBoard: TBoardIndex; Ch: TChannelIndex {= ciAll}; Counts: TUInt64): TWinErrCode; stdcall;
begin
	Result := DAC_OutputCounts(iBoard, Ch, Counts);
end;

function VBDAC_OutputV(iBoard: TBoardIndex; Ch: TChannelIndex {= ciAll}; V: TDouble): TWinErrCode; stdcall;
begin
	Result := DAC_OutputV(iBoard, Ch, V);
end;



function VBADC_SetRange1(iBoard: TBoardIndex; iSequencer: TSequencerIndex; Ch: TChannelIndex = ciAll; RangeCode: TRangeCode = rcBipolar10): TWinErrCode; stdcall;
begin
	Result := ADC_SetRange1(iBoard, iSequencer, Ch, RangeCode);
end;

function VBADC_SetRangeAll(iBoard: TBoardIndex; iSequencer: TSequencerIndex; RangeCt: TUInt32; pRangeCodes: TPRangeCode): TWinErrCode; stdcall;
begin
	Result := ADC_SetRangeAll(iBoard, iSequencer, RangeCt, pRangeCodes);
end;

function VBADC_SetRate(iBoard: TBoardIndex; iSequencer: TSequencerIndex; Hz: TDouble): TWinErrCode; stdcall;
begin
	Result := ADC_SetRate(iBoard, iSequencer, Hz);
end;

function VBADC_GetRate(iBoard: TBoardIndex; iSequencer: TSequencerIndex; pHz: TPDouble): TWinErrCode; stdcall;
begin
	Result := ADC_GetRate(iBoard, iSequencer, pHz);
end;

function VBADC_SetChannelCount(iBoard: TBoardIndex; iSequencer: TSequencerIndex; ChCt: TChannelIndex = ciAll): TWinErrCode; stdcall;
begin
	Result := ADC_SetChannelCount(iBoard, iSequencer, ChCt);
end;

function VBADC_SetDifferential(iBoard: TBoardIndex; bDifferential: LongBool): TWinErrCode; cdecl;
begin
	Result := ADC_SetDifferential(iBoard, bDifferential);
end;

function VBADC_GetImmediateV(iBoard: TBoardIndex; iSequencer: TSequencerIndex; out V: TDouble; Ch: TChannelIndex; Range: TRangeCode = rcNoChange): TWinErrCode; stdcall;
begin
	Result := ADC_GetImmediateV(iBoard, iSequencer, V, Ch, Range);
end;

function VBADC_GetImmediateRaw(iBoard: TBoardIndex; iSequencer: TSequencerIndex; out Data: TUInt32; Ch: TChannelIndex; Range: TRangeCode = rcNoChange): TWinErrCode; stdcall;
begin
	Result := ADC_GetImmediateRaw(iBoard, iSequencer, Data, Ch, Range);
end;

function VBADC_GetImmediateScanV(iBoard: TBoardIndex; pVData: TPDouble; Range: TRangeCode = rcNoChange): TWinErrCode; cdecl;
begin
	Result := ADC_GetImmediateScanV(iBoard, pVData, Range);
end;

function VBADC_GetImmediateScanRaw(iBoard: TBoardIndex; pRawData: TPUInt32; Range: TRangeCode = rcNoChange): TWinErrCode; cdecl;
begin
	Result := ADC_GetImmediateScanRaw(iBoard, pRawData, Range);
end;

function VBADC_ConfigureAcquire(iBoard: TBoardIndex; iSequencer: TSequencerIndex; ChunkingType: TChunkingType; Chunk: TUInt32): TWinErrCode; stdcall;
begin
	Result := ADC_ConfigureAcquire(iBoard, iSequencer, ChunkingType, Chunk);
end;

function VBADC_AcquireBlock(iBoard: TBoardIndex; iSequencer: TSequencerIndex; SampleCt: TUNative): TWinErrCode; stdcall;
begin
	Result := ADC_AcquireBlock(iBoard, iSequencer, SampleCt);
end;

function VBADC_AcquireStream(iBoard: TBoardIndex; iSequencer: TSequencerIndex): TWinErrCode; stdcall;
begin
	Result := ADC_AcquireStream(iBoard, iSequencer);
end;

function VBADC_AcquireEnd(iBoard: TBoardIndex; iSequencer: TSequencerIndex): TWinErrCode; stdcall;
begin
	Result := ADC_AcquireEnd(iBoard, iSequencer);
end;

function VBADC_SetCallback(iBoard: TBoardIndex; iSequencer: TSequencerIndex; CallbackType: TCallbackType; pCallback: Pointer = nil): TWinErrCode; stdcall;
begin
	Result := ADC_SetCallback(iBoard, iSequencer, CallbackType, pCallback);
end;

function VBADC_GetDataV(iBoard: TBoardIndex; iSequencer: TSequencerIndex; DataCt: TUInt32; var GotDataCt: TUInt32; pData: TPDouble = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; stdcall;
begin
	Result := ADC_GetDataV(iBoard, iSequencer, DataCt, GotDataCt, pData, pStatus, pTimestamp);
end;

function VBADC_GetDataCounts(iBoard: TBoardIndex; iSequencer: TSequencerIndex; DataCt: TUInt32; var GotDataCt: TUInt32; pData: TPUInt16 = nil; pStatus: TPUInt16 = nil; pTimestamp: TPUInt16 = nil): TWinErrCode; stdcall;
begin
	Result := ADC_GetDataCounts(iBoard, iSequencer, DataCt, GotDataCt, pData, pStatus, pTimestamp);
end;

function VBADC_GetDataRaw(iBoard: TBoardIndex; iSequencer: TSequencerIndex; DataCt: TUInt32; var GotDataCt: TUInt32; pDataRaw: TPUInt32 = nil): TWinErrCode; stdcall;
begin
	Result := ADC_GetDataRaw(iBoard, iSequencer, DataCt, GotDataCt, pDataRaw);
end;

function VBADC_PollData(iBoard: TBoardIndex; iSequencer: TSequencerIndex): TWinErrCode; stdcall;
begin
	Result := ADC_PollData(iBoard, iSequencer);
end;

function VBADC_ClearData(iBoard: TBoardIndex; iSequencer: TSequencerIndex): TWinErrCode; stdcall;
begin
	Result := ADC_ClearData(iBoard, iSequencer);
end;



function VBPIO_In8(iBoard: TBoardIndex; Offset: TUInt32): TUInt8; stdcall;
begin
	Result := PIO_In8(iBoard, Offset);
end;

function VBPIO_In16(iBoard: TBoardIndex; Offset: TUInt32): TUInt16; stdcall;
begin
	Result := PIO_In16(iBoard, Offset);
end;

function VBPIO_In32(iBoard: TBoardIndex; Offset: TUInt32): TUInt32; stdcall;
begin
	Result := PIO_In32(iBoard, Offset);
end;

function VBPIO_Out8(iBoard: TBoardIndex; Offset: TUInt32; Data: TUInt8): TWinErrCode; stdcall;
begin
	Result := PIO_Out8(iBoard, Offset, Data);
end;

function VBPIO_Out16(iBoard: TBoardIndex; Offset: TUInt32; Data: TUInt16): TWinErrCode; stdcall;
begin
	Result := PIO_Out16(iBoard, Offset, Data);
end;

function VBPIO_Out32(iBoard: TBoardIndex; Offset: TUInt32; Data: TUInt32): TWinErrCode; stdcall;
begin
	Result := PIO_Out32(iBoard, Offset, Data);
end;

function VBPIO_INS8(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt8): TWinErrCode; stdcall;
begin
	Result := PIO_INS8(iBoard, Offset, DataCt, pData);
end;

function VBPIO_INS16(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt16): TWinErrCode; stdcall;
begin
	Result := PIO_INS16(iBoard, Offset, DataCt, pData);
end;

function VBPIO_INS32(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt32): TWinErrCode; stdcall;
begin
	Result := PIO_INS32(iBoard, Offset, DataCt, pData);
end;

function VBPIO_OUTS8(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt8): TWinErrCode; stdcall;
begin
	Result := PIO_OUTS8(iBoard, Offset, DataCt, pData);
end;

function VBPIO_OUTS16(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt16): TWinErrCode; stdcall;
begin
	Result := PIO_OUTS16(iBoard, Offset, DataCt, pData);
end;

function VBPIO_OUTS32(iBoard: TBoardIndex; Offset: TUInt32; DataCt: TUInt32; pData: TPUInt32): TWinErrCode; stdcall;
begin
	Result := PIO_OUTS32(iBoard, Offset, DataCt, pData);
end;

function VBPIO_WaitForIRQ(iBoard: TBoardIndex; IRQIndex: TIRQIndex = iiOnly): TWinErrCode; stdcall;
begin
	Result := PIO_WaitForIRQ(iBoard, IRQIndex);
end;

function VBPIO_PollForIRQ(iBoard: TBoardIndex; IRQIndex: TIRQIndex = iiOnly): TWinErrCode; stdcall;
begin
	Result := PIO_PollForIRQ(iBoard, IRQIndex);
end;

function VBPIO_AbortIRQWait(iBoard: TBoardIndex; IRQIndex: TIRQIndex = iiOnly): TWinErrCode; stdcall;
begin
	Result := PIO_AbortIRQWait(iBoard, IRQIndex);
end;

function VBPIO_DMAPiongControl(iBoard: TBoardIndex; pControlReply: TPUInt8; ControlSize: TUInt32; ReplySize: TPUInt32 = nil): TWinErrCode; stdcall;
begin
	Result := PIO_DMAPiongControl(iBoard, pControlReply, ControlSize, ReplySize);
end;

function VBPIO_DMAPiongIn(iBoard: TBoardIndex; pData: TPUInt8; DataSize: TUInt32; pOverlap: POverlapped): TWinErrCode; stdcall;
begin
	Result := PIO_DMAPiongIn(iBoard, pData, DataSize, pOverlap);
end;

function VBPIO_DMAChPiongIn(iBoard: TBoardIndex; DMAChannel: TUInt32; pData: TPUInt8; DataSize: TUInt32; pOverlap: POverlapped): TWinErrCode; stdcall;
begin
	Result := PIO_DMAChPiongIn(iBoard, DMAChannel, pData, DataSize, pOverlap);
end;

function VBPIO_GetDeviceHandle(iBoard: TBoardIndex; var hDevice: THandle): TWinErrCode; cdecl;
begin
	Result := PIO_GetDeviceHandle(iBoard, hDevice);
end;

function VBPIO_QueryBARBase(iBoard: TBoardIndex; iBAR: LongWord; pBase: PLongWord): TWinErrCode; stdcall;
begin
	Result := PIO_QueryBARBase(iBoard, iBAR, pBase);
end;

exports
	PIO_DMAChPiongIn        , PIO_DMAChPiongIn         name '_PIO_DMAChPiongIn'        , VBPIO_DMAChPiongIn        ,

	BRD_GetDeviceID         , BRD_GetDeviceID          name '_BRD_GetDeviceID'         , VBBRD_GetDeviceID         ,

	ADC_SetDifferential     , ADC_SetDifferential      name '_ADC_SetDifferential'     , VBADC_SetDifferential     ,

	PIO_QueryBARBase        , PIO_QueryBARBase         name '_PIO_QueryBARBase'        , VBPIO_QueryBARBase        ,
	PIO_GetDeviceHandle     , PIO_GetDeviceHandle      name '_PIO_GetDeviceHandle'     , VBPIO_GetDeviceHandle     ,
	PIO_DMAPiongIn          , PIO_DMAPiongIn           name '_PIO_DMAPiongIn'          , VBPIO_DMAPiongIn          ,
	PIO_DMAPiongControl     , PIO_DMAPiongControl      name '_PIO_DMAPiongControl'     , VBPIO_DMAPiongControl     ,

	PIO_AbortIRQWait        , PIO_AbortIRQWait         name '_PIO_AbortIRQWait'        , VBPIO_AbortIRQWait        ,
	PIO_PollForIRQ          , PIO_PollForIRQ           name '_PIO_PollForIRQ'          , VBPIO_PollForIRQ          ,
	PIO_WaitForIRQ          , PIO_WaitForIRQ           name '_PIO_WaitForIRQ'          , VBPIO_WaitForIRQ          ,
	PIO_OUTS32              , PIO_OUTS32               name '_PIO_OUTS32'              , VBPIO_OUTS32              ,
	PIO_OUTS16              , PIO_OUTS16               name '_PIO_OUTS16'              , VBPIO_OUTS16              ,
	PIO_OUTS8               , PIO_OUTS8                name '_PIO_OUTS8'               , VBPIO_OUTS8               ,
	PIO_INS32               , PIO_INS32                name '_PIO_INS32'               , VBPIO_INS32               ,
	PIO_INS16               , PIO_INS16                name '_PIO_INS16'               , VBPIO_INS16               ,
	PIO_INS8                , PIO_INS8                 name '_PIO_INS8'                , VBPIO_INS8                ,
	PIO_Out32               , PIO_Out32                name '_PIO_Out32'               , VBPIO_Out32               ,
	PIO_Out16               , PIO_Out16                name '_PIO_Out16'               , VBPIO_Out16               ,
	PIO_Out8                , PIO_Out8                 name '_PIO_Out8'                , VBPIO_Out8                ,
	PIO_In32                , PIO_In32                 name '_PIO_In32'                , VBPIO_In32                ,
	PIO_In16                , PIO_In16                 name '_PIO_In16'                , VBPIO_In16                ,
	PIO_In8                 , PIO_In8                  name '_PIO_In8'                 , VBPIO_In8                 ,

	ADC_ClearData           , ADC_ClearData            name '_ADC_ClearData'           , VBADC_ClearData           ,
	ADC_PollData            , ADC_PollData             name '_ADC_PollData'            , VBADC_PollData            ,
	ADC_GetDataRaw          , ADC_GetDataRaw           name '_ADC_GetDataRaw'          , VBADC_GetDataRaw          ,
	ADC_GetDataCounts       , ADC_GetDataCounts        name '_ADC_GetDataCounts'       , VBADC_GetDataCounts       ,
	ADC_GetDataV            , ADC_GetDataV             name '_ADC_GetDataV'            , VBADC_GetDataV            ,
	ADC_SetCallback         , ADC_SetCallback          name '_ADC_SetCallback'         , VBADC_SetCallback         ,
	ADC_AcquireEnd          , ADC_AcquireEnd           name '_ADC_AcquireEnd'          , VBADC_AcquireEnd          ,
	ADC_AcquireStream       , ADC_AcquireStream        name '_ADC_AcquireStream'       , VBADC_AcquireStream       ,
	ADC_AcquireBlock        , ADC_AcquireBlock         name '_ADC_AcquireBlock'        , VBADC_AcquireBlock        ,
	ADC_ConfigureAcquire    , ADC_ConfigureAcquire     name '_ADC_ConfigureAcquire'    , VBADC_ConfigureAcquire    ,
	ADC_GetImmediateScanV   , ADC_GetImmediateScanV    name '_ADC_GetImmediateScanV'   , VBADC_GetImmediateScanV   ,
	ADC_GetImmediateScanRaw , ADC_GetImmediateScanRaw  name '_ADC_GetImmediateScanRaw' , VBADC_GetImmediateScanRaw ,
	ADC_GetImmediateRaw     , ADC_GetImmediateRaw      name '_ADC_GetImmediateRaw'     , VBADC_GetImmediateRaw     ,
	ADC_GetImmediateV       , ADC_GetImmediateV        name '_ADC_GetImmediateV'       , VBADC_GetImmediateV       ,
	ADC_SetChannelCount     , ADC_SetChannelCount      name '_ADC_SetChannelCount'     , VBADC_SetChannelCount     ,
	ADC_GetRate             , ADC_GetRate              name '_ADC_GetRate'             , VBADC_GetRate             ,
	ADC_SetRate             , ADC_SetRate              name '_ADC_SetRate'             , VBADC_SetRate             ,
	ADC_SetRangeAll         , ADC_SetRangeAll          name '_ADC_SetRangeAll'         , VBADC_SetRangeAll         ,
	ADC_SetRange1           , ADC_SetRange1            name '_ADC_SetRange1'           , VBADC_SetRange1           ,

	DAC_OutputV             , DAC_OutputV              name '_DAC_OutputV'             , VBDAC_OutputV             ,
	DAC_OutputCounts        , DAC_OutputCounts         name '_DAC_OutputCounts'        , VBDAC_OutputCounts        ,
	DAC_SetRangeAll         , DAC_SetRangeAll          name '_DAC_SetRangeAll'         , VBDAC_SetRangeAll         ,
	DAC_SetRange1           , DAC_SetRange1            name '_DAC_SetRange1'           , VBDAC_SetRange1           ,

	BRD_Reset               , BRD_Reset                name '_BRD_Reset'               , VBBRD_Reset               ,
	BRD_GetSerialNumber     , BRD_GetSerialNumber      name '_BRD_GetSerialNumber'     , VBBRD_GetSerialNumber     ,
	BRD_GetNameW            , BRD_GetNameW             name '_BRD_GetNameW'            , VBBRD_GetNameW            ,
	BRD_GetNameA            , BRD_GetNameA             name '_BRD_GetNameA'            , VBBRD_GetNameA            ,
	BRD_GetHighestBoardIndex, BRD_GetHighestBoardIndex name '_BRD_GetHighestBoardIndex', VBBRD_GetHighestBoardIndex;

begin
  InitDLL;
end.
