ProvidingEquip_Partial.cs
37.2 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
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;
namespace OnlineStore.DeviceLibrary
{
partial class ProvidingEquip
{
public event TrayProcessEnd TrayPEndEvent;
#region 托盘检测
protected override bool CheckWaitResult(LineMoveInfo moveInfo, WaitResultInfo wait)
{
if (wait.WaitType.Equals(WaitEnum.W201_ProvidingCanOut))
{
if (MoveInfo.MoveType.Equals(LineMoveType.None))
{
return true;
}
}
else if (wait.WaitType.Equals(WaitEnum.W202_DLineCanOut))
{
bool result = LineManager.Line.DLineStartOut(Config.DLineEquipNum, Config.DLineLineNum);
wait.IsEnd = result;
}
return false;
}
internal DateTime lastStopDown = DateTime.Now;
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;
}
//int num = TrayManager.GetTrayNum(DeviceID);
if (IOValue(IO_Type.StopCylinder_Check2).Equals(IO_VALUE.HIGH))
{
bool canProcess = (LineManager.Line.SwNoProcess(Config.SidesWayNum));
trayCheck2LowWait.Stop();
if (TrayManager.checkWatch(trayCheckWait, TrayManager.SwTrayWaitTime, false) && canProcess)
{
trayCheckWait.Stop();
SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_Stop2Down);
LogUtil.info(Name + " [" + trayCount + "] 托盘阻挡" + 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 check2Ok = TrayManager.checkWatch(trayCheck2LowWait, TrayManager.SwTrayWaitTime, false);
if (IOValue(IO_Type.StopCylinder_Check1).Equals(IO_VALUE.HIGH) )
{
bool canProcess = (LineManager.Line.SwNoProcess(Config.SidesWayNum));
if (TrayManager.checkWatch(trayCheckWait, TrayManager.SwTrayWaitTime, false) && (DateTime.Now - lastStopDown).TotalSeconds > 3 && check2Ok && canProcess)
{
trayCheckWait.Stop();
trayCheck2LowWait.Stop();
lastStopDown = DateTime.Now;
//托盘在第一个阻挡处
SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_00_Stop1Down);
LogUtil.debug(Name + " [" + trayCount + "] 托盘检测:" + SecondMoveInfo.SLog + "阻挡气缸1-1下降 ,等待 StopCylinder_Check1=0,清理托盘RFID");
ClearTrayRFID();
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH, 1200);
SecondMoveInfo.OneWaitCanEndStep = true;
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check1, IO_VALUE.LOW));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check2, IO_VALUE.HIGH));
}
}
else
{
trayCheckWait.Stop();
}
}
}
catch (Exception ex)
{
LogUtil.error(Name + " StartCheckFixture " + " 出错:" + ex.ToString());
}
finally
{
Monitor.Exit(lockObj);
}
}
else
{
LogUtil.error(Name + " StartCheckFixture " + "失败,未得到锁");
}
}
private void MO_14_TopCylinder_Down()
{
// SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
OutLog("放托盘(放开阻挡)" + MoveInfo.SLog + " 物品已移走,顶升气缸1下降");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_TopDown);
if (Config.SidesWayNum <= 0)
{
if (!CylinderIsOk(IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down))
{
CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
}
else
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_Stop2Down);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,阻挡2下降");
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
}
}
else
{
SecondMoveInfo.EndMove();
CheckLog("托盘放行 结束,触发 TrayPEndEvent ");
lastStopDown = DateTime.Now.AddSeconds(-1);
this.TrayPEndEvent?.Invoke(Config.SidesWayNum, currTrayNum);
}
}
private InOutParam CheckIsNeedOutStore(out string outMsg)
{
outMsg = "";
int lineNum = DeviceID % 100;
TrayInfo trayInfo = TrayManager.GetTrayInfo(currTrayNum);
if (!trayInfo.IsFull)
{
return null;
}
TimeSpan span = DateTime.Now - trayInfo.LastUpdateTime;
int youxianS = 180;
InOutParam inoup = trayInfo.InoutPar;
if (trayInfo.IsFull && trayInfo.InoutPar.InStoreNg && this.Config.SidesWayNum.Equals(4))
{
outMsg = "入料NG料";
//如果分配了库位,需要调用取消
if (trayInfo.InoutPar.WareCode != "" && trayInfo.InoutPar.PosId != "")
{
SServerManager.cancelPutInTask(Name, trayInfo.InoutPar.WareCode);
}
//入料失败料
return inoup;
}
else if (trayInfo.InOrOutStore.Equals(ReelType.OutStore) && inoup.urgentReel && this.Config.SidesWayNum.Equals(4))
{
outMsg = "出库紧急料";
return inoup;
}
else if (trayInfo.InOrOutStore.Equals(ReelType.OutStore) && inoup.urgentReel.Equals(false) && inoup.cutReel.Equals(false))
{
List<int> mustLine = new List<int>();
List<int> firstLine = new List<int>();
//urgentReel: true 表示紧急料,需要出到料串上
//cutReel: true 表示分盘料,需要出到料串上
//smallReel: true 小料(7x8),放置到小料架上
//rfid: 分配的料架RFID
//rfidLoc:
//是否是小盘
if (inoup.rfidLoc <= 0)
{
//-1时随意放
}
else if (inoup.smallReel)
{
if (inoup.rfidLoc >= 70 && inoup.rfidLoc <= 72)
{
// 70,71,72时只能分配到3 / 4号皮带线;
mustLine = new List<int> { 3, 4 };
}
else if (inoup.rfidLoc <= 46)
{
// 小料时,架位为1 - 46优先走1 / 2号皮带线
firstLine = new List<int> { 1, 2 };
}
else if (inoup.rfidLoc >= 47)
{
// ,47 - 92优先走3 / 4号皮带线,
firstLine = new List<int> { 3, 4 };
}
}
else
{
//大料12号只能走1号2后皮带线
// 料架的架位大料时,架位1 - 6,12号优先走1 / 2号皮带线,
//7 - 11优先走3 / 4号皮带线
if (inoup.Equals(12))
{
// 大料12号只能走1号2后皮带线
mustLine = new List<int> { 1, 2 };
}
else if (inoup.rfidLoc <= 6)
{
firstLine = new List<int> { 1, 2 };
}
else if (inoup.rfidLoc >= 7)
{
firstLine = new List<int> { 3, 4 };
}
}
bool kongxian = MoveInfo.MoveType.Equals(LineMoveType.None) || MoveInfo.MoveStep >= LineMoveStep.PO_08_CylinderRelax;
if (mustLine.Count > 0)
{
if (mustLine.Contains(lineNum))
{
outMsg = "必须线";
return inoup;
}
}
else if (firstLine.Count > 0)
{
if (firstLine.Contains(lineNum) && kongxian)
{
outMsg = "优先线且空闲";
return inoup;
}
else if (LineManager.Line.ProvidingCanUse(firstLine).Equals(false) && kongxian && LineNotBusy())
{
outMsg = "优先线不可用";
//优先线不可用
return inoup;
}
else if (span.TotalSeconds > youxianS && kongxian && LineNotBusy())
{
outMsg = "超过180秒";
//超过指定的时间
return inoup;
}
else if (span.TotalSeconds > youxianS * 3 && kongxian)
{
outMsg = "超过9分钟";
//超过指定的时间
return inoup;
}
}
else
{
//空闲且皮带线出料已结束
if (kongxian)
{
//随机分配
//Random r = new Random();
//int value = r.Next(1, 7) % 6;
//if (lineNum.Equals(1))
//{
// if ((value.Equals(0) || value.Equals(1)) || value.Equals(2) || value.Equals(3))
// {
// outMsg = "随意放" + value;
// return inoup;
// }
//}
//else if (lineNum.Equals(2))
//{
// if (value.Equals(3) || value.Equals(4) || value.Equals(5))
// {
// outMsg = "随意放" + value;
// return inoup;
// }
//}
if (lineNum.Equals(1) || lineNum.Equals(2))
{
if (LastValue.Equals(0))
{
outMsg = "随意放" + LastValue;
LastValue = 1;
return inoup;
}
else
{
LastValue = 0;
}
}
else
{
outMsg = "随意放";
return inoup;
}
}
}
}
//TODO 判断是否是需要移栽出料的料盘
return null;
}
private int LastValue = 0;
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))
{
TimeSpan span = DateTime.Now - SecondMoveInfo.LastSetpTime;
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_04_Wait);
LogUtil.debug(Name + "托盘阻挡" + SecondMoveInfo.SLog + " 阻挡气缸上升,下降耗时(" + FormUtil.GetSpanStr(span) + "),等待 阻挡2托盘检测=1)");
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 + " 再次检测料盘信号");
// //CheckLog("托盘阻挡" + SecondMoveInfo.SLog + " 等待" + TrayManager.SwTrayWaitTime + ",再次检测料盘信号");
//// IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check2, IO_VALUE.HIGH));
// if (Config.SidesWayNum.Equals(4))
// {
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(400));
// }
// }
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_03_Stop2Down))
{
CheckLog("托盘阻挡" + SecondMoveInfo.SLog + " ,等待编码信号稳定StopCylinder_Check2=1");
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_04_Wait);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check2, IO_VALUE.HIGH));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_04_Wait))
{
UpdateTrayNum();
if (Config.SidesWayNum.Equals(4))
{
CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
}
if (TrayManager.RightTrayCode(currTrayNum, preTrayNum, false))
{
if (TrayManager.ErrorDeviceId.Equals(DeviceID))
{
TrayManager.UpdateTrayNumError(-1, "");
}
//出料中,需要拦盘
string outMsg = "";
InOutParam param = CheckIsNeedOutStore(out outMsg);
if (param != null)
{
SecondMoveInfo.MoveParam = param;
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_05_WaitTime);
LogUtil.info(Name + "托盘 【" + currTrayNum + "】【" + outMsg + "】需要出料" + SecondMoveInfo.SLog + ":" + param.ToStr() + " 等待可以开始移栽 ");
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitProvidingEquipCanOut());
//等待
CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
if (Config.SidesWayNum.Equals(4) && LineManager.Line.SwCanUpMove(1))
{
CheckLog("托盘阻挡 " + SecondMoveInfo.SLog + " 顶升气缸上升,同时横移1处的顶升也可以上升 ");
LineManager.Line.CylinderMove(null, IO_Type.SW1_TopCylinder_Down, IO_Type.SW1_TopCylinder_Up);
}
else
{
CheckLog("托盘阻挡 " + SecondMoveInfo.SLog + " 顶升气缸上升 ");
}
return;
}
else
{
// SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_TopDown);
CheckLog("放托盘(放开阻挡)" + MoveInfo.SLog + " 托盘 【" + currTrayNum + "】直接放行,判断顶升需要下降或上升");
if (Config.SidesWayNum <= 0)
{
CylinderMove(SecondMoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
}
else if (Config.SidesWayNum.Equals(4))
{
CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
if (LineManager.Line.SwCanUpMove(1))
{
LineManager.Line.CylinderMove(null, IO_Type.SW1_TopCylinder_Down, IO_Type.SW1_TopCylinder_Up);
}
SecondMoveInfo.EndMove();
CheckLog("托盘放行 结束,触发 TrayPEndEvent ");
lastStopDown = DateTime.Now.AddSeconds(-1);
this.TrayPEndEvent?.Invoke(Config.SidesWayNum, currTrayNum);
}
}
}
else
{
string msg = Name + " 托盘顺序错乱,上个托盘号【" + preTrayNum + "】当前托盘号 【" + currTrayNum + "】最大盘号【" + TrayManager.MaxTrayNum + "】";
TrayManager.UpdateTrayNumError(DeviceID, msg);
LogUtil.error(msg);
return;
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_05_WaitTime) && MoveInfo.MoveType.Equals(LineMoveType.None))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_09_WaitLetFixtureGo);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + "开始新的出料任务~" + SecondMoveInfo.MoveParam.ToStr() + ",开始移栽");
bool result = StartOutStoreMove(SecondMoveInfo.MoveParam);
CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
if (Config.SidesWayNum.Equals(4) && LineManager.Line.SwCanUpMove(1))
{
CheckLog("托盘阻挡 " + SecondMoveInfo.SLog + " 顶升气缸上升,同时横移1处的顶升也可以上升 ");
LineManager.Line.CylinderMove(null, IO_Type.SW1_TopCylinder_Down, IO_Type.SW1_TopCylinder_Up);
}
else
{
CheckLog("托盘阻挡 " + SecondMoveInfo.SLog + " 顶升气缸上升 ");
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_06_TopUp))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_11_CodeRember);
LogInfo(SecondMoveInfo.MoveNum + " 托盘号【" + currTrayNum + "】等待移栽料盘");
SecondMoveInfo.EndStepWait();
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_11_CodeRember) && MoveInfo.MoveType.Equals(LineMoveType.None))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_09_WaitLetFixtureGo);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + "开始新的出料任务~" + SecondMoveInfo.MoveParam.ToStr() + ",开始移栽");
bool result = StartOutStoreMove(SecondMoveInfo.MoveParam);
}
#endregion
#region 不需要出出料,直接放行
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_14_TopDown))
{
if (Config.SidesWayNum > 0)
{
SecondMoveInfo.EndMove();
CheckLog("托盘放行 结束,触发 TrayPEndEvent ");
// lastStopDown = DateTime.Now.AddSeconds(-1);
this.TrayPEndEvent?.Invoke(Config.SidesWayNum, currTrayNum);
}
else
{
// lastStopDown = DateTime.Now.AddSeconds(1);
//SecondMoveInfo.NextMoveStep(LineMoveStep.MO_15_WaitCanGo);
//CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,等待 NextStopCheck=0");
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.NextStopCheck, IO_VALUE.LOW));
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_Stop2Down);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,阻挡2下降");
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_15_WaitCanGo))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_Stop2Down);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,阻挡2下降");
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_16_Stop2Down))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_17_Stop2Check);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " , 阻挡2托盘检测=0");
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_WaitTime);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " , 等待200ms后阻挡2上升");
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Check2, IO_VALUE.LOW));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_18_WaitTime))
{
trayCheck2LowWait.Restart();
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_19_StopCylinder_Back);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " , 阻挡气缸2上升 ");
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.LOW));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_19_StopCylinder_Back))
{
CheckLog("托盘放行 结束,触发 TrayPEndEvent ");
SecondMoveInfo.EndMove();
//lastStopDown = DateTime.Now.AddSeconds(-1);
this.TrayPEndEvent?.Invoke(Config.SidesWayNum, currTrayNum);
}
#endregion
}
#endregion
#region 料盘移栽处理
public override bool StartOutStoreMove(InOutParam param)
{
string posId = param != null ? param.PosId : "";
if (runStatus.Equals(LineRunStatus.Runing))
{
runStatus = LineRunStatus.Busy;
lineStatus = LineStatus.OutStoreExecute;
MoveInfo.MoveParam = param;
MoveInfo.NewMove(LineMoveType.OutStore);
if (CylinderIsOk(IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After))
{
PO_01_CylinderDown();
}
else
{
LogInfo("开始出料【" + posId + "】处理(移栽):PO_00_CylinderAfter, 前后气缸后退");
MoveInfo.NextMoveStep(LineMoveStep.PO_00_CylinderAfter);
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;
}
}
private void PO_01_CylinderDown()
{
MoveInfo.NextMoveStep(LineMoveStep.PO_01_CylinderDown);
OutLog(" " + MoveInfo.SLog + " : 上下气缸下降");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
UpdownDownP2Move(MoveInfo.MoveParam.PlateH, MoveInfo.MoveParam.PlateW);
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
if (Config.SidesWayNum.Equals(4) && LineManager.Line.SwCanUpMove(1))
{
OutLog(" 顶升气缸上升,同时横移1处的顶升也可以上升 ");
LineManager.Line.CylinderMove(null, IO_Type.SW1_TopCylinder_Down, IO_Type.SW1_TopCylinder_Up);
}
else
{
OutLog(" 顶升气缸上升 ");
}
}
protected override void OutStoreProcess()
{
if (MoveInfo.IsInWait)
{
CheckWait(MoveInfo);
}
if (MoveInfo.IsInWait)
{
return;
}
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosId : "";
if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_00_CylinderAfter))
{
PO_01_CylinderDown();
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_01_CylinderDown))
{
MoveInfo.NextMoveStep(LineMoveStep.PO_02_DownWait);
OutLog("出料 " + MoveInfo.SLog + " : 等待200后夹紧");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
}
//只有当BOX可以进行出出料时,移栽物品,防止卡住
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_02_DownWait))
{
int lineId = DeviceID % 100;
MoveInfo.NextMoveStep(LineMoveStep.PO_03_CylinderOpen);
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
if (MoveInfo.MoveParam.InStoreNg)
{
LogInfo("出料 【" + posId + "】" + MoveInfo.SLog + " : 夹料气缸夹紧,入料NG料,不更新料盘位置");
}
else
{
LogInfo("出料 【" + posId + "】" + MoveInfo.SLog + " : 夹料气缸夹紧,更新料盘位置【" + MoveInfo.MoveParam.WareCode + "】【INBELT】【" + lineId + "】");
//更新料盘位置
SServerManager.UpdateTrayLoc(Name, MoveInfo.MoveParam.WareCode, LocStatus.INBELT, lineId.ToString());
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_03_CylinderOpen))
{
MoveInfo.NextMoveStep(LineMoveStep.PO_04_CylinderUp);
OutLog("出料 " + MoveInfo.SLog + " : 上下气缸上升,皮带线准备出料");
UpdownUpMove();
StartLineOut(MoveInfo.MoveParam);
if (MoveInfo.MoveParam.PlateW.Equals(7))
{
MO_14_TopCylinder_Down();
}
else if (Config.SidesWayNum <= 0)
{
CylinderMove(null, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_04_CylinderUp))
{
int num = MoveInfo.MoveParam.TrayNumber;
MoveInfo.NextMoveStep(LineMoveStep.PO_05_WaitBox);
LogInfo("出料 【" + posId + "】" + MoveInfo.SLog + " 更新托盘【" + num + "】为空");
// MoveInfo.WaitList.Add(WaitResultInfo.WaitProvidingEquipCanOut());
TrayManager.UpdateTrayInfo(num);
if (SecondMoveInfo.MoveType.Equals(LineMoveType.None).Equals(false) && SecondMoveInfo.MoveStep < LineMoveStep.MO_14_TopDown)
{
//阻挡气缸移动
MO_14_TopCylinder_Down();
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_05_WaitBox))
{
MoveInfo.NextMoveStep(LineMoveStep.PO_06_CylinderBefore);
OutLog("出料:" + MoveInfo.SLog + " ,前后气缸前进)");
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_06_CylinderBefore))
{
if (CylinderIsOk(IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before))
{
if (LineIsReady())
{
//气缸不下降,直接扔料
//MoveInfo.NextMoveStep(LineMoveStep.PO_07_CylinderDown);
//OutLog("出料:" + MoveInfo.SLog + " ,上下气缸下降)");
//UpdownDownP3Move(MoveInfo.MoveParam.PlateH);
MoveInfo.NextMoveStep(LineMoveStep.PO_08_CylinderRelax);
OutLog("出料:" + MoveInfo.SLog + ",夹料气缸放松)");
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
if (MoveInfo.MoveParam.urgentReel && this.Config.SidesWayNum.Equals(4))
{
Task.Factory.StartNew(delegate
{
OutLog("出料:" + MoveInfo.SLog + ",紧急料,且SidesWayNum=4,发送 afterPutCut");
TaskData taskData;
string shefId = "BN";
int ShelfLoc = 1;
string msg = SServerManager.afterPutCut(Name, shefId, MoveInfo.MoveParam.WareCode, "", ShelfLoc, out taskData);
if (String.IsNullOrEmpty(msg).Equals(false))
{
LogUtil.error(Name + "【" + MoveInfo.MoveParam.WareCode + "】【" + shefId + "】【" + ShelfLoc.ToString() + "】afterPutCut 结果:" + msg);
taskData = null;
}
});
}
}
else if (MoveInfo.IsTimeOut())
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "]等待 皮带线可放料 " + "超时[" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, DeviceID * 1000 + 20);
Alarm(LineAlarmType.IoSingleTimeOut);
}
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.PO_06_CylinderBefore);
OutLog("出料:" + MoveInfo.SLog + " ,前后气缸前进)");
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
}
}
//else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_07_CylinderDown))
//{
// MoveInfo.NextMoveStep(LineMoveStep.PO_08_CylinderRelax);
// OutLog("出料:" + MoveInfo.SLog + ",夹料气缸放松)");
// CylinderMove(MoveInfo, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
//}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_08_CylinderRelax))
{
// MoveInfo.NextMoveStep(LineMoveStep.PO_09_CylinderUp);
// OutLog("出料:" + MoveInfo.SLog + ",上下气缸上升)");
// UpdownUpMove();
//}
//else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_09_CylinderUp))
//{
MoveInfo.NextMoveStep(LineMoveStep.PO_10_CylinderAfter);
OutLog("出料:" + MoveInfo.SLog + ",前后气缸后退,等待200 ,皮带线继续运动");
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
//出料皮带线停止出料
DisLineContiune();
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.PO_10_CylinderAfter))
{
OutLog("出料【" + posId + "】处理完成!");
MoveEndS();
}
}
private OutTrayLineBean GetDisLine()
{
try
{
int id = DeviceID % 100;
if (id.Equals(1))
{
return LineManager.Line.DisLineMap[301].TrayLine1;
}
else if (id.Equals(2))
{
return LineManager.Line.DisLineMap[301].TrayLine2;
}
else if (id.Equals(3))
{
return LineManager.Line.DisLineMap[302].TrayLine1;
}
else if (id.Equals(4))
{
return LineManager.Line.DisLineMap[302].TrayLine2;
}
}
catch (Exception ex)
{
LogUtil.error(Name, ex);
}
return null;
}
private void DisLineContiune()
{
OutTrayLineBean outline = GetDisLine();
if (outline != null)
{
if (outline.equipBean.runStatus <= LineRunStatus.Wait)
{
return;
}
outline.MoveInfo.NextMoveStep(LineMoveStep.DLO_05_TrayIsOk);
LogUtil.info(Name + "放料到皮带线完成," + outline.MoveInfo.Name + " " + outline.MoveInfo.SLog);
}
else
{
LogUtil.error(Name + "DisLineContiune()未找到对应的皮带线");
}
}
private bool LineIsReady()
{
OutTrayLineBean outline = GetDisLine();
if (outline != null)
{
if (outline.equipBean.runStatus <= LineRunStatus.Wait)
{
return true;
}
else if (outline.MoveInfo.MoveStep.Equals(LineMoveStep.DLO_04_CanReviceTray))
{
return true;
}
else if (outline.MoveInfo.MoveType.Equals(LineMoveType.None))
{
outline.StartOut(MoveInfo.MoveParam);
}
}
else
{
LogUtil.error(Name + "LineIsReady()未找到对应的皮带线");
}
return false;
}
private void StartLineOut(InOutParam param)
{
OutTrayLineBean outline = GetDisLine();
if (outline != null)
{
if (outline.equipBean.runStatus <= LineRunStatus.Wait)
{
return;
}
outline.StartOut(param);
}
else
{
LogUtil.error(Name + "StartLineOut未找到对应的皮带线");
}
}
private bool LineNotBusy()
{
OutTrayLineBean outline = GetDisLine();
if (outline != null)
{
if (outline.equipBean.MoveInfo.MoveType.Equals(LineMoveType.None))
{
return true;
}
}
else
{
LogUtil.error(Name + "StartLineOut未找到对应的皮带线");
}
return false;
}
#endregion
}
}