📄 readform.pas
字号:
unit ReadForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Driver, Global;
type
TfrmValue = class(TForm)
GroupBox1: TGroupBox;
EdtVolt: TEdit;
GroupBox2: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ScrSampleRate: TScrollBar;
BtnStop: TButton;
BtnReadData: TButton;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure BtnStopClick(Sender: TObject);
procedure BtnReadDataClick(Sender: TObject);
procedure ScrSampleRateChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure GetVoltage();
end;
var
frmValue: TfrmValue;
implementation
uses MainForm;
{$R *.dfm}
{*************************************************************
* Function: Handle the error code. If the input error code > 0,
* it means some error apperent. This function can
* show the error message to a message box and stop
* this application.
* Input: The error code.
* return: none
************************************************************* }
Function DoesErr(var lErrCode: LongInt): integer;
var
szErrMsg : string[100];
pszErrMsg : PChar;
begin
{Check the pressed error code}
If (lErrCode <> 0) Then
begin
pszErrMsg := @szErrMsg;
DRV_GetErrorMessage(lErrCode, pszErrMsg);
Application.MessageBox(pszErrMsg, 'Error!!', MB_OK);
DoesErr := 1;
end
else
DoesErr := 0;
end;
procedure TfrmValue.Timer1Timer(Sender: TObject);
begin
GetVoltage( );
end;
procedure TfrmValue.BtnStopClick(Sender: TObject);
begin
Timer1.Enabled := false;
DRV_DeviceClose(lDeviceHandle);
frmADExp.Show();
Hide();
end;
procedure TfrmValue.BtnReadDataClick(Sender: TObject);
begin
Timer1.Enabled := false;
GetVoltage();
end;
procedure TfrmValue.ScrSampleRateChange(Sender: TObject);
begin
Timer1.Enabled := true;
Timer1.Interval := 1000 div ScrSampleRate.Position;
end;
procedure TfrmValue.GetVoltage();
var
fVoltage : single;
begin
if(DevCfg.Daughter[gwChannel].dwBoardID = 0) then
begin
ptAIVoltageIn.chan := gwChannel;
ptAIVoltageIn.gain := ptAIConfig.DasGain;
ptAIVoltageIn.TrigMode := 0; // internal trigger
ptAIVoltageIn.voltage := @fVoltage;
lErrCde := DRV_AIVoltageIn(lDeviceHandle,ptAIVoltageIn);
if( DoesErr(lErrCde) = 1 ) then
begin
DRV_DeviceClose(lDeviceHandle);
Exit;
end;
end
else
begin
ptAIVoltageInExp.DasChan := gwChannel;
ptAIVoltageInExp.DasGain := gwGain;
ptAIVoltageInExp.ExpChan := usExpChan;
ptAIVoltageInExp.voltage := @fVoltage;
if (DevCfg.Daughter[gwChannel].dwBoardID = BD_PCLD788) then
ptAIVoltageInExp.ExpChan := usExpChan;
lErrCde := DRV_AIVoltageInExp(lDeviceHandle,ptAIVoltageInExp);
if( DoesErr(lErrCde) = 1 ) then
begin
DRV_DeviceClose(lDeviceHandle);
Exit;
end;
end;
// Display Data
EdtVolt.Text := FloatToStrF(fVoltage,ffFixed,7,7);
end;
procedure TfrmValue.FormCreate(Sender: TObject);
begin
ScrSampleRate.SetParams(1,1,10);
Timer1.Enabled := false;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -