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

📄 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, Grids, ValEdit, ComCtrls, Driver,Math;

type
  TGainList = class(TForm)
    butOK: TButton;
    GainView: TListView;
    cmbGain: TComboBox;
    procedure SetGainCtrl();
    procedure GainViewClick(Sender: TObject);
    procedure cmbGainChange(Sender: TObject);
    procedure butOKClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  GainList: TGainList;

implementation

uses MainForm;
{$R *.dfm}

procedure TGainList.SetGainCtrl();
var
   GainItem : TListItem;
   i        : integer;
   iPhyChan : integer;
   temp     : integer;

begin
   GainView.Items.Clear;
   cmbGain.Clear;

    if (DevFeature.usNumGain <> 0) then
    begin
        for i := 0 to DevFeature.usNumGain-1 do
            cmbGain.Items.Add(DevFeature.glGainList[i].szGainStr);
        cmbGain.ItemIndex := 0;
    end;


    iPhyChan := gwStartChl;
    for i:=0 to Min(gwChlNum-1,gwMaxLogChanNum-1)  do
    begin
        if(iPhyChan >= DevFeature.usMaxAISiglChl) then
            iPhyChan := iPhyChan - DevFeature.usMaxAISiglChl;

        GainItem:=GainView.Items.Add();
        GainItem.Caption:='Chan '+ IntToStr(iPhyChan);
        GainItem.SubItems.Add( DevFeature.glGainList[gwGain[frmMain.PhyChanToLogChan(DevConfig_AI,SmallInt(iPhyChan))]].szGainStr );

        if (iPhyChan < 32) then
           temp := (DevConfig_AI.ulChanConfig  and (1 shl (iPhyChan)))
        else
           temp := (DevConfig_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' );

        iPhyChan := iPhyChan + 1;
    end;

end;

procedure TGainList.GainViewClick(Sender: TObject);

begin
       if( GainView.ItemIndex < 0 ) then
       Exit;
       cmbGain.ItemIndex := gwGain[(frmMain.PhyChanToLogChan(DevConfig_AI,gwStartChl)+GainView.ItemIndex) mod gwMaxLogChanNum];

end;

procedure TGainList.cmbGainChange(Sender: TObject);
begin
       if( GainView.ItemIndex < 0 ) then
       Exit;

   GainView.Items[GainView.ItemIndex].SubItems[0] :=
   DevFeature.glGainList[cmbGain.ItemIndex].szGainStr;
   gwGain[(frmMain.PhyChanToLogChan(DevConfig_AI,gwStartChl)+GainView.ItemIndex) mod gwMaxLogChanNum] := cmbGain.ItemIndex;

end;

procedure TGainList.butOKClick(Sender: TObject);
begin
   Close();
end;

procedure TGainList.FormShow(Sender: TObject);
begin
    gwDevice := frmMain.lstDevice.ItemIndex;
    
    ErrCde := DRV_DeviceOpen(DeviceList[gwDevice].dwDeviceNum, DriverHandle);
    if( frmMain.DoesErr(ErrCde) = 1 ) then
        Exit;

    // get AI configuration
    ptAIGetConfig.size := SizeOf(DEVCONFIG_AI);
    DevConfig_AI.ulChanConfig := 0;
    ptAIGetConfig.buffer := @DevConfig_AI;
    ErrCde := DRV_AIGetConfig(DriverHandle, ptAIGetConfig);
    if frmMain.DoesErr(ErrCde) = 1  then
    begin
        DRV_DeviceClose(DriverHandle);
        Exit;
    end;

    // close device
    DRV_DeviceClose(DriverHandle);

    SetGainCtrl;
end;

end.

⌨️ 快捷键说明

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