📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, ComCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Button1: TButton;
GroupBox2: TGroupBox;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
Button2: TButton;
GroupBox3: TGroupBox;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
Button3: TButton;
GroupBox4: TGroupBox;
RadioButton7: TRadioButton;
RadioButton8: TRadioButton;
Button4: TButton;
Memo1: TMemo;
GroupBox5: TGroupBox;
Label2: TLabel;
GroupBox6: TGroupBox;
Label3: TLabel;
GroupBox7: TGroupBox;
Label4: TLabel;
GroupBox8: TGroupBox;
Label5: TLabel;
GroupBox9: TGroupBox;
Label6: TLabel;
GroupBox10: TGroupBox;
Label7: TLabel;
GroupBox12: TGroupBox;
Label8: TLabel;
GroupBox11: TGroupBox;
Label9: TLabel;
Button5: TButton;
Button6: TButton;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
StatusBar1: TStatusBar;
Timer1: TTimer;
ComboBox1: TComboBox;
Label10: TLabel;
N3: TMenuItem;
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Label2Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure N3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ComHaveSet:byte;
JiaoYangJianChe:byte;
DianChiZhanTaiChaXun:byte;
implementation
//uses Unit2, Unit3, Unit4;
uses Unit2, Unit3, Unit4, Unit5;
{$R *.dfm}
//uses Unit2, Unit3, Unit4, Unit5;
procedure TForm1.N1Click(Sender: TObject);
begin
Form2.showmodal;
end;
procedure TForm1.N2Click(Sender: TObject);
begin
if ComHaveSet<>55 then
begin
Application.MessageBox('老大'+#13+
' 麻烦你设置一下串口','警告',MB_ICONWARNING or MB_OK);
// ComboBox2.SetFocus;
Form2.showmodal;
end
else
begin
// Form3.showmodal;
end;
Form3.showmodal;
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 TForm1.Button1Click(Sender: TObject);
var strP25 :string;
var strN25 :string;
var TxstrP25: string;
var TxstrN25: string;
//var liao: string;
var liaoxu: string;
//var liaoxuming :string;
begin
//var BaudRate :integer;
//liao:='EB 04 01 01 01 0B 00 EC FE 00 90';
// Case Express Of //Express为表达式,必须为有序型
// <条件值> : StateMent;
// ....
// <条件值> : StateMent;
// [ Else
// Statement;] //可选
// End;
// 例如:
Case ComboBox1.ItemIndex Of
0 : begin
TxstrP25:='EB 04 01 01 01 0E 00 EE 02 00 00 05 01 90';
TxstrN25:='EB 04 01 01 01 0E 00 EE 03 00 00 06 01 90';
strP25:='发送:EB 04 01 01 01 0E 00 EE 02 00 00 05 01 90 ';
strN25:='发送:EB 04 01 01 01 0E 00 EE 03 00 00 06 01 90 ';
end;
1 : begin
TxstrP25:='EB 04 02 01 01 0E 00 EE 02 00 00 06 01 90';
TxstrN25:='EB 04 02 01 01 0E 00 EE 03 00 00 07 01 90';
strP25:='发送:EB 04 02 01 01 0E 00 EE 02 00 00 06 01 90 ';
strN25:='发送:EB 04 02 01 01 0E 00 EE 03 00 00 07 01 90 ';
end;
2 : begin
TxstrP25:='EB 04 03 01 01 0E 00 EE 02 00 00 07 01 90';
TxstrN25:='EB 04 03 01 01 0E 00 EE 03 00 00 08 01 90';
strP25:='发送:EB 04 03 01 01 0E 00 EE 02 00 00 07 01 90 ';
strN25:='发送:EB 04 03 01 01 0E 00 EE 03 00 00 08 01 90 ';
end;
3 : begin
TxstrP25:='EB 04 04 01 01 0E 00 EE 02 00 00 08 01 90';
TxstrN25:='EB 04 04 01 01 0E 00 EE 03 00 00 09 01 90';
strP25:='发送:EB 04 04 01 01 0E 00 EE 02 00 00 08 01 90 ';
strN25:='发送:EB 04 04 01 01 0E 00 EE 03 00 00 09 01 90 ';
end;
4 : begin
TxstrP25:='EB 04 05 01 01 0E 00 EE 02 00 00 09 01 90';
TxstrN25:='EB 04 05 01 01 0E 00 EE 03 00 00 0A 01 90';
strP25:='发送:EB 04 05 01 01 0E 00 EE 02 00 00 09 01 90 ';
strN25:='发送:EB 04 05 01 01 0E 00 EE 03 00 00 0A 01 90 ';
end;
5 : begin
TxstrP25:='EB 04 06 01 01 0E 00 EE 02 00 00 0A 01 90';
TxstrN25:='EB 04 06 01 01 0E 00 EE 03 00 00 0B 01 90';
strP25:='发送:EB 04 06 01 01 0E 00 EE 02 00 00 0A 01 90 ';
strN25:='发送:EB 04 06 01 01 0E 00 EE 03 00 00 0B 01 90 ';
end;
6 : begin
TxstrP25:='EB 04 07 01 01 0E 00 EE 02 00 00 0B 01 90';
TxstrN25:='EB 04 07 01 01 0E 00 EE 03 00 00 0C 01 90';
strP25:='发送:EB 04 07 01 01 0E 00 EE 02 00 00 0B 01 90 ';
strN25:='发送:EB 04 07 01 01 0E 00 EE 03 00 00 0C 01 90 ';
end;
7 : begin
TxstrP25:='EB 04 08 01 01 0E 00 EE 02 00 00 0C 01 90';
TxstrN25:='EB 04 08 01 01 0E 00 EE 03 00 00 0D 01 90';
strP25:='发送:EB 04 08 01 01 0E 00 EE 02 00 00 0C 01 90 ';
strN25:='发送:EB 04 08 01 01 0E 00 EE 03 00 00 0D 01 90 ';
end;
8 : begin
TxstrP25:='EB 04 09 01 01 0E 00 EE 02 00 00 0D 01 90';
TxstrN25:='EB 04 09 01 01 0E 00 EE 03 00 00 0E 01 90';
strP25:='发送:EB 04 09 01 01 0E 00 EE 02 00 00 0D 01 90 ';
strN25:='发送:EB 04 09 01 01 0E 00 EE 03 00 00 0E 01 90 ';
end;
9 : begin
TxstrP25:='EB 04 0A 01 01 0E 00 EE 02 00 00 0E 01 90';
TxstrN25:='EB 04 0A 01 01 0E 00 EE 03 00 00 0F 01 90';
strP25:='发送:EB 04 0A 01 01 0E 00 EE 02 00 00 0E 01 90 ';
strN25:='发送:EB 04 0A 01 01 0E 00 EE 03 00 00 0F 01 90 ';
end;
10 : begin
TxstrP25:='EB 04 0B 01 01 0E 00 EE 02 00 00 0F 01 90';
TxstrN25:='EB 04 0B 01 01 0E 00 EE 03 00 00 10 01 90';
strP25:='发送:EB 04 0B 01 01 0E 00 EE 02 00 00 0F 01 90 ';
strN25:='发送:EB 04 0B 01 01 0E 00 EE 03 00 00 10 01 90 ';
end;
else begin
TxstrP25:='EB 04 01 01 01 0E 00 EE 02 00 00 05 01 90';
TxstrN25:='EB 04 01 01 01 0E 00 EE 03 00 00 06 01 90';
strP25:='发送:EB 04 01 01 01 0E 00 EE 02 00 00 05 01 90 ';
strN25:='发送:EB 04 01 01 01 0E 00 EE 03 00 00 06 01 90 ';
end; ;
End;
//TxstrP25:='EB 04 01 01 01 0E 00 EE 02 00 00 05 01 90';
//TxstrN25:='EB 04 01 01 01 0E 00 EE 03 00 00 06 01 90';
//strP25:='发送:EB 04 01 01 01 0E 00 EE 02 00 00 05 01 90 ';
//strN25:='发送:EB 04 01 01 01 0E 00 EE 03 00 00 06 01 90 ';
if ComHaveSet<>55 then
begin
Application.MessageBox('老大'+#13+
' 麻烦你设置一下串口好不好?','警告',MB_ICONWARNING or MB_OK);
// ComboBox2.SetFocus;
Form2.showmodal;
end
else
begin
if RadioButton1.Checked then
begin
liaoxu:= HexStrToStr(TxstrP25);
// Form2.Comm1.WriteCommData(Pchar(HexStrToStr(TxstrP25)),Length(TxstrP25));
Form2.Comm1.WriteCommData(Pchar(liaoxu),Length(liaoxu));
Button1.Caption:='+2.5V';
Memo1.Text := Memo1.Text + StrP25;
Memo1.SelStart := Length(Memo1.Text);
Memo1.SelLength:= 0;
Memo1.Perform(EM_SCROLLCARET,0,0);
//\r\njlklkkjkjl
memo1.Lines.Append('');
memo1.Lines.Append('');
//if Comm1.WriteCommData(Pchar(str),Length(str)) then
//begin
// FTXNum:=FTXNum+Length(str);
// ShowTX;
// end;
end;
if RadioButton2.Checked then
begin
Button1.Caption:='-2.5V';
liaoxu:= HexStrToStr(TxstrN25);
Form2.Comm1.WriteCommData(Pchar(liaoxu),Length(liaoxu));
Memo1.Text := Memo1.Text + StrN25;
Memo1.SelStart := Length(Memo1.Text);
Memo1.SelLength:= 0;
Memo1.Perform(EM_SCROLLCARET,0,0);
//\r\njlklkkjkjl
memo1.Lines.Append('');
memo1.Lines.Append('');
end;
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
var strP25 :string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -