📄 setting.pas
字号:
unit Setting;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Spin, Inifiles;
type
TFormSetting = class(TForm)
Grpb_A: TGroupBox;
Label1: TLabel;
Chkb_A_Measure: TCheckBox;
Chkb_A_Flux: TCheckBox;
SEdit_A_HP: TSpinEdit;
Grpb_B: TGroupBox;
Label2: TLabel;
Chkb_B_Measure: TCheckBox;
Chkb_B_Flux: TCheckBox;
SEdit_B_HP: TSpinEdit;
Chkb_A_enable: TCheckBox;
GroupBox3: TGroupBox;
Chkb_B_enable: TCheckBox;
Label3: TLabel;
SEdit_Error: TSpinEdit;
Label4: TLabel;
SEdit_SampleTime: TSpinEdit;
Label5: TLabel;
SEdit_MaxTime: TSpinEdit;
BTN_OK: TButton;
BTN_Cancel: TButton;
Label6: TLabel;
SEdit_StableTime: TSpinEdit;
GroupBox4: TGroupBox;
procedure FormCreate(Sender: TObject);
procedure BTN_OKClick(Sender: TObject);
procedure Chkb_A_enableClick(Sender: TObject);
procedure Chkb_B_enableClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Box_A, Box_B : Boolean; //水箱启用
A_Measure, B_Measure : Boolean; //水位传感器
A_Flux, B_Flux : Boolean;//流量传感器
A_HP, B_HP : Integer; //期望水位
SampleTime : Integer; //采样时间
MaxTime : Integer; //最长实验时间
ErrorValue : Integer; //误差范围
StableTime : Integer; //稳定时间
MyIni : TInifile; //INI文件
end;
var
FormSetting: TFormSetting;
implementation
uses waterctrl;
{$R *.dfm}
procedure TFormSetting.FormCreate(Sender: TObject);
begin
//建立列表文件关联
MyIni := Tinifile.create(ExtractFilePath(paramstr(0))+'Fuzzy.Ini');
//赋值
Box_A := MyIni.ReadBool('水箱启用','A',True);
Box_B := MyIni.ReadBool('水箱启用','B',False);
A_Measure := MyIni.ReadBool('液位传感器','A',True);
B_Measure := MyIni.ReadBool('液位传感器','A',True);
A_Flux := MyIni.ReadBool('流量传感器','A',True);
B_Flux := MyIni.ReadBool('流量传感器','B',True);
A_HP := MyIni.ReadInteger('水位','期望A',120);
B_HP := MyIni.ReadInteger('水位','期望B',120);
ErrorValue := MyIni.ReadInteger('水位','误差范围',5);
SampleTime := MyIni.ReadInteger('时间','采样',1500);
MaxTime := MyIni.ReadInteger('时间','最长实验时间',30);
StableTime := MyIni.ReadInteger('时间','稳定时间',30);
//初始化
Chkb_A_enable.Checked := Box_A;
Chkb_B_enable.Checked := Box_B;
Chkb_A_Measure.Checked := A_Measure;
Chkb_B_Measure.Checked := B_Measure;
Chkb_A_Flux.Checked := A_Flux;
Chkb_B_Flux.Checked := B_Flux;
SEdit_A_HP.Value := A_HP;
SEdit_B_HP.Value := B_HP;
SEdit_Error.Value := ErrorValue;
SEdit_MaxTime.Value := MaxTime;
SEdit_SampleTime.Value := SampleTime;
SEdit_StableTime.Value := StableTime;
if not Chkb_A_enable.Checked then
Grpb_A.Enabled := False;
if not Chkb_B_enable.Checked then
Grpb_B.Enabled := False;
end;
procedure TFormSetting.BTN_OKClick(Sender: TObject);
begin
Box_A := Chkb_A_enable.Checked;
Box_B := Chkb_B_enable.Checked;
A_Measure := Chkb_A_Measure.Checked;
B_Measure := Chkb_B_Measure.Checked;
A_Flux := Chkb_A_Flux.Checked;
B_Flux := Chkb_B_Flux.Checked;
A_HP := SEdit_A_HP.Value;
B_HP := SEdit_B_HP.Value;
ErrorValue := SEdit_Error.Value;
MaxTime := SEdit_MaxTime.Value;
SampleTime := SEdit_SampleTime.Value;
StableTime := SEdit_StableTime.Value;
MyIni.WriteBool('水箱启用','A',Box_A);
MyIni.WriteBool('水箱启用','B',Box_B);
MyIni.WriteBool('液位传感器','A',A_Measure);
MyIni.WriteBool('液位传感器','B',B_Measure);
MyIni.WriteBool('流量传感器','A',A_Flux);
MyIni.WriteBool('流量传感器','B',B_Flux);
MyIni.WriteInteger('水位','期望A',A_HP);
MyIni.WriteInteger('水位','期望B',B_HP);
MyIni.WriteInteger('水位','误差范围',ErrorValue);
MyIni.WriteInteger('时间','采样',SampleTime);
MyIni.WriteInteger('时间','最长实验时间',MaxTime);
MyIni.WriteInteger('时间','稳定时间',StableTime);
FormWaterControl.FormCreate(Sender);
Close;
end;
procedure TFormSetting.Chkb_A_enableClick(Sender: TObject);
begin
if not Chkb_A_enable.Checked then
Grpb_A.Enabled := False
else Grpb_A.Enabled := True;
end;
procedure TFormSetting.Chkb_B_enableClick(Sender: TObject);
begin
if not Chkb_B_enable.Checked then
Grpb_B.Enabled := False
else Grpb_B.Enabled := True;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -