FrmSolderingSetting.cs
10.3 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
using URSoldering.Common;
using URSoldering.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace URSoldering.Client
{
public partial class FrmSolderingSetting : FrmBase
{
public FrmSolderingSetting()
{
InitializeComponent();
}
private void btnSaveSetting_Click(object sender, EventArgs e)
{
saveValue();
}
private void getValue()
{
int index = -1;
foreach (BoardInfo obj in BoardManager.boardList)
{
index++;
if (obj.boardId.Equals(BoardManager.CurrBoardId))
{
break;
}
}
if (index >= 0)
{
cmbBoardList.SelectedIndex = index;
}
this.txtOriginX.Text = ConfigAppSettings.GetValue(Setting_Init.BOARD_ORIGIN_X);
this.txtOriginY.Text = ConfigAppSettings.GetValue(Setting_Init.BOARD_ORIGIN_Y);
int ch = WeldRobotBean.SendWireXiShu;
//this.txtSpeed.Text = (double)ConfigAppSettings.GetIntValue(Setting_Init.ShuoKe_EndSpeed) / ch + "";
this.cmbOrgHand.SelectedIndex = WeldRobotBean.EpsonOrgHandDir;
txtOrgX.Text = WeldRobotBean.EpsonOrgX.ToString();
txtOrgY.Text = WeldRobotBean.EpsonOrgY.ToString();
txtOrgU.Text = WeldRobotBean.EpsonOrgU.ToString();
txtOrgZ.Text = WeldRobotBean.EpsonOrgZ.ToString();
txtLimZ.Text = ((double)ConfigAppSettings.GetNumValue(Setting_Init.Soldering_LIM_Z)).ToString();
txtsendWireSpeed.Text = ConfigAppSettings.GetValue(Setting_Init.ReverseSendWireSpeed);
txtsendWireTime.Text = ConfigAppSettings.GetValue(Setting_Init.ReverseSendWireTime);
txtClearU1.Text=WeldRobotBean.EpsonClearU1.ToString();
txtClearX1.Text=WeldRobotBean.EpsonClearX1.ToString();
txtClearY1.Text = WeldRobotBean.EpsonClearY1.ToString();
txtClearZ1.Text = WeldRobotBean.EpsonClearZ1.ToString();
this.cmbClearHand1.SelectedIndex = WeldRobotBean.EpsonClearHandDir1;
txtClearU2.Text = WeldRobotBean.EpsonClearU2.ToString();
txtClearX2.Text = WeldRobotBean.EpsonClearX2.ToString();
txtClearY2.Text = WeldRobotBean.EpsonClearY2.ToString();
txtClearZ2.Text = WeldRobotBean.EpsonClearZ2.ToString();
this.cmbClearHand2.SelectedIndex = WeldRobotBean.EpsonClearHandDir2;
txtXMin.Text = WeldRobotBean.EpsonXMin.ToString();
txtYMin.Text = WeldRobotBean.EpsonYMin.ToString();
txtZMin.Text = WeldRobotBean.EpsonZMin.ToString();
txtUMin.Text = WeldRobotBean.EpsonUMin.ToString();
txtXMax.Text = WeldRobotBean.EpsonXMax.ToString();
txtYMax.Text = WeldRobotBean.EpsonYMax.ToString();
txtZMax.Text = WeldRobotBean.EpsonZMax.ToString();
txtUMax.Text = WeldRobotBean.EpsonUMax.ToString();
}
private void saveValue()
{
try
{
int boardId = ((BoardInfo)cmbBoardList.SelectedItem).boardId;
BoardManager.UpdateCurrBoard(boardId);
int limz = FormUtil.GetIntValue(txtLimZ);
List<string> port = new List<string>(SerialPort.GetPortNames());
if (limz > 0)
{
MessageBox.Show("请输入正确的机器人最大Z点(<=0)");
this.txtLimZ.Focus();
txtLimZ.SelectAll();
return;
}
int sendWireSpeed = FormUtil.GetIntValue(txtsendWireSpeed);
if (sendWireSpeed >= 0)
{
MessageBox.Show("请输入正确的反转送丝速度!");
txtsendWireSpeed.Focus();
return;
}
int sendWireTime = FormUtil.GetIntValue(txtsendWireTime);
if (sendWireTime <= 0)
{
MessageBox.Show("请输入正确的反转送丝时间!");
txtsendWireTime.Focus();
return;
}
int hand = cmbOrgHand.SelectedIndex;
double orgx=FormUtil.getDoubleValue(txtOrgX) ;
double orgy = FormUtil.getDoubleValue(txtOrgY);
double orgu = FormUtil.getDoubleValue(txtOrgU);
double orgz = FormUtil.getDoubleValue(txtOrgZ);
//判断原点的Z轴
if (orgz > limz)
{
MessageBox.Show("待机点Z坐标不能高于最高Z点!");
txtOrgZ.Focus();
txtOrgZ.SelectAll();
return;
}
int clearHand1 = this.cmbClearHand1.SelectedIndex;
double clearx1 = FormUtil.getDoubleValue(txtClearX1);
double cleary1 = FormUtil.getDoubleValue(txtClearY1);
double clearu1 = FormUtil.getDoubleValue(txtClearU1);
double clearz1 = FormUtil.getDoubleValue(txtClearZ1);
//判断原点的Z轴
if (clearz1 > limz)
{
MessageBox.Show("清洗点1的Z坐标不能高于最高Z点!");
txtClearZ1.Focus();
txtClearZ1.SelectAll();
return;
}
int clearHand2 = this.cmbClearHand2.SelectedIndex;
double clearx2 = FormUtil.getDoubleValue(txtClearX2);
double cleary2 = FormUtil.getDoubleValue(txtClearY2);
double clearu2 = FormUtil.getDoubleValue(txtClearU2);
double clearz2 = FormUtil.getDoubleValue(txtClearZ2);
//判断原点的Z轴
if (clearz2 > limz)
{
MessageBox.Show("清洗点2的Z坐标不能高于最高Z点!");
txtClearZ2.Focus();
txtClearZ2.SelectAll();
return;
}
double XMin = FormUtil.getDoubleValue(txtXMin);
double YMin = FormUtil.getDoubleValue(txtYMin);
double ZMin = FormUtil.getDoubleValue(txtZMin);
double UMin = FormUtil.getDoubleValue(txtUMin);
double XMax = FormUtil.getDoubleValue(txtXMax);
double YMax = FormUtil.getDoubleValue(txtYMax);
double ZMax = FormUtil.getDoubleValue(txtZMax);
double UMax = FormUtil.getDoubleValue(txtUMax);
if (XMin > XMax)
{
MessageBox.Show("请正确输入机械臂X轴范围!");
txtXMin.Focus();
txtXMin.SelectAll();
return;
}
if (YMin > YMax)
{
MessageBox.Show("请正确输入机械臂Y轴范围!");
txtYMin.Focus();
txtYMin.SelectAll();
return;
}
if (ZMin > ZMax)
{
MessageBox.Show("请正确输入机械臂Z轴范围!");
txtZMin.Focus();
txtZMin.SelectAll();
return;
}
if (UMin > UMax)
{
MessageBox.Show("请正确输入机械臂U轴范围!");
txtUMin.Focus();
txtUMin.SelectAll();
return;
}
WeldRobotBean.UpdateOrgPoint(orgx, orgy, orgu, orgz, hand);
WeldRobotBean.UpdateClear1Point(clearx1, cleary1, clearu1, clearz1, clearHand1);
WeldRobotBean.UpdateClear2Point(clearx2, cleary2, clearu2, clearz2, clearHand2);
ConfigAppSettings.SaveValue(Setting_Init.Soldering_LIM_Z, limz.ToString());
EpsonDevice.Robot_LIM_Z = limz;
ConfigAppSettings.SaveValue(Setting_Init.Default_BoardID, boardId);
BoardManager.UpdateCurrBoard(boardId);
ConfigAppSettings.SaveValue(Setting_Init.ReverseSendWireSpeed, sendWireSpeed);
ConfigAppSettings.SaveValue(Setting_Init.ReverseSendWireTime, sendWireTime);
WeldRobotBean.EpsonXMin = XMin;
WeldRobotBean.EpsonXMax = XMax;
WeldRobotBean.EpsonYMin = YMin;
WeldRobotBean.EpsonYMax = YMax;
WeldRobotBean.EpsonUMin = UMin;
WeldRobotBean.EpsonUMax = UMax;
WeldRobotBean.EpsonZMin = ZMin;
WeldRobotBean.EpsonZMax = ZMax;
ConfigAppSettings.SaveValue(Setting_Init.Soldering_X_Min, XMin.ToString());
ConfigAppSettings.SaveValue(Setting_Init.Soldering_Y_Min, YMin.ToString());
ConfigAppSettings.SaveValue(Setting_Init.Soldering_Z_Min, ZMin.ToString());
ConfigAppSettings.SaveValue(Setting_Init.Soldering_U_Min, UMin.ToString());
ConfigAppSettings.SaveValue(Setting_Init.Soldering_X_Max, XMax.ToString());
ConfigAppSettings.SaveValue(Setting_Init.Soldering_Y_Max, YMax.ToString());
ConfigAppSettings.SaveValue(Setting_Init.Soldering_Z_Max, ZMax.ToString());
ConfigAppSettings.SaveValue(Setting_Init.Soldering_U_Max, UMax.ToString());
MessageBox.Show("保存成功,需要重启之后才能生效!");
this.Close();
}
catch
{
MessageBox.Show("保存失败!");
}
}
private void FrmRobotSetting_Load(object sender, EventArgs e)
{
LoadCom();
getValue();
}
private void LoadCom()
{
cmbBoardList.DataSource = null;
cmbBoardList.DataSource = BoardManager.boardList;
cmbBoardList.DisplayMember = "boardName";
cmbBoardList.ValueMember = "boardId";
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}