⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gainlistform.pas

📁 16 relay output channels and 16 isolated digital input channels LED indicators to show activated
💻 PAS
字号:
unit GainListForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, Global, Driver;

type
  TfrmGainList = class(TForm)
    Label1: TLabel;
    lstGainCtrl: TListView;
    cmbGain: TComboBox;
    btnExit: TButton;
    procedure SetGainList();
    procedure cmbGainChange(Sender: TObject);
    procedure lstGainCtrlClick(Sender: TObject);
    procedure btnExitClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmGainList: TfrmGainList;

implementation

uses MainForm;

{$R *.dfm}

procedure TfrmGainList.SetGainList();
var
    i           : integer;
    GainItem    : TListItem;
    temp        : Smallint;
    iPhyChan    : integer;
    iLogChan    : integer;
    
begin
    lstGainCtrl.Clear();
    cmbGain.Clear();

    for i := 0 to lpDevFeatures.usNumGain-1 do
        cmbGain.Items.Add(lpDevFeatures.glGainList[i].szGainStr);
    cmbGain.ItemIndex := 0;

    iPhyChan := usStartChan;
    for i:=0 to usChanNum-1 do
    begin
        if (lpDevConfig_AI.ulChanConfig = 1 ) then
        begin
            if ( iLogChan >= lpDevFeatures.usMaxAIDiffChl ) then
                break;
        end
        else
             if(iPhyChan >= lpDevFeatures.usMaxAISiglChl) then
                break;

        GainItem := lstGainCtrl.Items.Add();
        GainItem.Caption := 'Chan '+ IntToStr(iPhyChan);
        GainItem.SubItems.Add(lpDevFeatures.glGainList[usGainIndx[PhyChanToLogChan(lpDevConfig_AI,iPhyChan)]].szGainStr );

        if (lpDevConfig_AI.ulChanConfig = 1 ) then
        begin
              GainItem.SubItems.Add( 'Differential' );
              GainItem.Caption := 'Chan '+ IntToStr(iPhyChan);
        end
        else
        begin
              if (iPhyChan < 32) then
                   temp :=  (lpDevConfig_AI.ulChanConfig  and (1 shl (iPhyChan)))
              else
                   temp :=  (lpDevConfig_AI.ulChanConfigEx[0] and (1 shl (iPhyChan-32)));

              if( temp > 0 )  then
              begin
                   GainItem.SubItems.Add( 'Differential' );

                  if( (iPhyChan mod 2) = 0 ) then
                     iPhyChan := iPhyChan + 1;

                  GainItem.Caption := 'Chan '+ IntToStr(iPhyChan-1) + ',' + IntToStr(iPhyChan);
              end
              else
                 GainItem.SubItems.Add( 'Single-Ended' );
          end;
         iPhyChan := iPhyChan + 1;        
    end;

end;
procedure TfrmGainList.cmbGainChange(Sender: TObject);
begin
       if( lstGainCtrl.ItemIndex < 0 ) then
       Exit;

   lstGainCtrl.Items[lstGainCtrl.ItemIndex].SubItems[0] :=
   lpDevFeatures.glGainList[cmbGain.ItemIndex].szGainStr;
   usGainIndx[PhyChanToLogChan(lpDevConfig_AI,usStartChan)+lstGainCtrl.ItemIndex] := cmbGain.ItemIndex;

end;

procedure TfrmGainList.lstGainCtrlClick(Sender: TObject);
begin
       if( lstGainCtrl.ItemIndex < 0 ) then
       Exit;
       cmbGain.ItemIndex := usGainIndx[PhyChanToLogChan(lpDevConfig_AI,usStartChan)+lstGainCtrl.ItemIndex];

end;

procedure TfrmGainList.btnExitClick(Sender: TObject);
begin
  Close();
end;

procedure TfrmGainList.FormShow(Sender: TObject);
begin

    ErrCde := DRV_DeviceOpen(DeviceList[frmMain.lstDevice.ItemIndex].dwDeviceNum, DeviceHandle);
     If (ErrCde <> 0) Then
     begin
        DRV_GetErrorMessage(ErrCde, pszErrMsg);
        Application.MessageBox(pszErrMsg, 'Error!!', MB_OK);
        Exit;
      end;

    // get AI configuration
    ptAIGetConfig.size := SizeOf(DEVCONFIG_AI);
    lpDevConfig_AI.ulChanConfig := 0;
    ptAIGetConfig.buffer := @lpDevConfig_AI;
    ErrCde := DRV_AIGetConfig(DeviceHandle, ptAIGetConfig);
     If (ErrCde <> 0) Then
     begin
        DRV_GetErrorMessage(ErrCde, pszErrMsg);
        Application.MessageBox(pszErrMsg, 'Error!!', MB_OK);
        DRV_DeviceClose(DeviceHandle);
        Exit;
     end;

    // close device
    DRV_DeviceClose(DeviceHandle);

    SetGainList;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -