PackageLine_S2Station.cs
19.0 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static OnlineStore.DeviceLibrary.HttpServer;
namespace OnlineStore.DeviceLibrary
{
partial class PackageLine
{
string PkgShelfRFID = "";
string BigShelfRFID = "";
string TempBigRfid = "";
PackageRobotTaskBean packgeRobotTaskBean;
//public StepInfo<S2_STATION_STEP> s2StationStep = new StepInfo<S2_STATION_STEP>(S2_STATION_STEP.NONE);
/// <summary>
/// 包装料架工位
/// </summary>
public enum S2_STATION_STEP
{
NONE,
/// <summary>
/// 等待料架
/// </summary>
WAIT_SHELF,
/// <summary>
/// 等待料架进入S2工位
/// </summary>
WAIT_SHELF_TO_S2,
/// <summary>
/// 等待读取RFID
/// </summary>
READ_RFID,
/// <summary>
/// 放行料架
/// </summary>
OUT_SHELF,
/// <summary>
/// 等待料架离开
/// </summary>
WAIT_OUT_S2,
/// <summary>
/// 等待顶升上升
/// </summary>
WAIT_STATION_UP,
/// <summary>
/// 等待顶升上升
/// </summary>
WAIT_STATION_DOWN,
/// <summary>
/// 等待机器人抓取
/// </summary>
WAIT_ROBOT,
ROBOT_GET,
WAIT_ROBOT_GET_OK,
WAIT_ROBOT_PUT_FINISH,
WAIT_ROBOT_PUT_OK,
}
/// <summary>
/// 双层线大料工位
/// </summary>
//private void ProcessS2Station()
//{
// ProcessShelfOutS2();
// if (s2StationStep.IsStep(S2_STATION_STEP.NONE))
// {
// bool hasShelf = IOValue(IO_Type.S2_StopCheck2).Equals(IO_VALUE.HIGH);
// if (hasShelf)
// {
// s2StationStep.Msg ="工位2检测到料架,等待读取RFID";
// s2StationStep.ToNextStep(S2_STATION_STEP.READ_RFID);
// } else
// {
// s2StationStep.Msg ="工位2无料架,等待料架进入";
// s2StationStep.ToNextStep(S2_STATION_STEP.WAIT_SHELF);
// }
// }
// else if (s2StationStep.IsStep(S2_STATION_STEP.WAIT_SHELF)) {
// bool hasWaitShelf = IOValue(IO_Type.S2_StopCheck1).Equals(IO_VALUE.HIGH);
// //有等待的料架
// if (hasWaitShelf)
// {
// //验证料架是否可用
// if (LineManager.Line.S2CanGetShelf)
// {
// s2StationStep.Msg = "工位2等待位发现料架,降下S2_StopCylinder1(2秒),打开工位2链条, 将其送入工位";
// s2StationStep.ToNextStep(S2_STATION_STEP.WAIT_SHELF_TO_S2);
// s2StationStep.AddIoWait(IO_Type.S2_StopCheck1, IO_VALUE.LOW);
// s2StationStep.AddIoWait(IO_Type.S2_StopCheck2, IO_VALUE.HIGH);
// IOMove(IO_Type.S2_LineRun, IO_VALUE.HIGH);
// IOMove(IO_Type.S2_StopCylinder1, IO_VALUE.HIGH, 2000);
// }
// else
// {
// s2StationStep.Msg = "工位2等待位发现料架, 但工位一未使用完";
// }
// }
// }
// else if (s2StationStep.IsStep(S2_STATION_STEP.WAIT_SHELF_TO_S2)) {
// if (s2StationStep.IsFinished())
// {
// s2StationStep.Msg ="料架到达工位2, 停止工位2链条, 开始读取RFID";
// IOMove(IO_Type.S2_LineRun, IO_VALUE.LOW);
// s2StationStep.ToNextStep(S2_STATION_STEP.READ_RFID);
// }
// else
// {
// KeepLineRun(IO_Type.S2_LineRun);
// }
// }
// else if (s2StationStep.IsStep(S2_STATION_STEP.READ_RFID))
// {
// if (s2StationStep.IsTimeOut(1000))
// {
// string rfid = RFIDManager.ReadRFID(Config.S2_Rfid, true).NumStr();
// if (rfid.Contains("C"))
// {
// ResultBean resultBean = HttpServer.GetPackInfo(rfid, PkgShelfRFID);
// //发送指令到服务器
// if (resultBean != null)
// {
// if (resultBean.code == 0)
// {
// PackageRobotTaskBean shelfTaskBean = resultBean.data;
// if (shelfTaskBean.emptyInBig > 0)
// {
// s2StationStep.Msg = "料架[" + rfid + "]剩余包装料空位数位[" + shelfTaskBean.emptyInBig + "]工位2顶升";
// //还有包装料要放,升起顶升
// BigShelfRFID = rfid;
// s2StationStep.ToNextStep(S2_STATION_STEP.WAIT_STATION_UP);
// s2StationStep.AddIoWait(IO_Type.S2_TopCylinderUp, IO_VALUE.HIGH);
// s2StationStep.AddIoWait(IO_Type.S2_TopCylinderDown, IO_VALUE.LOW);
// CylinderMove(null, IO_Type.S2_TopCylinderDown, IO_Type.S2_TopCylinderUp);
// }
// else
// {
// s2StationStep.Msg = "工位2料架[" + rfid + "]已无空位,放行";
// s2StationStep.ToNextStep(S2_STATION_STEP.OUT_SHELF);
// }
// }
// else
// {
// s2StationStep.Msg = "工位2料架[" + rfid + "] 未从服务器获取到有效信息[" + resultBean.msg + "],放行大料架";
// s2StationStep.ToNextStep(S2_STATION_STEP.OUT_SHELF);
// }
// }
// }
// else if (rfid.Contains("D"))
// {
// s2StationStep.Msg = "工位2料架[" + rfid + "]不是大料架,直接放行";
// //不是大料架直接放行
// s2StationStep.ToNextStep(S2_STATION_STEP.OUT_SHELF);
// }
// else
// {
// s2StationStep.Msg = "工位2料架RFID读取错误["+rfid+"],重新读取";
// s2StationStep.ToNextStep(S2_STATION_STEP.READ_RFID);
// }
// }
// }
// else if (s2StationStep.IsStep(S2_STATION_STEP.OUT_SHELF))
// {
// TempBigRfid = "";
// BigShelfRFID = "";
// s2StationStep.Msg ="工位2顶升下降";
// s2StationStep.ToNextStep(S2_STATION_STEP.WAIT_STATION_DOWN);
// s2StationStep.AddIoWait(IO_Type.S2_TopCylinderUp, IO_VALUE.LOW);
// s2StationStep.AddIoWait(IO_Type.S2_TopCylinderDown, IO_VALUE.HIGH);
// CylinderMove(null, IO_Type.S2_TopCylinderUp, IO_Type.S2_TopCylinderDown);
// }
// else if (s2StationStep.IsStep(S2_STATION_STEP.WAIT_STATION_DOWN)) {
// if (s2StationStep.IsFinished())
// {
// s2StationStep.Msg ="工位2顶升下降完成,打开右侧下方线体, 开始放行料架";
// s2StationStep.ToNextStep(S2_STATION_STEP.WAIT_OUT_S2);
// s2StationStep.AddIoWait(IO_Type.S2_StopCheck2, IO_VALUE.LOW, 2000);
// s2StationStep.AddTimeWait(12000);
// KeepLineRun(IO_Type.S2_LineRun);
// //阻挡2下降2秒
// IOMove(IO_Type.S2_StopCylinder2, IO_VALUE.HIGH, 2000);
// //打开右侧下方线体
// KeepLineRun(IO_Type.R_LineRun);
// }
// }
// else if (s2StationStep.IsStep(S2_STATION_STEP.WAIT_OUT_S2)) {
// if (s2StationStep.IsFinished())
// {
// if (outShelfStep.IsStep(SHELF_TO_LEAVE_STATION.WAIT_OUT_IO))
// {
// //上一个料架流出未完成
// s2StationStep.Msg = "料架流出工位2完成,但上一个料架未到出口";
// }
// else
// {
// s2StationStep.Msg = "工位2放行料架完成,停止工位2线体";
// s2StationStep.ToNextStep(S2_STATION_STEP.NONE);
// IOMove(IO_Type.S2_LineRun, IO_VALUE.LOW);
// //右侧下方线体是否停止,要根据情况来
// outShelfStep.ToNextStep(SHELF_TO_LEAVE_STATION.SHELF_OUT_S2);
// }
// }
// else
// {
// KeepLineRun(IO_Type.R_LineRun);
// if (s2StationStep.IsTimeOut(15000))
// {
// s2StationStep.Msg = "工位2放行料架15秒仍未完成,重新放行";
// s2StationStep.ToNextStep(S2_STATION_STEP.OUT_SHELF);
// }
// }
// }
// else if (s2StationStep.IsStep(S2_STATION_STEP.WAIT_STATION_UP))
// {
// if (s2StationStep.IsFinished())
// {
// //顶升已经升起,等待机器人处理
// s2StationStep.ToNextStep(S2_STATION_STEP.WAIT_ROBOT);
// }
// }
// else if (s2StationStep.IsStep(S2_STATION_STEP.WAIT_ROBOT))
// {
// packgeRobotTaskBean = null;
// string currentPkgShelfRfid = "";
// if (pkgStationStep.IsStep(PKG_STATION_STEP.WAIT_ROBOT))
// {
// currentPkgShelfRfid = PkgShelfRFID;
// }
// //发送指令到服务器
// ResultBean resultBean = HttpServer.GetPackInfo(BigShelfRFID, currentPkgShelfRfid);
// if (resultBean != null)
// {
// if(resultBean.code == 0)
// {
// PackageRobotTaskBean shelfTaskBean = resultBean.data;
// if (pkgStationStep.IsStep(PKG_STATION_STEP.WAIT_ROBOT))
// {
// if (shelfTaskBean.reelInPackage <= 0)
// {
// s2StationStep.Msg = "包装料架[" + PkgShelfRFID + "]上已无料盘,放行";
// pkgStationStep.ToNextStep(PKG_STATION_STEP.SHELF_EMPTY);
// }
// }
// if (shelfTaskBean.emptyInBig <= 0)
// {
// s2StationStep.Msg = "工位2料架[" + BigShelfRFID + "]已无空位,放行";
// s2StationStep.ToNextStep(S2_STATION_STEP.OUT_SHELF);
// }
// else
// {
// if (TempBigRfid.Equals("") || TempBigRfid.Equals(shelfTaskBean.bigRfid) || BigShelfRFID.Equals(shelfTaskBean.realBigRfid))
// {
// //未绑定过或与绑定的虚拟料架一致
// if (pkgStationStep.IsStep(PKG_STATION_STEP.WAIT_ROBOT) && s2StationStep.IsStep(S2_STATION_STEP.WAIT_ROBOT))
// {
// if (TempBigRfid.Equals(""))
// {
// TempBigRfid = shelfTaskBean.bigRfid;
// }
// packgeRobotTaskBean = shelfTaskBean;
// s2StationStep.ToNextStep(S2_STATION_STEP.ROBOT_GET);
// s2StationStep.Msg = "机器人准备抓取包装料架[" + PkgShelfRFID + "]库位[" + shelfTaskBean.packageLoc + "]上的料盘[" + shelfTaskBean.barcode + "]";
// }
// }
// else
// {
// s2StationStep.Msg = "工位2料架" + BigShelfRFID + "[" + TempBigRfid + "]与服务器给定" + shelfTaskBean.bigRfid + "[" + shelfTaskBean.realBigRfid + "]不一致,放行大料架";
// s2StationStep.ToNextStep(S2_STATION_STEP.OUT_SHELF);
// }
// }
// }
// else
// {
// s2StationStep.Msg = "工位2料架" + BigShelfRFID + "[" + TempBigRfid + "】 未从服务器获取到有效信息["+resultBean.msg+"],放行大料架";
// s2StationStep.ToNextStep(S2_STATION_STEP.OUT_SHELF);
// }
// }
// }
// else if (s2StationStep.IsStep(S2_STATION_STEP.ROBOT_GET))
// {
// bool robotCanMove = IOValue(IO_Type.Pkg_Rotot_Forbidden_Check).Equals(IO_VALUE.LOW);
// if (robotCanMove)
// {
// s2StationStep.ToNextStep(S2_STATION_STEP.WAIT_ROBOT_GET_OK);
// s2StationStep.Msg ="机器人开始抓取包装料架[" + PkgShelfRFID + "]库位[" + packgeRobotTaskBean.packageLoc + "]上的料盘[" + packgeRobotTaskBean.barcode + "]";
// ABBControl.SendCmd(Config.ABB3_IP, ABBControl.Cmd_moveget, "p" + packgeRobotTaskBean.packageLoc, "L", ABBControl.DefaultSpeed);
// }else
// {
// s2StationStep.Msg = "包装线体机器人禁止区域有料架,暂停抓取";
// s2StationStep.ToNextStep(S2_STATION_STEP.ROBOT_GET);
// }
// }
// else if (s2StationStep.IsStep(S2_STATION_STEP.WAIT_ROBOT_GET_OK))
// {
// string getResult = ABBControl.GetAbbCmd(Config.ABB3_IP);
// if (getResult.Equals(""))
// {
// //如果包装料架已经空了,放行
// if (packgeRobotTaskBean.reelInPackage == 1)
// {
// s2StationStep.Msg ="包装料架[" + PkgShelfRFID + "]最后一盘料已取出,放行";
// pkgStationStep.ToNextStep(PKG_STATION_STEP.SHELF_EMPTY);
// }
// s2StationStep.ToNextStep(S2_STATION_STEP.WAIT_ROBOT_PUT_FINISH);
// s2StationStep.Msg ="机器人开始将料盘[" + packgeRobotTaskBean.barcode + "]放入[" + packgeRobotTaskBean.realBigRfid + "]库位[" + packgeRobotTaskBean.bigLoc + "]";
// ABBControl.SendCmd(Config.ABB3_IP, ABBControl.Cmd_moveput, "cp" + packgeRobotTaskBean.bigLoc, "L", ABBControl.DefaultSpeed);
// }
// } else if (s2StationStep.IsStep(S2_STATION_STEP.WAIT_ROBOT_PUT_FINISH))
// {
// string putResult = ABBControl.GetAbbCmd(Config.ABB3_IP);
// if (putResult.Contains("FINISHED"))
// {
// s2StationStep.Msg ="机器人将料盘[" + packgeRobotTaskBean.barcode + "]放入" + packgeRobotTaskBean.bigRfid + "[" + packgeRobotTaskBean.realBigRfid + "]库位[" + packgeRobotTaskBean.bigLoc + "]完成";
// s2StationStep.ToNextStep(S2_STATION_STEP.WAIT_ROBOT_PUT_OK);
// //发送消息到服务器
// HttpServer.PackFinish(packgeRobotTaskBean.barcode, packgeRobotTaskBean.packageRfid, packgeRobotTaskBean.packageLoc, BigShelfRFID, packgeRobotTaskBean.bigLoc);
// }
// }
// else if (s2StationStep.IsStep(S2_STATION_STEP.WAIT_ROBOT_PUT_OK))
// {
// string putResult = ABBControl.GetAbbCmd(Config.ABB3_IP);
// if (putResult.Equals(""))
// {
// s2StationStep.Msg ="机器人将料盘[" + packgeRobotTaskBean.barcode + "]放入[" + packgeRobotTaskBean.realBigRfid + "]库位[" + packgeRobotTaskBean.bigLoc + "]结束";
// s2StationStep.ToNextStep(S2_STATION_STEP.WAIT_ROBOT);
// }
// }
//}
private StepInfo<SHELF_TO_LEAVE_STATION> outShelfStep = new StepInfo<SHELF_TO_LEAVE_STATION>(SHELF_TO_LEAVE_STATION.NONE);
private enum SHELF_TO_LEAVE_STATION
{
NONE, SHELF_OUT_S1, WAIT_LINE_RUN_TIME,WAIT_OUT_IO
}
private void ProcessShelfOutS1()
{
if (outShelfStep.IsStep(SHELF_TO_LEAVE_STATION.SHELF_OUT_S1)){
bool hasShelfToLeave = IOValue(IO_Type.R_StopCheck2).Equals(IO_VALUE.HIGH);
KeepLineRun(IO_Type.R_LineRun);
//if (hasShelfToLeave)
{
outShelfStep.ToNextStep(SHELF_TO_LEAVE_STATION.WAIT_LINE_RUN_TIME);
//出料口已有料架,转动60秒
outShelfStep.Msg= "料架流出工位1,下层线体转动60秒";//时,出口已有料架,
outShelfStep.AddTimeWait(60000);
}
//else
//{
// //出料口无料架,等待出料口信号持续3秒
// outShelfStep.ToNextStep(SHELF_TO_LEAVE_STATION.WAIT_OUT_IO);
// outShelfStep.Msg = "料架流出工位1时,出口无料架,下层线体转动到料架到达出口";
// outShelfStep.AddIoWait(IO_Type.R_StopCheck2, IO_VALUE.HIGH, 3000);
// IOMove(IO_Type.R_StopCylinder1, IO_VALUE.HIGH,1500);
//}
}else if (outShelfStep.IsStep(SHELF_TO_LEAVE_STATION.WAIT_LINE_RUN_TIME) || outShelfStep.IsStep(SHELF_TO_LEAVE_STATION.WAIT_OUT_IO))
{
if (outShelfStep.IsFinished())
{
outShelfStep.Msg = "料架流出工位1完成,停止下层线体";
IOMove(IO_Type.R_LineRun, IO_VALUE.LOW);
outShelfStep.ToNextStep(SHELF_TO_LEAVE_STATION.NONE);
}
else
{
//检查线体是否停止,如果停止重新启动
KeepLineRun(IO_Type.R_LineRun);
}
}
}
}
}