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

📄 sccfg.pas

📁 usb4711A数据采集卡的DI转换通道程序
💻 PAS
字号:
unit SCCfg;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TfSCConfig = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    chkEnablePB00: TCheckBox;
    chkEnablePB01: TCheckBox;
    chkEnablePB02: TCheckBox;
    chkEnablePB03: TCheckBox;
    chkEnablePB04: TCheckBox;
    chkEnablePB05: TCheckBox;
    chkEnablePB06: TCheckBox;
    chkEnablePB07: TCheckBox;
    GroupBox2: TGroupBox;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    chkEnablePB40: TCheckBox;
    chkEnablePB41: TCheckBox;
    chkEnablePB42: TCheckBox;
    chkEnablePB43: TCheckBox;
    chkEnablePB44: TCheckBox;
    chkEnablePB45: TCheckBox;
    chkEnablePB46: TCheckBox;
    chkEnablePB47: TCheckBox;
    cmdCancel: TButton;
    cmdOk: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure cmdCancelClick(Sender: TObject);
    procedure cmdOkClick(Sender: TObject);
  private
    { Private declarations }
    pchkPB : array[0..1, 0..7] of ^TCheckBox;
  public
    { Public declarations }
    giPB0Value : integer;
    giPB4Value : integer;
  end;

var
  fSCConfig: TfSCConfig;

implementation

{$R *.DFM}

procedure TfSCConfig.FormCreate(Sender: TObject);
begin
    {Make control array for further use}
    {Port B0}
    pchkPB[0,0] := @chkEnablePB00;
    pchkPB[0,1] := @chkEnablePB01;
    pchkPB[0,2] := @chkEnablePB02;
    pchkPB[0,3] := @chkEnablePB03;
    pchkPB[0,4] := @chkEnablePB04;
    pchkPB[0,5] := @chkEnablePB05;
    pchkPB[0,6] := @chkEnablePB06;
    pchkPB[0,7] := @chkEnablePB07;

    {Port B4}
    pchkPB[1,0] := @chkEnablePB40;
    pchkPB[1,1] := @chkEnablePB41;
    pchkPB[1,2] := @chkEnablePB42;
    pchkPB[1,3] := @chkEnablePB43;
    pchkPB[1,4] := @chkEnablePB44;
    pchkPB[1,5] := @chkEnablePB45;
    pchkPB[1,6] := @chkEnablePB46;
    pchkPB[1,7] := @chkEnablePB47;
end;

procedure TfSCConfig.FormActivate(Sender: TObject);
Var
    i, j : integer;
    iValue : array[0..1] of integer;
begin
    iValue[0] := giPB0Value;
    iValue[1] := giPB4Value;

    for j :=0 to 1 Do
    Begin
        for i:= 0 to 7 Do
        Begin
            pchkPB[j,i]^.Checked := ((iValue[j] and 1) = 1);

            iValue[j] := iValue[j] div 2;
        End; {End of i Loop}
    End; {End of j Loop}

end;

procedure TfSCConfig.cmdCancelClick(Sender: TObject);
begin
    fSCConfig.Close;
end;

procedure TfSCConfig.cmdOkClick(Sender: TObject);
var
    i, j, k : integer;
    iValue : array[0..1] of integer;
begin
    {Accumulate configuration to value }
    for j := 0 to 1 do
    begin
        iValue[j] := 0;   {Clear content}

        for i := 0 to 7 do
        begin
            iValue[j] := iValue[j] * 2;     {Shift 1 bit left}
            if pchkPB[j, 7-i]^.Checked then
                iValue[j] := iValue[j] + 1; {Accumulate if checked}
        end;
    end;

    giPB0Value := iValue[0];
    giPB4Value := iValue[1];

    fSCConfig.Close;
end;

end.

⌨️ 快捷键说明

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