FrmOrgConfig.cs
6.5 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
using log4net;
using URSoldering.Common;
using URSoldering.DeviceLibrary;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using URSoldering.Common.util;
using System.IO;
using System.Drawing.Drawing2D;
using URSoldering.LoadCSVLibrary;
using System.Threading.Tasks;
using System.Timers;
using HalconDotNet;
namespace URSoldering.Client
{
public partial class FrmOrgConfig : FrmBase
{
private bool isAuto = false;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public FrmOrgConfig( )
{
InitializeComponent();
}
private System.Timers.Timer timer1 = new System.Timers.Timer();
private void FrmBoardInfo_Load(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
//此界面打开时,不能打开自动焊接
if (WeldRobotBean.ISRun)
{
LogUtil.error("进入焊接界面,发现WeldRobotBean自动运行中,关闭自动运行");
WeldRobotBean.StopRun();
}
if (URRobotControl.IsRun)
{
URRobotControl.FreeAxis();
URPointValue lastP = URRobotControl.GetLastPosition();
urRobotSControl1.ShowPoint(lastP);
}
else
{
}
isAuto = false;
timer1.Interval = 1000;
timer1.AutoReset = true;
timer1.Elapsed += timer_Elapsed;
timer1.Start();
timer2.Start();
}
private bool isRun = false;
private void timer_Elapsed(object sender, EventArgs e)
{
//if (!URRobotControl.IsRun && isRun.Equals(false))
//{
// Task.Factory.StartNew(delegate ()
// {
// bool result = URRobotControl.StartRobot();
// if (!result)
// {
// LogUtil.info("连接失败:" + result);
// }
// else
// {
// URRobotControl.FreeAxis();
// isAuto = false;
// }
// });
// isRun = true;
//}
//else
//{
// URPointValue lastP = URRobotControl.GetLastPosition();
// urRobotSControl1.ShowPoint(lastP);
//}
}
private void FrmBoardInfo_FormClosing(object sender, FormClosingEventArgs e)
{
URRobotControl.LockAxis();
timer2.Stop();
timer1.Stop();
UsbCameraHDevelop.CloseAllCamera();
}
private void btnRead_Click(object sender, EventArgs e)
{
URPointValue lastP = URRobotControl.GetLastPosition();
}
private void timer2_Tick(object sender, EventArgs e)
{
if (URRobotControl.IsRun)
{
}
}
protected override void OnVisibleChanged(EventArgs e)
{
base.OnVisibleChanged(e);
if (this.IsDisposed)
{
this.Close();
}
}
private void btnSetOrigin_Click(object sender, EventArgs e)
{
URPointValue point = GetCurrRobotPoint();
ConfigAppSettings.SaveValue(Setting_Init.BOARD_ORIGIN_X, point.X.ToString());
ConfigAppSettings.SaveValue(Setting_Init.BOARD_ORIGIN_Y, point.Y.ToString());
}
private void btnGoHome_Click(object sender, EventArgs e)
{
if (isAuto == false)
{
MessageBox.Show("请先切换到自动模式!");
return;
}
//RobotBean.KNDIOMove(IO_Type.SendWire_Down, IO_VALUE.LOW);
//RobotBean.KNDIOMove(IO_Type.SendWire_Up, IO_VALUE.HIGH);
URPointValue point = WeldRobotBean.HomePoint;
URRobotControl.MoveTo(point);
}
private void btnSaveHome_Click(object sender, EventArgs e)
{
URPointValue point = GetCurrRobotPoint();
DialogResult result = ShowConfire(point, "原点");
if (result.Equals(DialogResult.Yes))
{
WeldRobotBean.UpdateOrgPoint(point);
MessageBox.Show("保存原点成功!");
}
}
private URPointValue GetCurrRobotPoint()
{
return urRobotSControl1.GetPoint();
}
private void btnSetClear1_Click(object sender, EventArgs e)
{
URPointValue point = GetCurrRobotPoint();
DialogResult result = ShowConfire(point, "清洗点1");
if (result.Equals(DialogResult.Yes))
{
WeldRobotBean.UpdateClear1Point(point);
MessageBox.Show("保存清洗点1成功!");
}
}
private DialogResult ShowConfire(URPointValue point, string strMsg)
{
//判断原点的Z轴
if (point.Z > URRobotControl.Robot_LIM_Z)
{
MessageBox.Show("保存失败,"+ strMsg + "的Z坐标(" + point.Z + ")不能高于最高Z点(" + URRobotControl.Robot_LIM_Z + ")");
return DialogResult.Cancel;
}
DialogResult result = MessageBox.Show("是否将当前位置:" + point.ToShowStr() + "保存为" + strMsg + "?", "提示", MessageBoxButtons.YesNo);
return result;
}
private void btnSetClear2_Click(object sender, EventArgs e)
{
URPointValue point = GetCurrRobotPoint();
DialogResult result = ShowConfire(point, "清洗点2");
if (result.Equals(DialogResult.Yes))
{
WeldRobotBean.UpdateClear2Point(point);
MessageBox.Show("保存清洗点2成功!");
}
}
private void btnBack_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnMore_Click(object sender, EventArgs e)
{
FrmPwd frmOrgConfig = new FrmPwd();
this.Visible = false;
frmOrgConfig.ShowDialog();
this.Visible = true;
}
}
}