FrmSetting.cs
6.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
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 FrmSetting : FrmBase
{
public FrmSetting()
{
InitializeComponent();
}
private void btnSaveSetting_Click(object sender, EventArgs e)
{
saveValue();
}
private void getValue()
{
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);
minControl.ShowPoint(WeldRobotBean.RobotMin);
maxControl.ShowPoint(WeldRobotBean.RobotMax);
clear2Control.ShowPoint(WeldRobotBean.Clear2Point);
clear1Control.ShowPoint(WeldRobotBean.Clear1Point);
homeControl.ShowPoint(WeldRobotBean.HomePoint);
}
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;
}
URPointValue homeP = homeControl.GetPoint();
//判断原点的Z轴
if (homeP.Z < limz)
{
MessageBox.Show("待机点Z坐标不能低于最低Z点!");
homeControl.Focus();
return;
}
URPointValue clear1P = clear1Control.GetPoint();
//判断原点的Z轴
if (clear1P.Z < limz)
{
MessageBox.Show("清洗点1的Z坐标不能低于最低Z点!");
clear1Control.Focus();
return;
}
URPointValue clear2P = clear2Control.GetPoint();
//判断原点的Z轴
if (clear2P.Z < limz)
{
MessageBox.Show("清洗点2的Z坐标不能低于最低Z点!");
clear2Control.Focus();
return;
}
URPointValue minP = minControl.GetPoint();
URPointValue maxP = maxControl.GetPoint();
//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(homeP);
WeldRobotBean.UpdateClear1Point(clear1P);
WeldRobotBean.UpdateClear2Point(clear2P);
ConfigAppSettings.SaveValue(Setting_Init.Soldering_LIM_Z, limz.ToString());
URRobotControl.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.RobotMin = minP;
WeldRobotBean.RobotMax = maxP;
ConfigAppSettings.SaveValue(Setting_Init.Soldering_RobotMin, minP.ToJosonStr());
ConfigAppSettings.SaveValue(Setting_Init.Soldering_RobotMax, maxP.ToJosonStr());
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();
}
}
}