FrmOrgConfig.cs
5.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
using log4net;
using URSoldering.Common;
using URSoldering.DeviceLibrary;
using System;
using System.Reflection;
using System.Windows.Forms;
using System.Threading.Tasks;
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();
}
isAuto = false;
timer1.Interval = 1000;
timer1.AutoReset = true;
timer1.Elapsed += timer_Elapsed;
timer1.Start();
}
private bool isRun = false;
private void timer_Elapsed(object sender, EventArgs e)
{
if (!URRobotControl.IsRun && isRun.Equals(false))
{
isRun = true;
Task.Factory.StartNew(delegate ()
{
bool result = URRobotControl.StartRobot();
});
}
else
{
URPointValue lastP = URRobotControl.GetLastPosition();
urRobotSControl1.ShowPoint(lastP);
}
lblMsg.Text = URRobotControl.GetStatus();
}
private void FrmBoardInfo_FormClosing(object sender, FormClosingEventArgs e)
{
URRobotControl.LockAxis();
timer1.Stop();
}
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 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;
//}
if (!URRobotControl.IsValidZ(point.Z))
{
MessageBox.Show("保存失败,焊点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(3);
this.Visible = false;
frmOrgConfig.ShowDialog();
this.Visible = true;
}
private void btnSetMark_Click(object sender, EventArgs e)
{
URPointValue point = GetCurrRobotPoint();
DialogResult result = ShowConfire(point, "坐标偏移Mark点");
if (result.Equals(DialogResult.Yes))
{
WeldRobotBean.UpdateMarkPoint(point);
MessageBox.Show("保存清洗点2成功!");
}
}
}
}