DUOStoreBean_Partial.cs
76.8 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
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
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 string 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(string num, int type)
{
CurrShelfNum = num;
Properties.Settings1.Default.CurrShelfNum = num;
//ConfigAppSettings.SaveValue(Setting_Init.CurrShelfNum, num);
CurrShelfType = type;
Properties.Settings1.Default.CurrShelfType = type;
//ConfigAppSettings.SaveValue(Setting_Init.CurrShelfType, type);
Properties.Settings1.Default.Save();
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 (AxisManager.instance.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(1))
{
T1_BatchAxis.SuddenStop();
}
return true;
}
else
{
bool isOk = AxisManager.instance.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 (scanTask == null)
return true;
if (scanTask.IsCompleted)
return true;
//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;
}
LogUtil.OutputDebugString($"CanOut MoveType:{MoveInfo.MoveType},IsStart:{IsStart},Line_WaitCheck:{IOValue(IO_Type.Line_WaitCheck)},{Config.AgvInName}:{AgvClient.GetAction(Config.AgvInName)},{AgvClient.GetShelf(Config.AgvInName)}");
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 (CurrShelfType.Equals(0) || CurrShelfType.Equals(2))
{
if (IsStart)
{
return StartOutStoreMove(new InOutParam(MoveType.OutStore),false);
}
else
{
return true;
}
}
}
}
bool isLineEmpty = IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.LOW);
if (IsStart && isLineEmpty && (AgvClient.GetAction(Config.AgvInName) == Agv.ClientAction.None || AgvClient.GetAction(Config.AgvInName) == Agv.ClientAction.NeedEnter) && AgvClient.GetShelf(Config.AgvInName) != Agv.ClientShelf.Empty)
{
StoreManager.AgvNeedEmptyTime = DateTime.Now;
AgvNeedInshelf = Agv.ClientShelf.Empty;
AgvClient.SetToNone(Config.AgvInName);
AgvClient.NeedEnter(Config.AgvInName, "", AgvNeedInshelf);
LogUtil.info(Name + "CanOut AgvClient.NeedEnter" + Config.AgvInName + ",AgvNeedInshelf:" + AgvNeedInshelf);
//AgvNeedInshelf = Agv.ClientShelf.None;
}
return false;
}
public override bool StartOutStoreMove(InOutParam param,bool shelfisready=false)
{
if (IOValue(IO_Type.RaiseStation_BackendCheck).Equals(IO_VALUE.HIGH)
|| IOValue(IO_Type.RaiseStation_UpLocation1).Equals(IO_VALUE.HIGH)
) {
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.OutStoreExecute;
MoveInfo.NewMove(MoveType.OutStore, new InOutParam(MoveType.OutStore));
if (shelfisready) {
LogUtil.info(Name + " 料架已就位");
MoveInfo.NextMoveStep(StoreMoveStep.LO_08_AxisUpToP2);
}
else
{
LogUtil.info(Name + " 检测到库位有料架");
MoveInfo.NextMoveStep(StoreMoveStep.LO_07_RaiseStationForward);
}
return true;
}
//判断是哪个工位有料架
else if (IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
if (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;
}
bool rightTrayHas15 = false;
if (outParam.TargetBox == 1 && IOManager.IOValue(IO_Type.InDoor_Check, 2).Equals(IO_VALUE.HIGH) && BoxMap[2].MoveInfo.MoveParam != null && BoxMap[2].MoveInfo.MoveParam.PlateW == 15)
{
rightTrayHas15 = true;
LogUtil.error(Name + "StartTrayOut 左侧出库,但右侧料架存在15村盘");
}
//MoveInfo.NextMoveStep(StoreMoveStep.LO_11_BatchAxisDown);
//InOutStoreLog("取料:批量轴下降指定的高度");
lock (worklock)
{
if (MoveInfo.MoveType.Equals(MoveType.OutStore) && MoveInfo.MoveStep.Equals(StoreMoveStep.LO_09_WaitOut) && !rightTrayHas15)
{
MoveInfo.NewMove(MoveType.OutStore, outParam);
//可以开始出库啦
MoveInfo.NextMoveStep(StoreMoveStep.LO_11_BatchAxisDown);
int height = outParam.PlateH + 4;
if (outParam.PlateH >= 24)
height += 6;
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(null, targetPosition, Config.BatchAxis_P2Speed);
outStoreCount++;
StoreManager.putShelfFinished(outParam.PosID, CurrShelfNum, outStoreCount.ToString(), outParam.WareCode);
return true;
}
else
{
LogUtil.error(Name + "StartTrayOut 出库" + outParam.ToStr() + "失败,未准备好料架");
return false;
}
}
}
/// <summary>
/// 料串下降过度重新上升校准次数
/// </summary>
int TrayStringUpFix = 0;
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("料架出库: 提升机构上升");
InOutStation_RasieUp();
OpenGate(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_06_TopUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_07_RaiseStationForward);
InOutStoreLog("料架出库:横移机构前进");
InOutStation_GoIn();
LineStop(MoveInfo);
//hoisterCylinder.StartForward(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_07_RaiseStationForward))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_07_RaiseStationForward_2);
InOutStoreLog("料架出库:料窜到位,顶升上升");
InOutStation_Stop(1000);
InOutStation_LocationUp();
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_07_RaiseStationForward_2))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_08_AxisUpToP2);
InOutStoreLog("料架出库:上料轴开始慢速上升到P2点[" + Config.BatchAxis_P2 + "],等待检测到料盘");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
BatchAxisToP2(true);
//CloseGate(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_08_AxisUpToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_09_WaitOut);
InOutStoreLog("料架出库:料架准备完成,等待料盘出库");
TrayStringUpFix = 0;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
T1_BatchAxis.AbsMove(MoveInfo, T1_BatchAxis.GetAclPosition() - Config.BatchAxis_ChangeValue * 40, Config.BatchAxis_P1Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_09_WaitOut))
{
//if (OutstoreEndSendShelf && outStoreCount > 0)
//{
// InOutStoreLog("料架出库:OutstoreEndSendShelf=true,已出库盘数[" + outStoreCount + "],开始送出料架");
// LO_31_BatchAxisToP1();
//}
//else
{
int xuqiudan = StoreManager.unfinishedTaskCount(Name, CurrShelfNum);
if (outStoreCount == 0 || (xuqiudan > 0))// && !StoreManager.ShelfNeedOut))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_09_WaitOut);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
}
else
{
InOutStoreLog("料架出库:工单已结束,已出库盘数[" + outStoreCount + "],开始送出料架");
lock (StoreManager.Store)
{
StoreManager.ShelfNeedOut = false;
StoreManager.LastVisualRfid = "";
}
outStoreCount = 0;
LO_31_BatchAxisToP1();
}
//InOutStoreLog(" 等待料盘出库");
}
}
#endregion
#region 取放料处理
else if (MoveInfo.IsStep(StoreMoveStep.LO_11_BatchAxisDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_12a_ToBoxDoor);
/*
bool waitRightLeave = false;
if (HasT4Axis && MoveInfo.MoveParam.TargetBox.Equals(1) && IOManager.IOValue(IO_Type.InDoor_Check, 2).Equals(IO_VALUE.HIGH))
{
waitRightLeave = true;
}
*/
UpdateShelfNum(CurrShelfNum, 2);
if (MoveInfo.MoveParam.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);
if (HasT4Axis)
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P1, Config.InOutAxis_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);
if (HasT4Axis)
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P1, Config.InOutAxis_P3Speed);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_12a_ToBoxDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_12_ToBoxDoor);
if (HasT4Axis)
{
if (MoveInfo.MoveParam.TargetBox == 1)
{
InOutStoreLog("取料:进出轴回到待机点到P2 [" + Config.InOutAxis_P2 + "]");
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P2, Config.InOutAxis_P1Speed);
}
else
{
InOutStoreLog("取料:进出轴回到取料前点到P3 [" + Config.InOutAxis_P3 + "]");
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P3, Config.InOutAxis_P1Speed);
}
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_12_ToBoxDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_13_UpdownDown);
if (MoveInfo.MoveParam.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))
{
if (electricClamp.Clamp(null))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_14_CylinderTighten);
InOutStoreLog("取料:夹爪气缸夹紧");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
else if (MoveInfo.IsTimeOut(10))
{
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.LO_14_CylinderTighten))
{
ClearTimeoutAlarm("电夹爪空闲");
MoveInfo.NextMoveStep(StoreMoveStep.LO_15a_UpdownUp);
if (MoveInfo.MoveParam.TargetBox.Equals(1))
{
InOutStoreLog("取料:BOX1 升降轴上升到料门口高点P4 [" + Config.UpdownAxis_P4 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P4, (int)(Config.UpdownAxis_P4Speed));
}
else
{
InOutStoreLog("取料:BOX2 升降轴上升到料门口高点P6 [" + Config.UpdownAxis_P6 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P6, (int)(Config.UpdownAxis_P6Speed));
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_15a_UpdownUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_15_UpdownUp);
if (HasT4Axis)
{
if (MoveInfo.MoveParam.TargetBox.Equals(1))
{
InOutStoreLog("取料:进出轴回到待机点到P6 [" + Config.InOutAxis_P6 + "]");
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P6, Config.InOutAxis_P1Speed);
}
else
{
InOutStoreLog("取料:进出轴回到取料前点到P1 [" + Config.InOutAxis_P1 + "]");
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P1, Config.InOutAxis_P1Speed);
}
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_15_UpdownUp))
{
if (BoxMap[MoveInfo.MoveParam.TargetBox].IOValue(IO_Type.InDoor_Check).Equals(IO_VALUE.LOW))
{
//BoxMap[MoveInfo.MoveParam.TargetBox].MoveInfo.MoveParam.TargetPosition = 1;
//BoxMap[MoveInfo.MoveParam.TargetBox].MoveInfo.NextMoveStep(StoreMoveStep.SO_14_InoutToP1);
}
MoveInfo.NextMoveStep(StoreMoveStep.LO_16_MiddleToP1);
InOutStoreLog("取料:旋转轴到料串位置P4 [" + Config.MiddleAxis_P4 + "]");
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P4, Config.MiddleAxis_P4Speed);
//T2_MiddleAxis_Run_Count++;
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_16_MiddleToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_17_UpdownToP2);
if (HasT4Axis)
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P4, Config.InOutAxis_P4Speed);
}
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, (int)(Config.UpdownAxis_P1Speed * 2));
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_18_UpdownDown))
{
if (electricClamp.Release()) {
MoveInfo.NextMoveStep(StoreMoveStep.LO_19_CylinderRelax);
InOutStoreLog("料盘移栽: 夹爪气缸放松");
}
else if (MoveInfo.IsTimeOut(10))
{
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.LO_19_CylinderRelax))
{
ClearTimeoutAlarm("电夹爪空闲");
MoveInfo.NextMoveStep(StoreMoveStep.LO_20_BatchAxisToP2);
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
InOutStoreLog("料盘移栽: 升降轴上升到P2");
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_20_BatchAxisToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_20a_UpdownUp);
//只有提升轴位置过低时才需要到P3
int currPosition = T1_BatchAxis.GetAclPosition();
int reoppos = (Config.BatchAxis_P1 + Config.BatchAxis_ChangeValue * 100);
InOutStoreLog($"料盘移栽: 当前T1位置[{currPosition}],最低需要重新上升位置:[{reoppos}]");
if (currPosition <= reoppos && TrayStringUpFix < 2)
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_20_UpdownUp_wait);
TrayStringUpFix++;
InOutStoreLog($"料盘移栽: 第{TrayStringUpFix}次,升降轴到料串高点[" + Config.UpdownAxis_P2 + "],提升轴[" + currPosition + $"]需要到P2");
BatchAxisToP2();
}
else
{
InOutStoreLog("料盘移栽: 升降轴到料串高点[" + Config.UpdownAxis_P2 + "],提升轴[" + currPosition + "]不需要到P2");
}
if (HasT4Axis)
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P1, Config.InOutAxis_P1Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_20_UpdownUp_wait))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_20a_UpdownUp);
int currPosition = T1_BatchAxis.GetAclPosition();
int targetP2 = currPosition - Config.BatchAxis_ChangeValue * 20;
InOutStoreLog($"料盘移栽: 料串下降当前位置:{currPosition},目标位置:{targetP2}");
T1_BatchAxis.AbsMove(MoveInfo, targetP2, Config.BatchAxis_P1Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_20a_UpdownUp))
{
if (T2_MiddleAxis_Run_Count > T2_MiddleAxis_Run_Reset)
MoveInfo.NextMoveStep(StoreMoveStep.LO_20b_UpdownUp);
else
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_20_UpdownUp);
return;
}
T2_MiddleAxis_Run_Count = 0;
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P6, Config.UpdownAxis_P2Speed);
T2_MiddleAxis.HomeMove(MoveInfo);
InOutStoreLog($"取料:取料旋转轴运动满100次开始回原复位{T2_MiddleAxis_Run_Count}");
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_20b_UpdownUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_20_UpdownUp);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog($"料盘移栽: 等待");
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_20_UpdownUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_21_NeedSendShelf);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog("料盘移栽:判断是否送出料架");
if (T2_MiddleAxis_Run_Count==0)
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P4, Config.MiddleAxis_P4Speed);
int currPositon = T1_BatchAxis.GetAclPosition();
int tp = currPositon - Config.BatchAxis_ChangeValue * 60;
if (tp <= Config.BatchAxis_P1)
{
LO_31_BatchAxisToP1(" 提升轴位置:" + currPositon + ",料架已满,需要送出料架");
}
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_RaiseStationBack);
InOutStoreLog("送出料架:升降盘定位气缸后退");
InOutStation_LocationDown();
InOutStation_RasieUp();
OpenGate(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_32_RaiseStationBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_32_RaiseStationBack_2);
InOutStoreLog("送出料架:横移机构后退");
InOutStation_GoOut();
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_32_RaiseStationBack_2))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_32_RaiseStationBack_3);
InOutStation_Stop();
InOutStoreLog("送出料架:横移机构停止");
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_32_RaiseStationBack_3))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_33_TopCylinderDown);
InOutStoreLog("送出料架:顶升气缸下降");
InOutStation_RasieDown();
CloseGate(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_33_TopCylinderDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_34_WorkStopDown);
InOutStoreLog("送出料架:流水线开始转动");
UpdateShelfNum(CurrShelfNum, -1);
Properties.Settings1.Default.LastOutShelfType = 1;
Properties.Settings1.Default.Save();
//ConfigAppSettings.SaveValue(Setting_Init.LastOutShelfType, 1);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
LineRun(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_34_WorkStopDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_35_WaitShelfGo);
InOutStoreLog("送出料架:上料阻挡下降2秒,等待上料无料架");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.HIGH, false, 1000);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WorkCheck, IO_VALUE.LOW));
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_35_WaitShelfGo))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_36_LineRun);
AgvNeedOutshelf = Agv.ClientShelf.Full;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3500));
InOutStoreLog($"送出料架:流水线再转动3秒 AgvNeedOutshelf:{AgvNeedOutshelf}");
LineRun(MoveInfo);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_OutCheck, IO_VALUE.HIGH));
}
else if (MoveInfo.IsStep(StoreMoveStep.LO_36_LineRun))
{
MoveInfo.NextMoveStep(StoreMoveStep.LO_37_LineStop);
//var rfiddevice = RFIDManager.GetShelfId(Config.Out_Rfid_IP);
//var rfid = rfiddevice.NumStr();
//AgvNeedOutshelf = Agv.ClientShelf.Full;
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 + "] ");
StoreManager.LastVisualRfid = "";
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);
}
if (IOValue(IO_Type.RaiseStation_FrontCheck).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.RaiseStation_BackendCheck).Equals(IO_VALUE.HIGH))
{
StartInStoreMove(null);
}
return false;
}
public async Task AgvSendShelfIn() {
bool result = await ShelfEnterProcess();
if (result) {
AgvClient.SetStatus(StoreManager.Config.AgvInName, "", Agv.ClientAction.FinishEnter);
_=Task.Run(() => {
Task.Delay(2000).Wait();
AgvClient.SetStatus(StoreManager.Config.AgvInName, "", Agv.ClientAction.None);
});
}
}
private Task<bool> ShelfEnterProcess()
{
//入口有料架,需要转动链条
return Task<bool>.Run(new Func<bool>(()=>
{
InShelfInProcess = true;
bool result = false;
try
{
InOutStoreLog("检测到入口(X03-Line_InCheck)有料");
InShelfInProcess = true;
LineRun("ShelfEnterProcess",999);
Thread.Sleep(1000 * 20);
//等待进料检测信号
result = WaitIo(IO_Type.Line_InCheck, IO_VALUE.LOW, 10000);
//InOutStoreLog($"Line_InCheck:{result}");
result = WaitIo(IO_Type.Line_WaitCheck, IO_VALUE.HIGH, 50000);
//InOutStoreLog($"Line_WaitCheck:{result}");
}
catch (Exception ex)
{
InOutStoreLog("检测到入口(X03-Line_InCheck)有料:"+ex.ToString());
}
finally
{
InShelfInProcess = false;
LineStop("ShelfEnterProcess");
}
return result;
}));
}
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(3000));
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))
{
InOutStoreLog($"入料检测: 上料工作区有料架1 ,阻挡1下降2000,阻挡2上升,流水线转动 ,等待料架到达上料区,CurrShelfType:{CurrShelfType}");
L_05_WaitTime(StoreMoveStep.LI_05_WaitTime);
}
else if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_05_WaitTime);
InOutStoreLog($"入料检测: 上料等待区有料架2 ,阻挡1下降2000,阻挡2上升,流水线转动 ,等待料架到达上料区,CurrShelfType:{CurrShelfType}");
IOMove(IO_Type.Line_Stop1_Wait, IO_VALUE.HIGH, false, 1000);//进料阻挡下降
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.LOW);//缓冲阻挡前进1000
LineRun(MoveInfo);
//等待指定时间
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2500));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WorkCheck, IO_VALUE.HIGH));
}
else
{
if (!InShelfInProcess)
{
LineStop("n", "LI_04_LineStart");
}
MoveEndP();
LogUtil.info(" 未检测到料架,入料结束");
}
}
public override bool StartInStoreMove(InOutParam param)
{
if (IOValue(IO_Type.RaiseStation_BackendCheck).Equals(IO_VALUE.HIGH)
|| IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
if (CurrShelfType.Equals(1))
{
if (IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
InOutStoreLog($"StartInStoreMove CurrShelfNum:{CurrShelfNum},CurrShelfType={CurrShelfType}");
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(MoveType.InStore, new InOutParam(MoveType.InStore));
L_05_WaitTime(StoreMoveStep.LI_05_WaitTime);
return true;
}
else {
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(MoveType.InStore, new InOutParam(MoveType.InStore));
MoveInfo.NextMoveStep(StoreMoveStep.LI_06_TopUp);
return true;
}
} else if (CurrShelfType==2)
{
//runStatus = StoreRunStatus.Busy;
//storeStatus = StoreStatus.OutStoreExecute;
//MoveInfo.NewMove(MoveType.OutStore, new InOutParam(MoveType.OutStore));
StartOutStoreMove(new InOutParam(MoveType.OutStore));
//先将当前料架送出
//LO_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));
//先将当前料架送出
LI_31_BatchAxisToP1();
} else if (IOValue(IO_Type.RaiseStation_BackendCheck).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("检测到料架:取料提升机构后退端");
InOutStation_LocationDown();
}
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);
InOutStation_LocationDown();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_02_HoisterBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_03_LocationDown);
InOutStoreLog("入料检测:定位气缸下降");
InOutStation_RasieDown();
}
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);
InOutStation_RasieUp();
OpenGate(MoveInfo);
CurrShelfNum = Properties.Settings1.Default.CurrShelfNum;
CurrShelfType = Properties.Settings1.Default.CurrShelfType;
var rfiddevice = RFIDManager.GetShelfId(Config.In_Rfid_IP);
var rfid = rfiddevice.NumStr();
InOutStoreLog($"入料检测:读取到rfid: {rfid}");
if (rfid == "000")
{
rfid = CurrShelfNum;
}
if (rfid == CurrShelfNum && CurrShelfType == 2)
{
MoveEndP();
}
else
{
CurrShelfType = 1;
}
UpdateShelfNum(rfid, CurrShelfType);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_06_TopUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_07_HoisterForward);
InOutStoreLog("入料检测:进出机构前进");
InOutStation_GoIn();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_07_HoisterForward))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_07_HoisterForward_2);
InOutStoreLog("入料检测:定位销上升");
InOutStation_LocationUp();
InOutStation_Stop();
//CloseGate(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_07_HoisterForward_2))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_08_AxisUpToP2);
InOutStoreLog("入料检测:上料轴开始慢速上升到P2 [" + Config.BatchAxis_P2 + "],等待检测到料盘");
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P1, Config.MiddleAxis_P1Speed);
BatchAxisToP2(true);
ShelfNoTray = false;
}
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 + "]进出轴回p1");
if (HasT4Axis)
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P1, Config.InOutAxis_P1Speed);
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P4, Config.MiddleAxis_P4Speed);
//T2_MiddleAxis_Run_Count++;
}
#endregion
#region 取放料处理
else if (MoveInfo.IsStep(StoreMoveStep.LI_11_AxisToTray))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_11a_AxisToTray);
if (HasT4Axis)
{
InOutStoreLog("取料:进出轴到P4");
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P4, Config.InOutAxis_P4Speed);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_11a_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))
{
if (electricClamp.Clamp(null))
{
InOutStoreLog("取料:夹爪气缸夹紧");
MoveInfo.NextMoveStep(StoreMoveStep.LI_13_CylinderTighten);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
}
else if (MoveInfo.IsTimeOut(10)) {
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_13_CylinderTighten))
{
ClearTimeoutAlarm("电夹爪空闲");
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("取料:等待没有提升机构料盘检测");
InOutStoreLog($"取料:夹爪状态 IsPushEmpty:{!electricClamp.IsClamp},IsReached:{!electricClamp.IsBusy}");
if (Math.Abs(T1_BatchAxis.GetAclPosition() - Config.BatchAxis_P2) > T1_BatchAxis.Config.CanErrorCountMin)
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.BatchAxis_Check, IO_VALUE.LOW));
}
}
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);
LastWidth = GetWidth();
LastHeight = GetHeight();
//if (LastWidth == 13)
// electricClamp.Clamp(null,15);
InOutStoreLog($"取料:记录高度尺寸 LastWidth:{LastWidth}, LastHeight{LastHeight},计算高度");
MoveInfo.WaitList.Add(WaitResultInfo.WaitScanCode());
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_17_SaveSize))
{
bool hasbox = false;
foreach (int k in BoxMap.Keys)
{
if (BoxMap[k].runStatus >= StoreRunStatus.Runing && BoxMap[k].IOValue(IO_Type.InDoor_Check).Equals(IO_VALUE.LOW))
{
hasbox = true;
}
}
if (hasbox)
LI_18_GetPosID();
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_18_GetPosID))
{
if (getPosTask.IsCompleted && LastPosParam != null)
{
if (LastPosParam.InStoreNg)
{
int box = GetInstoreNgBox();
if (HasT4Axis)
{
if (LastWidth >= 13)
box = 2;
else
box = 1;
}
LastPosParam.TargetBox = box;
LastPosParam.TargetPosition = 1;
MoveInfo.MoveParam = LastPosParam;
}
else
{
int storeId = LastPosParam.GetStoreId();
if (storeId.Equals(1))
{
LastPosParam.TargetBox = 1;
}
else
{
LastPosParam.TargetBox = 2;
}
}
if (HasT4Axis)
{
if (LastPosParam.TargetBox == 2)
{
InOutStoreLog("取料:进出轴回到待机点到P1 [" + Config.InOutAxis_P1 + "]");
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P1, Config.InOutAxis_P1Speed);
}
else
{
InOutStoreLog("取料:进出轴回到取料前点到P6 [" + Config.InOutAxis_P6 + "]");
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P6, Config.InOutAxis_P1Speed);
}
}
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();
if (storeId == -1)
storeId = LastPosParam.TargetBox;
// InOutStoreLog($"料盘移栽:storeId :{storeId}");
//BoxBean box = BoxMap[storeId];
bool waitRightLeave = false;
if (HasT4Axis && storeId == 1 && (IOManager.IOValue(IO_Type.InDoor_Check, 2).Equals(IO_VALUE.HIGH) || (BoxMap[2].MoveInfo.MoveStep < StoreMoveStep.SI_05_InoutToP1 && BoxMap[2].MoveInfo.MoveStep > StoreMoveStep.SI_03_InoutToP2)))
{
waitRightLeave = true;
}
bool boxdoorready = BoxMap[storeId].InoutAxis.GetAclPosition() < (BoxMap[storeId].Config.InOutAxis_P2 - BoxMap[storeId].Config.InOutAxis_P1) / 2;
if (IOManager.IOValue(IO_Type.InDoor_Check, storeId).Equals(IO_VALUE.LOW) && boxdoorready && !waitRightLeave)// && box.waitInStoreParam == null
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_22a_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_22a_ToBoxDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_22_ToBoxDoor);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
//判断是左侧还是右侧
if (HasT4Axis)
{
if (LastPosParam.TargetBox.Equals(1))
{
InOutStoreLog($"料盘移栽:左侧,进出轴到P2:{Config.InOutAxis_P2}");
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P2, Config.InOutAxis_P2Speed);
}
else
{
InOutStoreLog($"料盘移栽:右侧,进出轴到P3:{Config.InOutAxis_P3}");
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P3, Config.InOutAxis_P3Speed);
}
}
}
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},补偿:{(LastHeight - 8) * Config.UpdownAxis_ChangeValue}],开始预扫码");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P3 - (LastHeight - 8) * Config.UpdownAxis_ChangeValue, (int)(Config.UpdownAxis_P3Speed * 2));
}
else
{
InOutStoreLog($"料盘移栽: 升降轴到料门口低点P5[{Config.UpdownAxis_P5},补偿:{(LastHeight - 8) * Config.UpdownAxis_ChangeValue}],开始预扫码");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P5 - (LastHeight - 8) * Config.UpdownAxis_ChangeValue, (int)(Config.UpdownAxis_P5Speed * 2));
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_23_UpdownDown))
{
if (electricClamp.Release())
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_24_CylinderRelax);
InOutStoreLog("料盘移栽: 上料气缸放松");
}
else if (MoveInfo.IsTimeOut(10))
{
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_24_CylinderRelax))
{
ClearTimeoutAlarm("电夹爪空闲");
MoveInfo.NextMoveStep(StoreMoveStep.LI_25_UpdownUp);
if (LastPosParam.TargetBox.Equals(1))
{
InOutStoreLog("料盘移栽: 升降轴到料门口高点P4[" + Config.UpdownAxis_P4 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P4, (int)(Config.UpdownAxis_P4Speed));
}
else
{
InOutStoreLog("料盘移栽: 升降轴到料门口高点P6[" + Config.UpdownAxis_P6 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P6, (int)(Config.UpdownAxis_P6Speed));
}
int storeId = LastPosParam.GetStoreId();
BoxBean box;
if (storeId == -1)
storeId = LastPosParam.TargetBox;
box = BoxMap[storeId];
InOutStoreLog($"料盘移栽:storeId={storeId},targetpos={LastPosParam.TargetPosition},isNG={LastPosParam.InStoreNg}");
box.waitInStoreParam = LastPosParam.clone();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_25_UpdownUp))
{
if (T2_MiddleAxis_Run_Count > T2_MiddleAxis_Run_Reset)
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_25a_UpdownUp);
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_26_AxisToWait);
//return;
}
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog("料盘移栽:旋转轴返回待机点P1[" + Config.MiddleAxis_P1 + "],升降轴到料串高点P2[" + Config.UpdownAxis_P2 + "]进出轴回P1");
//T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P1, Config.MiddleAxis_P1Speed);
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
if (HasT4Axis)
T4_InOut_Axis.AbsMove(MoveInfo, Config.InOutAxis_P1, Config.InOutAxis_P1Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_25a_UpdownUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_26_AxisToWait);
T2_MiddleAxis_Run_Count = 0;
T2_MiddleAxis.HomeMove(MoveInfo);
InOutStoreLog("取料:取料旋转轴运动满100次开始回原复位");
}
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("送出料架:顶升气缸下降");
InOutStation_LocationDown();
InOutStation_RasieUp();
OpenGate(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_32_HoisterBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_33_TopCylinderDown);
InOutStoreLog("送出料架:升降盘定位气缸后退");
InOutStation_GoOut();
//hoisterCylinder.StartBack(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_33_TopCylinderDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_33_TopCylinderDown_2);
InOutStoreLog("送出料架:进出滚筒往外");
InOutStation_GoOut();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_33_TopCylinderDown_2))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_33_TopCylinderDown_3);
InOutStoreLog("送出料架:进出机构下降");
InOutStation_RasieDown();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_33_TopCylinderDown_3))
{
InOutStation_Stop(1000);
CloseGate(MoveInfo);
/*
InOutStoreLog($"送出料架:BoxMap[1]={BoxMap[1].storeStatus},BoxMap[2]={BoxMap[2].storeStatus}");
//如果有等待出库的料先出库
if (BoxMap[1].storeStatus == StoreStatus.OutStoreExecute || BoxMap[1].storeStatus == StoreStatus.OutStoreBoxEnd
|| BoxMap[2].storeStatus == StoreStatus.OutStoreExecute || BoxMap[2].storeStatus == StoreStatus.OutStoreBoxEnd)
{
InOutStoreLog("送出料架:检测到有待出库料盘,立刻开始出库");
LineStop(MoveInfo);
if (!StartOutStoreMove(new InOutParam(MoveType.OutStore),false))
{
InOutStoreLog("送出料架:转换出库失败.");
//MoveEndP();
}
}
//判断是否需要送出料架,如果入口和等待区无料架,暂不送出
else */
if (true || 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(CurrShelfNum, -1);
Properties.Settings1.Default.LastOutShelfType = 0;
Properties.Settings1.Default.Save();
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
LineRun(MoveInfo);
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.HIGH, false, 1000);
}
else
{
InOutStoreLog("送出料架:入口和等待区暂无料架,不需要送出料架");
LineStop(MoveInfo);
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_WorkCheck, IO_VALUE.LOW));
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_35_WaitShelfGo))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_36_LineRun);
InOutStoreLog("送出料架:流水线再转动3秒");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(4000));
LineRun(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_36_LineRun))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_37_LineStop);
InOutStoreLog("送出料架:流水线停止转动");
LineStop(MoveInfo);
AgvNeedOutshelf = Agv.ClientShelf.Empty;
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_37_LineStop))
{
LineStop(MoveInfo);
MoveEndP();
}
#endregion
}
private int GetInstoreNgBox()
{
//空闲且门口无料盘
foreach (BoxBean box in BoxMap.Values)
{
if (IOManager.IOValue(IO_Type.InDoor_Check, box.ID).Equals(IO_VALUE.LOW))
{
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(""))
{
result.Param.InStoreNg = true;
LastPosParam = result.Param.clone();
LogUtil.error(Name + "【" + code + "】第[" + count + "]次 LI_18_GetPosID 入库NG:" + result.Msg);
break;
}
else
{
LastPosParam = result.Param.clone();
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);
//T2_MiddleAxis_Run_Count++;
}
Task<List<string>> scanTask;
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(2000));
try
{
scanTask = Task.Factory.StartNew(delegate
{
IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
Task.Delay(10).Wait();
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
if (LastCodeList.Count <= 0)
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name, 3000);
}
IOMove(IO_Type.Camera_Led, IO_VALUE.LOW);
return LastCodeList;
});
}
catch (Exception ex)
{
LogUtil.error("FI_13_ScanCode扫码出错:", ex);
}
}
}
private void YuScanCode()
{
//TODO 此处需要等待空托盘
if (ShelfNoTray.Equals(false))
{
InOutStoreLog("料盘移栽 : ,预扫码");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
//还有料盘,直接扫码
YuCodeList = new List<string>();
List<string> bijiaoList = new List<string>(LastCodeList);
try
{
Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{
IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
Task.Delay(10).Wait();
YuCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name.Trim() + "预扫码");
//IOMove(IO_Type.Camera_Led, IO_VALUE.LOW);
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;
UpdateShelfNum(CurrShelfNum, 0);
int box1miscout = 0;
int box2miscout = 0;
bool hasMission = false;
int MissionTest = 0;
while (MissionTest < 10 && !hasMission)
{
//lock (BoxMap[1].waitOutStoreList)
{
var box1wl = BoxMap[1].waitOutStoreList.ToList();
box1miscout = (from a in box1wl where a.TargetPosition == 0 select a).Count();
}
//lock (BoxMap[2].waitOutStoreList)
{
var box1wl = BoxMap[2].waitOutStoreList.ToList();
box2miscout = (from a in box1wl where a.TargetPosition == 0 select a).Count();
}
//如果有等待出库的料先出库
if (box1miscout > 0 || box2miscout > 0)
hasMission = true;
MissionTest++;
Thread.Sleep(50);
}
if (!hasMission) {
hasMission= BoxMap[1].MoveInfo.MoveStep == StoreMoveStep.SO_11_GoBack || BoxMap[2].MoveInfo.MoveStep == StoreMoveStep.SO_11_GoBack;
}
InOutStoreLog($"检测料架为空:BoxMap[1]={box1miscout},BoxMap[2]={box2miscout}");
if (hasMission)
{
InOutStoreLog("检测料架为空:检测到有待出库料盘,立刻开始出库");
if (!StartOutStoreMove(new InOutParam(MoveType.OutStore), true))
{
InOutStoreLog("检测料架为空:转换出库失败.");
LI_31_BatchAxisToP1();
//MoveEndP();
}
}
else
{
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_P1Speed);
}
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, isFirstMove?targetSpeed: targetSpeed/2);
//开始检测信号
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 = $"(最后一盘料已补充{Config.LastTrayAddHeight})";
height += Config.LastTrayAddHeight;
}
if (LastWidth == 15) {
height -= 2;
}else if (LastWidth == 13)
{
//height -= 3;
}
//如果检测出<=15,都按照8计算
if (height < 12)
{
LastHeight = 8;
}
else
{
List<int> heightList = new List<int> { 8, 12, 16, 24, 32, 44, 56 };
//heightList = (from m in heightList orderby m descending select m).ToList<int>();
//float minCha = height;
foreach (int h in heightList)
{
if (height > h)
{
LastHeight = h;
}/*
//取差值最小的接近值
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()
{
if (IOManager.IOValue(IO_Type.TrayCheck_15, 0).Equals(IO_VALUE.HIGH))
return 15;
if (IOManager.IOValue(IO_Type.TrayCheck_11to13, 0).Equals(IO_VALUE.HIGH))
return 13;
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_15_UpdownUp)
{
if (MoveInfo.MoveParam != null && 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!=null && MoveInfo.MoveParam.TargetBox.Equals(id))
{
return false;
}
}
}
return true ;
}
#endregion
}
}