FrmPointInfo.cs
12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using URSoldering.DeviceLibrary;
using URSoldering.Common;
namespace URSoldering.Client
{
public partial class FrmPointInfo : FrmBase
{
public delegate void OpClose(DialogResult result,WeldPointInfo point);
public event OpClose OnCloseEnd;
public WeldPointInfo weldPointInfo = new WeldPointInfo();
public FrmPointInfo()
{
InitializeComponent();
this.Text = "新增焊点";
cmbPointType.SelectedIndex = 0;
groupPoint.Text = "新增焊点";
}
public FrmPointInfo(string name,URPointValue point)
{
InitializeComponent();
this.Text = "新增焊点";
groupPoint.Text = "新增焊点";
this.txtName.Text = name;
cmbPointType.SelectedIndex = 0;
ShowPoint(point);
this.txtClearTime.Text = WeldRobotBean.RobotConfig.ClearMSenconds.ToString();
}
public FrmPointInfo(WeldPointInfo weldPointInfo)
{
InitializeComponent();
if (weldPointInfo == null)
{
return;
}
this.Text = "修改焊点【" + weldPointInfo.pointName + "】";
groupPoint.Text = "修改焊点【" + weldPointInfo.pointName + "】";
this.weldPointInfo = weldPointInfo;
this.txtDpreheatTemperature.Text = weldPointInfo.preheatTemperature.ToString();
this.txtDpreheatTime.Text = weldPointInfo.preheatTime.ToString();
this.txtDsendWireSpeed.Text = weldPointInfo.sendWireSpeed.ToString();
this.txtDsendWireTime.Text = weldPointInfo.sendWireTime.ToString();
this.txtDweldTemMax.Text = weldPointInfo.weldTemperatureMax.ToString();
this.txtDweldTemMin.Text = weldPointInfo.weldTemperatureMin.ToString();
this.txtDweldTemperature.Text = weldPointInfo.weldTemperature.ToString();
this.txtDweldTime.Text = weldPointInfo.weldTime.ToString();
this.txtPreTempMax.Text = weldPointInfo.preheatTemperatureMax.ToString();
this.txtPreTempMin.Text = weldPointInfo.preheatTemperatureMin.ToString();
this.txtStartDsendWireSpeed.Text = weldPointInfo.startSendWireSpeed.ToString();
this.txtStartDsendWireTime.Text = weldPointInfo.startSendWireTime.ToString();
this.txtName.Text = weldPointInfo.pointName;
this.cmbPointType.SelectedIndex = weldPointInfo.pointType;
this.chbClear.Checked = weldPointInfo.isNeedClear;
this.txtClearTime.Text = WeldRobotBean.RobotConfig.ClearMSenconds.ToString();
if (weldPointInfo.isNeedClear && weldPointInfo.ClearTime > 0)
{
this.txtClearTime.Text = weldPointInfo.ClearTime.ToString();
}
ShowPoint(weldPointInfo.GetURPoint());
}
private void btnSave_Click(object sender, EventArgs e)
{
saveInfo();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
OnCloseEnd?.Invoke(DialogResult,null);
}
private void saveInfo()
{
int ptemp = FormUtil.GetIntValue(txtDpreheatTemperature);
int ptempmax = FormUtil.GetIntValue( txtPreTempMax);
int ptempmin = FormUtil.GetIntValue(txtPreTempMin);
int wTemp = FormUtil.GetIntValue(txtDweldTemperature);
int wTempMax = FormUtil.GetIntValue(txtDweldTemMax);
int wTempMin = FormUtil.GetIntValue(txtDweldTemMin );
double sendSpeed = FormUtil.getDoubleValue(txtDsendWireSpeed);
double sendtime = FormUtil.getDoubleValue(this.txtDsendWireTime);
double startsendSpeed = FormUtil.getDoubleValue(txtStartDsendWireSpeed);
double startsendTime = FormUtil.getDoubleValue(txtStartDsendWireTime);
string name = FormUtil.getValue(txtName);
int clearTime = FormUtil.GetIntValue(txtClearTime);
double pTime = FormUtil.getDoubleValue(txtDpreheatTime);
double wTime = FormUtil.getDoubleValue(txtDweldTime);
if (name.Equals(""))
{
MessageBox.Show("请输入焊点名称!");
txtName.Focus();
return;
}
if (cmbPointType.SelectedIndex < 0)
{
MessageBox.Show("请选择焊点类型!");
cmbPointType.Focus();
return;
}
int pointType = cmbPointType.SelectedIndex;
if (pointType.Equals(0))
{
if (ptemp > 400)
{
MessageBox.Show("预热温度范围:200°-400°");
txtDpreheatTemperature.Focus();
return;
}
if (ptempmin < 0)
{
MessageBox.Show("预热温度下限必须大于0°");
txtDweldTemMin.Focus();
return;
}
if (wTemp > 400)
{
MessageBox.Show("焊接温度范围:200°-400°");
txtDweldTemperature.Focus();
return;
}
if (wTempMin < 0)
{
MessageBox.Show("焊接温度下限必须大于0°");
txtPreTempMin.Focus();
return;
}
if (ptempmax < ptempmin)
{
MessageBox.Show("预设温度上限必须大于预设温度下限");
this.txtPreTempMax.Focus();
return;
}
if (wTempMax < wTempMin)
{
MessageBox.Show("焊接温度上限必须大于焊接温度下限");
this.txtDweldTemMax.Focus();
return;
}
if (!(ptempmin <= ptemp && ptemp <= ptempmax))
{
MessageBox.Show("预设温度范围在:" + ptempmin + "°-" + ptempmax + "°");
this.txtDpreheatTemperature.Focus();
return;
}
if (!(wTempMin <= wTemp && wTemp <= wTempMax))
{
MessageBox.Show("焊接温度范围在:" + wTempMin + "°-" + wTempMax + "°");
this.txtDweldTemperature.Focus();
return;
}
if (pTime < 0 || pTime > 60)
{
MessageBox.Show("预热时间范围:0-60!");
txtDpreheatTime.Focus();
return;
}
if (pTime < 0 || pTime > 60)
{
MessageBox.Show("焊接时间范围:0-60!");
txtDweldTime.Focus();
return;
}
if (startsendSpeed < 0)
{
MessageBox.Show("请正确输入起始送丝速度!");
txtStartDsendWireSpeed.Focus();
return;
}
if (startsendTime < 0)
{
MessageBox.Show("起始送丝时间范围:0-60");
txtStartDsendWireTime.Focus();
return;
}
if (sendSpeed < 0)
{
MessageBox.Show("请正确输入送丝速度!");
txtDsendWireSpeed.Focus();
return;
}
if (sendtime < 0 || sendtime > 60)
{
MessageBox.Show("送丝时间范围:0-60 ");
txtDsendWireSpeed.Focus();
return;
}
if (chbClear.Checked)
{
if (clearTime <= 0)
{
MessageBox.Show("请输入清洗时间!");
txtClearTime.Focus();
return;
}
}
}
weldPointInfo.preheatTemperature = ptemp;
weldPointInfo.preheatTime = pTime;
weldPointInfo.sendWireSpeed = sendSpeed;
weldPointInfo.sendWireTime = sendtime;
weldPointInfo.weldTemperatureMax = wTempMax;
weldPointInfo.weldTemperatureMin = wTempMin;
weldPointInfo.weldTemperature = wTemp;
weldPointInfo.weldTime = wTime;
weldPointInfo.preheatTemperatureMax = ptempmax;
weldPointInfo.preheatTemperatureMin = ptempmin;
weldPointInfo.startSendWireSpeed = startsendSpeed;
weldPointInfo.startSendWireTime = startsendTime;
weldPointInfo.pointName = name;
weldPointInfo.isNeedClear = chbClear.Checked;
weldPointInfo.ClearTime = clearTime;
weldPointInfo.pointType = cmbPointType.SelectedIndex;
URPointValue p = urRobot.GetPoint();
weldPointInfo.RobotX = p.X;
weldPointInfo.RobotY = p.Y;
weldPointInfo.RobotZ = p.Z;
weldPointInfo.RobotRX = p.RX;
weldPointInfo.RobotRY = p.RY;
weldPointInfo.RobotRZ = p.RZ;
this.DialogResult = DialogResult.OK;
closeForm();
}
private void closeForm()
{
this.Close();
OnCloseEnd?.Invoke(DialogResult,this.weldPointInfo);
}
private void FrmWeldPointInfo_Load(object sender, EventArgs e)
{
}
private void btnUpdate_Click(object sender, EventArgs e)
{
URPointValue point = URRobotControl.GetLastPosition();
//判断原点的Z轴
//if (point.Z > URRobotControl.Robot_LIM_Z)
//{
// MessageBox.Show("保存失败,焊点Z坐标(" + point.Z + ")不能高于最高Z点(" + URRobotControl.Robot_LIM_Z + ")");
// return;
//}
if (!URRobotControl.IsValidZ(point.Z))
{
MessageBox.Show("保存失败,焊点Z坐标(" + point.Z + ")不能低于最低Z点(" + URRobotControl.Robot_LIM_Z + ")");
return;
}
DialogResult result = MessageBox.Show("当前坐标:" +point.ToShowStr()+ ",是否确定更新?", "提示", MessageBoxButtons.YesNo);
if (result.Equals(DialogResult.Yes))
{
ShowPoint(point);
}
}
private void ShowPoint(URPointValue point)
{
urRobot.ShowPoint(point);
}
private void chbClear_CheckedChanged(object sender, EventArgs e)
{
if (chbClear.Checked)
{
txtClearTime.Enabled = true;
}
else
{
txtClearTime.Enabled = false;
}
}
private void cmbPointType_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbPointType.SelectedIndex.Equals(0))
{
lblMsg .Text= "普通焊点,机械臂先抬起再移动至焊点";
gbIron.Enabled = true ;
gbWireFeeding.Enabled = true ;
}
else if (cmbPointType.SelectedIndex.Equals(1))
{
lblMsg.Text = "两个焊点之间的位置跳转点";
gbIron.Enabled = false;
gbWireFeeding.Enabled = false;
}else if (cmbPointType.SelectedIndex.Equals(2))
{
lblMsg.Text = "拖焊焊点,机械臂不抬起直接移动至焊点";
gbIron.Enabled = true;
gbWireFeeding.Enabled = true;
}else if (cmbPointType.SelectedIndex.Equals(3))
{
lblMsg.Text = "拍照点,用于坐标检测偏移";
gbIron.Enabled = false;
gbWireFeeding.Enabled = false;
}
}
}
}