MoveEquip_Partial.cs
39.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
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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
namespace OnlineStore.DeviceLibrary
{
partial class MoveEquip
{
#region 出库
public override bool StartOutStoreMove(InOutParam param)
{
string posId = param != null ? param.PosId : "";
if (param.Equals(null))
{
LogUtil.error(Name + "出库【" + posId + "】失败,param=null");
return false;
}
if (runStatus.Equals(LineRunStatus.Runing))
{
LogInfo("启动出库【" + posId + "】 ");
runStatus = LineRunStatus.Busy;
lineStatus = LineStatus.OutStoreExecute;
MoveInfo.NewMove(LineMoveType.OutStore);
MoveInfo.MoveParam = param;
MoveInfo.NextMoveStep(LineMoveStep.MO_50_StartOutProcess);
// TrayManager.AddNeedEmptyTrayNum();
return true;
}
else
{
LogUtil.error(Name + " 启动出库【" + posId + "】失败,runStatus=" + runStatus);
return false;
}
}
protected override void OutStoreProcess()
{
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosId : "";
if (MoveInfo.IsInWait)
{
CheckWait(MoveInfo);
}
if (SecondMoveInfo.IsInWait)
{
CheckWait(SecondMoveInfo);
}
if (MoveInfo.IsInWait)
{
return;
}
#region 移载装置 移栽物品操作
if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_50_StartOutProcess))
{
MoveInfo.NextMoveStep(LineMoveStep.MO_51_CylinderBefore);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
OutLog("出库 " + MoveInfo.MoveStep + ": 前后气缸前进");
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_51_CylinderBefore))
{
if (CylinderIsOk(IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before))
{
MoveInfo.NextMoveStep(LineMoveStep.MO_52_CylinderDown);
OutLog("出库 " + MoveInfo.SLog + ": 上下气缸下降 ");
UpdownDownP3Move(MoveInfo.MoveParam.PlateH);
// CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down);
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.MO_51_CylinderBefore);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
OutLog("出库 " + MoveInfo.MoveStep + ": 前后气缸前进");
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_52_CylinderDown))
{
MoveInfo.NextMoveStep(LineMoveStep.MO_53_DownWait);
OutLog("出库 " + MoveInfo.SLog + ": 等待200ms后夹紧");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_53_DownWait))
{
MoveInfo.NextMoveStep(LineMoveStep.MO_54_CylinderOpen);
OutLog("出库 " + MoveInfo.SLog + ": 夹料气缸夹紧,更新料盘位置【" + MoveInfo.MoveParam.WareCode + "】【MOVING】【" + DeviceID + "】");
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
//更新料盘位置
SServerManager.UpdateTrayLoc(Name, MoveInfo.MoveParam.WareCode, LocStatus.MOVING, DeviceID.ToString());
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_54_CylinderOpen))
{
MoveInfo.NextMoveStep(LineMoveStep.MO_55_CylinderUp);
OutLog("出库 " + MoveInfo.SLog + ": 上下气缸上升");
UpdownUpMove();
// CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_55_CylinderUp))
{
if (IsBigStore())
{
if (TrayIsOk())
{
MoveInfo.NextMoveStep(LineMoveStep.MO_56_CylinderAfter);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
OutLog("出库 " + MoveInfo.SLog + ": 前后气缸后退");
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
}
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.MO_56_CylinderAfter);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
OutLog("出库 " + MoveInfo.SLog + ": 前后气缸后退");
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
}
}
#endregion
#region 移载装置,放物品到流水线操作
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_56_CylinderAfter))
{
if (CylinderIsOk(IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After))
{
//if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_11_CodeRember) && !SecondMoveInfo.IsInWait)
//{
if (TrayIsOk())
{
int trayNum = SecondMoveInfo.MoveParam.TrayNumber;
//去掉直接丢盘处理
MoveInfo.NextMoveStep(LineMoveStep.MO_58_CylinderDown);
OutLog("出库 " + MoveInfo.SLog + ": 夹具检测编码完成, 上下气缸下降 ,更新料盘位置【" + MoveInfo.MoveParam.WareCode + "】【INLINE】【" + trayNum + "】,顶升气缸上升");
if (MoveInfo.MoveParam != null)
{
MoveInfo.MoveParam.TrayNumber = trayNum;
}
else
{
MoveInfo.MoveParam = SecondMoveInfo.MoveParam;
}
//更新料盘位置
SServerManager.UpdateTrayLoc(Name, MoveInfo.MoveParam.WareCode, LocStatus.INLINE, "E" + trayNum.ToString().PadLeft(2, '0'));
UpdownDownP2Move(MoveInfo.MoveParam.PlateH, MoveInfo.MoveParam.PlateW);
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
}
//}
//else if (MoveInfo.IsTimeOut(180))
//{
// WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.SLog + "]等待空托盘到达超时[" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
// LogUtil.error(WarnMsg, DeviceID + 12);
// Alarm(LineAlarmType.IoSingleTimeOut);
//}
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_58_CylinderDown))
{
OutLog("出库 " + MoveInfo.SLog + ": 夹料气缸放松,更新托盘【" + MoveInfo.MoveParam.TrayNumber + "】,有料盘,OutStore,【" + MoveInfo.MoveParam.ToStr() + "】");
TrayManager.UpdateTrayInfo(MoveInfo.MoveParam.TrayNumber, true, ReelType.OutStore, MoveInfo.MoveParam);
//出库全部完成
lineStatus = LineStatus.StoreOnline;
MoveInfo.NextMoveStep(LineMoveStep.MO_59_CylinderRelax);
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_59_CylinderRelax))
{
this.MoveInfo.NextMoveStep(LineMoveStep.MO_60_CylinderUp);
OutLog("出库 " + MoveInfo.SLog + ": 上下气缸上升,同时顶升气缸先下降");
UpdownUpMove();
CylinderMove(null, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MO_60_CylinderUp))
{
// 减去需要的盘数
// TrayManager.DelNeedEmptyTrayNum();
SOutLog("出库 :移栽完成,放行托盘");
SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_TopDown);
CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
OutLog("出库处理结束!");
MoveEndS();
}
#endregion
}
private bool TrayIsOk()
{
if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_11_CodeRember) && !SecondMoveInfo.IsInWait)
{
return true;
}
else if (MoveInfo.IsTimeOut(180))
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.SLog + "]等待空托盘到达超时[" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, DeviceID * 1000 + 12);
Alarm(LineAlarmType.IoSingleTimeOut);
return false;
}
return false;
}
private bool IsBigStore()
{
return Config.IsBigTray.Equals(1);
}
#endregion
#region 入库
/// <summary>
/// 入库移动移动
/// </summary>
public override bool StartInStoreMove(InOutParam param)
{
string posId = param != null ? param.PosId : "";
if (runStatus.Equals(LineRunStatus.Runing))
{
runStatus = LineRunStatus.Busy;
lineStatus = LineStatus.InStoreExecute;
MoveInfo.MoveParam = param;
MoveInfo.NewMove(LineMoveType.InStore);
LogInfo("入库【" + posId + "】处理(移栽):MI_05_ToLineUp, 前后气缸后退)");
//MoveInfo.NextMoveStep(LineMoveStep.MI_06_CylinderDown);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
//UpdownDownP2Move(MoveInfo.MoveParam.PlateH);
MoveInfo.NextMoveStep(LineMoveStep.MI_05_ToLineUp);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
return true;
}
else
{
LogUtil.error(Name + " 启动一个 入库【" + posId + "】运动失败,当前状态,storeStatus=" + runStatus);
}return false;
}
protected override void InStoreProcess()
{
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.MI_05_ToLineUp))
{
MoveInfo.NextMoveStep(LineMoveStep.MI_06_CylinderDown);
InLog("入库 " + MoveInfo.SLog + ": 升降下降,顶升上升");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
UpdownDownP2Move(MoveInfo.MoveParam.PlateH, MoveInfo.MoveParam.PlateW);
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_06_CylinderDown))
{
MoveInfo.NextMoveStep(LineMoveStep.MI_07_DownWait);
InLog("入库 " + MoveInfo.SLog + ": 等待200ms后夹紧");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
}
//只有当BOX可以进行出入库时,移栽物品,防止卡住
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_07_DownWait))
{
MoveInfo.NextMoveStep(LineMoveStep.MI_08_CylinderOpen);
InLog("入库 " + MoveInfo.SLog + ": 夹料气缸夹紧");
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_08_CylinderOpen))
{
MoveInfo.NextMoveStep(LineMoveStep.MI_09_CylinderUp);
InLog("入库 " + MoveInfo.SLog + ": 上下气缸上升");
UpdownUpMove();
//if (MoveInfo.MoveParam.PlateW.Equals(7))
//{
// InLog("放托盘(放开阻挡): " + MoveInfo.SLog + " 7寸盘已移走,气缸1下降");
// SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_TopDown);
// CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
//}
//else
//{
CylinderMove(null, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
//}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_09_CylinderUp))
{
int num = MoveInfo.MoveParam.TrayNumber;
MoveInfo.NextMoveStep(LineMoveStep.MI_10_WaitBox);
LogInfo("入库【" + posId + "】 " + MoveInfo.SLog + ": 等待box可入库,更新托盘【" + num + "】为空盘");
MoveInfo.WaitList.Add(WaitResultInfo.WaitBoxCanReviceTray());
TrayManager.UpdateTrayInfo(num);
//阻挡气缸移动
//if (SecondMoveInfo.MoveStep < LineMoveStep.MO_14_TopDown)
//{
// SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
InLog("放托盘(放开阻挡): " + MoveInfo.SLog + " 物品已移走,顶升气缸1下降");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_TopDown);
CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
//}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_10_WaitBox))
{
MoveInfo.NextMoveStep(LineMoveStep.MI_10_CylinderBefore);
InLog("入库: " + MoveInfo.SLog + " 前后气缸1前进");
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_10_CylinderBefore))
{
if (CylinderIsOk(IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before))
{
MoveInfo.NextMoveStep(LineMoveStep.MI_11_CylinderDown);
InLog("入库 " + MoveInfo.SLog + " ,上下气缸下降");
UpdownDownP3Move(MoveInfo.MoveParam.PlateH);
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.MI_10_CylinderBefore);
InLog("入库: " + MoveInfo.SLog + " 前后气缸1前进");
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_11_CylinderDown))
{
MoveInfo.NextMoveStep(LineMoveStep.MI_12_CylinderRelax);
InLog("入库 " + MoveInfo.SLog + ",夹料气缸放松");
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_12_CylinderRelax))
{
MoveInfo.NextMoveStep(LineMoveStep.MI_13_UpdownCylinderUp);
InLog("入库 " + MoveInfo.SLog + ",上下气缸上升");
UpdownUpMove();
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_13_UpdownCylinderUp))
{
MoveInfo.NextMoveStep(LineMoveStep.MI_14_CylinderAfter);
InLog("入库 " + MoveInfo.SLog + ",前后气缸后退,等待300 ");
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
//此时box就可以入库操作了 //触发事件,BOX入库
// LineServer.StartInStore(DeviceID, MoveInfo.MoveParam);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_14_CylinderAfter))
{
MoveInfo.NextMoveStep(LineMoveStep.MI_15_SendPosToStore);
InLog("入库 " + MoveInfo.SLog + ",通知BOX开始入库,等待3000");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
//此时box就可以入库操作了 //触发事件,BOX入库
LineServer.StartInStore(DeviceID, MoveInfo.MoveParam);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_15_SendPosToStore))
{
MoveInfo.NextMoveStep(LineMoveStep.MI_16_SendEnd);
//判断料仓是否在入库中,如果么有在入库中,需要重新发送入库消息
if (!LineServer.IsInStorePro(DeviceID))
{
InLog("入库 " + MoveInfo.SLog + " , 送料流程完成,料仓还未开始入库,再次发送starIn命令");
LineServer.StartInStore(DeviceID, MoveInfo.MoveParam);
}
else
{
InLog("入库 " + MoveInfo.SLog + " , 送料流程完成,料仓已开始入库");
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.MI_16_SendEnd))
{
LogInfo("入库【" + posId + "】处理(移栽)全部完成!");
MoveEndS();
}
}
private bool IsInStoreNeed()
{
if (waitInStoreList.Count > 0)
{
lock (waitInListLock)
{
bool needRemove = false;
int index = 0;
//判断是否是自己排队列表中的入库信息
foreach (InOutParam cc in waitInStoreList)
{
if (cc.TrayNumber.Equals(currTrayNum) && (!cc.WareCode.Equals("")))
{
//判断是否验证成功,如果验证失败,不入库
if (LineServer.RightInPosId(DeviceID, cc.PosId))
{
SecondMoveInfo.MoveParam = new InOutParam(cc.TrayNumber, cc.WareCode, cc.PosId, cc.PlateH, cc.PlateW, cc.InStoreNg);
return true;
}
else
{
SecondMoveInfo.MoveParam = new InOutParam(cc.TrayNumber, cc.WareCode, cc.PosId, cc.PlateH, cc.PlateW, cc.InStoreNg);
LogUtil.error(Name + "托盘号【"+currTrayNum+"】入库信息【"+cc.ToStr()+ "】料仓未验证成功,重新发送验证消息");
LineServer.CheckInStorePos(DeviceID, cc);
return true;
}
}
index++;
}
if (needRemove && index >= 0 && index < waitInStoreList.Count)
{
waitInStoreList.RemoveAt(index);
LogUtil.info("从waitInStoreList中删除 index=" + index + "的任务");
}
}
}
return false;
}
/// <summary>
/// 是否需要出库的托盘
/// </summary>
/// <param name="currMoveTrayNum"></param>
/// <returns></returns>
private bool CheckIsNeedOutStore()
{
if (currTrayNum <= 0)
{
return false;
}
bool isFull = TrayManager.TrayIsFull(currTrayNum);
bool moveOk = (IsBigStore() && MoveInfo.MoveStep >= LineMoveStep.MO_55_CylinderUp) || MoveInfo.MoveStep >= LineMoveStep.MO_56_CylinderAfter;
if (MoveInfo.MoveType.Equals(LineMoveType.OutStore) && moveOk
&& (!MoveInfo.MoveStep.Equals(LineMoveStep.MO_60_CylinderUp)))
{
if (isFull.Equals(false))
{
LogInfo(" 出库中,拦截空托盘【 " + currTrayNum + "】~");
return true;
}
}
return false;
}
/// <summary>
/// 判断盘号是否需要入库
/// </summary>
/// <returns></returns>
private bool CheckIsNeedInStore()
{
if (currTrayNum <= 0)
{
return false;
}
//如果正在出库执行中,不能拦截入库托盘
if (MoveInfo.MoveType.Equals(LineMoveType.OutStore))
{
return false;
}
else if (waitOutStoreList.Count > 0)
{
return false;
}
bool isfull = TrayManager.TrayIsFull(currTrayNum);
if (!isfull)
{
return false;
}
InOutParam currCode = null;
if (waitInStoreList.Count > 0)
{
lock (waitInListLock)
{
//判断是否是自己排队列表中的入库信息
int reIndex = -1;
for (int i = 0; i < waitInStoreList.Count; i++)
{
InOutParam cc = waitInStoreList[i];
if (cc.TrayNumber.Equals(currTrayNum) && (!cc.WareCode.Equals("")))
//if (cc.TrayNumber.Equals(currTrayNum) && (!cc.WareCode.Equals("")) && LineServer.RightInPosId(DeviceID, cc.PosId))
{
reIndex = i;
currCode = cc;
SecondMoveInfo.MoveParam = new InOutParam(cc.TrayNumber, cc.WareCode, cc.PosId, cc.PlateH, cc.PlateW, cc.InStoreNg);
break;
}
}
if (reIndex >= 0)
{
if (!LineServer.BoxCanInStore(DeviceID))
{
LogInfo("*******托盘" + currTrayNum + "需要入库【" + currCode.ToStr() + "】,BoxCanInStore验证失败,先放托盘通过");
return false;
}
else
{
//判断是否验证成功,如果验证失败,不入库
if (LineServer.RightInPosId(DeviceID, currCode.PosId))
{
waitInStoreList.RemoveAt(reIndex);
LogInfo("*******托盘" + currTrayNum + "需要入库【" + currCode.ToStr() + "】 ,开始入库移栽");
return true;
}
else
{
LogUtil.error(Name + "托盘号【" + currTrayNum + "】入库信息【" + currCode.ToStr() + "】料仓未验证成功,不拦截托盘,更新此托盘为NG,从waitInStoreList中删除,取消入库任务");
TrayManager.UpdateInStoreNG(currTrayNum, true, "Box验证入库失败");
waitInStoreList.RemoveAt(reIndex);
Task.Factory.StartNew(delegate {
SServerManager.cancelPutInTask(Name, currCode.WareCode);
});
return false;
}
}
}
}
}
return false;
}
#endregion
#region 托盘检测
private Stopwatch trayCheckWait = new Stopwatch();
private Stopwatch trayCheck2LowWait = new Stopwatch();
private object lockObj = "";
private void StartCheckFixture()
{
if (Monitor.TryEnter(lockObj, 100))
{
try
{
if (SecondMoveInfo.MoveType.Equals(LineMoveType.None).Equals(false))
{
LogUtil.error(Name + " StartCheckFixture " + " 不在空闲中,直接返回 ");
return;
}
if (IOValue(IO_Type.StopCylinder_Check2).Equals(IO_VALUE.HIGH))
{
trayCheck2LowWait.Stop();
if (TrayManager.checkWatch(trayCheckWait, TrayManager.SwTrayWaitTime, true))
{
SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_Stop2Down);
CheckLog("托盘阻挡" + SecondMoveInfo.SLog + " 阻挡气缸1-1上升)");
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down1, IO_VALUE.LOW));
}
}
else
{
bool check2IsOk = TrayManager.checkWatch(trayCheck2LowWait, TrayManager.SwTrayWaitTime, false );
if (IOValue(IO_Type.StopCylinder_Check1).Equals(IO_VALUE.HIGH))
{
if (TrayManager.checkWatch(trayCheckWait, TrayManager.SwTrayWaitTime, false ) && check2IsOk)
{
trayCheckWait.Stop();
trayCheck2LowWait.Stop();
//托盘在第一个阻挡处
SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_00_Stop1Down);
//SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
CheckLog(" 托盘检测:料盘检测StopCylinder_Check1 " + SecondMoveInfo.SLog + "阻挡气缸1-1下降 , 等待 StopCylinder_Check1=0");
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH, 1200);
SecondMoveInfo.OneWaitCanEndStep = true;
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check1, IO_VALUE.LOW));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check2, IO_VALUE.HIGH));
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.StopDownWaitTime));
}
}
else
{
trayCheckWait.Stop();
}
}
}
catch (Exception ex)
{
LogUtil.error(Name + " StartCheckFixture " + " 出错:" + ex.ToString());
}
finally
{
Monitor.Exit(lockObj);
}
}
else
{
LogUtil.error(Name + " StartCheckFixture " + "失败,未得到锁");
}
}
protected override void CheckFixtureProcess()
{
if (!LineManager.Line.LineCanRun())
{
return;
}
if (SecondMoveInfo.IsInWait)
{
CheckWait(SecondMoveInfo);
}
if (SecondMoveInfo.IsInWait)
{
return;
}
#region 托盘检测
if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_00_Stop1Down))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_01_FixtureCheck);
CheckLog("托盘阻挡" + SecondMoveInfo.SLog + " 阻挡气缸1-1上升,等待 阻挡2托盘检测=1)");
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_01_FixtureCheck))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_Stop2Down);
CheckLog("托盘阻挡" + SecondMoveInfo.SLog + " 再次等待托盘信号");
IOMove(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_03_Stop2Down))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_04_Wait);
CheckLog("托盘阻挡" + SecondMoveInfo.SLog + " ,等待编码信号稳定StopCylinder_Check2=1");
CheckAndMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
//SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check2, IO_VALUE.HIGH));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_04_Wait))
{
try
{
//判断是否需要顶升
bool isNeed = false;
UpdateTrayNum();
bool isFull = TrayManager.TrayIsFull(currTrayNum);
if (TrayManager.RightTrayCode(currTrayNum, preTrayNum, false))
{
//出库中,需要拦盘
if (CheckIsNeedOutStore())
{
isNeed = true;
}
else if (isFull && IsInStoreNeed())
{
isNeed = true;
}
}
else
{
string msg = Name + " 托盘顺序错乱,上个托盘号【" + preTrayNum + "】当前托盘号 【" + currTrayNum + "】最大盘号【" + TrayManager.MaxTrayNum + "】";
TrayManager.UpdateTrayNumError(DeviceID, msg);
LogUtil.error(msg);
return;
}
if (isNeed)
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_05_WaitTime);
CheckLog("托盘阻挡" + SecondMoveInfo.SLog + " 等待一秒钟)");
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
}
else
{
LogUtil.debug(Name + SecondMoveInfo.MoveNum + "***************上个托盘号【" + preTrayNum + "】,当前" + (isFull ? "有料托盘" : "空托盘") + "【" + currTrayNum + "】没有出入库任务,放盘通过~");
// preTrayNum = currMoveTrayNum;
if (TrayManager.ErrorDeviceId.Equals(DeviceID))
{
TrayManager.UpdateTrayNumError(-1, "");
}
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_15_WaitCanGo);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,等待 NextStopCheck=0");
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.NextStopCheck, IO_VALUE.LOW));
}
}
catch (Exception ex)
{
LogUtil.error("判断托盘是否需要顶升出错:", ex);
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_05_WaitTime))
{
//如果是出库,且盘高大于30,暂不顶升
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_06_TopUp);
if (MoveInfo.MoveType.Equals(LineMoveType.OutStore))
{
if (MoveInfo.MoveParam != null && MoveInfo.MoveParam.PlateH >= 30)
{
CheckLog("托盘阻挡" + SecondMoveInfo.SLog + " 高度>30,暂不顶升上升");
}
}
else if (SecondMoveInfo.MoveParam != null)
{
if (!LineServer.RightInPosId(DeviceID, SecondMoveInfo.MoveParam.PosId))
{
LogUtil.error(Name + " " + SecondMoveInfo.SLog + "[" + SecondMoveInfo.MoveParam.PosId + "]料仓未验证成功,等待3秒");
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
}
if (SecondMoveInfo.MoveParam.PlateH >= 30)
{
CheckLog("托盘阻挡" + SecondMoveInfo.SLog + " 高度>30,暂不顶升上升");
}
}
else
{
CheckLog("托盘阻挡" + SecondMoveInfo.SLog + " 顶升气缸上 升 )");
CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_06_TopUp))
{
CheckLog("托盘阻挡*************** 托盘号【" + currTrayNum + "】");
//托盘号正确
//preTrayNum = num;
bool isNeedMove = false;
//判断盘是空盘,空盘并且编号正确才需要放料盘过去
if (CheckIsNeedOutStore())
{
SecondMoveInfo.MoveParam = new InOutParam(currTrayNum);
isNeedMove = true;
LogInfo(SecondMoveInfo.MoveNum + "*************** 空托盘【" + currTrayNum + "】,正在出库中,移栽料盘");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_11_CodeRember);
SecondMoveInfo.EndStepWait();
}
else if (CheckIsNeedInStore())
{
LogInfo(SecondMoveInfo.MoveNum + "*************** 托盘【" + currTrayNum + "】,有对应的入库任务,等待移栽");
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_08_WaitInStore);
isNeedMove = true;
}
else
{
LogInfo(SecondMoveInfo.MoveNum + "*************** 托盘【" + currTrayNum + "】不需要出入库, 放盘通过");
}
if (!isNeedMove)
{
//preTrayNum = num;
if (TrayManager.ErrorDeviceId.Equals(DeviceID))
{
TrayManager.UpdateTrayNumError(-1, "");
}
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_TopDown);
CheckLog("托盘检测" + SecondMoveInfo.SLog + " ,托盘号【" + currTrayNum + "】,直接放盘通过,顶升气缸下降 ");
CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_08_WaitInStore) && MoveInfo.MoveType.Equals(LineMoveType.None))
{
StartInStoreMove(SecondMoveInfo.MoveParam);
CheckLog("托盘放行" + SecondMoveInfo.SLog + " ,等待移栽完成后放开阻挡)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_09_WaitLetFixtureGo);
}
#endregion
#region 不需要出入库,直接放行
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_14_TopDown))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_15_WaitCanGo);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,等待 NextStopCheck=0");
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.NextStopCheck, IO_VALUE.LOW));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_15_WaitCanGo))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_Stop2Down);
CheckLog("托盘放行" + SecondMoveInfo.SLog + " ,阻挡气缸1-2下降)");
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_16_Stop2Down))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_17_Stop2Check);
CheckLog("托盘放行" + SecondMoveInfo.SLog + " , 阻挡2托盘检测=0), 延时2秒)");
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check2, IO_VALUE.LOW));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_17_Stop2Check))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_18_StopCylinder_Back);
CheckLog("托盘放行" + SecondMoveInfo.SLog + " , 阻挡气缸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_18_StopCylinder_Back))
{
CheckLog("托盘放行 SecondMove:(托盘放行结束) ");
// IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
SecondMoveInfo.EndMove();
}
#endregion
}
#endregion
}
}