Какой именно модуль интересует ?
Например, для LTR22 так :
unit ltr22api;
interface
uses windows, SysUtils;
const
LTR_OK=0;
LTR22_ADC_NUMBERS=4;
LTR22_ADC_CHANNELS=LTR22_ADC_NUMBERS;
LTR22_RANGE_NUMBER=6;
LTR22_RANGE_OVERFLOW=7;
type
TLTR = packed record
saddr:Cardinal; // сетевой адрес сервера
sport:word; // сетевой порт сервера
csn:array [0..15] of byte; // серийный номер крейта
cc:word; // номер канала крейта
flags:Cardinal; // флаги состояния канала
tmark:Cardinal; // последняя принятая метка времени
internal:Pointer; // указатель на канал
end;
DAC_CHANNEL_CALIBRATION=packed record
FactoryCalibOffset:array [0..LTR22_RANGE_NUMBER] of real;
FactoryCalibScale:array [0..LTR22_RANGE_NUMBER] of real;
UserCalibOffset:array [0..LTR22_RANGE_NUMBER] of real;
UserCalibScale:array [0..LTR22_RANGE_NUMBER] of real;
end;
TDESCRIPTION_MODULE=packed record // //
CompanyName:array[0..16] of byte; //
DeviceName:array[0..16] of byte; // название изделия
SerialNumber:array[0..16] of byte; // серийный номер изделия
Revision:byte; // ревизия изделия
Comment:array[0..256] of byte; //
end;
TDESCRIPTION_CPU=packed record // //
Active:byte; // флаг достоверности остальных полей структуры
Name:array[0..16] of byte; // название
ClockRate:double;
FirmwareVersion:Cardinal; //
Comment:array[0..256] of byte; //
end; //
// описание модуля (не реализованно)
TDESCRIPTION_LTR22=packed record // //
Description:TDESCRIPTION_MODULE; //
Cpu:TDESCRIPTION_CPU; //
end; //
// структура, задающая режим работы АЦП для модуля E-440
TLTR22 = packed record
//**** служебная информация
ltr:TLTR; // структура описывающая модуль в крейте – описание в ltrapi.pdf
//**** настройки модуля
// настройки модуля
Fdiv_rg:byte; // дивайзер частоты клоков 1..15
Adc384:bool; // дополнительный дивайзер частоты сэмплов true =3 false =4
AC_DC_State:bool; // состояние true =AC+DC false=AC
MeasureADCZero:bool; // измерение Zero true - включено false - выключено
DataReadingProcessed:bool; // состояние считывания АЦП true-АЦП считывается false - нет
ADCChannelRange:array [0..LTR22_ADC_NUMBERS] of Byte;// предел имзерений АЦП по каналам 0 - 1В 1 - 0.3В 2 - 0.1В 3 - 0.03В 4 - 10В 5 - 3В
ChannelEnabled:array [0..LTR22_ADC_NUMBERS] of bool; // Состояние каналов, включен - true выключен - false
SyncType:Byte; // Тип синхронизации 0 - внутренний старт по сигналу Go
//1 - внутренний старт по сигналу Go с трансляцией сигнала,
//2 - внешний старт
//3 - резервировано
ADCCalibration:array [1..LTR22_ADC_NUMBERS] of DAC_CHANNEL_CALIBRATION;
ModuleDescription:TDESCRIPTION_LTR22;
end;
pTLTR22 = ^TLTR22;
Function LTR22_Init(module:pTLTR22) : Integer; stdcall;
Function LTR22_Open(module:pTLTR22; saddr:Cardinal; sport:Cardinal;csnArrayByte:Pointer;cc:short) : Integer; stdcall;
Function LTR22_Close(module:pTLTR22) : Integer; stdcall;
Function LTR22_IsOpened(module:pTLTR22) : Integer; stdcall;
Function LTR22_GetConfig(module:pTLTR22) : Integer; stdcall;
Function LTR22_SetConfig(module:pTLTR22) : Integer; stdcall;
Function LTR22_ClearBuffer(module:pTLTR22) : Integer; stdcall;
Function LTR22_SwitchADCStartStop(module:pTLTR22;Value:bool) : Integer; stdcall;
Function LTR22_SetSyncType(module:pTLTR22;Value:Byte) : Integer; stdcall;
Function LTR22_SwitchMeasureADCZero(module:pTLTR22;Value:bool) : Integer; stdcall;
Function LTR22_SetFreq(module:pTLTR22;adc384:bool;Freq_dv:Byte) : Integer; stdcall;
Function LTR22_SetADCRange(module:pTLTR22;ADCChannel:Byte;ADCChannelRange:Byte) : Integer; stdcall;
Function LTR22_SetADCChannel(module:pTLTR22;ADCChannel:Byte;EnableADC:bool) : Integer; stdcall;
Function LTR22_GetCalibrovka(module:pTLTR22) : Integer; stdcall;
Function LTR22_Recv(module:pTLTR22; dataCardinalArray:Pointer; tstampCardinal:Pointer; size:Cardinal; timeout:Cardinal) : Integer; stdcall;
Function LTR22_GetModuleDescription(module:pTLTR22) : Integer; stdcall;
Function LTR22_ProcessData(module:pTLTR22; dataSourceCardinalArray:Pointer; dataDestinationDouble:Pointer;
Size:Cardinal;calibrMainPset:bool;calibrExtraVolts:bool;OverflowFlagsByteArray:Pointer) : Integer; stdcall;
Function LTR22_ReadAVREEPROM(module:pTLTR22; dataByteArray:Pointer; address:short;size:short) : Integer; stdcall;
Function LTR22_WriteAVREEPROM(module:pTLTR22; dataByteArray:Pointer;address:short;size:short) : Integer; stdcall;
Function LTR22_GetErrorString(Index:Integer) : string; stdcall;
implementation
Function LTR22_Init(module:pTLTR22) : Integer; external 'ltr22api.dll';
Function LTR22_Open(module:pTLTR22; saddr:Cardinal; sport:Cardinal;csnArrayByte:Pointer;cc:short) : Integer; external 'ltr22api.dll';
Function LTR22_Close(module:pTLTR22) : Integer; external 'ltr22api.dll';
Function LTR22_IsOpened(module:pTLTR22) : Integer; external 'ltr22api.dll';
Function LTR22_GetConfig(module:pTLTR22) : Integer; external 'ltr22api.dll';
Function LTR22_SetConfig(module:pTLTR22) : Integer; external 'ltr22api.dll';
Function LTR22_ClearBuffer(module:pTLTR22) : Integer; external 'ltr22api.dll';
Function LTR22_SwitchADCStartStop(module:pTLTR22;Value:bool) : Integer; external 'ltr22api.dll';
Function LTR22_SetSyncType(module:pTLTR22;Value:Byte) : Integer; external 'ltr22api.dll';
Function LTR22_SwitchMeasureADCZero(module:pTLTR22;Value:bool) : Integer; external 'ltr22api.dll';
Function LTR22_SetFreq(module:pTLTR22;adc384:bool;Freq_dv:Byte) : Integer; external 'ltr22api.dll';
Function LTR22_SetADCRange(module:pTLTR22;ADCChannel:Byte;ADCChannelRange:Byte) : Integer; external 'ltr22api.dll';
Function LTR22_SetADCChannel(module:pTLTR22;ADCChannel:Byte;EnableADC:bool) : Integer; external 'ltr22api.dll';
Function LTR22_GetCalibrovka(module:pTLTR22) : Integer; external 'ltr22api.dll';
Function LTR22_Recv(module:pTLTR22; dataCardinalArray:Pointer; tstampCardinal:Pointer; size:Cardinal; timeout:Cardinal) : Integer; external 'ltr22api.dll';
Function LTR22_GetModuleDescription(module:pTLTR22) : Integer; external 'ltr22api.dll';
Function LTR22_ProcessData(module:pTLTR22; dataSourceCardinalArray:Pointer; dataDestinationDouble:Pointer;
Size:Cardinal;calibrMainPset:bool;calibrExtraVolts:bool;OverflowFlagsByteArray:Pointer) : Integer; external 'ltr22api.dll';
Function LTR22_ReadAVREEPROM(module:pTLTR22; dataByteArray:Pointer; address:short;size:short) : Integer; external 'ltr22api.dll';
Function LTR22_WriteAVREEPROM(module:pTLTR22; dataByteArray:Pointer;address:short;size:short) : Integer; external 'ltr22api.dll';
Function LTR22_GetErrorString(Index:Integer) : string; external 'ltr22api.dll';
end.
----------------------------------------------
program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils,
Windows,
ltr22api in 'ltr22api.pas';
Procedure TestADCStartStop(module:TLTR22);
var
Res:Integer;
Values:array [0..1000] of Double;
ValuesSource:array [0..1000] of Cardinal;
begin
Res:=LTR22_SwitchADCStartStop(@module,true);
if (Res=LTR_OK) then
begin
Res:=LTR22_Recv(@module, @ValuesSource,nil,1000,600);
if (Res=1000) then
begin
Res:=LTR22_SwitchADCStartStop(@module,false);
if (Res=LTR_OK) then
begin
Res:=LTR22_ClearBuffer(@module);
if (Res=LTR_OK) then
begin
Res:=LTR22_ProcessData(@module,@ValuesSource,@Values,1000,false,false,nil);
if (Res<>LTR_OK) then
Writeln('Error Processing Data ',Res);
end
else Writeln('Error Clearing Buffers ',Res);
end
else Writeln('Error Stopping ADC ',Res);
end
else Writeln('Error ADC Data ',Res);
end
else Writeln('Error Starting ADC ',Res);
if Res=LTR_OK then Writeln('Testing ReadWrite Successfull');
end;
var
module:TLTR22;
Handle: Cardinal;
gg:string;
Res:Integer;
Counter:Integer;
LTR34_InitTest:function(module1:pTLTR22):Integer;
EEPROMData:array [0..8192] of Byte;
begin
{ TODO -oUser -cConsole Main : Insert code here }
Handle := LoadLibrary('ltr22api.dll');
if Handle=0 then Writeln('Error Load Dll');
@LTR34_InitTest:=GetProcAddress(Handle, 'LTR22_Init');
if @LTR34_InitTest=nil then Writeln('Error Load LTR22_Init');
Res:=LTR22_Open(@module,module.ltr.saddr,module.ltr.sport,@module.ltr.csn,module.ltr.cc);
if Res=LTR_OK then
begin
Writeln('Module Open Succesfull');
module.ADCChannelRange[0]:=3;
module.ADCChannelRange[1]:=2;
module.ADCChannelRange[2]:=3;
module.ADCChannelRange[3]:=0;
Res:=LTR22_SetConfig(@module);
if Res=LTR_OK then
begin
Res:=LTR22_GetConfig(@module);
if (Res<>LTR_OK) then Writeln('Error Reading module Configuration ',Res);
TestADCStartStop(module);
Res:=LTR22_GetModuleDescription(@module);
if (Res<>LTR_OK) then Writeln('Error Reading module Description ',Res);
Res:=LTR22_GetCalibrovka(@module);
if (Res<>LTR_OK) then Writeln('Error Reading module Calibration ',Res);
for Counter := 0 to 512 do
EEPROMData[Counter]:=Counter;
Res:=LTR22_WriteAVREEPROM(@module, @EEPROMData,0,512);
if (Res<>LTR_OK) then Writeln('Error Writing EEPROM ',Res);
for Counter := 0 to 512 do
EEPROMData[Counter]:=0;
Res:=LTR22_ReadAVREEPROM(@module, @EEPROMData,0,512);
if (Res<>LTR_OK) then Writeln('Error Reading EEPROM ',Res);
end
else Writeln('Error Setting Configuration ',Res);
Res:=LTR22_Close(@module);
if (Res<>LTR_OK) then Writeln('Error Close module ',Res);
end
else Writeln('Error Open module ',Res);
if Res=LTR_OK then Writeln('All Right ! :-)');
Writeln('Press any key to exit from application');
Read(gg);
end.