DUOStoreBean_Partial.cs
50.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
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
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
using DeviceLib;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
partial class DUOStoreBean
{
public bool InstoreEndSendShelf = false;
public bool OutstoreEndSendShelf = false;
public int CurrShelfNum = 0;
/// <summary>
/// 料架类型,0=空料架,1=入库料架,2=出库料架
/// </summary>
public int CurrShelfType = 0;
/// <summary>
/// 更新料架信息
/// </summary>
/// <param name="num">料架编号</param>
/// <param name="type">料架类型,0=空料架,1=入库料架,2=出库料架</param>
private void UpdateShelfNum(int num,int type)
{
CurrShelfNum = num;
CurrShelfType = type;
ConfigAppSettings.SaveValue(Setting_Init.CurrShelfType, type);
ConfigAppSettings.SaveValue(Setting_Init.CurrShelfNum, num);
if (type.Equals(0) || type.Equals(1))
{
outStoreCount = 0;
}
LogUtil.info(Name + "更新料架信息:【" + CurrShelfNum + "】【" + CurrShelfType + "】");
}
protected override bool CheckWaitResult(StoreMoveInfo moveInfo, WaitResultInfo wait)
{
if (wait.WaitType.Equals(WaitEnum.W008_BatchAxis))
{
//等待信号亮或者走到绝对位置才停止
if (IOValue(T1_BatchAxis.TargetIoType).Equals(T1_BatchAxis.TargetIoValue))
{
LogUtil.debug(Name + "CheckWaitResult 检测到" + T1_BatchAxis.TargetIoType + "=" + T1_BatchAxis.TargetIoValue + ",停止运行");
T1_BatchAxis.StopAxisCheckMove();
if (ACServerManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(1))
{
T1_BatchAxis.SuddenStop();
}
return true;
}
else
{
bool isOk = ACServerManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(0);
if (isOk)
{
//TODO 判断是否达到高度,如果未达到,继续上升
T1_BatchAxis.StopAxisCheckMove();
return true;
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W009_ScanCode))
{
if (LastCodeList.Count > 0)
{
return true;
}
}
return false;
}
#region 料架出料
public int outStoreCount = 0;
public bool CanOut(bool IsStart = false)
{
if (isInSuddenDown || isNoAirCheck)
{
return false;
}
if (runStatus <= StoreRunStatus.Wait)
{
return false;
}
if (MoveInfo.MoveType.Equals(MoveType.OutStore))
{
return true;
}
else if (MoveInfo.MoveType.Equals(MoveType.None))
{
if (IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
if (CurrShelfNum >= 0 && (CurrShelfType.Equals(0) || CurrShelfType.Equals(2)))
{
if (IsStart)
{
return StartOutStoreMove(new InOutParam(MoveType.OutStore));
}
else
{
return true;
}
}
}
}
return false;
}
public override bool StartOutStoreMove(InOutParam param)
{
//判断是哪个工位有料架
if (IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
if (CurrShelfNum >= 0 && (CurrShelfType.Equals(0) || CurrShelfType.Equals(2)))
{
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.OutStoreExecute;
MoveInfo.NewMove(MoveType.OutStore, new InOutParam(MoveType.OutStore));
LogUtil.info(Name + " 当前料架["+CurrShelfNum+"]["+CurrShelfType+"],开始出库");
UpdateShelfNum(CurrShelfNum, 2);
L_05_WaitTime(StoreMoveStep.LO_05_WaitTime);
return true;
}
}
return false;
}
public bool StartTrayOut(InOutParam outParam)
{
if (outParam == null || outParam.PosID == null || outParam.PosID.Equals(""))
{
LogUtil.error(Name + " StartTrayOut 出库失败,参数不完整:");
LogUtil.error(outParam.ToStr());
return false;
}
//MoveInfo.NextMoveStep(StoreMoveStep.LO_11_BatchAxisDown);
//InOutStoreLog("取料:批量轴下降指定的高度");
if (MoveInfo.MoveType.Equals(MoveType.OutStore) && MoveInfo.MoveStep.Equals(StoreMoveStep.LO_09_WaitOut))
{
MoveInfo.NewMove(MoveType.OutStore, outParam);
//可以开始出库啦
MoveInfo.NextMoveStep(StoreMoveStep.LO_11_BatchAxisDown);
int height = outParam.PlateH + 4;
int targetPosition = T1_BatchAxis.GetAclPosition() - height * Config.BatchAxis_ChangeValue;
if (targetPosition < Config.BatchAxis_P1)
{
targetPosition = Config.BatchAxis_P1;
}
InOutStoreLog(" StartTrayOut 出库移栽:" + outParam.ToStr() +" 提升伺服下降" + height + "mm,目标:" + targetPosition);
T1_BatchAxis.AbsMove(MoveInfo, targetPosition, Config.BatchAxis_P2Speed);
return true;
}
else
{
LogUtil.error(Name + "StartTrayOut 出库" + outParam.ToStr() + "失败,未准备好料架");
return false;
}
}
protected override void OutStoreProcess()
{
if (MoveInfo.IsInWait)
{
CheckWait();
}
if (MoveInfo.IsInWait)
{
return;
}
#region 料串检测
else if (MoveInfo.IsStep(StoreMoveStep.LO_05_WaitTime))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_06_TopUp);
InOutStoreLog("料架出库: 顶升气缸上升");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_06_TopUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_07_HoisterForward);
InOutStoreLog("料架出库:取料提升机构前进");
hoisterCylinder.StartForward(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_07_HoisterForward))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_08_AxisUpToP2);
InOutStoreLog("料架出库:上料轴开始慢速上升到P2点["+Config.BatchAxis_P2+"],等待检测到料盘");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
BatchAxisToP2(true);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_08_AxisUpToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_09_WaitOut);
InOutStoreLog("料架出库:料架准备完成,等待料盘出库");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_09_WaitOut))
{
if (OutstoreEndSendShelf && outStoreCount > 0)
{
InOutStoreLog("料架出库:OutstoreEndSendShelf=true,已出库盘数["+outStoreCount+"],开始送出料架");
LO_31_BatchAxisToP1();
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_09_WaitOut);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
//InOutStoreLog(" 等待料盘出库");
}
}
#endregion
#region 取放料处理
else if (MoveInfo.IsStep(StoreMoveStep.LO_11_BatchAxisDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_12_ToBoxDoor);
if (LastPosParam.TargetBox.Equals(1))
{
InOutStoreLog("取料, BOX1 升降轴到料门口高点[" + Config.UpdownAxis_P4 + "],旋转轴到料仓门口 P2 [" + Config.MiddleAxis_P2 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P4, Config.UpdownAxis_P4Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P2, Config.MiddleAxis_P2Speed);
}
else
{
InOutStoreLog("取料, BOX2 升降轴到料门口高点[" + Config.UpdownAxis_P6 + "],旋转轴到料仓门口 P3 [" + Config.MiddleAxis_P3 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P6, Config.UpdownAxis_P6Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P3, Config.MiddleAxis_P3Speed);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_12_ToBoxDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_13_UpdownDown);
if (LastPosParam.TargetBox.Equals(1))
{
InOutStoreLog("取料:BOX1 升降轴到料门口低点P3[" + Config.UpdownAxis_P3 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P3, Config.UpdownAxis_P3Speed);
}
else
{
InOutStoreLog("取料:BOX2 升降轴到料门口低点P5[" + Config.UpdownAxis_P5 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P5, Config.UpdownAxis_P5Speed);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_13_UpdownDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_14_CylinderTighten);
InOutStoreLog("取料:夹爪气缸夹紧");
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Relax, IO_Type.ClampCylinder_Clamp);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_14_CylinderTighten))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_15_UpdownUp);
if (LastPosParam.TargetBox.Equals(1))
{
InOutStoreLog("取料:BOX1 升降轴上升到料门口高点P4 [" + Config.UpdownAxis_P4 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P4, Config.UpdownAxis_P4Speed);
}
else
{
InOutStoreLog("取料:BOX2 升降轴上升到料门口高点P6 [" + Config.UpdownAxis_P6 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P6, Config.UpdownAxis_P6Speed);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_15_UpdownUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_16_MiddleToP1);
InOutStoreLog("取料:旋转轴到料串位置P1 ["+Config.MiddleAxis_P1+"]");
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P1, Config.MiddleAxis_P1Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_16_MiddleToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_17_UpdownToP2);
InOutStoreLog("取料:升降轴到料串高点P2 ["+ Config.UpdownAxis_P2 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_17_UpdownToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_18_UpdownDown);
InOutStoreLog("取料:升降轴到料串放料低点P1 ["+ Config.UpdownAxis_P1 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P1, Config.UpdownAxis_P1Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_18_UpdownDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_19_CylinderRelax);
InOutStoreLog("料盘移栽: 夹爪气缸放松");
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Clamp, IO_Type.ClampCylinder_Relax);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_19_CylinderRelax))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_20_UpdownUp);
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
//只有提升轴位置过低时才需要到P3
int currPosition = T1_BatchAxis.GetAclPosition();
if (currPosition <= (Config.BatchAxis_P1 + Config.BatchAxis_ChangeValue * 40))
{
InOutStoreLog("料盘移栽: 升降轴到料串高点[" + Config.UpdownAxis_P2 + "],提升轴[" + currPosition + "]需要到P2");
BatchAxisToP2();
}
else
{
InOutStoreLog("料盘移栽: 升降轴到料串高点[" + Config.UpdownAxis_P2 + "],提升轴[" + currPosition + "]不需要到P2");
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_20_UpdownUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_21_NeedSendShelf);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog("料盘移栽:判断是否送出料架");
int currPositon = T1_BatchAxis.GetAclPosition();
int tp = currPositon - Config.BatchAxis_ChangeValue * 40;
if (tp <= Config.BatchAxis_P1)
{
LO_31_BatchAxisToP1(" 提升轴位置:" + currPositon + ",料架已满,需要送出料架");
}
else if (OutstoreEndSendShelf)
{
LO_31_BatchAxisToP1(" 提升轴位置:" + currPositon + ",OutstoreEndSendShelf=true,需要送出料架");
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_09_WaitOut);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
InOutStoreLog(" 等待料盘出库");
}
}
#endregion
#region 送出料架处理
else if (MoveInfo.IsStep(StoreMoveStep.LO_31_BatchAxisToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_32_HoisterBack);
InOutStoreLog("送出料架:升降盘定位气缸后退");
hoisterCylinder.StartBack(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_32_HoisterBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_33_TopCylinderDown);
InOutStoreLog("送出料架:顶升气缸下降");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Up);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_33_TopCylinderDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_34_WorkStopDown);
InOutStoreLog("送出料架:上料阻挡下降1秒,流水线开始转动");
UpdateShelfNum(-1, -1);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
LineRun(MoveInfo);
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.HIGH, false, 1500);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_34_WorkStopDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_35_WaitShelfGo);
InOutStoreLog("送出料架:等待上料无料架");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WaitCheck, IO_VALUE.LOW));
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_35_WaitShelfGo))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_36_LineRun);
InOutStoreLog("送出料架:流水线再转动3秒");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
LineRun(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_36_LineRun))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_37_LineStop);
InOutStoreLog("送出料架:流水线停止转动");
LineStop(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_37_LineStop))
{
LineStop(MoveInfo);
MoveEndP();
}
#endregion
}
private void LO_31_BatchAxisToP1(string msg = "")
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_31_BatchAxisToP1);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
InOutStoreLog("出库 :" + msg + "开始送出料架,提升伺服到P1点 ["+ Config.BatchAxis_P1 + "] ");
UpdateShelfNum(CurrShelfNum, 0);
T1_BatchAxis.SuddenStop();
T1_BatchAxis.AbsMove(MoveInfo, Config.BatchAxis_P1, Config.BatchAxis_P2Speed);
}
#endregion
#region 料架入料
private bool ShelfNoTray = false;
private int StartMovePosition = 0;
private int EndMovePosition = 0;
private int LastHeight = 0;
private int LastWidth = 0;
private List<string> LastCodeList = new List<string>();
private List<string> YuCodeList = new List<string>();
private Task getPosTask = null;
private string lastcode = "";
private InOutParam LastPosParam = null;
private bool InShelfInProcess = false;
private bool StartInStoreP()
{
if (IOValue(IO_Type.Line_InCheck).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.LOW) && (!InShelfInProcess))
{
ShelfEnterProcess();
}
if (!MoveInfo.MoveType.Equals(MoveType.None))
{
return false;
}
//判断是否检测到料架
if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
StartInStoreMove(null);
}
return false;
}
private void ShelfEnterProcess()
{
//入口有料架,需要转动链条
Task.Factory.StartNew(delegate
{
InShelfInProcess = true;
try
{
InShelfInProcess = true;
LineRun(null);
//等待进料检测信号
bool result = WaitIo(IO_Type.Line_InCheck, IO_VALUE.LOW, 10000);
}
catch (Exception ex)
{
}
finally
{
InShelfInProcess = false;
LineStop(null);
}
});
}
private void L_05_WaitTime(StoreMoveStep step)
{
//定位工位有料架,等待1秒后再次检测
MoveInfo.NextMoveStep(step);
InOutStoreLog("上料区检测到料架: 阻挡1上升,阻挡2上升,转动流水线5秒");
IOMove(IO_Type.Line_Stop1_Wait, IO_VALUE.LOW);
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.LOW);
LineRun(MoveInfo);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WorkCheck, IO_VALUE.HIGH));
}
private void LI_04_LineStart()
{
UpdateShelfNum(GetShelfNum(), 1);
if (IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
L_05_WaitTime(StoreMoveStep.LI_05_WaitTime);
}
else if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_04_LineStart);
InOutStoreLog("入料检测: 上料等待区有料架 ,阻挡1下降2000,阻挡2上升,流水线转动 ,等待料架到达上料区");
IOMove(IO_Type.Line_Stop1_Wait, IO_VALUE.HIGH, false, 2000);//进料阻挡下降
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.LOW);//缓冲阻挡前进1000
LineRun(MoveInfo);
//等待指定时间
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WorkCheck, IO_VALUE.HIGH));
}
else
{
if (!InShelfInProcess)
{
LineStop(null);
}
MoveEndP();
LogUtil.info(" 未检测到料架,入料结束");
}
}
public override bool StartInStoreMove(InOutParam param)
{
//判断是哪个工位有料架
if (IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
if (CurrShelfNum < 0 || CurrShelfType.Equals(1))
{
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(MoveType.InStore,new InOutParam(MoveType.InStore));
L_05_WaitTime(StoreMoveStep.LI_05_WaitTime);
return true;
}
else if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH))
{
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(MoveType.InStore, new InOutParam(MoveType.InStore));
//先将当前料架送出
LI_31_BatchAxisToP1();
}
}
else if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH))
{
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(MoveType.InStore, new InOutParam(MoveType.InStore));
if (T1_BatchAxis.IsInPosition(Config.BatchAxis_P1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_02_HoisterBack);
InOutStoreLog("检测到料架:取料提升机构后退端");
hoisterCylinder.StartBack(MoveInfo);
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_01_BatchAxisToP1);
InOutStoreLog("检测到料架,提升轴先返回P1");
T1_BatchAxis.AbsMove(MoveInfo, Config.BatchAxis_P1, Config.BatchAxis_P1Speed);
}
return true;
}
return false ;
}
protected override void InStoreProcess()
{
if (MoveInfo.IsInWait)
{
CheckWait();
}
if (MoveInfo.IsInWait)
{
return;
}
#region 料串检测
if (MoveInfo.IsStep(StoreMoveStep.LI_01_BatchAxisToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_02_HoisterBack);
InOutStoreLog("检测到料架:取料提升机构后退端");
hoisterCylinder.StartBack(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_02_HoisterBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_03_LocationDown);
InOutStoreLog("入料检测:定位气缸下降");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_03_LocationDown))
{
LI_04_LineStart();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_04_LineStart))
{
LI_04_LineStart();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_05_WaitTime))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_06_TopUp);
InOutStoreLog("入料检测:链条停止转动, 顶升气缸上升");
LineStop(MoveInfo);
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_06_TopUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_07_HoisterForward);
InOutStoreLog("入料检测:取料提升机构前进");
hoisterCylinder.StartForward(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_07_HoisterForward))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_08_AxisUpToP2);
InOutStoreLog("入料检测:上料轴开始慢速上升到P2 [" + Config.BatchAxis_P2 + "],等待检测到料盘");
BatchAxisToP2(true);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_08_AxisUpToP2))
{
CheckHasTray();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_09_ScanCode))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_11_AxisToTray);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog("入料检测:有料盘:升降轴到料串高点P2["+ Config.UpdownAxis_P2 + "],旋转轴到料串位置P4["+ Config.MiddleAxis_P4 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P4, Config.MiddleAxis_P4Speed);
}
#endregion
#region 取放料处理
else if (MoveInfo.IsStep(StoreMoveStep.LI_11_AxisToTray))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_12_UpdownAxisToP3);
InOutStoreLog("取料:升降轴到料串低点P1["+ Config.UpdownAxis_P1 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P1, Config.UpdownAxis_P1Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_12_UpdownAxisToP3))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_13_CylinderTighten);
InOutStoreLog("取料:夹爪气缸夹紧");
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Relax, IO_Type.ClampCylinder_Clamp);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_13_CylinderTighten))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_14_UpdownToP1);
InOutStoreLog("取料:升降轴到料串高点P2["+ Config.UpdownAxis_P2 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_14_UpdownToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_15_WaitNoCheck);
InOutStoreLog("取料:等待没有提升机构料盘检测");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.BatchAxis_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_15_WaitNoCheck))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_16_BatchAxisToP2);
InOutStoreLog("取料:批量轴到P2 ["+Config.BatchAxis_P2+"],计算高度,");
BatchAxisToP2(false);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_16_BatchAxisToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_17_SaveSize);
InOutStoreLog("取料:记录高度尺寸");
LastWidth = GetWidth();
LastHeight = GetHeight();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_17_SaveSize))
{
LI_18_GetPosID();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_18_GetPosID))
{
if (getPosTask.IsCompleted && LastPosParam != null)
{
if (LastPosParam.InStoreNg)
{
int box = GetInstoreNgBox();
LastPosParam.TargetBox = box;
}
else
{
int storeId = LastPosParam.GetStoreId();
if (storeId.Equals(1))
{
LastPosParam.TargetBox = 1;
}
else
{
LastPosParam.TargetBox = 2;
}
}
MoveInfo.NextMoveStep(StoreMoveStep.LI_21_WaitToBox);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog("料盘移栽:" + LastPosParam.ToStr() + " 等待料仓门口无信号");
ClearTimeoutAlarm("获取库位号超时");
}
else if (MoveInfo.IsTimeOut(120))
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 获取库位号超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, ID * 1000 + 30);
Alarm(AlarmType.IoSingleTimeOut);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_21_WaitToBox))
{
int storeId = LastPosParam.GetStoreId();
BoxBean box = BoxMap[storeId];
if (IOManager.IOValue(IO_Type.InDoor_Check, storeId).Equals(IO_VALUE.LOW) && box.waitInStoreParam == null)
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_22_ToBoxDoor);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
//判断是左侧还是右侧
if (LastPosParam.TargetBox.Equals(1))
{
InOutStoreLog("料盘移栽:获取库位号完成, BOX " + storeId + " 升降轴到料门口高点P4[" + Config.UpdownAxis_P4 + "],旋转轴到料仓门口 P2[" + Config.MiddleAxis_P2 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P4, Config.UpdownAxis_P4Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P2, Config.MiddleAxis_P2Speed);
}
else
{
InOutStoreLog("料盘移栽:获取库位号完成, BOX " + storeId + " 升降轴到料门口高点P6[" + Config.UpdownAxis_P6 + "],旋转轴到料仓门口 P3[" + Config.MiddleAxis_P3 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P6, Config.UpdownAxis_P6Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P3, Config.MiddleAxis_P3Speed);
}
ClearTimeoutAlarm("入料口无料盘");
}
else if (MoveInfo.IsTimeOut(120))
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 等待BOX_" + storeId + " 入料口无料盘 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, ID * 1000 + 30);
Alarm(AlarmType.IoSingleTimeOut);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_22_ToBoxDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_23_UpdownDown);
YuScanCode();
if (LastPosParam.TargetBox.Equals(1))
{
InOutStoreLog("料盘移栽: 升降轴到料门口低点P3[" + Config.UpdownAxis_P3 + "],开始预扫码");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P3, Config.UpdownAxis_P3Speed);
}
else
{
InOutStoreLog("料盘移栽: 升降轴到料门口低点P5[" + Config.UpdownAxis_P5 + "],开始预扫码");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P5, Config.UpdownAxis_P5Speed);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_23_UpdownDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_24_CylinderRelax);
InOutStoreLog("料盘移栽: 上料气缸放松");
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Clamp, IO_Type.ClampCylinder_Relax);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_24_CylinderRelax))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_25_UpdownUp);
if (LastPosParam.TargetBox.Equals(1))
{
InOutStoreLog("料盘移栽: 升降轴到料门口高点P4[" + Config.UpdownAxis_P4 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P4, Config.UpdownAxis_P4Speed);
}
else
{
InOutStoreLog("料盘移栽: 升降轴到料门口高点P6[" + Config.UpdownAxis_P6 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P6, Config.UpdownAxis_P6Speed);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_25_UpdownUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_26_AxisToWait);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog("料盘移栽:旋转轴返回待机点P1["+ Config.MiddleAxis_P1 + "],升降轴到料串高点P2["+ Config.UpdownAxis_P2 + "]");
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P1, Config.MiddleAxis_P1Speed);
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_26_AxisToWait))
{
CheckHasTray();
}
#endregion
#region 送出料架处理
else if (MoveInfo.IsStep(StoreMoveStep.LI_31_BatchAxisToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_32_HoisterBack);
InOutStoreLog("送出料架:升降盘定位气缸后退");
hoisterCylinder.StartBack(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_32_HoisterBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_33_TopCylinderDown);
InOutStoreLog("送出料架:顶升气缸下降");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Up);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_33_TopCylinderDown))
{
//判断是否需要送出料架,如果入口和等待区无料架,暂不送出
if (IOValue(IO_Type.Line_InCheck).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH) || InstoreEndSendShelf)
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_34_WorkStopDown);
InOutStoreLog("送出料架[" + InstoreEndSendShelf + "]:上料阻挡下降1秒,流水线开始转动");
UpdateShelfNum(-1, -1);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
LineRun(MoveInfo);
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.HIGH, false, 2000);
}
else
{
InOutStoreLog("送出料架:入口和等待区暂无料架,不需要送出料架");
MoveEndP();
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_34_WorkStopDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_35_WaitShelfGo);
InOutStoreLog("送出料架:等待上料无料架");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WaitCheck, IO_VALUE.LOW));
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_35_WaitShelfGo))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_36_LineRun);
InOutStoreLog("送出料架:流水线再转动3秒");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
LineRun(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_36_LineRun))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_37_LineStop);
InOutStoreLog("送出料架:流水线停止转动");
LineStop(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_37_LineStop))
{
LineStop(MoveInfo);
MoveEndP();
}
#endregion
}
private int GetInstoreNgBox()
{
//空闲且门口无料盘
foreach(BoxBean box in BoxMap.Values)
{
if (box.MoveInfo.MoveType.Equals(MoveType.None) && IOManager.IOValue(IO_Type.InDoor_Check, box.ID).Equals(IO_VALUE.LOW))
{
return box.ID;
}
}
//忙碌且目标是出料口
foreach (BoxBean box in BoxMap.Values)
{
if (box.MoveInfo.MoveType.Equals(MoveType.None))
{
if (IOManager.IOValue(IO_Type.InDoor_Check, box.ID).Equals(IO_VALUE.LOW))
{
return box.ID;
}
}
else if (box.MoveInfo.MoveParam.TargetPosition.Equals(1))
{
return box.ID;
}
}
return 1;
}
private void LI_18_GetPosID()
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_18_GetPosID);
InOutStoreLog("料盘移栽:从服务器获取入库库位号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
LastPosParam = null;
string code = CodeManager.ProcessCode(LastCodeList);
lastcode = code;
getPosTask = Task.Factory.StartNew(delegate
{
//更新托盘条码信息
try
{
int count = 1;
while (MoveInfo.MoveType.Equals(MoveType.InStore))
{
//从服务器获取库位号
GetPosResult result = StoreManager.GetPosId(Name, LastCodeList, LastHeight, LastWidth, CurrShelfNum);
if (result.IsTimeOut)
{
LogUtil.error(Name + "【" + code + "】第[" + count + "]次 LI_18_GetPosID 超时,等待1s后重新获取");
Thread.Sleep(1000);
}
else if (result.Result.Equals(99) || result.Result.Equals(100))
{
LogUtil.error(Name + "【" + code + "】第[" + count + "]次 LI_18_GetPosID 结果【" + result.Result + "】,等待3s后重新获取");
Thread.Sleep(3000);
}
else if (!result.Msg.Equals(""))
{
LastPosParam = result.Param;
LogUtil.error(Name + "【" + code + "】第[" + count + "]次 LI_18_GetPosID 入库NG:" + result.Msg);
break;
}
else
{
LastPosParam = result.Param;
break;
}
count++;
}
}
catch (Exception ex)
{
LogUtil.error(Name + "【" + code + "】获取库位号报错:" + ex.ToString());
}
});
MoveInfo.MoveParam = LastPosParam;
}
private void LI_11_AxisToTray()
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_11_AxisToTray);
InOutStoreLog("入料检测:有料盘:升降轴到料串高点P2 ["+ Config.UpdownAxis_P2 + "],旋转轴到料串位置P4 ["+ Config.MiddleAxis_P4 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P4, Config.MiddleAxis_P4Speed);
}
private void LI_09_ScanCode()
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_09_ScanCode);
LastCodeList = new List<string>();
if (YuCodeList.Count > 0)
{
InOutStoreLog("入料检测:开始扫码:使用预扫码");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
LastCodeList = new List<string>(YuCodeList);
YuCodeList = new List<string>();
LI_11_AxisToTray();
}
else
{
InOutStoreLog("料盘移栽 :开始扫码");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitScanCode());
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(7000));
try
{
Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
if (LastCodeList.Count <= 0)
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name, 3000);
}
return LastCodeList;
});
}
catch (Exception ex)
{
LogUtil.error("FI_13_ScanCode扫码出错:", ex);
}
}
}
private void YuScanCode()
{
//TODO 此处需要等待空托盘
if (ShelfNoTray.Equals(false))
{
InOutStoreLog("料盘移栽 : ,预扫码");
//还有料盘,直接扫码
YuCodeList = new List<string>();
List<string> bijiaoList = new List<string>(LastCodeList);
try
{
Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{
Thread.Sleep(500);
YuCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name.Trim() + "预扫码");
bool isCanUse = true;
//判断是否可用
foreach (string nC in YuCodeList)
{
foreach (string n in bijiaoList)
{
if (nC.Length > 15 && nC.Equals(n))
{
LogUtil.error(Name + "预扫码结果【" + nC + "】与上个条码【" + n + "】重复,预扫码不可用");
isCanUse = false;
break;
}
}
}
if (!isCanUse)
{
YuCodeList = new List<string>();
}
//if (!CodeManager.HasRightCode(YuCodeList.ToArray()))
//{
// YuCodeList = new List<string>();
//}
return YuCodeList;
});
}
catch (Exception ex)
{
LogUtil.error(" 为下一盘料扫码出错:", ex);
}
}
}
private void CheckHasTray()
{
if (IOValue(IO_Type.BatchAxis_Check).Equals(IO_VALUE.HIGH) && ShelfNoTray.Equals(false))
{
LI_09_ScanCode();
}
else
{
if (ShelfNoTray.Equals(false))
{
//判断当前位置是否在指定的位置
int currP = T1_BatchAxis.GetAclPosition();
int chaz = Math.Abs(currP - Config.BatchAxis_P2);
if (chaz > T1_BatchAxis.Config.CanErrorCountMax)
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_08_AxisUpToP2);
InOutStoreLog(" CheckHasTray:上料轴开始慢速上升到P2["+Config.BatchAxis_P2+"],等待检测到料盘");
ShelfNoTray = false;
BatchAxisToP2(false);
return;
}
}
//无料盘
ShelfNoTray = true;
LI_31_BatchAxisToP1();
}
}
private void LI_31_BatchAxisToP1()
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_31_BatchAxisToP1);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
InOutStoreLog("料盘移栽 :未检测到料盘,提升伺服到P1点 ["+ Config.BatchAxis_P1 + "] ");
UpdateShelfNum(CurrShelfNum, 0);
T1_BatchAxis.SuddenStop();
T1_BatchAxis.AbsMove(MoveInfo, Config.BatchAxis_P1, Config.BatchAxis_P2Speed);
}
private void BatchAxisToP2(bool isFirstMove = true)
{
int targetP2 = Config.BatchAxis_P2;
int targetSpeed = Config.BatchAxis_P2Speed;
if (!isFirstMove)
{
int currPosition = T1_BatchAxis.GetAclPosition();
if (currPosition != -1)
{
targetP2 = currPosition + Config.BatchAxis_ChangeValue * 80;
if (targetP2 > Config.BatchAxis_P2)
{
targetP2 = Config.BatchAxis_P2;
}
LogUtil.info(Name + " BatchAxisToP2 目标P2: " + targetP2 + "(" + currPosition + ")");
}
//targetSpeed = Config.BatchAxis_P3Speed / 2;
}
MoveInfo.TimeOutSeconds = 200;
MoveInfo.CanWhileCount = 0;
// 需要增加定时器,获取验证信号并停止伺服
StartMovePosition = T1_BatchAxis.GetAclPosition();
MoveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxisMove(Config.T1_Batch_Axis, targetP2, targetSpeed));
Config.T1_Batch_Axis.TargetPosition = targetP2;
T1_BatchAxis.AbsMove(null, targetP2, targetSpeed);
//开始检测信号
T1_BatchAxis.BatchAxisStartCheck(IO_Type.BatchAxis_Check, IO_VALUE.HIGH);
}
private int GetHeight()
{
LastHeight = 0;
int AxisChangeValue = Config.BatchAxis_ChangeValue;
//计算高度
EndMovePosition = T1_BatchAxis.GetAclPosition();
bool isLast = false;
int chaz = Math.Abs(EndMovePosition - Config.BatchAxis_P2);
if (chaz < T1_BatchAxis.Config.CanErrorCountMax)
{
isLast = true;
}
float height = (float)Math.Ceiling(1F * Math.Abs(EndMovePosition - StartMovePosition) / AxisChangeValue);
string buchongStr = "";
if (isLast)
{
buchongStr = "(最后一盘料已补充5)";
height += 5;
}
//如果检测出<=15,都按照8计算
if (height <= 15)
{
LastHeight = 8;
}
else
{
List<int> heightList = new List<int> { 8, 12, 16, 20 };
heightList = (from m in heightList orderby m descending select m).ToList<int>();
float minCha = height;
foreach (int h in heightList)
{
//取差值最小的接近值
float cha = Math.Abs(h - (height - 4));
if (cha < minCha)
{
LastHeight = h;
minCha = cha;
}
}
}
if (LastHeight <= 8) { LastHeight = 8; }
string code = CodeManager.ProcessCode(LastCodeList);
string msg = Name + " 计算盘高:上升前 [" + StartMovePosition + "]实时[ " + EndMovePosition + "]差值[" + (EndMovePosition - StartMovePosition) + "]系数[" + AxisChangeValue + "] 计算后" + buchongStr + "[" + height + "]" + ",归类为【" + LastHeight + "mm】条码【" + code + "】";
LogUtil.info(msg);
return LastHeight;
}
public int GetWidth()
{
return 7;
}
#endregion
#region MyRegion
internal bool BoxDoorFree(int id)
{
if (MoveInfo.MoveType.Equals(MoveType.OutStore))
{
if (MoveInfo.MoveStep >= StoreMoveStep.LO_13_UpdownDown && MoveInfo.MoveStep <= StoreMoveStep.LO_16_MiddleToP1)
{
if (MoveInfo.MoveParam.TargetBox.Equals(id))
{
return false;
}
}
}else if (MoveInfo.MoveType.Equals(MoveType.InStore))
{
if (MoveInfo.MoveStep >= StoreMoveStep.LI_23_UpdownDown && MoveInfo.MoveStep <= StoreMoveStep.LI_26_AxisToWait)
{
if (MoveInfo.MoveParam.TargetBox.Equals(id))
{
return false;
}
}
}
return true ;
}
#endregion
}
}