FrmBatchMove.cs
7.7 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 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 System.Runtime.CompilerServices;
using System.Threading;
using System.IO;
using System.Runtime.InteropServices;
using OnlineStore.DeviceLibrary;
using log4net;
using System.Reflection;
using UserFromControl;
using OnlineStore.LoadCSVLibrary;
using OnlineStore.Common;
namespace OnlineStore.XLRStore
{
internal partial class FrmBatchMove : FrmBase
{
private bool IsLoad = false;
private BatchMoveBean moveBean;
internal FrmBatchMove(BatchMoveBean moveEquip)
{
this.moveBean = moveEquip;
Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
}
private bool IsInCheck = false;
private void timer1_Tick(object sender, EventArgs e)
{
try
{
if (!this.Visible)
{
return;
}
lblWarnMsg.Text = moveBean.WarnMsg;
lblCurrInfo.Text = moveBean.GetMoveStr();
}
catch (Exception ex)
{
LogUtil.error(moveBean.Name + "界面定时器出错:", ex);
}
}
private void FrmTest_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
if (this.timer1.Enabled)
{
this.timer1.Enabled = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace, "Exception(异常)", MessageBoxButtons.OK, MessageBoxIcon.Error);
LogUtil.error("", ex);
}
}
private void FrmStoreIOStatus_Load(object sender, EventArgs e)
{
axisMoveControl1.LoadData(StoreManager.XLRStore.inputEquip, new AxisBean[] { moveBean.BatchAxis });
lblName.Text = moveBean.Name;
batchAxisP1.SetMoveData(moveBean.BatchAxis, StoreManager.XLRStore.inputEquip.Config.BatchAxis_P1Speed, moveBean.BatchAxisP1);
batchAxisP2.SetMoveData(moveBean.BatchAxis, StoreManager.XLRStore.inputEquip.Config.BatchAxis_P2Speed, moveBean.BatchAxisP2 );
IsLoad = true;
}
private void FrmIOStatus_Shown(object sender, EventArgs e)
{
timer1.Start();
}
private void btnStart_Click(object sender, EventArgs e)
{
moveBean.Reset();
LogUtil.info(moveBean.Name + "点击:" + btnStart.Text);
}
private void btnSave_Click(object sender, EventArgs e)
{
int p1 = batchAxisP1.PointValue;
int p2 = batchAxisP2.PointValue;
moveBean.BatchAxisP1 = p1;
moveBean.BatchAxisP2 = p2;
if (moveBean.EquipType.Equals(1))
{
StoreManager.XLRStore.inputEquip.Config.BatchAxisP1_A = p1;
StoreManager.XLRStore.inputEquip.Config.BatchAxisP2_A = p2;
}
else
{
StoreManager.XLRStore.inputEquip.Config.BatchAxisP1_B = p1;
StoreManager.XLRStore.inputEquip.Config.BatchAxisP2_B = p2;
}
StoreManager.SaveInputEquipConfig(StoreManager.XLRStore.inputEquip.Config);
MessageBox.Show("保存成功");
}
private int TargetP2;
private bool StartTest = false;
private void btnStartTest_Click(object sender, EventArgs e)
{
ConfigMoveAxis moveAxis = moveBean.BatchAxis.Config;
bool isServoOn = AxisManager.instance.IsServeoOn(moveAxis.DeviceName, moveAxis.GetAxisValue());
if (!isServoOn)
{
MessageBox.Show(moveAxis.Explain + " 未打开,请先打开伺服 ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
bool isStop = AxisManager.instance.GetBusyStatus(moveAxis.DeviceName, moveAxis.GetAxisValue()).Equals(0);
if (isServoOn && isStop)
{
//判断提升轴是否停止且到位
TargetP2 = moveBean.BatchAxisP2;
LogUtil.info(moveBean.Name + "点击:" + btnStartTest.Text + ",目标位置:" + moveBean.BatchAxisP2);
moveBean.BatchAxisToP2(true, false, true);
lblTestMsg.Text = "开始入料运动,目标位置[" + TargetP2 + "] ,开始位置[" + moveBean.StartMovePosition + "],";
StartTest = true;
}
else
{
MessageBox.Show(moveAxis.Explain + " 忙碌中,无法开始运动 ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
private void btnTestStop_Click(object sender, EventArgs e)
{
LogUtil.info(moveBean.Name + "点击:" + btnTestStop.Text);
moveBean.BatchAxis.AxisStopCheckMove();
moveBean.BatchAxis.SuddenStop();
}
private void BatchTimerPro()
{
if (moveBean.BatchAxis.IsBatchMove())
{
btnStartTest.Enabled = false;
if (moveBean.LastMoveIsTest)
{
ConfigMoveAxis moveAxis = moveBean.BatchAxis.Config;
bool countError = false;
bool isStop = false;
bool result = AxisManager.instance.AbsMoveIsEnd(moveAxis.DeviceName, moveAxis.GetAxisValue(), TargetP2, moveAxis.CanErrorCountMax, out countError);
if (result)
{
isStop = true;
LogUtil.info(moveBean.Name + "提升轴上料功能测试,发现提升轴已到达目标位置【" + TargetP2 + "】,停止上料测试 ");
}
else
{
bool axisMoveIsEnd = HuichuanLibrary.HCBoardManager.MoveIsEnd(moveBean.BatchAxis.Config.GetAxisValue());
if (axisMoveIsEnd)
{
isStop = true;
LogUtil.info(moveBean.Name + "提升轴上料功能测试,发现提升轴已停止运动,停止上料测试");
}
}
if (isStop)
{
StartTest = false;
moveBean.BatchAxis.AxisStopCheckMove();
btnStartTest.Enabled = true;
btnTestStop.Enabled = false;
int height = moveBean.GetHeight();
lblTestMsg.Text = "目标位置[" + TargetP2 + "] ,开始位置[" + moveBean.StartMovePosition + "],停止位置[" + moveBean.EndMovePosition + "],高度[" + height + "]mm";
}
else
{
btnTestStop.Enabled = true;
}
}
else
{
btnTestStop.Enabled = false;
}
}
else
{
if (StartTest)
{
StartTest = false;
int height = moveBean.GetHeight();
lblTestMsg.Text = "目标位置[" + TargetP2 + "] ,开始位置[" + moveBean.StartMovePosition + "],停止位置[" + moveBean.EndMovePosition + "],高度[" + height + "]mm";
}
btnStartTest.Enabled = true;
btnTestStop.Enabled = false;
}
}
}
}