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

📄 settingform.pas

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

interface

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

type
  TfrmSetting = class(TForm)
    GroupBox2: TGroupBox;
    RadioDataWidth16: TRadioButton;
    RadioDataWidth8: TRadioButton;
    GroupBox3: TGroupBox;
    RadioStartTypeSoftware: TRadioButton;
    RadioStartTypeExt: TRadioButton;
    GroupBox4: TGroupBox;
    RadioStopTypeSoftware: TRadioButton;
    RadioStopTypeExt: TRadioButton;
    GroupBox5: TGroupBox;
    RadioCyclic: TRadioButton;
    RadioNonCyclic: TRadioButton;
    GroupBox6: TGroupBox;
    Label2: TLabel;
    ListBoxTriggerSource: TListBox;
    EditCounterValue: TEdit;
    GroupBox7: TGroupBox;
    ListBoxUserBuffer: TListBox;
    ButtonOK: TButton;
    GroupBox1: TGroupBox;
    radNormal: TRadioButton;
    radBurst: TRadioButton;
    rad8255: TRadioButton;
    RadioDataWidth32: TRadioButton;
    RadioStartMatch: TRadioButton;
    RadioStopMatch: TRadioButton;
    RadioGroup1: TRadioGroup;
    RadioDmaSlave: TRadioButton;
    RadioDmaMaster: TRadioButton;
    GroupBox8: TGroupBox;
    txtPattern: TEdit;
    procedure ButtonOKClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure txtPatternKeyPress(Sender: TObject; var Key: Char);
    procedure txtPatternChange(Sender: TObject);
    procedure radBurstClick(Sender: TObject);
    procedure radNormalClick(Sender: TObject);
    procedure rad8255Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmSetting: TfrmSetting;

implementation

uses MainForm;

{$R *.dfm}

procedure TfrmSetting.ButtonOKClick(Sender: TObject);
begin

     // save the data width
     if RadioDataWidth32.Checked then // 32-bit
        gdwDataWidth := 0
     else if RadioDataWidth16.Checked then //16-bit
        gdwDataWidth := 2
     else
        gdwDataWidth := 3;

     // save operation type
     if  radNormal.Checked then // normal
        gdwDIOperationMode := 0;
     if rad8255.Checked then // 8255
         gdwDIOperationMode := 1;
     if radBurst.Checked  then // burst
        gdwDIOperationMode := 2;

     // save the start type
     if RadioStartTypeSoftware.Checked then    // software
        gdwDIStartMode := 1;
     if RadioStartTypeExt.Checked then    // External
        gdwDIStartMode := 2;
     if RadioStartMatch.Checked then    // Pattern match
        gdwDIStartMode := 3;

     // save the stop type
     if RadioStopTypeSoftware.Checked then    // software
        gdwDIStopMode := 1;
     if RadioStopTypeExt.Checked then    // External
        gdwDIStopMode := 2;
     if RadioStopMatch.Checked then    // Pattern match
        gdwDIStopMode := 3;

     // save the cyclic mode
     if RadioCyclic.Checked then           // cyclic
        gdwCyclicMode := 1
     else
        gdwCyclicMode := 0;

     // save the trigger source
     gdwDITriggerSource := ListBoxTriggerSource.ItemIndex + 1;

     // save the counter 0 value
     gdwCounterValue[0] := StrToInt(EditCounterValue.Text);

     // save the user bufer
     gdwUserbufferSize :=  ListBoxUserBuffer.ItemIndex;

     // save the Pattern match value
     gdwDIMatchValue := StrToInt('$'+txtPattern.Text);

     // save DMA mode
     if gdwBoardId = BD_MIC3755 then
     begin
        if RadioDmaSlave.Checked then
           gdwDiDmaMode := 0
        else
           gdwDiDmaMode := 1;
     end;

     Close;
end;

