mainform.pas
资源名称:st800.rar [点击查看]
上传用户:jitai139
上传日期:2013-04-11
资源大小:1244k
文件大小:149k
源码类别:
防火墙与安全工具
开发平台:
Delphi
- unit mainform;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, OleCtrls, MSCommLib_TLB, StdCtrls, ExtCtrls, ComCtrls,math;
- type
- TForm1 = class(TForm)
- Panel1: TPanel;
- GroupBox1: TGroupBox;
- Edit1: TEdit;
- GroupBox2: TGroupBox;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- Edit2: TEdit;
- Edit3: TEdit;
- Edit4: TEdit;
- Edit5: TEdit;
- Edit6: TEdit;
- Edit7: TEdit;
- Edit8: TEdit;
- Edit9: TEdit;
- Edit10: TEdit;
- Edit11: TEdit;
- Edit12: TEdit;
- Edit13: TEdit;
- Edit14: TEdit;
- Edit15: TEdit;
- Edit16: TEdit;
- Edit17: TEdit;
- Edit18: TEdit;
- Edit19: TEdit;
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- Button5: TButton;
- Button6: TButton;
- Button7: TButton;
- Button8: TButton;
- Button9: TButton;
- Button10: TButton;
- Button11: TButton;
- Button12: TButton;
- Button13: TButton;
- Button14: TButton;
- Button15: TButton;
- Button16: TButton;
- Button17: TButton;
- Button18: TButton;
- Edit20: TEdit;
- Edit21: TEdit;
- Edit22: TEdit;
- Edit23: TEdit;
- Edit24: TEdit;
- Edit25: TEdit;
- Button19: TButton;
- Button20: TButton;
- Button21: TButton;
- GroupBox3: TGroupBox;
- ComboBox1: TComboBox;
- Button22: TButton;
- GroupBox4: TGroupBox;
- Edit26: TEdit;
- Label7: TLabel;
- Button24: TButton;
- GroupBox5: TGroupBox;
- ComboBox2: TComboBox;
- Edit27: TEdit;
- Edit28: TEdit;
- Button25: TButton;
- MSComm1: TMSComm;
- StatusBar1: TStatusBar;
- Timer1: TTimer;
- Button26: TButton;
- OpenDialog1: TOpenDialog;
- SaveDialog1: TSaveDialog;
- Button27: TButton;
- Timer2: TTimer;
- Timer3: TTimer;
- Timer4: TTimer;
- Timer5: TTimer;
- Timer6: TTimer;
- Timer7: TTimer;
- Timer8: TTimer;
- Timer9: TTimer;
- Timer10: TTimer;
- Timer11: TTimer;
- Timer12: TTimer;
- Timer13: TTimer;
- Timer14: TTimer;
- Button28: TButton;
- SaveDialog2: TSaveDialog;
- Shape1: TShape;
- Timer15: TTimer;
- Timer16: TTimer;
- Label8: TLabel;
- Label9: TLabel;
- Label10: TLabel;
- Memo1: TMemo;
- CheckBox1: TCheckBox;
- CheckBox2: TCheckBox;
- CheckBox3: TCheckBox;
- CheckBox4: TCheckBox;
- CheckBox5: TCheckBox;
- CheckBox6: TCheckBox;
- Label12: TLabel;
- Edit29: TEdit;
- Label13: TLabel;
- Label14: TLabel;
- Edit30: TEdit;
- Label15: TLabel;
- Edit31: TEdit;
- Label16: TLabel;
- ComboBox3: TComboBox;
- ComboBox4: TComboBox;
- ComboBox5: TComboBox;
- ComboBox6: TComboBox;
- ComboBox7: TComboBox;
- ComboBox8: TComboBox;
- Label17: TLabel;
- Label18: TLabel;
- Label19: TLabel;
- Label20: TLabel;
- Label21: TLabel;
- Label22: TLabel;
- Button23: TButton;
- Label11: TLabel;
- Button29: TButton;
- procedure Button22Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button6Click(Sender: TObject);
- procedure Button9Click(Sender: TObject);
- procedure Button12Click(Sender: TObject);
- procedure Button15Click(Sender: TObject);
- procedure Button18Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Button26Click(Sender: TObject);
- procedure Button27Click(Sender: TObject);
- procedure Button5Click(Sender: TObject);
- procedure Button8Click(Sender: TObject);
- procedure Button11Click(Sender: TObject);
- procedure Button14Click(Sender: TObject);
- procedure Button17Click(Sender: TObject);
- procedure Timer2Timer(Sender: TObject);
- procedure Timer3Timer(Sender: TObject);
- procedure Timer4Timer(Sender: TObject);
- procedure Timer5Timer(Sender: TObject);
- procedure Timer6Timer(Sender: TObject);
- procedure Button21Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Timer7Timer(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- procedure Button7Click(Sender: TObject);
- procedure Button10Click(Sender: TObject);
- procedure Button13Click(Sender: TObject);
- procedure Button16Click(Sender: TObject);
- procedure Timer8Timer(Sender: TObject);
- procedure Timer9Timer(Sender: TObject);
- procedure Timer10Timer(Sender: TObject);
- procedure Timer11Timer(Sender: TObject);
- procedure Timer12Timer(Sender: TObject);
- procedure Button24Click(Sender: TObject);
- procedure Timer13Timer(Sender: TObject);
- procedure Button25Click(Sender: TObject);
- procedure Timer14Timer(Sender: TObject);
- procedure Button28Click(Sender: TObject);
- procedure Button19Click(Sender: TObject);
- procedure Timer15Timer(Sender: TObject);
- procedure Button20Click(Sender: TObject);
- procedure Timer16Timer(Sender: TObject);
- procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure ComboBox1Change(Sender: TObject);
- procedure ComboBox2Change(Sender: TObject);
- procedure Button23Click(Sender: TObject);
- // procedure Edit1Enter(Sender: TObject);
- // function setvar(tag:boolean;btn:tbutton):integer;
- private
- { Private declarations }
- function TsInputVal(staStr:string):boolean;
- public
- { Public declarations }
- timesum,tag,success,p,tagc,pc:integer;
- flag:boolean;
- zuhao:integer;
- tindexnum:integer;
- end;
- var
- Form1: TForm1;
- implementation
- //uses sysutils;
- {$R *.dfm}
- {function setvar(tag:boolean;btn:tbutton):integer;
- var
- i:integer;
- begin
- i:=-1;
- while tag<>true do begin
- if (edit2.)or()or()or()or()or()
- btn.Click;
- end;
- i:=1 ;
- tag:=false;
- result:= i;
- end; }
- //function senddata(cid:integer) :boolean;
- //hao add
- function TForm1.TsInputVal(staStr:string):boolean;
- var
- flag1,flag2:boolean ;
- f:real;
- begin
- f:=strToFloat(staStr);
- if f>=0.000 then
- flag1:=true
- else
- flag1:=false;
- if f<=9.999 then
- flag2:=true
- else
- flag2:=false;
- if flag1 and flag2 then
- begin
- result:=true;
- exit;
- end
- else
- begin
- showmessage('输入或所得的设定值非法!!--范围在:0.000~9.999 之间。');
- result:=false;
- end;
- end;
- PROCEDURE TIMEDELAY(DT:DWORD); //延时程序 timedelay(sencond)
- VAR
- TT:DWORD;
- begin
- //取得现在的TICK值
- TT:=GetTickCount();
- //计算TICK差值是否超过设置之
- while GetTickCount()-TT<DT do
- APPLICATION.ProcessMessages;//释放控制权
- end;
- function hex(c:char):integer; //16进制转换
- var
- x:integer;
- begin
- if c='' then
- x:=0
- else if (ord(c)>=ord('0'))and(ord(c)<=ord('9')) then
- x:=ord(c)-ord('0')
- else if (ord(c)>=ord('a'))and(ord(c)<=ord('f')) then
- x:=ord(c)-ord('a')+10
- else if (ord(c)>=ord('A'))and(ord(c)<=ord('F')) then
- x:=ord(c)-ord('A')+10
- else
- x:=-1;
- result:=x;
- end;
- function hextoint(s:string):integer ; //16进制toINT
- var
- tmpstr1,tmpstr2:integer;
- begin
- if length(s)=1 then
- begin
- result:=hex(s[1]);
- end
- else if length(s)=2 then
- begin
- tmpstr1:=hex(s[1]) ;
- tmpstr2:=hex(s[2]);
- if(tmpstr1=-1)and(tmpstr2=-1) then
- result:=-1
- else
- result:=tmpstr1*16+tmpstr2;
- end
- else
- result:=-1;
- end;
- procedure TForm1.Button22Click(Sender: TObject); //open the serial port
- begin
- if not mscomm1.PortOpen then
- begin
- mscomm1.CommPort:=combobox1.ItemIndex+1;
- tindexnum:= combobox1.ItemIndex;
- mscomm1.Settings:='2400,n,8,1';
- mscomm1.PortOpen:=true;
- statusbar1.Panels[0].Text:='串口com'+inttostr(combobox1.ItemIndex+1)+'已打开';
- shape1.Brush.Color:=clgreen;
- button22.Caption:='断开';
- end else
- begin
- mscomm1.PortOpen:=false;
- shape1.Brush.Color:=clred;
- tindexnum:= combobox1.ItemIndex;
- statusbar1.Panels[0].Text:='串口com'+inttostr(combobox1.ItemIndex+1)+'已关闭';
- button22.Caption:='连接';
- edit4.Text:='';
- edit7.Text:='';
- edit10.Text:='';
- edit13.Text:='';
- edit16.Text:='';
- edit19.Text:='';
- combobox2.ItemIndex:=0;
- label8.Visible:=false;
- label9.Visible:=false;
- label10.Visible:=false;
- label11.Visible:=false;
- label12.Visible:=false;
- label13.Visible:=false;
- label14.Visible:=false;
- label15.Visible:=false;
- label16.Visible:=false;
- edit27.Visible:=false;
- edit28.Visible:=false;
- edit29.Visible:=false;
- edit30.Visible:=false;
- edit31.Visible:=false;
- end;
- // mscomm1.CommPort:=combobox1.ItemIndex+1;
- //mscomm1.Settings:='2400,n,8,1';
- // mscomm1.PortOpen:=true;
- //statusbar1.Panels[0].Text:='serial was open';
- //shape1.Brush.Color:=clgreen;
- //edit3.Text:='';
- edit4.Text:='';
- // edit6.Text:='';
- edit7.Text:='';
- // edit9.Text:='';
- edit10.Text:='';
- // edit12.Text:='';
- edit13.Text:='';
- //edit15.Text:='';
- edit16.Text:='';
- // edit18.Text:='';
- edit19.Text:='';
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- var
- a,b:real;
- c: real;
- m,n:variant;
- str1:string;
- ll:integer;
- begin
- c:=0.00;
- if (edit3.Text<>'') and (edit4.Text<>'') then
- begin {if (strtofloat(edit3.Text) >25.00) or(strtofloat(edit3.Text)<-45.00) then
- begin
- showmessage('数值超出合理范围(-45.00~+25.00)'); /////////////////////////////////
- edit3.Text:='';
- end else begin }
- str1:=label17.Caption;
- if str1='dBm' then begin
- a:=strtofloat(edit4.Text);
- n:=a;
- a:=power(10,n/10.0); //dbm to mw
- a:=a*1000.0; //mw to uw
- b:=strtofloat(edit3.Text);
- ll:=combobox3.ItemIndex;
- case ll of
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit3.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);;
- end;
- end;
- // c:= m/ n;
- //edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- if str1='uw' then begin
- a:=strtofloat(edit4.Text);
- n:=a;
- // m:=m;
- b:=strtofloat(edit3.Text);
- ll:=combobox3.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0; }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit3.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/a;
- edit2.Text:=formatfloat('0.000',c);;
- end;
- end;
- // c:= m/ n;
- end;
- // edit2.Text:=formatfloat('0.000',c);
- end;
- if str1='nw' then begin
- a:=strtofloat(edit4.Text);
- n:=a;
- a:=a/1000.0;
- b:=strtofloat(edit3.Text);
- ll:=combobox3.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m/1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0;
- end; }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit3.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);;
- end;
- // c:= m/ n;
- end;
- //edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- if str1='mw' then begin
- a:=strtofloat(edit4.Text);
- n:=a;
- a:=a*1000.0;
- b:=strtofloat(edit3.Text);
- ll:=combobox3.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0; }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit3.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit3.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit2.Text:=formatfloat('0.000',c);;
- end;
- end;
- //edit2.Text:=formatfloat('0.000',c);
- end;
- end;
- end
- else
- begin
- showmessage('请先输入正确的值!');
- end;
- end;
- //end;
- //end;
- //end;
- procedure TForm1.Button9Click(Sender: TObject);
- var
- a,b:real;
- c: real;
- m,n:variant;
- str1:string;
- ll:integer;
- begin
- c:=0.00;
- if (edit9.Text<>'') and (edit10.Text<>'') then
- begin {if (strtofloat(edit3.Text) >25.00) or(strtofloat(edit3.Text)<-45.00) then
- begin
- showmessage('数值超出合理范围(-45.00~+25.00)'); /////////////////////////////////
- edit3.Text:='';
- end else begin }
- str1:=label19.Caption;
- if str1='dBm' then begin
- a:=strtofloat(edit10.Text);
- n:=a;
- a:=power(10,a/10.0); //dbm to mw
- a:=a*1000.0; //mw to uw
- b:=strtofloat(edit9.Text);
- ll:=combobox5.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0
- end; }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit9.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit8.Text:=formatfloat('0.000',c);;
- end;
- end;
- // c:= m/ n;
- end;
- //edit8.Text:=formatfloat('0.000',c);
- end;
- if str1='uw' then begin
- a:=strtofloat(edit10.Text);
- n:=a;
- // m:=m;
- b:=strtofloat(edit9.Text);
- ll:=combobox5.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit9.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b;
- c:=b/a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit8.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- //c:= m/ n;
- // edit8.Text:=formatfloat('0.000',c);
- end;
- if str1='nw' then begin
- a:=strtofloat(edit10.Text);
- n:=a;
- a:=a/1000.0;
- b:=strtofloat(edit9.Text);
- ll:=combobox5.ItemIndex;
- case ll of
- {0:begin m:=power(10,b/10.0); m:=m/1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit9.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit8.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- // c:= m/ n;
- //edit8.Text:=formatfloat('0.000',c);
- end;
- if str1='mw' then begin
- a:=strtofloat(edit10.Text);
- n:=a;
- a:=a*1000.0;
- b:=strtofloat(edit9.Text);
- ll:=combobox5.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit9.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit8.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit9.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/a;
- edit8.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- // edit8.Text:=formatfloat('0.000',c);
- end;
- // end;
- end
- else
- begin
- showmessage('请先输入正确的值!');
- end;
- end;
- // end;
- // end;
- procedure TForm1.Button6Click(Sender: TObject);
- var
- a,b:real;
- c: real;
- m,n:variant;
- str1:string;
- ll:integer;
- begin
- c:=0.00;
- if (edit6.Text<>'') and (edit7.Text<>'') then
- begin {if (strtofloat(edit3.Text) >25.00) or(strtofloat(edit3.Text)<-45.00) then
- begin
- showmessage('数值超出合理范围(-45.00~+25.00)'); /////////////////////////////////
- edit3.Text:='';
- end else begin }
- str1:=label18.Caption;
- if str1='dBm' then begin
- a:=strtofloat(edit7.Text);
- n:=a;
- a:=power(10,a/10.0); //dbm to mw
- a:=a*1000.0; //mw to uw
- b:=strtofloat(edit6.Text);
- ll:=combobox4.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0
- end; }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit6.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);;
- end;
- end;
- // c:= m/ n;
- //edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- if str1='uw' then begin
- a:=strtofloat(edit7.Text);
- n:=a;
- // m:=m;
- b:=strtofloat(edit6.Text);
- ll:=combobox4.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0
- end;
- c:= m/ n;
- edit5.Text:=formatfloat('0.000',c);}
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit6.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/a;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/a;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- end;
- if str1='nw' then begin
- a:=strtofloat(edit7.Text);
- n:=a;
- a:=a/1000.0;
- b:=strtofloat(edit6.Text);
- ll:=combobox4.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m/1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0
- end;
- c:= m/ n;
- edit5.Text:=formatfloat('0.000',c); }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit6.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/a ;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- end;
- if str1='mw' then begin
- a:=strtofloat(edit7.Text);
- n:=a;
- a:=a*1000.0;
- b:=strtofloat(edit6.Text);
- ll:=combobox4.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0
- end;
- edit5.Text:=formatfloat('0.000',c); }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit6.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit5.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit6.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/a;
- edit5.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- end;
- end
- else
- begin
- showmessage('请先输入正确的值!');
- end;
- end;
- procedure TForm1.Button12Click(Sender: TObject);
- var
- a,b:real;
- c: real;
- m,n:variant;
- str1:string;
- ll:integer;
- begin
- c:=0.00;
- if (edit12.Text<>'') and (edit13.Text<>'') then
- begin {if (strtofloat(edit3.Text) >25.00) or(strtofloat(edit3.Text)<-45.00) then
- begin
- showmessage('数值超出合理范围(-45.00~+25.00)'); /////////////////////////////////
- edit3.Text:='';
- end else begin }
- str1:=label20.Caption;
- if str1='dBm' then begin
- a:=strtofloat(edit13.Text);
- n:=a;
- a:=power(10,a/10.0); //dbm to mw
- a:=a*1000.0; //mw to uw
- b:=strtofloat(edit12.Text);
- ll:=combobox6.ItemIndex;
- case ll of
- {0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 } 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit12.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- // c:= m/ n;
- // edit11.Text:=formatfloat('0.000',c);
- end;
- if str1='uw' then begin
- a:=strtofloat(edit13.Text);
- n:=a;
- // m:=m;
- b:=strtofloat(edit12.Text);
- ll:=combobox6.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit12.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- // c:= m/ n;
- //edit11.Text:=formatfloat('0.000',c);
- end;
- if str1='nw' then begin
- a:=strtofloat(edit13.Text);
- n:=a;
- a:=a/1000.0;
- b:=strtofloat(edit12.Text);
- ll:=combobox6.ItemIndex;
- case ll of
- {0:begin m:=power(10,b/10.0); m:=m/1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit12.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin a:= b*1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- // c:= m/ n;
- // edit11.Text:=formatfloat('0.000',c);
- end;
- if str1='mw' then begin
- a:=strtofloat(edit13.Text);
- n:=a;
- a:=a*1000.0;
- b:=strtofloat(edit12.Text);
- ll:=combobox6.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit12.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入数值超出范围!');
- edit12.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit11.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- //edit11.Text:=formatfloat('0.000',c);
- end;
- // end;
- end
- else
- begin
- showmessage('请先输入正确的值!');
- end;
- end;
- procedure TForm1.Button15Click(Sender: TObject);
- var
- a,b:real;
- c: real;
- m,n:variant;
- str1:string;
- ll:integer;
- begin
- c:=0.00;
- if (edit15.Text<>'') and (edit16.Text<>'') then
- begin {if (strtofloat(edit3.Text) >25.00) or(strtofloat(edit3.Text)<-45.00) then
- begin
- showmessage('数值超出合理范围(-45.00~+25.00)'); /////////////////////////////////
- edit3.Text:='';
- end else begin }
- str1:=label21.Caption;
- if str1='dBm' then begin
- a:=strtofloat(edit16.Text);
- n:=a;
- a:=power(10,a/10.0); //dbm to mw
- a:=a*1000.0; //mw to uw
- b:=strtofloat(edit15.Text);
- ll:=combobox7.ItemIndex;
- case ll of
- {0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit15.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit14.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- // c:= m/ n;
- // edit14.Text:=formatfloat('0.000',c);
- end;
- if str1='uw' then begin
- a:=strtofloat(edit16.Text);
- n:=a;
- // m:=m;
- b:=strtofloat(edit15.Text);
- ll:=combobox7.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit15.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/a;
- edit14.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- //c:= m/ n;
- //edit14.Text:=formatfloat('0.000',c);
- end;
- if str1='nw' then begin
- a:=strtofloat(edit16.Text);
- n:=a;
- a:=a/1000.0;
- b:=strtofloat(edit15.Text);
- ll:=combobox7.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m/1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit15.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b;
- c:= b/a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit14.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- // c:= m/ n;
- //edit14.Text:=formatfloat('0.000',c);
- end;
- if str1='mw' then begin
- a:=strtofloat(edit16.Text);
- n:=a;
- a:=a*1000.0;
- b:=strtofloat(edit15.Text);
- ll:=combobox7.ItemIndex;
- case ll of
- {0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit15.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b;
- c:= b/a;
- edit14.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入的数值超出范围!');
- edit15.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/a;
- edit14.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- //edit14.Text:=formatfloat('0.000',c);
- end;
- // end;
- end
- else
- begin
- showmessage('请先输入正确的值!');
- end;
- end;
- procedure TForm1.Button18Click(Sender: TObject);
- var
- a,b:real;
- c: real;
- m,n:variant;
- str1:string;
- ll:integer;
- begin
- c:=0.00;
- if (edit18.Text<>'') and (edit19.Text<>'') then
- begin {if (strtofloat(edit3.Text) >40.00) or(strtofloat(edit3.Text)<-45.00) then
- begin
- showmessage('数值超出合理范围'); /////////////////////////////////
- edit3.Text:='';
- end else begin }
- str1:=label22.Caption;
- if str1='dBm' then begin
- a:=strtofloat(edit19.Text);
- n:=a;
- a:=power(10,n/10.0); //dbm to mw
- a:=a*1000.0; //mw to uw
- b:=strtofloat(edit18.Text);
- ll:=combobox8.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit18.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b;
- c:= b/a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/a;
- edit17.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- // c:= m/ n;
- //edit17.Text:=formatfloat('0.000',c);
- end;
- if str1='uw' then begin
- a:=strtofloat(edit19.Text);
- n:=a;
- // m:=m;
- b:=strtofloat(edit18.Text);
- ll:=combobox8.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit18.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b;
- c:= b/ a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/a;
- edit17.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- // c:= m/ n;
- //edit17.Text:=formatfloat('0.000',c);
- end;
- if str1='nw' then begin
- a:=strtofloat(edit19.Text);
- n:=a;
- a:=a/1000.0;
- b:=strtofloat(edit18.Text);
- ll:=combobox8.ItemIndex;
- case ll of
- { 0:begin m:=power(10,b/10.0); m:=m/1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit18.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b;
- c:=b/a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/a;
- edit17.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- // c:= m/ n;
- //edit17.Text:=formatfloat('0.000',c);
- end;
- if str1='mw' then begin
- a:=strtofloat(edit19.Text);
- n:=a;
- a:=a*1000.0;
- b:=strtofloat(edit18.Text);
- ll:=combobox8.ItemIndex;
- case ll of
- {0:begin m:=power(10,b/10.0); m:=m*1000.0; end;
- 1:m:= b*1000.0;
- 2:m:= b;
- 3:m:= b/1000.0 }
- 0:begin if (b<=-70) or (b>=10) then
- begin
- showmessage('输入的数值超出范围!') ;
- edit18.Text:='';
- end
- else begin
- b:=power(10,b/10.0);
- b:=b*1000.0;
- c:= b/ a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 1:begin if (b>10) or (b<1/10000000) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b*1000.0;
- c:= b/ a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 2:begin if (b>1000)or (b<1/10000) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b;
- c:= b/a;
- edit17.Text:=formatfloat('0.000',c);
- end;
- end;
- 3:begin if (b>1000000)or (b<1/10) then begin
- showmessage('输入的数值超出范围!');
- edit18.Text:='';
- end
- else begin b:= b/1000.0;
- c:= b/ a;
- edit17.Text:=formatfloat('0.000',c);;
- end;
- end;
- end;
- edit17.Text:=formatfloat('0.000',c);
- end;
- // end;
- end
- else
- begin
- showmessage('请先输入正确的值!');
- end;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- var
- v,len,i,count:integer;
- tmpstr:string;
- tmpvar:variant;
- xornum:byte;
- arr:array of byte;
- f:real;
- begin
- arr:=nil;
- if (edit2.Text='') then
- begin
- showmessage('无设定值!');
- end
- else begin if not mscomm1.PortOpen then begin
- showmessage('串口没有打开!');
- end else begin
- //hao add
- if not TsInputVal(edit2.Text) then
- begin
- edit2.SetFocus;
- exit
- end;
- //hao add end
- setlength(arr,9);
- f:=strtofloat(edit2.text)*1000.0;
- tmpstr:=floattostr(f);
- v:=strtoint(tmpstr);
- arr[0]:=$7e; //soi
- arr[1]:=$10; //ver
- arr[2]:= $04; //length
- arr[3]:=$a1; //cid
- arr[4]:=$00; //datainfo
- arr[5]:=v div 256;
- arr[6]:= v mod 256 ;
- xornum:= arr[2] xor arr[3] xor arr[4] xor arr[5]xor arr[6];
- arr[7]:=xornum;
- arr[8]:=$0d;
- // send data
- len:=length(arr);
- i:=0;
- count:=0;
- tmpvar:=vararraycreate([0,0],varbyte);
- //tmpvar[count]:=arr[i];
- //inc(count);
- //inc(i);
- while(count<=len-1)do begin
- tmpvar[count]:=arr[i];
- inc(count);
- inc(i);
- vararrayredim(tmpvar,count);
- end;
- MSComm1.Output:=tmpvar;
- timer1.Enabled:=true;
- end;
- //while mscomm1.InBufferCount
- end;
- end;
- procedure TForm1.Timer1Timer(Sender: TObject);
- var
- i,n,m,chksum:integer; //,timesum
- arr:array of byte;
- tmpvar:variant;
- begin
- arr:=nil;
- chksum:=$00;
- timesum:=timesum+integer(timer1.Interval)+10;
- if timesum<900 then
- begin
- if mscomm1.InBufferCount>0 then begin
- timer1.Enabled:=false;
- timesum:=100;
- n:=mscomm1.InBufferCount;
- setlength(arr,n);
- tmpvar:=mscomm1.input;
- for i:=0 to n-1 do arr[i]:=tmpvar[i];
- if (arr[0]=$7e)and(arr[1]=$10)and(arr[n-1]=$0d) then
- begin
- for m:=2 to (n-3) do chksum:=chksum xor arr[m];
- if (arr[n-2]=chksum)and(arr[3]=$a1) then begin
- //edit4.Text:=inttostr(arr[4]*256+arr[5]);
- if arr[n-3]=$0cc then begin
- showmessage('设置成功!') ;
- //tag:=true;
- end
- else if arr[n-3]=$66 then begin //success:=true;
- timer1.Enabled:=false;
- showmessage('设置失败!');
- end else begin timer1.Enabled:=false;
- showmessage('数据包错误!');
- end;
- end else
- begin
- timer1.Enabled:=false;
- showmessage('帧校验错误!'); //帧校验错误
- //success:=true;
- end;
- end else begin
- timer1.Enabled:=false;
- showmessage('响应数据错误!');
- //success:=true;
- end;
- end else begin
- sleep(10);
- timer1.Enabled:=true;
- end;
- end else begin
- //success:=true;
- timer1.Enabled:=false;
- timesum:=100;
- showmessage('通道0参数设定时响应超时!');
- end;
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- tindexnum:=-1;
- timesum:=100;
- flag:=false;
- success:=0;
- zuhao:=-1;
- tag:=0;
- tagc:=0;
- pc:=0;
- p:=0;
- {edit4.Enabled:=false;
- edit7.Enabled:=false;
- edit10.Enabled:=false;
- edit13.Enabled:=false;
- edit16.Enabled:=false;
- edit19.Enabled:=false; }
- edit20.Enabled:=false;
- edit21.Enabled:=false;
- edit22.Enabled:=false;
- edit23.Enabled:=false;
- edit24.Enabled:=false;
- edit25.Enabled:=false;
- edit26.Enabled:=false;
- edit27.Enabled:=false;
- edit28.Enabled:=false;
- edit29.Enabled:=false;
- edit30.Enabled:=false;
- edit31.Visible:=false;
- label8.Visible:=false;
- label9.Visible:=false;
- label10.Visible:=false;
- label11.Visible:=false;
- label12.Visible:=false;
- label13.Visible:=false;
- label14.Visible:=false;
- label15.Visible:=false;
- label16.Visible:=false;
- edit29.Visible:=false;
- edit30.Visible:=false;
- edit27.Visible:=false;
- edit28.Visible:=false;
- button23.Visible:=false;
- end;
- procedure TForm1.Button26Click(Sender: TObject);
- begin
- if messagedlg('你确定要退出吗?',mtConfirmation,[mbyes,mbno],0)=mryes then
- begin
- if mscomm1.PortOpen then begin
- mscomm1.PortOpen:=false;
- shape1.Brush.Color:=clred;
- end;
- application.Terminate;
- end;
- end ;
- procedure TForm1.Button27Click(Sender: TObject);
- var
- pt:boolean;
- filename,s,ed:string;
- i:integer;
- text:textfile;
- dataarr:array[1..6] of string;
- begin
- pt:=false;
- if opendialog1.Execute then
- begin filename:=opendialog1.FileName;
- filename:=extractfilename(filename);
- if fileexists(filename) then begin
- if edit1.Text='' then ed:='""' else ed:=edit1.Text;
- assignfile(text,filename);
- reset(text);
- try
- while not eof(text) do
- begin
- readln(text,s);
- if s=ed then begin
- pt:=true;
- for i:=1 to 6 do begin
- readln(text,s) ;
- dataarr[i]:=s ;
- end;
- edit20.Text:=dataarr[1];
- edit21.Text:=dataarr[2];
- edit22.Text:=dataarr[3];
- edit23.Text:=dataarr[4];
- edit24.Text:=dataarr[5];
- edit25.Text:=dataarr[6];
- if edit20.Text= edit2.Text then
- checkbox1.Checked:=true else checkbox1.Checked:=false;
- if edit21.Text= edit5.Text then
- checkbox2.Checked:=true else checkbox2.Checked:=false;
- if edit22.Text= edit8.Text then
- checkbox3.Checked:=true else checkbox3.Checked:=false;
- if edit23.Text= edit11.Text then
- checkbox4.Checked:=true else checkbox4.Checked:=false;
- if edit24.Text= edit14.Text then
- checkbox5.Checked:=true else checkbox5.Checked:=false;
- if edit25.Text= edit17.Text then
- checkbox6.Checked:=true else checkbox6.Checked:=false;
- end ;
- end;
- finally
- closefile(text);
- end;
- if pt=false then begin
- edit20.Text:='';
- edit21.Text:='';
- edit22.Text:='';
- edit23.Text:='';
- edit24.Text:='';
- edit25.Text:='';
- showmessage('文件中无合适的记录!');
- end;
- end else
- begin
- edit20.Text:='';
- edit21.Text:='';
- edit22.Text:='';
- edit23.Text:='';
- edit24.Text:='';
- edit25.Text:='';
- showmessage('没有找到指定文件!');
- end;
- end;
- end;
- procedure TForm1.Button5Click(Sender: TObject);
- var
- v,len,i,count:integer;
- tmpstr:string;
- tmpvar:variant;
- xornum:byte;
- arr:array of byte;
- f:real;
- begin
- arr:=nil;
- if (edit5.Text='') then
- begin
- showmessage('无设定值!');
- end
- else begin if not mscomm1.PortOpen then begin
- showmessage('串口没有打开!');
- end else begin
- //hao add
- if not TsInputVal(edit5.Text) then
- begin
- edit5.SetFocus;
- exit
- end;
- //hao add end
- setlength(arr,9);
- f:=strtofloat(edit5.text)*1000.0;
- tmpstr:=floattostr(f);
- v:=strtoint(tmpstr);
- arr[0]:=$7e; //soi
- arr[1]:=$10; //ver
- arr[2]:= $04; //length
- arr[3]:=$a1; //cid
- arr[4]:=$01; //datainfo
- arr[5]:=v div 256;
- arr[6]:= v mod 256 ;
- xornum:= arr[2] xor arr[3] xor arr[4] xor arr[5]xor arr[6];
- arr[7]:=xornum;
- arr[8]:=$0d;
- // send data
- len:=length(arr);
- i:=0;
- count:=0;
- tmpvar:=vararraycreate([0,0],varbyte);
- //tmpvar[count]:=arr[i];
- //inc(count);
- //inc(i);
- while(count<=len-1)do begin
- tmpvar[count]:=arr[i];
- inc(count);
- inc(i);
- vararrayredim(tmpvar,count);
- end;
- MSComm1.Output:=tmpvar;
- timer2.Enabled:=true;
- end;
- //while mscomm1.InBufferCount
- end;
- end;
- procedure TForm1.Button8Click(Sender: TObject);
- var
- v,len,i,count:integer;
- tmpstr:string;
- tmpvar:variant;
- xornum:byte;
- arr:array of byte;
- f:real;
- begin
- arr:=nil;
- if (edit8.Text='') then
- begin
- showmessage('无设定值!');
- end
- else begin if not mscomm1.PortOpen then begin
- showmessage('串口没有打开!');
- end else begin
- //hao add
- if not TsInputVal(edit8.Text) then
- edit8.SetFocus;
- //hao add end
- setlength(arr,9);
- f:=strtofloat(edit8.text)*1000.0;
- tmpstr:=floattostr(f);
- v:=strtoint(tmpstr);
- arr[0]:=$7e; //soi
- arr[1]:=$10; //ver
- arr[2]:= $04; //length
- arr[3]:=$a1; //cid
- arr[4]:=$02; //datainfo
- arr[5]:=v div 256;
- arr[6]:= v mod 256 ;
- xornum:= arr[2] xor arr[3] xor arr[4] xor arr[5]xor arr[6];
- arr[7]:=xornum;
- arr[8]:=$0d;
- // send data
- len:=length(arr);
- i:=0;
- count:=0;
- tmpvar:=vararraycreate([0,0],varbyte);
- //tmpvar[count]:=arr[i];
- //inc(count);
- //inc(i);
- while(count<=len-1)do begin
- tmpvar[count]:=arr[i];
- inc(count);
- inc(i);
- vararrayredim(tmpvar,count);
- end;
- MSComm1.Output:=tmpvar;
- timer3.Enabled:=true;
- end;
- //while mscomm1.InBufferCount
- end;
- end;
- procedure TForm1.Button11Click(Sender: TObject);
- var
- v,len,i,count:integer;
- tmpstr:string;
- tmpvar:variant;
- xornum:byte;
- arr:array of byte;
- f:real;
- begin
- arr:=nil;
- if (edit11.Text='') then
- begin
- showmessage('无设定值!');
- end
- else begin if not mscomm1.PortOpen then begin
- showmessage('串口没有打开!');
- end else begin
- //hao add
- if not TsInputVal(edit11.Text) then
- begin
- edit11.SetFocus;
- exit
- end;
- //hao add end
- setlength(arr,9);
- f:=strtofloat(edit11.text)*1000.0;
- tmpstr:=floattostr(f);
- v:=strtoint(tmpstr);
- arr[0]:=$7e; //soi
- arr[1]:=$10; //ver
- arr[2]:= $04; //length
- arr[3]:=$a1; //cid
- arr[4]:=$03; //datainfo
- arr[5]:=v div 256;
- arr[6]:= v mod 256 ;
- xornum:= arr[2] xor arr[3] xor arr[4] xor arr[5]xor arr[6];
- arr[7]:=xornum;
- arr[8]:=$0d;
- // send data
- len:=length(arr);
- i:=0;
- count:=0;
- tmpvar:=vararraycreate([0,0],varbyte);
- //tmpvar[count]:=arr[i];
- //inc(count);
- //inc(i);
- while(count<=len-1)do begin
- tmpvar[count]:=arr[i];
- inc(count);
- inc(i);
- vararrayredim(tmpvar,count);
- end;
- MSComm1.Output:=tmpvar;
- timer4.Enabled:=true;
- end;
- //while mscomm1.InBufferCount
- end;
- end;
- procedure TForm1.Button14Click(Sender: TObject);
- var
- v,len,i,count:integer;
- tmpstr:string;
- tmpvar:variant;
- xornum:byte;
- arr:array of byte;
- f:real;
- begin
- arr:=nil;
- if (edit14.Text='') then
- begin
- showmessage('无设定值!');
- end
- else begin if not mscomm1.PortOpen then begin
- showmessage('串口没有打开!');
- end else begin
- //hao add
- if not TsInputVal(edit14.Text) then
- begin
- edit14.SetFocus;
- exit
- end;
- //hao add end
- setlength(arr,9);
- f:=strtofloat(edit14.text)*1000.0;
- tmpstr:=floattostr(f);
- v:=strtoint(tmpstr);
- arr[0]:=$7e; //soi
- arr[1]:=$10; //ver
- arr[2]:= $04; //length
- arr[3]:=$a1; //cid
- arr[4]:=$04; //datainfo
- arr[5]:=v div 256;
- arr[6]:= v mod 256 ;
- xornum:= arr[2] xor arr[3] xor arr[4] xor arr[5]xor arr[6];
- arr[7]:=xornum;
- arr[8]:=$0d;
- // send data
- len:=length(arr);
- i:=0;
- count:=0;
- tmpvar:=vararraycreate([0,0],varbyte);
- //tmpvar[count]:=arr[i];
- //inc(count);
- //inc(i);
- while(count<=len-1)do begin
- tmpvar[count]:=arr[i];
- inc(count);
- inc(i);
- vararrayredim(tmpvar,count);
- end;
- MSComm1.Output:=tmpvar;
- timer5.Enabled:=true;
- end;
- //while mscomm1.InBufferCount
- end;
- end;
- procedure TForm1.Button17Click(Sender: TObject);
- var
- v,len,i,count:integer;
- tmpstr:string;
- tmpvar:variant;
- xornum:byte;
- arr:array of byte;
- f:real;
- begin
- arr:=nil;
- if (edit17.Text='') then
- begin
- showmessage('无设定值!');
- end
- else begin if not mscomm1.PortOpen then begin
- showmessage('串口没有打开!');
- end else begin
- //hao add
- if not TsInputVal(edit17.Text) then
- begin
- edit17.SetFocus;
- exit
- end;
- //hao add end
- setlength(arr,9);
- f:=strtofloat(edit17.text)*1000.0;
- tmpstr:=floattostr(f);
- v:=strtoint(tmpstr);
- arr[0]:=$7e; //soi
- arr[1]:=$10; //ver
- arr[2]:= $04; //length
- arr[3]:=$a1; //cid
- arr[4]:=$05; //datainfo
- arr[5]:=v div 256;
- arr[6]:= v mod 256 ;
- xornum:= arr[2] xor arr[3] xor arr[4] xor arr[5]xor arr[6];
- arr[7]:=xornum;
- arr[8]:=$0d;
- // send data
- len:=length(arr);
- i:=0;
- count:=0;
- tmpvar:=vararraycreate([0,0],varbyte);
- //tmpvar[count]:=arr[i];
- //inc(count);
- //inc(i);
- while(count<=len-1)do begin
- tmpvar[count]:=arr[i];
- inc(count);
- inc(i);
- vararrayredim(tmpvar,count);
- end;
- MSComm1.Output:=tmpvar;
- timer6.Enabled:=true;
- end;
- //while mscomm1.InBufferCount
- end;
- end;
- procedure TForm1.Timer2Timer(Sender: TObject);
- var
- i,n,m,chksum:integer; //,timesum
- arr:array of byte;
- tmpvar:variant;
- begin
- arr:=nil;
- chksum:=$00;
- timesum:=timesum+integer(timer2.Interval)+10;
- if timesum<900 then
- begin
- if mscomm1.InBufferCount>0 then begin
- timer2.Enabled:=false;
- timesum:=100;
- n:=mscomm1.InBufferCount;
- setlength(arr,n);
- tmpvar:=mscomm1.input;
- for i:=0 to n-1 do arr[i]:=tmpvar[i];
- if (arr[0]=$7e)and(arr[1]=$10)and(arr[n-1]=$0d) then
- begin
- for m:=2 to (n-3) do chksum:=chksum xor arr[m];
- if (arr[n-2]=chksum)and(arr[3]=$a1) then begin
- //edit4.Text:=inttostr(arr[4]*256+arr[5]);
- if arr[n-3]=$0cc then begin
- showmessage('设置成功!') ;
- //tag:=true;
- end
- else if arr[n-3]=$66 then begin //success:=true;
- timer2.Enabled:=false;
- showmessage('设置失败!');
- end else begin timer1.Enabled:=false;
- showmessage('数据包错误!');
- end;
- end else begin
- timer2.Enabled:=false;
- showmessage('数据错误!'); //帧校验错误
- end;
- end else begin
- timer2.Enabled:=false;
- showmessage('响应数据错误!');
- end;
- end else begin
- sleep(10);
- timer2.Enabled:=true;
- end;
- end else begin
- timesum:=100;
- timer2.Enabled:=false;
- showmessage('通道5参数设定响应超时!');
- end;
- end;
- procedure TForm1.Timer3Timer(Sender: TObject);
- var
- i,n,m,chksum:integer; //,timesum
- arr:array of byte;
- tmpvar:variant;
- begin
- timer3.Enabled:=false;
- arr:=nil;
- chksum:=$00;
- timesum:=timesum+integer(timer3.Interval)+10;
- if timesum<900 then
- begin
- if mscomm1.InBufferCount>0 then begin
- timer3.Enabled:=false;
- timesum:=100;
- n:=mscomm1.InBufferCount;
- setlength(arr,n);
- tmpvar:=mscomm1.input;
- for i:=0 to n-1 do arr[i]:=tmpvar[i];
- if (arr[0]=$7e)and(arr[1]=$10)and(arr[n-1]=$0d) then
- begin
- for m:=2 to (n-3) do chksum:=chksum xor arr[m];
English
