MainMachine _LeftProcess.cs
12.9 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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
using OnlineStore;
using CodeLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
partial class MainMachine
{
bool LeftShelfNoTray = false;
int LeftCount = 0;
public bool SafeReleaseLeftShelf = false;
void LeftProcess()
{
if (CheckWait(LeftMoveInfo))
return;
switch (LeftMoveInfo.MoveStep)
{
case MoveStep.L01:
LeftCount = 0;
LeftShelfNoTray = false;
LeftMoveInfo.NextMoveStep(MoveStep.L03);
CylinderMove(null, IO_Type.LeftStopDown, IO_Type.LeftStopUP);
LeftBatchAxisToP2(true);
LeftMoveInfo.log($"批量轴上升到P2位置,第一次提升,LeftStartMovePosition={LeftStartMovePosition}");
break;
case MoveStep.L02:
LeftMoveInfo.NextMoveStep(MoveStep.L03);
LeftBatchAxisToP2(false);
LeftMoveInfo.log($"批量轴上升到P2位置,二次提升,LeftStartMovePosition={LeftStartMovePosition}");
break;
case MoveStep.L03:
//if (IOValue(IO_Type.LeftOverHead_Check).Equals(IO_VALUE.HIGH))
//{
// LeftMoveInfo.NextMoveStep(MoveStep.L02);
// Left_Batch_Axis.AbsMove(LeftMoveInfo, LeftStartMovePosition, Config.Left_Batch_P2_speed);
// LeftMoveInfo.log($"批量轴上升过头,下降到:LeftStartMovePosition={LeftStartMovePosition}");
//}
//else
{
LeftMoveInfo.NextMoveStep(MoveStep.L04);
}
break;
case MoveStep.L04:
var currpos = Left_Batch_Axis.GetAclPosition();
if (currpos <= Config.Left_Batch_P1)
{
//LeftShelfNoTray = true;
LeftMoveInfo.NextMoveStep(MoveStep.L40_ShelfFull);
LeftMoveInfo.log($"批量轴已下降到底,料串已满,Left_Batch_P1={Config.Left_Batch_P1},needpos={currpos}");
}
else
{
LeftMoveInfo.NextMoveStep(MoveStep.L10_WaitReelPut);
//Left_Batch_Axis.AbsMove(LeftMoveInfo, currpos, Config.Left_Batch_P1_speed);
//LeftMoveInfo.log($"批量轴已下降一张料盘位置,等待料盘放入,needpos={currpos}");
}
break;
case MoveStep.L10_WaitReelPut:
Msg.add(crc.GetString("Res0095", "左侧空闲中"), MsgLevel.info);
break;
case MoveStep.L11_ReelPutted:
LeftCount++;
LeftMoveInfo.NextMoveStep(MoveStep.L12);
LeftBatchAxisToP1();
//LeftMoveInfo.log($"料盘已放入,批量轴上升,LeftStartMovePosition={LeftStartMovePosition}");
LeftMoveInfo.log($"左侧料盘已放入,批量轴下降");
break;
case MoveStep.L12:
//if (IOValue(IO_Type.LeftOverHead_Check).Equals(IO_VALUE.HIGH))
//{
// LeftMoveInfo.NextMoveStep(MoveStep.L11_ReelPutted);
// Left_Batch_Axis.AbsMove(LeftMoveInfo, LeftStartMovePosition, Config.Left_Batch_P2_speed);
// LeftMoveInfo.log($"批量轴上升过头,下降到:LeftStartMovePosition={LeftStartMovePosition}");
//}
//else
{
LabelMoveInfo.MoveParam = LeftMoveInfo.MoveParam.clone();
LeftMoveInfo.NextMoveStep(MoveStep.L20_WaitLabel);
LeftMoveInfo.log($"批量轴完成上升,等待贴标");
}
break;
case MoveStep.L20_WaitLabel:
break;
case MoveStep.L30_LabelFinish:
if (SafeReleaseLeftShelf)
{
//LeftShelfNoTray = true;
SafeReleaseLeftShelf = false;
LeftMoveInfo.NextMoveStep(MoveStep.L40_ShelfFull);
LeftMoveInfo.log($"用户请求释放料架");
}
else
{
LeftMoveInfo.NextMoveStep(MoveStep.L04);
LeftBatchAxisToP2(false);
LeftMoveInfo.log($"贴标完成,准备下一盘料,批量轴上升到P2位置,二次提升,LeftStartMovePosition={LeftStartMovePosition}");
}
break;
case MoveStep.L40_ShelfFull:
LeftShelfNoTray = true;
LeftMoveInfo.NextMoveStep(MoveStep.LEND);
Left_Batch_Axis.AbsMove(LeftMoveInfo, Config.Left_Batch_P1, Config.Left_Batch_P1_speed);
LeftMoveInfo.log($"料串已满,批量轴下降到P1位置");
break;
case MoveStep.LEND:
LeftMoveInfo.EndMove();
LeftMoveInfo.log($"结束运动");
break;
//}
//料串出料流程
//switch (LeftMoveInfo.MoveStep)
//{
case MoveStep.L50_OutShelf:
LeftMoveInfo.NextMoveStep(MoveStep.L51);
Left_Batch_Axis.AbsMove(LeftMoveInfo, Config.Left_Batch_P1, Config.Left_Batch_P1_speed);
LeftMoveInfo.log($"批量轴下降到P1位置");
break;
case MoveStep.L51:
LeftMoveInfo.NextMoveStep(MoveStep.L52);
CylinderMove(null, IO_Type.LeftStopUP, IO_Type.LeftStopDown);
LeftMoveInfo.log($"阻挡下降");
break;
case MoveStep.L52:
LeftMoveInfo.NextMoveStep(MoveStep.L53);
IOMove(IO_Type.LeftMoto_Run, IO_VALUE.LOW);
IOMove(IO_Type.LeftMoto_Reverse, IO_VALUE.HIGH);
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftEnd_Check, IO_VALUE.LOW));
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
LeftMoveInfo.log($"电滚筒向外滚动");
break;
case MoveStep.L53:
LeftMoveInfo.NextMoveStep(MoveStep.L54);
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftFornt_Check, IO_VALUE.LOW));
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
LeftMoveInfo.OneWaitCanEndStep = true;
LeftMoveInfo.log($"等待前置检测拉低");
break;
case MoveStep.L54:
LeftMoveInfo.NextMoveStep(MoveStep.L55);
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
break;
case MoveStep.L55:
LeftMoveInfo.NextMoveStep(MoveStep.REND);
IOMove(IO_Type.LeftMoto_Reverse, IO_VALUE.HIGH, false, 500);
LeftMoveInfo.log($"电滚停止");
break;
//}
//料串入料流程
//switch (LeftMoveInfo.MoveStep)
//{
case MoveStep.L60_InShelf:
LeftMoveInfo.NextMoveStep(MoveStep.L61);
Left_Batch_Axis.AbsMove(LeftMoveInfo, Config.Left_Batch_P1, Config.Left_Batch_P1_speed);
LeftMoveInfo.log($"批量轴下降到P1位置");
break;
case MoveStep.L61:
LeftMoveInfo.NextMoveStep(MoveStep.L62);
CylinderMove(null, IO_Type.LeftStopUP, IO_Type.LeftStopDown);
LeftMoveInfo.log($"阻挡下降");
break;
case MoveStep.L62:
LeftMoveInfo.NextMoveStep(MoveStep.L63);
IOMove(IO_Type.LeftMoto_Reverse, IO_VALUE.LOW);
IOMove(IO_Type.LeftMoto_Run, IO_VALUE.HIGH);
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftEnd_Check, IO_VALUE.HIGH));
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(60000));
LeftMoveInfo.TimeOutSeconds = 60;
LeftMoveInfo.OneWaitCanEndStep = true;
LeftMoveInfo.log($"等待料串到位");
break;
case MoveStep.L63:
LeftMoveInfo.NextMoveStep(MoveStep.L64);
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
break;
case MoveStep.L64:
LeftMoveInfo.NextMoveStep(MoveStep.L65);
IOMove(IO_Type.LeftMoto_Run, IO_VALUE.HIGH, false, 500);
CylinderMove(null, IO_Type.LeftStopDown, IO_Type.LeftStopUP);
LeftMoveInfo.log($"电滚筒停止,阻挡上升");
break;
case MoveStep.L65:
if (IOValue(IO_Type.LeftEnd_Check).Equals(IO_VALUE.HIGH))
{
LeftMoveInfo.NewMove(MoveStep.L01);
LeftMoveInfo.log($"料串进入开始上料");
}
else
{
LeftMoveInfo.NextMoveStep(MoveStep.LEND);
LeftMoveInfo.log($"料串进入失败");
}
break;
default:
LeftMoveInfo.log($"未找到对应步骤:{LeftMoveInfo.MoveStep}");
break;
}
}
string LeftState()
{
string state = "";
if (IOValue(IO_Type.LeftEnd_Check).Equals(IO_VALUE.HIGH))
{
state += string.Format(crc.GetString("Res0069", "有料串,已放置{0}张料盘"), LeftCount);
if (LeftShelfNoTray)
state += "," + crc.GetString("Res0043", "料串已满");
else
state += ".";
state += crc.GetString("Res0045", "当前ReelID:") + LeftMoveInfo.MoveParam.WareCode;
}
else
{
return crc.GetString("Res0046", "无料串");
}
return state;
}
int LeftStartMovePosition = 0;
void LeftBatchAxisToP2(bool isFirstMove = true)
{
int targetP2 = Config.Left_Batch_P2;
int targetSpeed = Config.Left_Batch_P2_speed;
if (!isFirstMove)
{
int currPosition = Left_Batch_Axis.GetAclPosition();
if (currPosition != -1)
{
//targetP2 = currPosition + Config.Left_Batch_ChangeValue * 80;
if (targetP2 > Config.Left_Batch_P2)
{
targetP2 = Config.Left_Batch_P2;
}
LeftMoveInfo.log("BatchAxisToP2 目标P2: " + targetP2 + "(" + currPosition + ")");
}
targetSpeed = Config.Left_Batch_P2_speed / 10;
}
LeftMoveInfo.TimeOutSeconds = 200;
LeftMoveInfo.CanWhileCount = 0;
// 需要增加定时器,获取验证信号并停止伺服
LeftStartMovePosition = Left_Batch_Axis.GetAclPosition();
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxisMove(Config.Left_Batch_Axis, targetP2, targetSpeed));
Config.Left_Batch_Axis.TargetPosition = targetP2;
Left_Batch_Axis.AbsMove(null, targetP2, targetSpeed);
//开始检测信号
Left_Batch_Axis.BatchAxisStartCheck(IO_Type.LeftTop_Check, IO_VALUE.HIGH);
}
/// <summary>
/// 左批量轴下降到X23对射信号灭
/// </summary>
void LeftBatchAxisToP1()
{
int targetP1 = Config.Left_Batch_P1;
int targetSpeed = Config.Left_Batch_P2_speed / 10;
LeftMoveInfo.TimeOutSeconds = 200;
LeftMoveInfo.CanWhileCount = 0;
// 需要增加定时器,获取验证信号并停止伺服
LeftStartMovePosition = Left_Batch_Axis.GetAclPosition();
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxisMove(Config.Left_Batch_Axis, targetP1, targetSpeed));
Config.Left_Batch_Axis.TargetPosition = targetP1;
Left_Batch_Axis.AbsMove(null, targetP1, targetSpeed);
//开始检测信号
Left_Batch_Axis.BatchAxisStartCheck(IO_Type.LeftTop_Check, IO_VALUE.LOW);
}
}
}