📄 unityarnls.pas.bak
字号:
hh1:=hh2+str;
tt:=length(hh1);
hh2:='';
LS:=false;
if tt<16 then exit;
if tt>16 then begin
hh2:=copy(hh1,17,tt-16);
LS:=true;
end;
end
else begin
hh1:=hh1+str;
tt:=length(hh1);
if tt<16 then exit;
if tt>16 then begin
hh2:=copy(hh1,17,tt-16);
LS:=true;
end
else LS:=false;
end;
ss:=hh1[1]+hh1[2];
if ss='PE'then begin
a:=ord(hh1[5]);
b:=ord(hh1[6]);
c:=ord(hh1[7]);
xx:=a*256+b+c*0.01;
end
else begin
a:=ord(hh1[5]);
b:=ord(hh1[6]);
c:=ord(hh1[7]);
yy:=a*256+b+c*0.01;
end;
ss:=hh1[9]+hh1[10];
if ss='PE'then begin
a:=ord(hh1[13]);
b:=ord(hh1[14]);
c:=ord(hh1[15]);
xx:=a*256+b+c*0.01;
end
else begin
a:=ord(hh1[13]);
b:=ord(hh1[14]);
c:=ord(hh1[15]);
yy:=a*256+b+c*0.01;
end;
series1.AddXY(xx,yy);
label1.Caption:=floattostr(yy);
label13.Caption:=floattostr(xx);
//memo1.Lines.Add(floatTostr(xx));
//memo1.Lines.Add(floatTostr(yy));
hh1:='';
df.x:=xx;
df.y:=yy ;
write(f,df);
ee[j]:=xx;
ff[j]:=yy;
j:=j+1;
exit;
end;
procedure TFormYarnLS.BitBtn3Click(Sender: TObject);
var
ss:string;
begin
if comport1.Connected then
begin
comport1.Close;
Bitbtn2.Enabled:=false;
Bitbtn4.Enabled:=false;
Bitbtn5.Enabled:=false;
BitbtnLs.Enabled:=false;
end
else
begin
comport1.Open;
Bitbtn2.Enabled:=true;
Bitbtn4.Enabled:=true;
Bitbtn5.Enabled:=true;
BitbtnLs.Enabled:=true;
comport1.WriteStr('QF');
sleep(180);
comport1.ReadStr(ss,2);
if ss<>'QS' then
showmessage('请求没有成功,请检查下位机是否开启')
else
showmessage('已经实现与下位机的通信,试验可以开始')
end;
end;
procedure TFormYarnLS.ComPort1AfterClose(Sender: TObject);
begin
BitBtn3.Caption:='打开通讯口';
end;
procedure TFormYarnLS.ComPort1AfterOpen(Sender: TObject);
begin
BitBtn3.Caption:='关闭通讯口';
end;
procedure TFormYarnLS.BitBtn1Click(Sender: TObject);
begin
OKRightDlg.ShowModal;
end;
procedure TFormYarnLS.BitBtnLsClick(Sender: TObject);
var
Ayear,Amonth,Aday,Ahour,Aminute,Asecond,Amilisecond:word;
begin
j:=0;
decodedatetime(now, Ayear,Amonth,Aday,Ahour,Aminute,Asecond,Amilisecond);
sj:=inttostr(Amonth)+inttostr(Aday)+inttostr(Ahour)+
inttostr(Aminute)+inttostr(Asecond)+'.dat';
DataMDYarn.ADOTableTestpre2.Insert;
DataMDYarn.ADOTableTestpre2['data']:=sj;
assignfile(f,sj);
rewrite(f);
comport1.WriteStr('ks');
end;
procedure TFormYarnLS.BitBtn2Click(Sender: TObject);
var
sj,sd,gj,ss:string;
begin
Label17.Caption:=edit3.Text;
// 数据写入数据库
DataMDYarn.ADOTablePreSetting.Insert;
DataMDYarn.ADOTablePreSetting['SampleName']:=ComboBox2.Text;
DataMDYarn.ADOTablePreSetting['Optioner']:=ComboBox3.Text;
DataMDYarn.ADOTablePreSetting['TestDate']:=date;
DataMDYarn.ADOTablePreSetting['Testtime']:=timetostr(time);
DataMDYarn.ADOTablePreSetting['Tp']:=strtoint(edit4.Text);
DataMDYarn.ADOTablePreSetting['Rh']:=strtoint(edit5.Text);
DataMDYarn.ADOTablePreSetting['Tnum']:=strtoint(edit3.Text);
DataMDYarn.ADOTablePreSetting['Att']:=edit1.Text;
DataMDYarn.ADOTablePreSetting['Gauge']:=strtofloat(edit11.Text);
DataMDYarn.ADOTablePreSetting['Preforce']:=strtofloat(edit7.Text);
DataMDYarn.ADOTablePreSetting['Espeed']:=strtofloat(edit2.Text);
DataMDYarn.ADOTablePreSetting['Tex']:=strtofloat(edit10.Text);
DataMDYarn.ADOTablePreSetting.Post;
//DataMDYarn.ADOTablePreSetting.Refresh;
//有部分参数得传到下位机,日期,隔距,速度等
//sj:=datetimetostr(date); 'sj'+sj+'#'+
// sd:=edit2.Text;
//gj:=edit11.Text;
// ss:='sd'+sd+'#'+'gj'+gj+'#';
// comport1.WriteStr(ss);
//要是收到对方试验完成则进行计算数据转存进行计算
end;
procedure TFormYarnLS.FormShow(Sender: TObject);
begin
while not DataMDYarn.ADOTableFSIndex.Eof do
begin
ComboBox2.Items.Add(DataMDYarn.ADOTableFSIndex['SampleName']);
DataMDYarn.ADOTableFSIndex.Next;
end;
ComboBox2.ItemIndex:=0;
while not DataMDYarn.ADOTableFopindex.Eof do
begin
ComboBox3.Items.Add(DataMDYarn.ADOTableFopindex['Foptioner']);
DataMDYarn.ADOTableFopindex.Next;
ComboBox3.ItemIndex:=0;
end;
end;
procedure TFormYarnLS.ComboBox2Exit(Sender: TObject);
begin
if not DataMDYarn.ADOTableFSIndex.Locate('SampleName',ComboBox2.Text,[]) then
if ComboBox2.Text<>'' then
begin
DataMDYarn.ADOTableFSIndex.Insert;
DataMDYarn.ADOTableFSIndex['SampleName']:=ComboBox2.Text;
DataMDYarn.ADOTableFSIndex.Post;
ComboBox2.Items.Add(ComboBox2.Text);
end;
end;
procedure TFormYarnLS.ComboBox3Exit(Sender: TObject);
begin
if not DataMDYarn.ADOTableFopindex.Locate('Foptioner',ComboBox3.Text,[]) then
if ComboBox3.Text<>'' then
//showmessage('数据库里已经有这个名字了,不必添加')
// else
begin
DataMDYarn.ADOTableFopindex.Insert;
DataMDYarn.ADOTableFopindex['Foptioner']:=ComboBox3.Text;
DataMDYarn.ADOTableFopindex.Post;
ComboBox3.Items.Add(ComboBox3.Text);
end;
end;
procedure TFormYarnLS.BitBtn4Click(Sender: TObject);
begin
comport1.WriteStr('yy');
end;
procedure TFormYarnLS.BitBtn5Click(Sender: TObject);
begin
Label1.Caption:='0.0';
Label13.Caption:='0.0';
end;
procedure TFormYarnLS.Button1Click(Sender: TObject);
begin
FormyarnLSlook.Show;
end;
procedure TFormYarnLS.FormDeactivate(Sender: TObject);
begin
//DataMDYarn.ADOConnection1.Close;
end;
procedure TFormYarnLS.FormActivate(Sender: TObject);
begin
//DataMDYarn.ADOConnection1.Open;
end;
procedure TFormYarnLS.N2Click(Sender: TObject);
begin
DataBack.Show;
end;
procedure TFormYarnLS.N4Click(Sender: TObject);
var
X:LongInt;
begin
if printer.Printers.Count=0 then
begin
if messagedlg('没能找到打印机,是否安装打印机',mtconfirmation,[mbyes,mbno],0)=mryes then
begin
//调用打印机添加向导
X:=winexec('rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter',9);
printdialog1.Execute;
end
else
exit
end
else
PrintDialog1.Execute;
end;
procedure TFormYarnLS.N6Click(Sender: TObject);
begin
close;
end;
procedure TFormYarnLS.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
if messagebox(Application.Handle,'您将关闭程序,是否继续?','提示',MB_YESNO+MB_ICONQUESTION)=ID_NO then
Canclose:=false;
end;
procedure TFormYarnLS.N13Click(Sender: TObject);
begin
AboutBox.Show;
end;
procedure TFormYarnLS.N15Click(Sender: TObject);
begin
SetActiveLanguage('English.ini');
end;
procedure TFormYarnLS.N16Click(Sender: TObject);
begin
SetActiveLanguage('Chinese GB.ini');
{Label1.Caption :='0.0';
Label2.Caption :='样品名称:';
Label3.Caption :='检测者:';
label4.caption :='拉伸速度(mm/min):';
label5.caption :='试验次数:';
label6.caption :='温度 ℃';
label7.caption :='相对湿度(%)';
label8.caption :='备注:';
label12.caption :='预加张力(cN):';
label13.caption :='0.0 ';
label14.caption :='强力值 cN ';
label15.caption :='伸长值 mm';
label16.caption :='剩余次数:';
label17.caption :='0 ';
label21.caption :='纤维细度(tex):';
label22.caption :='隔距长度(mm):';
Button1.Caption :='数据浏览';
BitBtn1.Caption :='定伸长点设置';
//Button1.Hint :=按钮1_提示';
BitBtn2.Caption :='发送试验参数';
BitBtn3.Caption :='打开通讯口';
BitBtn4.Caption :='纱架右移';
BitBtn5.Caption :='力值复零';
BitBtnls.Caption:='开始拉伸试验';
groupbox1.Caption:='参数设置';
N1.Caption :='文件';
N2.Caption :='纤维数据库备份及恢复';
N4.Caption :='打印机设置';
N6.Caption :='退出试验';
N7.Caption :='数据浏览';
N8.Caption :='数据浏览';
N9.Caption :='数据库维护';
N10.Caption :='定伸长点设置';
N11.Caption :='数据库维护';
N12.Caption :='关于';
N13.Caption :='版本及作者信息';
N14.Caption :='语言';
N15.Caption :='英语';
N16.Caption :='简体中文'; }
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -