DischargeLine_Partial.cs
19.4 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
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
partial class DischargeLine
{
#region 托盘检测
private void StartCheckFixture()
{
int num = TrayManager.GetNum(DeviceID);
if (IOValue(IO_Type.StopCylinder_Check2).Equals(IO_VALUE.HIGH))
{
//托盘在两个阻挡内
if (num > 0)
{
SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
CheckLog("托盘检测(流水线阻挡)SecondStoreMove:(MIO_03_StopCylinder2Down 阻挡气缸1-1上升)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_StopCylinder2Down);
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down1, IO_VALUE.LOW));
// SecondMoveInfo.EndStepWait();
}
else
{
LogUtil.error(Name + "检测到check4亮,但是为获取到托盘号,StartCheckFixture失败~");
}
}
else if (IOValue(IO_Type.StopCylinder_Check1).Equals(IO_VALUE.HIGH))
{
//托盘在第一个阻挡处
SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_01_StopCylinder1Down);
CheckLog(" 托盘检测:料盘检测 SecondStoreMove(MIO_01_StopCylinder1Down阻挡气缸1-1下降 ,最多等待1秒)");
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH));
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Fixture_Check_4, IO_VALUE.HIGH));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
}
private bool CheckIsNeedOutStore()
{
//TODO 判断是否是需要移栽出料的料盘
return false;
}
protected override void CheckFixtureProcess()
{
if (!LineManager.Line.isCanProcessLine())
{
return;
}
if (SecondMoveInfo.IsInWait)
{
CheckWait(SecondMoveInfo);
}
if (SecondMoveInfo.IsInWait)
{
return;
}
#region 托盘检测
if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_01_StopCylinder1Down))
{
CheckLog("托盘检测(流水线阻挡)SecondStoreMove:(MIO_02_FixtureCheck 阻挡气缸1-1上升,等待 阻挡2托盘检测=1)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_StopCylinder2Down);
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down1, IO_VALUE.LOW));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check2, IO_VALUE.HIGH));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_02_FixtureCheck))
{
CheckLog("托盘检测(流水线阻挡)SecondStoreMove:(MIO_03_StopCylinder2Down 阻挡气缸1-1上升)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_StopCylinder2Down);
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down1, IO_VALUE.LOW));
// SecondMoveInfo.EndStepWait();
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_03_StopCylinder2Down))
{
CheckLog("托盘检测(流水线阻挡)SecondStoreMove:(MIO_04_Wait ,等待编码信号稳定)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_04_Wait);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_04_Wait))
{
try
{
//判断是否需要顶升
bool isNeed = false;
//此处先对托盘号进行验证
currMoveTrayNum = TrayManager.GetNum(DeviceID);
bool isFull = TrayManager.IsFixTureFull(currMoveTrayNum);
if (TrayManager.RightTrayCode(currMoveTrayNum, preTrayNum, false))
{
//出料中,需要拦盘
if (CheckIsNeedOutStore())
{
//preTrayNum = currMoveTrayNum;
SecondMoveInfo.MoveParam = new InOutParam(currMoveTrayNum);
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_05_CodeRember);
SecondMoveInfo.EndStepWait();
return;
}
}
else
{
string msg = Name + " 托盘顺序错乱,上个托盘号【" + preTrayNum + "】当前托盘号 【" + currMoveTrayNum + "】最大盘号【" + TrayManager.MaxTrayNum + "】";
TrayManager.UpdateTrayNumError(DeviceID, msg);
LogUtil.error(msg);
return;
}
if (isNeed)
{
CheckLog("托盘检测(流水线阻挡)SecondStoreMove:(MIO_05_WaitTime 等待一秒钟)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_05_WaitTime);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
}
else
{
LogInfo(SecondMoveInfo.MoveNum + "***************上个托盘号【" + preTrayNum + "】,当前" + (isFull ? "有料托盘" : "空托盘") + "【" + currMoveTrayNum + "】没有出出料任务,放盘通过~");
// preTrayNum = currMoveTrayNum;
if (TrayManager.ErrorStoreId.Equals(DeviceID))
{
TrayManager.UpdateTrayNumError(-1, "");
}
CheckLog("托盘放行 SecondStoreMove:(MO_07_WaitCanGo ,移栽2,需要判断是否可以放盘通过,最多等待10000)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_07_WaitCanGo);
//if (DeviceID.Equals(2))
//{
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitSideWay());
// SecondMoveInfo.OneWaitCanEndStep = true;
//}
}
}
catch (Exception ex)
{
LogUtil.error("判断托盘是否需要顶升出错:" + ex.ToString());
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_05_WaitTime))
{
CheckLog("托盘检测(流水线阻挡)SecondStoreMove:(MIO_06_TopCylinderUp 顶升气缸上 升 )");
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_06_TopCylinderUp);
CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_06_TopCylinderUp))
{
CheckLog("托盘检测(流水线阻挡)SecondStoreMove:(MIO_07_TopCylinderUpWait ,顶升气缸上升时等待1秒钟,再下降)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_07_TopCylinderUpWait);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_07_TopCylinderUpWait))
{
CheckLog("托盘检测(流水线阻挡)*************** 托盘号【" + currMoveTrayNum + "】");
//托盘号正确
//preTrayNum = num;
bool isNeedMove = false;
//判断盘是空盘,空盘并且编号正确才需要放料盘过去
if (CheckIsNeedOutStore())
{
SecondMoveInfo.MoveParam = new InOutParam(currMoveTrayNum);
isNeedMove = true;
LogInfo(SecondMoveInfo.MoveNum + "*************** 托盘号【" + currMoveTrayNum + "】可以放出料托盘,正在出料中,移栽料盘");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_05_CodeRember);
SecondMoveInfo.EndStepWait();
}
else
{
//preTrayNum = num;
if (TrayManager.ErrorStoreId.Equals(DeviceID))
{
TrayManager.UpdateTrayNumError(-1, "");
}
CheckLog("托盘检测 SecondStoreMove:(MO_09_TopCylinder_Down ,托盘号【" + currMoveTrayNum + "】,直接放盘通过,顶升气缸下降)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_06_TopCylinder_Down);
CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_08_WaitInStore) && MoveInfo.MoveType.Equals(LineMoveType.None))
{
CheckLog("托盘放行 SecondStoreMove:(MIO_09_WaitLetFixtureGo ,等待移栽完成后放开阻挡)");
StartOutStoreMove(SecondMoveInfo.MoveParam);
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_09_WaitLetFixtureGo);
}
#endregion
#region 不需要出出料,直接放行
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_06_TopCylinder_Down))
{
CheckLog("托盘放行 SecondStoreMove:(MO_07_WaitCanGo ,移栽2,需要判断是否可以放盘通过,最多等待10000)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_07_WaitCanGo);
if (DeviceID.Equals(2))
{
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitSideWay());
SecondMoveInfo.OneWaitCanEndStep = true;
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_07_WaitCanGo))
{
CheckLog("托盘放行 SecondStoreMove:(MO_10_StopCylinder2_Down ,阻挡气缸1-2下降)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_10_StopCylinder2_Down);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
// SecondMoveInfo.EndStepWait();
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_10_StopCylinder2_Down))
{
CheckLog("托盘放行 SecondStoreMove:(MO_11_Tray_Check , 阻挡2托盘检测=0), 延时2秒)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_11_Tray_Check);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check2, IO_VALUE.LOW));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_11_Tray_Check))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_12_StopCylinder_Back);
CheckLog("托盘放行 SecondStoreMove:(MO_12_StopCylinder_Back , 阻挡气缸1-2上升 )");
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.LOW));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_12_StopCylinder_Back))
{
preTrayNum = currMoveTrayNum;
CheckLog("托盘放行 SecondStoreMove:(托盘放行结束) ");
// IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
SecondMoveInfo.EndMove();
}
#endregion
}
#endregion
#region 料盘移栽处理
public override bool StartOutStoreMove(InOutParam param)
{
string posId = param != null ? param.PosId : "";
//调试模式移栽装置不需要有操作
if (IsDebug)
{
LogInfo("需要出料【" + posId + "】处于调试模式,暂时不再进行出出料操作");
return false;
}
if (runStatus.Equals(LineRunStatus.Runing))
{
runStatus = LineRunStatus.Busy;
lineStatus = LineStatus.OutStoreExecute;
MoveInfo.MoveParam = param;
MoveInfo.NewMove(LineMoveType.OutStore);
LogInfo("出料【" + posId + "】处理(移栽):(PO_01_UpDownCylinderDown,上下气缸1下降)");
MoveInfo.NextMoveStep(LineMoveStep.PO_01_UpDownCylinderDown);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down);
return true;
}
else
{
LogUtil.error(Name + " 启动出料【" + posId + "】 失败,当前 storeStatus=" + runStatus);
return false;
}
}
protected override void OutStoreProcess()
{
if (MoveInfo.IsInWait)
{
CheckWait(MoveInfo);
}
if (SecondMoveInfo.IsInWait)
{
CheckWait(SecondMoveInfo);
}
if (MoveInfo.IsInWait)
{
return;
}
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosId : "";
if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_01_UpDownCylinderDown))
{
InStoreLog("出料:(PO_02_UpDownCylinderDownWait, 编码与仓位一致,上下气缸1下降后等待0.3秒再夹紧,防止没有下降到位就夹紧");
MoveInfo.NextMoveStep(LineMoveStep.PO_02_UpDownCylinderDownWait);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
}
//只有当BOX可以进行出出料时,移栽物品,防止卡住
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_02_UpDownCylinderDownWait))
{
InStoreLog("出料:(PO_02_UpDownCylinderDownWait,夹料气缸夹紧)");
MoveInfo.NextMoveStep(LineMoveStep.PO_03_ClampCylinderSlack);
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_03_ClampCylinderSlack))
{
InStoreLog("出料:(PO_04_UpDownCylinderUp,上下气缸上升)");
MoveInfo.NextMoveStep(LineMoveStep.PO_04_UpDownCylinderUp);
CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_04_UpDownCylinderUp))
{
int num = MoveInfo.MoveParam.TrayNumber;
MoveInfo.NextMoveStep(LineMoveStep.PO_05_WaitBox);
LogInfo("出料PO_05_WaitBox【" + posId + "】处理(等待可以移栽) 更新盘号【" + num + "】为空盘");
MoveInfo.WaitList.Add(WaitResultInfo.WaitBoxCanReviceTray());
TrayManager.UpdateFixtureValue(num, false, 0);
//阻挡气缸移动
InStoreLog("放托盘(放开阻挡):SecondStoreMove=MO_09_TopCylinder_Down 物品已移走,顶升气缸1下降)");
SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_06_TopCylinder_Down);
CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_05_WaitBox))
{
InStoreLog("出料:(PO_06_BeforeAfterCylinderBefore,前后气缸前进)");
MoveInfo.NextMoveStep(LineMoveStep.PO_06_BeforeAfterCylinderBefore);
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_06_BeforeAfterCylinderBefore))
{
InStoreLog("出料:(PO_07_UpDownCylinderDown ,上下气缸下降)");
MoveInfo.NextMoveStep(LineMoveStep.PO_07_UpDownCylinderDown);
CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_07_UpDownCylinderDown))
{
InStoreLog("出料: (PO_08_ClampCylinderTighten,夹料气缸放松)");
MoveInfo.NextMoveStep(LineMoveStep.PO_08_ClampCylinderTighten);
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_08_ClampCylinderTighten))
{
InStoreLog("出料:(PO_09_UpdownCylinderUp,上下气缸上升)");
MoveInfo.NextMoveStep(LineMoveStep.PO_09_UpdownCylinderUp);
CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_09_UpdownCylinderUp))
{
InStoreLog("出料:(PO_10_BeforeAfterCylinderAfter,前后气缸后退,等待4000 )");
MoveInfo.NextMoveStep(LineMoveStep.PO_10_BeforeAfterCylinderAfter);
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(4000));
}
else if( MoveInfo.MoveStep.Equals(LineMoveStep.PO_10_BeforeAfterCylinderAfter))
{
LogInfo("出料【" + posId + "】处理完成!");
runStatus = LineRunStatus.Runing;
lineStatus = LineStatus.StoreOnline;
MoveInfo.EndMove();
}
}
#endregion
private void CheckLog(string msg)
{
LogUtil.debug(Name + msg);
}
private void InStoreLog(string msg)
{
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosId : "";
LogUtil.info(Name + "【" + posId + "】" + msg);
}
private void OutStoreLog(string msg)
{
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosId : "";
LogUtil.info(Name + "【" + posId + "】" + msg);
}
}
}