📄 unit1.pas
字号:
//----------------------------------------------------------------------------
//搽除绘图区所有曲线
dot := round(image2.left+202);
image2.Canvas.Pen.Color := clblack;
image2.Canvas.Pen.Width := image2.Height;
image2.Canvas.Pen.Style := pssolid;
image2.Canvas.MoveTo(image2.Left ,image2.Height);
image2.Canvas.LineTo(round(image2.width),image2.Height);
image2.Canvas.Brush.Color := clblack;
image2.Canvas.Pen.Color := clred;
image2.Canvas.Pen.Width := 1;
image2.Canvas.Pen.Style := pssolid;
image2.Canvas.FillRect(rect(0,0,round(image2.width),round(image2.height)));
//重绘坐标
x1 := round(image2.left+20);
y1 := round(image2.height-14);
image2.Canvas.MoveTo(x1,y1);
image2.Canvas.LineTo(round(image2.width),y1);
image2.Canvas.MoveTo(x1,y1);
image2.Canvas.LineTo(x1,round(image2.top));
//重写坐标值
image2.Canvas.Font.Color := clGreen;
image2.Canvas.Font.Size := 8;
image2.Canvas.TextOut(x1-20 ,y1-10 ,'000' );
image2.Canvas.TextOut(x1-20 ,y1-30 ,'100' );
image2.Canvas.TextOut(x1-20 ,y1-50 ,'200' );
image2.Canvas.TextOut(x1-20 ,y1-70 ,'300' );
image2.Canvas.TextOut(x1-20 ,y1-90 ,'400' );
image2.Canvas.TextOut(x1-20 ,y1-115 ,'500' );
//重定位
image2.Canvas.MoveTo(image2.left+20,image2.height-14);
//---------------------------------------------------------------------------
//重绘送丝速度坐标
//---------------------------------------------------------------------------
//搽除绘图区所有曲线
dot := round(image3.left+20);
image3.Canvas.Pen.Color := clblack;
image3.Canvas.Pen.Width := image3.Height;
image3.Canvas.Pen.Style := pssolid;
image3.Canvas.MoveTo(image3.Left ,image3.Height);
image3.Canvas.LineTo(round(image3.width),image3.Height);
image3.Canvas.Brush.Color := clblack;
image3.Canvas.Pen.Color := clred;
image3.Canvas.Pen.Width := 1;
image3.Canvas.Pen.Style := pssolid;
image3.Canvas.FillRect(rect(0,0,round(image2.width),round(image3.height)));
//重绘坐标
x1 := round(image3.left+20);
y1 := round(image3.height-14);
image3.Canvas.MoveTo(x1,y1);
image3.Canvas.LineTo(round(image3.width),y1);
image3.Canvas.MoveTo(x1,y1);
image3.Canvas.LineTo(x1,round(image3.top));
//重写坐标值
image3.Canvas.Font.Color := clGreen;
image3.Canvas.Font.Size := 8;
image3.Canvas.TextOut(x1-20 ,y1-10 ,'00' );
image3.Canvas.TextOut(x1-20 ,y1-30 ,'06' );
image3.Canvas.TextOut(x1-20 ,y1-50 ,'12' );
image3.Canvas.TextOut(x1-20 ,y1-70 ,'18' );
image3.Canvas.TextOut(x1-20 ,y1-90 ,'24' );
image3.Canvas.TextOut(x1-20 ,y1-110 ,'30' );
//重定位
image3.Canvas.MoveTo(image3.left+20,image3.height-14);
//----------------------------------------------------------------------------
//重绘堆积量坐标
//----------------------------------------------------------------------------
//搽除绘图区所有曲线
dot := round(image4.left+202);
image4.Canvas.Pen.Color := clblack;
image4.Canvas.Pen.Width := image4.Height;
image4.Canvas.Pen.Style := pssolid;
image4.Canvas.MoveTo(image4.Left ,image4.Height);
image4.Canvas.LineTo(round(image4.width),image4.Height);
image4.Canvas.Brush.Color := clblack;
image4.Canvas.Pen.Color := clred;
image4.Canvas.Pen.Width := 1;
image4.Canvas.Pen.Style := pssolid;
image4.Canvas.FillRect(rect(0,0,round(image4.width),round(image4.height)));
//重绘坐标
x1 := round(image4.left+20);
y1 := round(image4.height-14);
image4.Canvas.MoveTo(x1,y1);
image4.Canvas.LineTo(round(image4.width),y1);
image4.Canvas.MoveTo(x1,y1);
image4.Canvas.LineTo(x1,round(image4.top));
//重写坐标值
image4.Canvas.Font.Color := clGreen;
image4.Canvas.Font.Size := 8;
image4.Canvas.TextOut(x1-20 ,y1-10 ,'00' );
image4.Canvas.TextOut(x1-20 ,y1-25 ,'15' );
image4.Canvas.TextOut(x1-20 ,y1-40 ,'30' );
image4.Canvas.TextOut(x1-20 ,y1-55 ,'45' );
image4.Canvas.TextOut(x1-20 ,y1-70 ,'60' );
image4.Canvas.TextOut(x1-20 ,y1-85 ,'75' );
//重定位
image4.Canvas.MoveTo(image4.left+20,image4.height-14);
end;
end;
//=========================================================================
//程序启动要绘制的界面
//==========================================================================
procedure TMainForm.FormPaint(Sender: TObject);
var
x1,y1:integer;
begin
//---------------------------------------------------------------------------
//电压曲线
//---------------------------------------------------------------------------
image1.Canvas.Brush.Color := clblack;
image1.Canvas.Pen.Color := clred;
image1.Canvas.Pen.Width := 1;
image1.Canvas.Pen.Style := pssolid;
image1.Canvas.FillRect(rect(0,0,round(image1.width),round(image1.height)));
//绘坐标
x1 := round(image1.left+20);
y1 := round(image1.height-14);
image1.Canvas.MoveTo(x1,y1);
image1.Canvas.LineTo(round(image1.width),y1);
image1.Canvas.MoveTo(x1,y1);
image1.Canvas.LineTo(x1,round(image1.top));
//写坐标值
image1.Canvas.Font.Color := clGreen;
image1.Canvas.Font.Size := 8;
image1.Canvas.TextOut(x1-20 ,y1-10 ,'00' );
image1.Canvas.TextOut(x1-20 ,y1-30 ,'15' );
image1.Canvas.TextOut(x1-20 ,y1-50 ,'30' );
image1.Canvas.TextOut(x1-20 ,y1-70 ,'45' );
image1.Canvas.TextOut(x1-20 ,y1-90 ,'60' );
image1.Canvas.TextOut(x1-20 ,y1-110 ,'75' );
//----------------------------------------------------------------------------
//电流曲线
//----------------------------------------------------------------------------
image2.Canvas.Brush.Color := clblack;
image2.Canvas.Pen.Color := clred;
image2.Canvas.Pen.Width := 1;
image2.Canvas.Pen.Style := pssolid;
image2.Canvas.FillRect(rect(0,0,round(image2.width),round(image2.height)));
//绘坐标
x1 := round(image2.left+20);
y1 := round(image2.height-14);
image2.Canvas.MoveTo(x1,y1);
image2.Canvas.LineTo(round(image2.width),y1);
image2.Canvas.MoveTo(x1,y1);
image2.Canvas.LineTo(x1,round(image2.top));
//写坐标值
image2.Canvas.Font.Color := clGreen;
image2.Canvas.Font.Size := 8;
image2.Canvas.Font.Color := clGreen;
image2.Canvas.Font.Size := 8;
image2.Canvas.TextOut(x1-20 ,y1-10 ,'000' );
image2.Canvas.TextOut(x1-20 ,y1-30 ,'100' );
image2.Canvas.TextOut(x1-20 ,y1-50 ,'200' );
image2.Canvas.TextOut(x1-20 ,y1-70 ,'300' );
image2.Canvas.TextOut(x1-20 ,y1-90 ,'400' );
image2.Canvas.TextOut(x1-20 ,y1-110 ,'500' );
//----------------------------------------------------------------------------
//送丝速度曲线
//----------------------------------------------------------------------------
image3.Canvas.Brush.Color := clblack;
image3.Canvas.Pen.Color := clred;
image3.Canvas.Pen.Width := 1;
image3.Canvas.Pen.Style := pssolid;
image3.Canvas.FillRect(rect(0,0,round(image3.width),round(image3.height)));
//绘坐标
x1 := round(image3.left+20);
y1 := round(image3.height-14);
image3.Canvas.MoveTo(x1,y1);
image3.Canvas.LineTo(round(image3.width),y1);
image3.Canvas.MoveTo(x1,y1);
image3.Canvas.LineTo(x1,round(image3.top));
//写坐标值
image3.Canvas.Font.Color := clGreen;
image3.Canvas.Font.Size := 8;
image3.Canvas.TextOut(x1-20 ,y1-10 ,'00' );
image3.Canvas.TextOut(x1-20 ,y1-30 ,'03' );
image3.Canvas.TextOut(x1-20 ,y1-50 ,'06' );
image3.Canvas.TextOut(x1-20 ,y1-70 ,'09' );
image3.Canvas.TextOut(x1-20 ,y1-90 ,'12' );
image3.Canvas.TextOut(x1-20 ,y1-110 ,'15' );
//-----------------------------------------------------------------------------
//焊丝堆积量曲线
//-----------------------------------------------------------------------------
image4.Canvas.Brush.Color := clblack;
image4.Canvas.Pen.Color := clred;
image4.Canvas.Pen.Width := 1;
image4.Canvas.Pen.Style := pssolid;
image4.Canvas.FillRect(rect(0,0,round(image4.width),round(image4.height)));
//绘坐标
x1 := round(image4.left+20);
y1 := round(image4.height-14);
image4.Canvas.MoveTo(x1,y1);
image4.Canvas.LineTo(round(image4.width),y1);
image4.Canvas.MoveTo(x1,y1);
image4.Canvas.LineTo(x1,round(image4.top));
//写坐标值
image4.Canvas.Font.Color := clGreen;
image4.Canvas.Font.Size := 8;
image4.Canvas.TextOut(x1-20 ,y1-10 ,'00' );
image4.Canvas.TextOut(x1-20 ,y1-25 ,'15' );
image4.Canvas.TextOut(x1-20 ,y1-40 ,'30' );
image4.Canvas.TextOut(x1-20 ,y1-55 ,'45' );
image4.Canvas.TextOut(x1-20 ,y1-70 ,'60' );
image4.Canvas.TextOut(x1-20 ,y1-85 ,'75' );
//---------------------------------------------------------------------------
//把画笔移动到各个画布的原点
//---------------------------------------------------------------------------
image1.Canvas.MoveTo(image1.left+20,image1.height-14);
image2.Canvas.MoveTo(image2.left+20,image2.height-14);
image3.Canvas.MoveTo(image3.left+20,image3.height-14);
image4.Canvas.MoveTo(image4.left+20,image4.height-14);
end;
//=========================================================================
//发送检气命令
//=========================================================================
//==========================================================================
//发送送丝命令
//==========================================================================
procedure TMainForm.BitBtn1Click(Sender: TObject);
begin
if MSComm.PortOpen =true then
MSComm.Output:= 't';
end;
//==========================================================================
//电压设定,步进0.1V
//==========================================================================
procedure TMainForm.Button2Click(Sender: TObject);
begin
edit2.Text := floattostr(strtofloat(Edit2.Text)+0.1);
if MSComm.PortOpen =true then
MSComm.Output:= 'V';
if (strtofloat(Edit2.Text)>=49.3) then
edit2.Text :='49.3';
end;
procedure TMainForm.Button3Click(Sender: TObject);
begin
edit2.Text := floattostr(strtofloat(Edit2.Text)-0.1);
if MSComm.PortOpen =true then
MSComm.Output:= 'v';
if (strtofloat(Edit2.Text)<=11.9) then
edit2.Text :='11.9';
end;
procedure TMainForm.Button4Click(Sender: TObject);
begin
edit3.Text := floattostr(strtofloat(Edit3.Text)+1);
if MSComm.PortOpen =true then
MSComm.Output:= 'I';
if (strtofloat(Edit3.Text)>=516) then
edit3.Text :='516';
end;
procedure TMainForm.Button5Click(Sender: TObject);
begin
edit3.Text := floattostr(strtofloat(Edit3.Text)-1);
if MSComm.PortOpen =true then
MSComm.Output:= 'i';
if (strtofloat(Edit3.Text)<=32) then
edit3.Text :='32';
end;
procedure TMainForm.BitBtn5Click(Sender: TObject);
begin
if MSComm.PortOpen =true then
MSComm.Output:= 'r';
shptrans.Brush.Color := clWhite;
shpgas.Brush.Color := clWhite;
shpfilum.Brush.Color := clWhite;
shpabnormal.Brush.Color := clWhite;
edit2.Text := '24';
edit3.Text := '230' ;
end;
procedure TMainForm.BitBtn3MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if MSComm.PortOpen =true then
MSComm.Output:= 'g';
end;
procedure TMainForm.BitBtn3MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if MSComm.PortOpen =true then
MSComm.Output:= 'n';
end;
procedure TMainForm.BitBtn4MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if MSComm.PortOpen =true then
MSComm.Output:= 'p';
end;
procedure TMainForm.BitBtn4MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if MSComm.PortOpen =true then
MSComm.Output:= 'n';
end;
procedure TMainForm.BitBtn6Click(Sender: TObject);
begin
if MSComm.PortOpen =true then
MSComm.Output:= 'b';
end;
procedure TMainForm.BitBtn7Click(Sender: TObject);
begin
if MSComm.PortOpen =true then
MSComm.Output:= 'd';
shptrans.Brush.Color := clWhite;
shpgas.Brush.Color := clWhite;
shpfilum.Brush.Color := clWhite;
shpabnormal.Brush.Color := clWhite;
end;
procedure TMainForm.BitBtn8Click(Sender: TObject);
begin
if MSComm.PortOpen =true then
MSComm.Output:= 'w';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -