📄 unit3.pas
字号:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Grids, Menus, ExtCtrls;
type
TForm3 = class(TForm)
Label1: TLabel;
StringGrid1: TStringGrid;
GroupBox1: TGroupBox;
BitBtn1: TBitBtn;
CheckBox1: TCheckBox;
GroupBox2: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
RadioButton7: TRadioButton;
RadioButton8: TRadioButton;
RadioButton9: TRadioButton;
RadioButton10: TRadioButton;
Timer1: TTimer;
RadioButton11: TRadioButton;
RadioButton12: TRadioButton;
RadioButton13: TRadioButton;
Timer2: TTimer;
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure RadioButton5Click(Sender: TObject);
procedure RadioButton6Click(Sender: TObject);
procedure RadioButton7Click(Sender: TObject);
procedure RadioButton11Click(Sender: TObject);
procedure RadioButton12Click(Sender: TObject);
procedure RadioButton13Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
//uses Unit2, Unit1;
{$R *.dfm}
uses Unit2, Unit1;
procedure TForm3.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[0,0]:=' 溫度序号 ';
StringGrid1.Cells[0,1]:=' 溫度1 ';
StringGrid1.Cells[0,2]:=' 溫度2 ';
StringGrid1.Cells[0,3]:=' 溫度3 ';
StringGrid1.Cells[0,4]:=' 溫度4 ';
StringGrid1.Cells[0,5]:=' 溫度5 ';
StringGrid1.Cells[1,0]:=' 溫度值 ';
StringGrid1.Cells[2,0]:=' 电池号 ';
StringGrid1.Cells[3,0]:=' 电池电压 ';
StringGrid1.Cells[2,1]:=' 第1节 ';
StringGrid1.Cells[2,2]:=' 第2节 ';
StringGrid1.Cells[2,3]:=' 第3节 ';
StringGrid1.Cells[2,4]:=' 第4节 ';
StringGrid1.Cells[2,5]:=' 第5节 ';
StringGrid1.Cells[2,6]:=' 第6节 ';
StringGrid1.Cells[2,7]:=' 第7节 ';
StringGrid1.Cells[2,8]:=' 第8节 ';
StringGrid1.Cells[2,9]:=' 第9节 ';
StringGrid1.Cells[2,10]:=' 第10节 ';
StringGrid1.Cells[2,11]:=' 第11节 ';
StringGrid1.Cells[4,0]:=' 电池号 ';
StringGrid1.Cells[5,0]:=' 电池电压 ';
StringGrid1.Cells[4,1]:=' 第12节 ';
StringGrid1.Cells[4,2]:=' 第13节 ';
StringGrid1.Cells[4,3]:=' 第14节 ';
StringGrid1.Cells[4,4]:=' 第15节 ';
StringGrid1.Cells[4,5]:=' 第16节 ';
StringGrid1.Cells[4,6]:=' 第17节 ';
StringGrid1.Cells[4,7]:=' 第18节 ';
StringGrid1.Cells[4,8]:=' 第19节 ';
StringGrid1.Cells[4,9]:=' 第20节 ';
StringGrid1.Cells[4,10]:=' 第21节 ';
StringGrid1.Cells[4,11]:=' 第22节 ';
StringGrid1.Cells[6,0]:=' 电池号 ';
StringGrid1.Cells[7,0]:=' 电池电压 ';
StringGrid1.Cells[6,1]:=' 第23节 ';
StringGrid1.Cells[6,2]:=' 第24节 ';
StringGrid1.Cells[6,3]:=' 第25节 ';
StringGrid1.Cells[6,4]:=' 第26节 ';
StringGrid1.Cells[6,5]:=' 第27节 ';
StringGrid1.Cells[6,6]:=' 第28节 ';
StringGrid1.Cells[6,7]:=' 第29节 ';
StringGrid1.Cells[6,8]:=' 第30节 ';
StringGrid1.Cells[6,9]:=' 第31节 ';
StringGrid1.Cells[6,10]:=' 第32节 ';
StringGrid1.Cells[6,11]:=' 第33节 ';
// RadioButton4
Timer1.Enabled:=True;
// Timer1.Enabled:=False;
end;
function HexStrToStr(const S:string):string;
//16进制字符串转换成字符串
var
t:Integer;
ts:string;
M,Code:Integer;
begin
t:=1;
Result:='';
while t<=Length(S) do
begin //xlh 2006.10.21
while (t<=Length(S)) and (not (S[t] in ['0'..'9','A'..'F','a'..'f'])) do
inc(t);
if (t+1>Length(S))or(not (S[t+1] in ['0'..'9','A'..'F','a'..'f'])) then
ts:='$'+S[t]
else
ts:='$'+S[t]+S[t+1];
Val(ts,M,Code);
if Code=0 then
Result:=Result+Chr(M);
inc(t,2);
end;
end;
procedure TForm3.BitBtn1Click(Sender: TObject);
var strP25 :string;
//var strN25 :string;
//var TxstrP25: string;
//var TxstrN25: string;
var liao: string;
var liaoxu: string;
//var liaoxuming :string;
begin
Case Form1.ComboBox1.ItemIndex Of
0 : begin
liao:='EB 04 01 01 01 0B 00 01 13 00 90';
strP25:='发送:EB 04 01 01 01 0B 00 01 13 00 90';
end;
1 : begin
liao:='EB 04 02 01 01 0B 00 01 14 00 90';
strP25:='发送:EB 04 02 01 01 0B 00 01 14 00 90';
end;
2 : begin
liao:='EB 04 03 01 01 0B 00 01 15 00 90';
strP25:='发送:EB 04 03 01 01 0B 00 01 15 00 90';
end;
3 : begin
liao:='EB 04 04 01 01 0B 00 01 16 00 90';
strP25:='发送:EB 04 04 01 01 0B 00 01 16 00 90';
end;
4 : begin
liao:='EB 04 05 01 01 0B 00 01 17 00 90';
strP25:='发送:EB 04 05 01 01 0B 00 01 17 00 90';
end;
5 : begin
liao:='EB 04 06 01 01 0B 00 01 18 00 90';
strP25:='发送:EB 04 06 01 01 0B 00 01 18 00 90';
end;
6 : begin
liao:='EB 04 07 01 01 0B 00 01 19 00 90';
strP25:='发送:EB 04 07 01 01 0B 00 01 19 00 90';
end;
7 : begin
liao:='EB 04 08 01 01 0B 00 01 1A 00 90';
strP25:='发送:EB 04 08 01 01 0B 00 01 1A 00 90';
end;
8 : begin
liao:='EB 04 09 01 01 0B 00 01 1B 00 90';
strP25:='发送:EB 04 09 01 01 0B 00 01 1B 00 90';
end;
9 : begin
liao:='EB 04 0A 01 01 0B 00 01 1C 00 90';
strP25:='发送:EB 04 0A 01 01 0B 00 01 1C 00 90';
end;
10 : begin
liao:='EB 04 0B 01 01 0B 00 01 1D 00 90';
strP25:='发送:EB 04 0B 01 01 0B 00 01 1D 00 90';
end;
else begin
liao:='EB 04 01 01 01 0B 00 01 13 00 90';
strP25:='发送:EB 04 01 01 01 0B 00 01 13 00 90';
end; ;
End;
//var BaudRate :integer;
//liao:='EB 04 01 01 01 0B 00 01 13 00 90';
//strP25:='发送:EB 04 01 01 01 0B 00 01 13 00 90';
//strN25:='发送:EB 04 01 01 01 0E 00 EE 03 00 00 06 01 90 ';
liaoxu:= HexStrToStr(liao);
// Form2.Comm1.WriteCommData(Pchar(HexStrToStr(TxstrP25)),Length(TxstrP25));
Form2.Comm1.WriteCommData(Pchar(liaoxu),Length(liaoxu));
// Button1.Caption:='+2.5V';
Form1.Memo1.Text :=Form1. Memo1.Text + StrP25;
Form1.Memo1.SelStart := Length(Form1.Memo1.Text);
Form1.Memo1.SelLength:= 0;
Form1.Memo1.Perform(EM_SCROLLCARET,0,0);
//\r\njlklkkjkjl
Form1.memo1.Lines.Append('');
Form1.memo1.Lines.Append('');
DianChiZhanTaiChaXun:=55;
//if Comm1.WriteCommData(Pchar(str),Length(str)) then
//begin
// FTXNum:=FTXNum+Length(str);
// ShowTX;
// end;
end;
procedure TForm3.CheckBox1Click(Sender: TObject);
begin
//RadioButton4.Checked:=Ture;
if RadioButton1.Checked then
begin
Timer1.Interval:=500;
end;
if RadioButton2.Checked then
begin
Timer1.Interval:=1000;
end;
if RadioButton3.Checked then
begin
Timer1.Interval:=2000;
end;
if RadioButton4.Checked then
begin
Timer1.Interval:=3000;
end;
if RadioButton5.Checked then
begin
Timer1.Interval:=4000;
end;
if RadioButton6.Checked then
begin
Timer1.Interval:=5000;
end;
if RadioButton7.Checked then
begin
Timer1.Interval:=6000;
end;
if RadioButton11.Checked then
begin
Timer1.Interval:=8000;
end;
if RadioButton12.Checked then
begin
Timer1.Interval:=12000;
end;
if RadioButton13.Checked then
begin
Timer1.Interval:=16000;
end;
// Timer1.Interval:=2000;
BitBtn1.Click;
end;
procedure TForm3.Timer1Timer(Sender: TObject);
begin
if CheckBox1.Checked then
begin
BitBtn1.Click;
BitBtn1.Enabled:=False;
end
else
begin
BitBtn1.Enabled:=True;
end;
end;
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Timer1.Enabled:=False;
end;
procedure TForm3.FormShow(Sender: TObject);
begin
Timer1.Enabled:=True;
end;
procedure TForm3.RadioButton1Click(Sender: TObject);
begin
Timer1.Interval:=500;
end;
procedure TForm3.RadioButton2Click(Sender: TObject);
begin
Timer1.Interval:=1000;
end;
procedure TForm3.RadioButton3Click(Sender: TObject);
begin
Timer1.Interval:=2000;
end;
procedure TForm3.RadioButton5Click(Sender: TObject);
begin
Timer1.Interval:=4000;
end;
procedure TForm3.RadioButton6Click(Sender: TObject);
begin
Timer1.Interval:=5000;
end;
procedure TForm3.RadioButton7Click(Sender: TObject);
begin
Timer1.Interval:=6000;
end;
procedure TForm3.RadioButton11Click(Sender: TObject);
begin
Timer1.Interval:=8000;
end;
procedure TForm3.RadioButton12Click(Sender: TObject);
begin
Timer1.Interval:=12000;
end;
procedure TForm3.RadioButton13Click(Sender: TObject);
begin
Timer1.Interval:=16000;
end;
procedure TForm3.Timer2Timer(Sender: TObject);
begin
if CheckBox1.Checked then
begin
BitBtn1.Enabled:=False;
end
else
begin
BitBtn1.Enabled:=True;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -