FeedingEquip_InStore.cs
51.1 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
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
partial class FeedingEquip
{
protected override bool CheckWaitResult(LineMoveInfo moveInfo, WaitResultInfo wait)
{
if (wait.WaitType.Equals(WaitEnum.W101_BatchAxisMove))
{
//等待信号亮或者走到绝对位置才停止
if (IOValue(TargetIoType).Equals(TargetIoValue))
{
LogInfo("CheckWaitResult 检测到" + TargetIoType + "=" + TargetIoValue + ",停止运行");
BatchAxis.SuddenStop();
BatchAxisStopCheck();
return true;
}
else
{
bool isOk = ACServerManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(0);
if (isOk)
{
//TODO 判断是否达到高度,如果未达到,继续上升
BatchAxisStopCheck();
return true;
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W102_FeedScanCode))
{
if (LastCodeList.Count > 0)
{
return true;
}
}
return false;
}
public event TrayProcessEnd TrayPEndEvent;
#region 托盘检测
private InOutParam CheckParam = new InOutParam();
private DateTime lastStopDown = DateTime.Now;
private Stopwatch swWaitWatch = new Stopwatch();
private void StartCheckFixture()
{
if (!LineManager.Line.CanProcessLine())
{
swWaitWatch.Stop();
return;
}
if (Config.SidesWayNum > 0)
{
bool canProcess = (LineManager.Line.SwNoProcess(Config.SidesWayNum));
if (IOValue(IO_Type.SW_TrayCheck).Equals(IO_VALUE.HIGH) && canProcess)
{
if (TrayManager.checkWatch(swWaitWatch, TrayManager.SwTrayWaitTime, true))
{
UpdateTrayNum();
//判断是否是需要的托盘
if (CurrTrayIsNeed(currTrayNum, true))
{
SecondMoveInfo.NewMove(LineMoveType.CheckFixture, CheckParam);
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_06_TopCylinderUp);
CheckLog("检测到SW_TrayCheck:" + SecondMoveInfo.SLog + "横移顶升气缸上升 )");
CylinderMove(SecondMoveInfo, IO_Type.SW_TopCylinder_Down, IO_Type.SW_TopCylinder_Up);
}
else
{
SMoveEnd();
}
}
}
else if (Config.SidesWayNum.Equals(2) && IOValue(IO_Type.SW_StopCheck).Equals(IO_VALUE.HIGH) && canProcess
&& (DateTime.Now - lastStopDown).TotalSeconds > 4)
{
if (TrayManager.checkWatch(swWaitWatch, TrayManager.SwTrayWaitTime, true))
{
SecondMoveInfo.NewMove(LineMoveType.CheckFixture, CheckParam);
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_00_StopCylinder1Down);
CheckLog("检测到SW_StopCheck:" + SecondMoveInfo.SLog + "阻挡气缸下降 ,等待" + TrayManager.StopDownWaitTime);
IOMove(IO_Type.SW_StopDown, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.StopDownWaitTime));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW_StopDown, IO_VALUE.HIGH));
lastStopDown = DateTime.Now;
//IOMove(IO_Type.SW_StopDown, IO_VALUE.HIGH, TrayManager.StopDownWaitTime);
}
}
else
{
swWaitWatch.Stop();
}
}
else
{
//托盘在两个阻挡内
if (IOValue(IO_Type.FL_TrayCheck).Equals(IO_VALUE.HIGH))
{
if (TrayManager.checkWatch(swWaitWatch, TrayManager.SwTrayWaitTime, true))
{
SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
CheckLog("检测到FL_TrayCheck:" + SecondMoveInfo.SLog + " FL阻挡1上升)");
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_StopCylinder2Down);
IOMove(IO_Type.FL_StopCylinder_Down1, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.FL_StopCylinder_Down1, IO_VALUE.LOW));
}
}
else if (IOValue(IO_Type.FL_StopCheck).Equals(IO_VALUE.HIGH))
{
if (TrayManager.checkWatch(swWaitWatch, TrayManager.SwTrayWaitTime, true))
{
//托盘在第一个阻挡处
SecondMoveInfo.NewMove(LineMoveType.CheckFixture);
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_00_StopCylinder1Down);
CheckLog(" 检测到FL_StopCheck:" + SecondMoveInfo.SLog + " FL阻挡1下降 ,等待 "+ TrayManager.StopDownWaitTime);
IOMove(IO_Type.FL_StopCylinder_Down1, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.FL_StopCylinder_Down1, IO_VALUE.HIGH));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.StopDownWaitTime));
}
}
else
{
swWaitWatch.Stop();
}
}
}
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_StopCylinder1Down))
{
if (Config.SidesWayNum <= 0)
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_StopCylinder2Down);
CheckLog("托盘检测:" + SecondMoveInfo.SLog + "阻挡1上升,等待FL_TrayCheck=1)");
IOMove(IO_Type.FL_StopCylinder_Down1, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.FL_StopCylinder_Down1, IO_VALUE.LOW));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.FL_TrayCheck, IO_VALUE.HIGH));
}
else
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_01_FixtureCheck);
CheckLog("托盘检测:" + SecondMoveInfo.SLog + "阻挡气缸上升,等待SW_TrayCheck=1)");
IOMove(IO_Type.SW_StopDown, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW_TrayCheck, IO_VALUE.HIGH));
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_01_FixtureCheck))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_02_WaitFixture);
CheckLog("托盘检测:" + SecondMoveInfo.SLog + "再次等待SW_TrayCheck=1并需要持续:" + TrayManager.SwTrayWaitTime);
CheckAndMove(IO_Type.SW_StopDown, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW_TrayCheck, IO_VALUE.HIGH));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.SwTrayWaitTime));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_02_WaitFixture))
{
if (IOValue(IO_Type.SW_TrayCheck).Equals(IO_VALUE.HIGH))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_03_StopCylinder2Down);
CheckLog("托盘检测:" + SecondMoveInfo.SLog + "阻挡气缸上升,等待SW_TrayCheck=1)");
IOMove(IO_Type.SW_StopDown, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW_TrayCheck, IO_VALUE.HIGH));
}
else
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_02_WaitFixture);
CheckLog("托盘检测:" + SecondMoveInfo.SLog + "再次等待SW_TrayCheck=1并需要持续:" + TrayManager.SwTrayWaitTime);
IOMove(IO_Type.SW_StopDown, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW_TrayCheck, IO_VALUE.HIGH));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.SwTrayWaitTime));
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_03_StopCylinder2Down))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_04_Wait);
CheckLog("托盘检测:" + SecondMoveInfo.SLog + " ,等待编码信号稳定)");
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_04_Wait))
{
//preTrayNum = currTrayNum;
//currTrayNum = TrayManager.GetTrayNum(DeviceID);
UpdateTrayNum();
//出料中,需要拦盘
if (CurrTrayIsNeed(currTrayNum, true))
{
SecondMoveInfo.MoveParam = CheckParam;
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_06_TopCylinderUp);
if (Config.SidesWayNum <= 0)
{
CheckLog("托盘检测: " + SecondMoveInfo.SLog + " 顶升气缸上 升 )");
CylinderMove(SecondMoveInfo, IO_Type.FL_TopCylinder_Down, IO_Type.FL_TopCylinder_Up);
}
else
{
CheckLog("托盘检测:" + SecondMoveInfo.SLog + " 需要此托盘,横移顶升气缸上 升 )");
CylinderMove(SecondMoveInfo, IO_Type.SW_TopCylinder_Down, IO_Type.SW_TopCylinder_Up);
}
}
else
{
if (Config.SidesWayNum <= 0)
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_15_WaitCanGo);
TrayInfo tray = TrayManager.GetTrayInfo(currTrayNum);
LogInfo(SecondMoveInfo.MoveNum + "***************上个托盘号【" + preTrayNum + "】,当前 【" + tray.ToStr() + "】没有出入料任务,放盘通过~");
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,移栽2,需要判断是否可以放盘通过,最多等待10000)");
}
else
{
CheckLog("托盘检测:不需要次托盘,结束处理 )");
SMoveEnd();
}
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_06_TopCylinderUp))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_07_LocationCylinderUp);
CheckLog("托盘检测: " + SecondMoveInfo.SLog + " , 定位气缸上升 )");
if (Config.SidesWayNum > 0)
{
CylinderMove(SecondMoveInfo, IO_Type.SW_LocationCylinder_Down, IO_Type.SW_LocationCylinder_Up);
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MIO_07_LocationCylinderUp))
{
CheckLog("托盘阻挡*************** 托盘号【" + currTrayNum + "】");
//判断盘是空盘,空盘并且编号正确才需要放料盘过去
if (MoveInfo.MoveType.Equals(LineMoveType.InStore))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_11_CodeRember);
LogInfo(SecondMoveInfo.MoveNum + SecondMoveInfo.SLog + "*************** 托盘号【" + currTrayNum + "】 ,需要入料,移栽料盘");
SecondMoveInfo.EndStepWait();
}
else
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_200_WaitInoutParam);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitFeedNoMove());
LogInfo(SecondMoveInfo.MoveNum + SecondMoveInfo.SLog + " ,托盘号【" + currTrayNum + "】需要出库,等待开始出库");
}
}
#endregion
#region 不需要托盘或移栽入库料盘完成
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_12_MoveOk))
{
if (Config.SidesWayNum > 0)
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_13_LoactionCylinder_Down);
SInLog("托盘放行, " + SecondMoveInfo.SLog + " 托盘开始放行,环形线定位气缸下降");
CylinderMove(SecondMoveInfo, IO_Type.SW_LocationCylinder_Up, IO_Type.SW_LocationCylinder_Down);
}
else
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_TopCylinder_Down);
CheckLog("托盘放行, " + SecondMoveInfo.SLog + " , 顶升气缸下降)");
CylinderMove(SecondMoveInfo, IO_Type.FL_TopCylinder_Up, IO_Type.FL_TopCylinder_Down);
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_13_LoactionCylinder_Down))
{
if (Config.SidesWayNum.Equals(2))
{
//preTrayNum = currTrayNum;
CheckLog("托盘放行: 此处为环形线横移2,顶升气缸不需要下降, (托盘放行结束) ");
SMoveEnd();
}
else
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_TopCylinder_Down);
CheckLog("托盘放行, " + SecondMoveInfo.SLog + " ,环形线顶升气缸下降)");
CylinderMove(SecondMoveInfo, IO_Type.SW_TopCylinder_Up, IO_Type.SW_TopCylinder_Down);
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_14_TopCylinder_Down))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_15_WaitCanGo);
if (Config.SidesWayNum > 0)
{
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,等待托盘离开");
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW_TrayCheck, IO_VALUE.LOW));
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_15_WaitCanGo))
{
if (Config.SidesWayNum > 0)
{
CheckLog("托盘放行 SecondStoreMove:(托盘放行结束) ");
SMoveEnd();
}
else
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_StopCylinder2_Down);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,阻挡气缸1-2下降,等待"+TrayManager.StopDownWaitTime);
IOMove(IO_Type.FL_StopCylinder_Down2, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.FL_StopCylinder_Down2, IO_VALUE.HIGH));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.StopDownWaitTime));
}
// SecondMoveInfo.EndStepWait();
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_16_StopCylinder2_Down))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_17_Tray_Check);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,上升阻挡气缸2, 等待托盘离开");
IOMove(IO_Type.FL_StopCylinder_Down2, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.FL_StopCylinder_Down2, IO_VALUE.LOW));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_17_Tray_Check))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_18_StopCylinder_Back);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,等待托盘离开 )");
//IOMove(IO_Type.FL_StopCylinder_Down2, IO_VALUE.LOW);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.FL_TrayCheck, IO_VALUE.LOW));
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_18_StopCylinder_Back))
{
//preTrayNum = currTrayNum;
CheckLog("托盘放行 SecondStoreMove:(托盘放行结束) ");
SMoveEnd();
}
#endregion
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_200_WaitInoutParam))
{
if (MoveInfo.MoveType.Equals(LineMoveType.None) && StartTrayOut(SecondMoveInfo.MoveParam))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_201_WaitOutEnd);
}
else
{
TimeSpan span = DateTime.Now - MoveInfo.LastSetpTime;
if (span.TotalSeconds > 180)
{
WarnMsg = SecondMoveInfo.Name + "[" + SecondMoveInfo.MoveType + "][" + SecondMoveInfo.MoveStep + "]等待横移机构空闲可出库超时[" + Math.Round(span.TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, DeviceID + 11);
Alarm(LineAlarmType.IoSingleTimeOut);
}
}
}
}
private void SMoveEnd()
{
lastStopDown = DateTime.Now.AddSeconds(-2);
SecondMoveInfo.EndMove();
this.TrayPEndEvent?.Invoke(Config.SidesWayNum, currTrayNum);
}
#endregion
#region 入料流程
private bool StartInStoreP()
{
//若定位工位,阻挡工位,有 料架,需要进行处理
if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.SL_Stop_Check).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.SL_Entry_Check).Equals(IO_VALUE.HIGH))
{
StartInStoreMove(null);
}
else if (IOValue(IO_Type.SL_Entry_Check).Equals(IO_VALUE.HIGH))
{
//小车到达,开始处理
if (runStatus >= (LineRunStatus.Runing) &&
MoveInfo.MoveType.Equals(LineMoveType.None) &&
ProcessShelfEnter.Equals(false) &&
IOValue(IO_Type.SL_Stop_Check).Equals(IO_VALUE.LOW))
{
ShelfEnterProcess();
}
}
else if (IOValue(IO_Type.SL_Out_Check).Equals(IO_VALUE.HIGH))
{
//线体出口检测到料架,需要通知AGV小车
AgvClient.ReadyEmpty(Config.AgvOutName);
// SendShelfToAGV();
}
return false;
}
public override bool StartInStoreMove(InOutParam param)
{
runStatus = LineRunStatus.Busy;
lineStatus = LineStatus.InStoreExecute;
MoveInfo.NewMove(LineMoveType.InStore);
MoveInfo.MoveParam = new InOutParam();
//判断是哪个工位有料架
if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.HIGH))
{
FI_04_WaitTime();
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.FI_01_TrayLocation_After);
TrayLCylinderAfter(MoveInfo);
InLog("检测到料架, "+MoveInfo.MoveStep+" :升降盘定位气缸下降");
}
return true ;
}
private void FI_04_WaitTime()
{
//定位工位有料架,等待1秒后再次检测
MoveInfo.NextMoveStep(LineMoveStep.FI_04_WaitTime);
InLog("定位工位检测到料架: " + MoveInfo.SLog + ",进料阻挡上升,缓冲阻挡上升, 等待1秒再次检测");
IOMove(IO_Type.SL_Entry_StopDown, IO_VALUE.LOW);
IOMove(IO_Type.SL_Buffer_StopDown, IO_VALUE.LOW);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
private void LineInStoreProcess()
{
IOMove(IO_Type.SL_Line_Run, IO_VALUE.LOW);
//判断是哪个工位有料架
if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.HIGH))
{
FI_04_WaitTime();
}
//阻挡工位有料架,流水线转动一个工位
else if (IOValue(IO_Type.SL_Stop_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_03_LineStart);
InLog("入料检测: " + MoveInfo.SLog + " 阻挡工位检测有料架,进料阻挡下降,缓冲阻挡下降,流水线转动 1000");
IOMove(IO_Type.SL_Entry_StopDown, IO_VALUE.HIGH);//进料阻挡下降
IOMove(IO_Type.SL_Buffer_StopDown, IO_VALUE.LOW);//缓冲阻挡下降
IOMove(IO_Type.SL_Line_Run, IO_VALUE.HIGH);
//等待指定时间
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_Location_Check, IO_VALUE.HIGH));
} else if (IOValue(IO_Type.SL_Entry_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_03_LineStart);
InLog("入料检测: " + MoveInfo.SLog + " 进料口检测有料架,进料阻挡上升,缓冲阻挡上升,流水线转动 1000");
IOMove(IO_Type.SL_Entry_StopDown, IO_VALUE.LOW);//进料阻挡上升
IOMove(IO_Type.SL_Buffer_StopDown, IO_VALUE.HIGH);//缓冲阻挡上升
IOMove(IO_Type.SL_Line_Run, IO_VALUE.HIGH);
//等待指定时间
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_Stop_Check, IO_VALUE.HIGH));
}
else
{
MoveInfo.EndMove();
runStatus = LineRunStatus.Runing;
LogUtil.info(" 未检测到料架,入料结束");
}
}
protected override void InStoreProcess()
{
if (MoveInfo.IsInWait)
{
CheckWait(MoveInfo);
}
if (MoveInfo.IsInWait)
{
return;
}
#region 入料:料架进入并开始检测托盘
if (MoveInfo.MoveStep.Equals(LineMoveStep.Wait))
{
//MoveInfo.NextMoveStep(LineMoveStep.FI_01_TrayLocation_After);
//InLog("料架入库" + MoveInfo.SLog + " :升降盘定位气缸下降");
//TrayLCylinderAfter(MoveInfo);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_01_TrayLocation_After))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_02_LocationCylinder_Down);
InLog("料架入库" + MoveInfo.SLog + ":定位气缸下降,提升伺服移动到P1");
CylinderMove(MoveInfo, IO_Type.SL_LocationCylinder_Up, IO_Type.SL_LocationCylinder_Down);
BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP1, Config.BatchAxis_P1Speed);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_02_LocationCylinder_Down))
{
LineInStoreProcess();
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_03_LineStart))
{
LineInStoreProcess();
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_04_WaitTime))
{
if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.ShelfNoTray = false;
//定位工位有料架,直接开始入料
MoveInfo.NextMoveStep(LineMoveStep.FI_07_LocationCylinder_Up);
InLog("定位工位检测到料架: " + MoveInfo.SLog + " 缓冲阻挡上升, 定位气缸上升,读取料架号");
IOMove(IO_Type.SL_Buffer_StopDown, IO_VALUE.LOW);//缓冲阻挡下降
CylinderMove(MoveInfo, IO_Type.SL_LocationCylinder_Down, IO_Type.SW4_LocationCylinder_Up);
UpdateShelfId();
}
else
{
MoveInfo.EndMove();
runStatus = LineRunStatus.Runing;
InLog(" 未检测到料架,入料结束");
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_05_WaitS))
{
//定位工位有料架,直接开始入料
MoveInfo.NextMoveStep(LineMoveStep.FI_07_LocationCylinder_Up);
InLog("定位工位检测到料架: " + MoveInfo.SLog + " 缓冲阻挡上升, 定位气缸上升");
IOMove(IO_Type.SL_Buffer_StopDown, IO_VALUE.LOW);//缓冲阻挡下降
CylinderMove(MoveInfo, IO_Type.SL_LocationCylinder_Down, IO_Type.SW4_LocationCylinder_Up);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_07_LocationCylinder_Up))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_08_BatchAxisToP2);
InLog("料架入库" + MoveInfo.SLog + ":提升轴下降到位P2,定位气缸上升");
IOMove(IO_Type.SL_Line_Run, IO_VALUE.LOW);
BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
CylinderMove(MoveInfo, IO_Type.SL_LocationCylinder_Down, IO_Type.SL_LocationCylinder_Up);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_08_BatchAxisToP2))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_09_TrayLocation_Before);
InLog("料架入库" + MoveInfo.SLog + ":升降盘定位气缸前进");
TrayLCylinderBefore(MoveInfo);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_09_TrayLocation_Before))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_10_AxisUpMove);
InLog("料架入库" + MoveInfo.SLog + ":上料轴开始慢速上升到P3点,等待检测到料盘");
MoveInfo.ShelfNoTray = false;
BatchAxisToP3();
}
#endregion
#region 检测到托盘,扫码,取料并放入托盘
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_10_AxisUpMove))
{
CheckHasTray();
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_11_MoveCylinder_Up))
{
FI_12_MoveCylinder_Give();
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_12_MoveCylinder_Give))
{
if (IOValue(IO_Type.SL_MoveCylinder_Give).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.SL_MoveCylinder_Take).Equals(IO_VALUE.LOW))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_13_ScanCode);
bool isScan = ConfigAppSettings.GetIntValue(Setting_Init.NeedScanCode).Equals(1);
InLog("料盘移栽" + MoveInfo.SLog + ":开始扫码:是否需要扫码【" + isScan + "】");
LastCodeList = new List<string>();
if (isScan)
{
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitFeedScanCode());
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(6000));
try
{
Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList());
if (LastCodeList.Count <= 0)
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList());
}
return LastCodeList;
});
}
catch (Exception ex)
{
LogUtil.error("FI_13_ScanCode扫码出错:" + ex.ToString());
}
}
}
else
{
FI_12_MoveCylinder_Give();
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_13_ScanCode))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_14_MoveCylinder_Take);
InLog("料盘移栽" + MoveInfo.SLog + ":上料横移取料端");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Give, IO_Type.SL_MoveCylinder_Take);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_14_MoveCylinder_Take))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_15_UpdownAxisToP3);
InLog("料盘移栽" + MoveInfo.SLog + ":升降轴到P3");
UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP3, Config.UpdownAxis_P3Speed);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_15_UpdownAxisToP3))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_16_MoveCylinder_Tighten);
InLog("料盘移栽" + MoveInfo.SLog + ":上料横移机构夹紧");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Slack, IO_Type.SL_MoveCylinder_Tighten);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_16_MoveCylinder_Tighten))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_17_UpdownAxisToP1);
InLog("料盘移栽" + MoveInfo.SLog + ":升降伺服到P1点");
UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_17_UpdownAxisToP1))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_17_BatchAxisToP3);
InLog("料盘移栽" + MoveInfo.SLog + ":提升伺服运动到P3,横移气缸上升");
CylinderMove(null, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
BatchAxisToP3();
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_17_BatchAxisToP3))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_18_SaveSize);
LastHeight = GetHeight();
LastWidth = GetWidth();
//判断是否还有料盘
if (IOValue(IO_Type.SL_AxisLocationCheck).Equals(IO_VALUE.LOW))
{
int currP = BatchAxis.GetAclPosition();
int chaz = Math.Abs(currP - Config.BatchAxisP3);
if (chaz < BatchAxis.Config.CanErrorCountMax)
{
InLog("料盘移栽" + MoveInfo.SLog + ":记录高度尺寸 高度【" + LastHeight + "】宽度【" + LastWidth + "】,已经没有料盘,且已达到P3:"+Config.BatchAxisP3+",提升轴开始回下降待机点P2");
MoveInfo.ShelfNoTray = true;
BatchAxis.AbsMove(null, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
}
else
{
InLog("料盘移栽" + MoveInfo.SLog + ":记录高度尺寸 高度【" + LastHeight + "】宽度【" + LastWidth + "】,此时未检测到料盘,上料轴位置【"+ currP + "】不在P3:" + Config.BatchAxisP3 + "");
}
}
else
{
InLog("料盘移栽" + MoveInfo.SLog + ":记录高度尺寸 高度【" + LastHeight + "】宽度【" + LastWidth + "】");
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_18_SaveSize))
{
if (MoveCylineCanTakeOrGive())
{
MoveInfo.NextMoveStep(LineMoveStep.FI_19_MoveCylinder_Emptying);
InLog("料盘移栽" + MoveInfo.SLog + ":上料横移气缸放料SOL");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give);
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.FI_18_SaveSize);
InLog("料盘移栽" + MoveInfo.SLog + ":上料横移气缸放料SOL前先上升横移气缸");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_19_MoveCylinder_Emptying))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_20_WaitTray);
InLog("料盘移栽" + MoveInfo.SLog + ":等待空托盘到达");
//TODO 此处需要等待空托盘
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_20_WaitTray))//TODO
{
if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_11_CodeRember))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_21_UpdownAxisToP2);
int targetPositon = Config.GetUpdownPositionP2(LastHeight);
InLog("料盘移栽" + MoveInfo.SLog + ":移栽伺服下降到P2:" + targetPositon+ ",托盘号【" + currTrayNum + "】,获取库位号,更新托盘信息");
UpdownAxis.AbsMove(MoveInfo, targetPositon, Config.UpdownAxis_P2Speed);
Task.Factory.StartNew(delegate
{
//更新托盘条码信息
string code = CodeManager.ProcessCode(LastCodeList);
// TrayManager.UpdateTrayInfo(currTrayNum, true, 1, code, "", LastHeight, LastWidth);
if (code.Equals(""))
{
InOutParam param = new InOutParam(currTrayNum, code, "", LastHeight, LastWidth, true );
TrayManager.UpdateTrayInfo(currTrayNum, true,ReelType.InStore, param, "扫码失败");
}
//从服务器获取库位号
string result = SServerManager.CodeReceived(Name, currTrayNum, LastCodeList, LastHeight, LastWidth);
if (!result.Equals(""))
{
InOutParam param = new InOutParam(currTrayNum, code, "", LastHeight, LastWidth, true);
TrayManager.UpdateTrayInfo(currTrayNum, true, ReelType.InStore, param, result);
// TrayManager.UpdateInStoreNG(currTrayNum, true, result);
LogUtil.error(Name + "托盘【" + currTrayNum + "】" + result);
}
});
}
else
{
TimeSpan span = DateTime.Now - MoveInfo.LastSetpTime;
if (span.TotalSeconds > 180)
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.SLog + "]等待空托盘到达超时[" + Math.Round(span.TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, DeviceID + 12);
Alarm(LineAlarmType.IoSingleTimeOut);
}
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_21_UpdownAxisToP2))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_22_MoveCylinder_Down);
InLog("料盘移栽" + MoveInfo.SLog + ":上料机构下降,");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Up, IO_Type.SL_MoveCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_22_MoveCylinder_Down))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_23_MoveCylinder_Slack);
InLog("料盘移栽" + MoveInfo.SLog + ":上料气缸放松");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Tighten, IO_Type.SL_MoveCylinder_Slack);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_23_MoveCylinder_Slack))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_24_MoveCylinder_Up);
InLog("料盘移栽" + MoveInfo.SLog + ":上料横移机构上升 ");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_24_MoveCylinder_Up))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_25_UpDownAxisToP1);
InLog("料盘移栽" + MoveInfo.SLog + ":升降伺服到P1点");
UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_25_UpDownAxisToP1))
{
InLog("料盘移栽" + MoveInfo.SLog + ":上料横移机构上升已到位,托盘开始放行 ");
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_12_MoveOk);
CheckHasTray();
}
#endregion
#region 未检测到托盘或放料完成
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_31_BatchAxisToP2))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_32_TrayLocationCylinder_After);
InLog("上料完成" + MoveInfo.SLog + ": 升降盘定位气缸后退");
TrayLCylinderAfter(MoveInfo);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_32_TrayLocationCylinder_After))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_33_BatchAxisToP1);
InLog("上料完成" + MoveInfo.SLog + ":提升伺服到P1点,定位气缸下降");
BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP1, Config.BatchAxis_P1Speed);
CylinderMove(MoveInfo, IO_Type.SL_LocationCylinder_Up, IO_Type.SL_LocationCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_33_BatchAxisToP1))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_35_OutTopCylinder_Up);
InLog("上料完成" + MoveInfo.SLog + ",出口顶升气缸上升,出料缓冲阻挡上升");
CylinderMove(MoveInfo, IO_Type.SL_OutTopCylinder_Down, IO_Type.SL_OutTopCylinder_Up);
IOMove(IO_Type.SL_Out_StopDown, IO_VALUE.LOW);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_35_OutTopCylinder_Up))
{
//TODO
MoveInfo.NextMoveStep(LineMoveStep.FI_36_SideWayLineRun);
InLog("上料完成" + MoveInfo.SLog + ", 线体横移电机运转,等待料架离开上料工位");
IOMove(IO_Type.SL_LocationSideWay_Run, IO_VALUE.HIGH);
IOMove(IO_Type.SL_OutSideWay_Run, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_Location_Check, IO_VALUE.LOW));
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_36_SideWayLineRun))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_37_WaitShelfGo);
InLog("上料完成" + MoveInfo.SLog + ", 线体横移电机运转,等待料架到达出口");
IOMove(IO_Type.SL_LocationSideWay_Run, IO_VALUE.HIGH);
IOMove(IO_Type.SL_OutSideWay_Run, IO_VALUE.HIGH);
//MoveInfo.OneWaitCanEndStep = true;
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_Out_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_37_WaitShelfGo))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_38_LineStop);
InLog("上料完成" + MoveInfo.SLog + ", 料架到达出口,线体横移电机停止 ");
IOMove(IO_Type.SL_LocationSideWay_Run, IO_VALUE.LOW);
IOMove(IO_Type.SL_OutSideWay_Run, IO_VALUE.LOW);
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_38_LineStop))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_39_TopCylinderDown);
InLog("上料完成" + MoveInfo.SLog + ", 料架到达出口,出口顶升下降 , ");
CylinderMove(MoveInfo, IO_Type.SL_OutTopCylinder_Up, IO_Type.SL_OutTopCylinder_Down);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_39_TopCylinderDown))
{
MoveInfo.EndMove();
runStatus = LineRunStatus.Runing;
// MoveInfo.NextMoveStep(LineMoveStep.FI_39_OutLineRun);
InLog("上料完成,料架到达出口处, 通知AGV取空料架, 入料流程结束");
AgvClient.ReadyEmpty(Config.AgvOutName);
}
#endregion
}
private void FI_12_MoveCylinder_Give()
{
if (MoveCylineCanTakeOrGive())
{
MoveInfo.NextMoveStep(LineMoveStep.FI_12_MoveCylinder_Give);
InLog("料盘移栽" + MoveInfo.SLog + ":上料机构检测到料盘,横移机构到放料端");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give);
}
else
{
//有料盘
MoveInfo.NextMoveStep(LineMoveStep.FI_11_MoveCylinder_Up);
InLog("料盘移栽" + MoveInfo.SLog + ":上料机构检测到料盘,横移机构上升");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
}
}
private void CheckHasTray()
{
if (IOValue(IO_Type.SL_AxisLocationCheck).Equals(IO_VALUE.HIGH) && MoveInfo.ShelfNoTray.Equals(false))
{
FI_12_MoveCylinder_Give();
}
else
{
if (MoveInfo.ShelfNoTray.Equals(false))
{
//判断当前位置是否在指定的位置
int currP = BatchAxis.GetAclPosition();
int chaz = Math.Abs(currP - Config.BatchAxisP3);
if (chaz > BatchAxis.Config.CanErrorCountMax)
{
MoveInfo.NextMoveStep(LineMoveStep.FI_10_AxisUpMove);
InLog("料架入库" + MoveInfo.SLog + ":CheckHasTray:上料轴开始慢速上升到P3点,等待检测到料盘");
MoveInfo.ShelfNoTray = false;
BatchAxisToP3();
return;
}
}
//无料盘
MoveInfo.ShelfNoTray = true;
MoveInfo.NextMoveStep(LineMoveStep.FI_31_BatchAxisToP2);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
InLog("料盘移栽" + MoveInfo.SLog + ":未检测到料盘,提升伺服到P2点");
BatchAxis.SuddenStop();
BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
}
}
private void BatchAxisToP3()
{
MoveInfo.TimeOutSeconds = 200;
MoveInfo.CanWhileCount = 0;
// 需要增加定时器,获取验证信号并停止伺服
StartMovePosition = BatchAxis.GetAclPosition();
MoveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxis(Config.Batch_Axis, Config.BatchAxisP3, Config.BatchAxis_P3Speed));
Config.Batch_Axis.TargetPosition = Config.BatchAxisP3;
BatchAxis.AbsMove( null, Config.BatchAxisP3, Config.BatchAxis_P3Speed);
//开始检测信号
BatchAxisStartCheck();
}
private int StartMovePosition = 0;
private int EndMovePosition = 0;
private int LastHeight = 0;
private int LastWidth = 0;
private List<string> LastCodeList = new List<string>();
private int GetHeight()
{
int AxisChangeValue = Config.Height_ChangeValue;
//计算高度
EndMovePosition = BatchAxis.GetAclPosition();
int height = (int)Math.Ceiling(1F * (EndMovePosition - StartMovePosition) / AxisChangeValue);
int addHeight = 0;
//如果检测信号未亮,极限亮了,需要补充高
//if (IOManager.IOValue(IO_Type.TrayCheck_LoadMaterial).Equals(IO_VALUE.LOW))
//{
// addHeight = Config.LastTrayAddHeight;
//}
height += addHeight;
if (height <= 8) { height = 8; }
else
{
height = (int)Math.Floor(1F * (height - 4) / 4) * 4;
}
if (height <= 8) { height = 8; }
LastHeight = height;
List<int> heightList = LineManager.GetTrayList();
heightList = (from m in heightList orderby m descending select m).ToList<int>();
foreach (int h in heightList)
{
if (height >= h)
{
LastHeight = h;
}
}
string msg = Name + " 计算盘高:上升前【" + StartMovePosition + "】实时【" + EndMovePosition + "】补充【" + addHeight + "】计算后【" + height + "】" + ",归类为" + LastHeight;
LogUtil.info(msg);
return LastHeight;
}
public int GetWidth()
{
int width = 15;
if (IOValue(IO_Type.SL_TrayCheck4).Equals(IO_VALUE.HIGH))
{
width = 15;
}
else if (IOValue(IO_Type.SL_TrayCheck3).Equals(IO_VALUE.HIGH))
{
width = 13;
}
else if (IOValue(IO_Type.SL_TrayCheck2).Equals(IO_VALUE.HIGH))
{
width = 11;
}
else if (IOValue(IO_Type.SL_TrayCheck1).Equals(IO_VALUE.HIGH))
{
width = 7;
}else
{
width = 7;
}
return width;
}
#endregion
internal bool CurrTrayIsNeed(int trayNum, bool NeedSaveParam )
{
try
{
if (IsDebug && runStatus <= LineRunStatus.Wait)
{
return false;
}
if (trayNum <= 0)
{
return false;
}
TrayInfo info = TrayManager.GetTrayInfo(trayNum);
InOutParam param = info.InoutPar;
//是出料的模块
if (Config.IsCanOut.Equals(1))
{
//此托盘是紧急出料盘,需要通过料架出库
bool debugNeed = (runStatus >= LineRunStatus.Runing) && info.IsFull && info.InOrOutStore.Equals(2);
debugNeed = false;
//if (param.PosId.Equals(""))
//{
// param = new InOutParam(trayNum, "紧急出料测试", "1#AC1_3_2", 12, 7);
//}
bool isJinji = (param.urgentReel || param.cutReel) && info.InOrOutStore.Equals(2) && info.IsFull && runStatus >= LineRunStatus.Runing;
//入料失败的盘也从此处出库
// bool instoeEnd = (runStatus >= LineRunStatus.Runing) && info.IsFull && info.InStoreNG;
if (debugNeed || isJinji)
{
//判断是否有料架,是否可以出库
if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.LOW))
{
LogUtil.error(Name + " 【" + info.ToStr() + "】需要出库,定位工位无料架,暂不处理", DeviceID + 16);
}
else if (OutStoreHeight < 0)
{
LogUtil.error(Name + " 【" + info.ToStr() + "】需要出库,料架未准备好,暂不处理", DeviceID + 17);
}
else
{
if (NeedSaveParam)
{
LogInfo(" 【" + info.ToStr() + "】需要出库,参数信息:" + param.ToStr());
CheckParam = param;
}
return true;
}
}
}
else
{
bool trayCanUse = LineManager.Line.runStatus <= LineRunStatus.Wait || (!info.IsFull);
if (trayCanUse && runStatus.Equals(LineRunStatus.Busy) && MoveInfo.MoveType.Equals(LineMoveType.InStore))
{
//入料执行中, 且需要空托盘
if (MoveInfo.MoveStep >= LineMoveStep.FI_11_MoveCylinder_Up && MoveInfo.MoveStep <= LineMoveStep.FI_20_WaitTray)
{
if (NeedSaveParam)
{
CheckParam = param;
LogUtil.info(Name + "拦截到空托盘【" + trayNum + "】,入料执行中,需要空托盘");
}
return true;
}
}
}
if (NeedSaveParam&&LineManager.Line.runStatus>=LineRunStatus.HomeMoving&& LineManager.Line.CanProcessLine())
{
LogInfo(" 【" + info.ToStr() + "】不需要出入库" );
}
}
catch (Exception ex)
{
LogUtil.error(Name + "CurrTrayIsNeed出错:" + ex.StackTrace);
}
return false;
}
}
}