procedure TfrmSetting.FormShow(Sender: TObject);
begin
     // initialize data width
     if ( gdwDataWidth = 0 ) then// 32-bit
        RadioDataWidth32.Checked := TRUE
     else if ( gdwDataWidth = 2 ) then // 16-bit
        RadioDataWidth16.Checked := TRUE
     else // 8-bit
        RadioDataWidth8.Checked := TRUE;

     // initialize start type
     if ( gdwDIStartMode = 1 ) then // software
        RadioStartTypeSoftware.Checked := TRUE;
     if ( gdwDIStartMode = 2 ) then // External
        RadioStartTypeExt.Checked := TRUE;
     if ( gdwDIStartMode = 3 ) then // Pattern Match
        RadioStartMatch.Checked := TRUE;

     // initialize operation type
     if ( gdwDIOperationMode = 0 ) then // normal
        radNormal.Checked := TRUE;
     if ( gdwDIOperationMode = 1 ) then // 8255
        rad8255.Checked := TRUE;
     if ( gdwDIOperationMode = 2 ) then // burst
        radBurst.Checked := TRUE;

     // initialize stop type
     if ( gdwDIStopMode = 1 ) then // software
        RadioStopTypeSoftware.Checked := TRUE ;
     if ( gdwDIStopMode = 2 ) then // External
        RadioStopTypeExt.Checked := TRUE;
     if ( gdwDIStopMode = 3 ) then // Pattern Match
        RadioStopMatch.Checked := TRUE;

     // initialize cycle mod
     if ( gdwCyclicMode = 0 ) then // nocyclic
        RadioNonCyclic.Checked := TRUE
     else
        RadioCyclic.Checked := TRUE;

     // initialize trigger source listbox
     ListBoxTriggerSource.ItemIndex := gdwDITriggerSource - 1;

     // initialize counter 0 value
     EditCounterValue.Text := InttoStr(gdwCounterValue[0]);

     // initialize the user buffer
     ListBoxUserBuffer.ItemIndex := gdwUserBufferSize;
     // initialize the Pattern match value
     txtPattern.Text := IntToHex(gdwDIMatchValue,2);

     // initialize DI DMA mode
     if gdwBoardId = BD_MIC3755 then
     begin
        if gdwDiDmaMode = 0 then
           RadioDmaSlave.Checked := true;
        if gdwDiDmaMode = 1 then
           RadioDmaMaster.Checked := true;
     end

end;

procedure TfrmSetting.txtPatternKeyPress(Sender: TObject; var Key: Char);
var
  Asckey : BYTE;
  i      : Integer;

begin

  Asckey :=  BYTE(Key);



 If ((Asckey >= BYTE('0')) and (Asckey <= BYTE('9')) ) Then
    exit;

  If ( (Asckey >= BYTE('A')) And (Asckey <= BYTE('F')) ) Then
   exit;

  If ( (Asckey >= BYTE('a')) And (Asckey <= BYTE('f')) ) Then
  begin
      for i :=0 to (BYTE('a') - BYTE('A')-1) do
      begin
         Dec(Key);
      end;
       exit;
  end;


  Key := Low(Key);
end;

procedure TfrmSetting.txtPatternChange(Sender: TObject);
var
    lStart : Longint;
    lLength : Longint;
   strHex : String;
begin

  //ound the Pattern Match value in 0 ~ FFFFFFFFh

  If (Length(txtPattern.Text) > 8) Then
  begin
    //Out of value bound
    lStart := txtPattern.SelStart;
    lLength := txtPattern.SelLength;
    If lStart <> 0 Then lStart := lStart - 1;

    txtPattern.Text := IntToHex(txtPattern.Tag,8);
    
    txtPattern.SelStart := lStart;
    txtPattern.SelLength := lLength  ;
  end;
  
  If (Length(txtPattern.Text) = 0) Then
  begin
    // 0 Value
    txtPattern.Text := '0';
    txtPattern.SelStart := 0;
  end;

  // Valid Patterm Match value,write this new property value to device.
  strHex := '$' + txtPattern.Text;
  lStart := StrToInt(strHex);
  txtPattern.Tag := lStart;
end;

procedure TfrmSetting.radBurstClick(Sender: TObject);
begin
   if gdwBoardId = BD_PCI1755 then
   begin
      ListBoxTriggerSource.ItemIndex := 4;
   end;

   if gdwBoardId = BD_MIC3755 then
   begin
      RadioDmaSlave.Enabled := true;
      RadioDmaMaster.Enabled := true;
   end;

end;

procedure TfrmSetting.radNormalClick(Sender: TObject);
begin
   RadioDmaSlave.Enabled := false;
   RadioDmaMaster.Enabled := false;
end;

procedure TfrmSetting.rad8255Click(Sender: TObject);
begin
   RadioDmaSlave.Enabled := false;
   RadioDmaMaster.Enabled := false;
end;

end.

⌨️ 快捷键说明

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