BoxEquip_Partial.cs
57.6 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
using CodeLibrary;
using log4net.Util;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary.deviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms.VisualStyles;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
namespace OnlineStore.DeviceLibrary
{
partial class BoxEquip
{
public bool IgnoreFortACheck = false;
public bool ForkAChecking = false;
public bool ForkBChecking = false;
public bool IgnoreForkBCheck = false;
public bool IsStopForkCheck = false;
bool enableForkCehck { get { return ConfigHelper.Config.Get("启用行走中料叉检测", true); } }
public void StopForkCheck()
{
ForkAChecking = false;
ForkBChecking = false;
IsStopForkCheck = true;
IgnoreFortACheck = false;
IgnoreForkBCheck = false;
if (!enableForkCehck) return;
LogUtil.info($"{Name}-停止料叉监控");
}
public void ForkACheck()
{
if (!enableForkCehck) return;
ForkAChecking = true;
IsStopForkCheck = false;
Task.Run(() =>
{
try
{
Task.Delay(200).Wait();
IgnoreFortACheck = false;
DateTime highTime = DateTime.Now;
LogUtil.info($"{Name}-开始料叉{IO_Type.ForkA_Tray_Check}监控");
while (!IsStopForkCheck && !IgnoreFortACheck)
{
if (MoveStop)
{
Task.Delay(50).Wait();
highTime = DateTime.Now;
SetCriticalMsg($"料叉A监控到料盘信号丢失");
continue;
}
bool check = IOValue(IO_Type.ForkA_Tray_Check).Equals(IO_VALUE.HIGH);
if (check)
{
highTime = DateTime.Now;
}
var highinterval = (DateTime.Now - highTime).TotalSeconds;
if (highinterval >= 1)
{
UserPause(true, $"料叉{IO_Type.ForkA_Tray_Check}检测到灭了{highinterval}秒");
Thread.Sleep(500);
MoveAxis.SuddenStop();
LogUtil.error($"料叉{IO_Type.ForkA_Tray_Check}检测到灭了{highinterval}秒,行走机构停止");
}
Task.Delay(50).Wait();
}
LogUtil.info($"{Name}-结束料叉{IO_Type.ForkA_Tray_Check}监控,停止状态={IsStopForkCheck},忽略状态={IgnoreFortACheck}");
}
catch (Exception ex)
{
LogUtil.error("ForkACheck error", ex);
}
});
}
void ForkCheckWhenRunning()
{
if (IOValue(IO_Type.ForkA_Tray_Check).Equals(IO_VALUE.HIGH))
{
ForkACheck();
}
if (IOValue(IO_Type.ForkB_Tray_Check).Equals(IO_VALUE.HIGH))
{
ForkBCheck();
}
}
public void ForkBCheck()
{
if (!enableForkCehck) return;
ForkAChecking = true;
IsStopForkCheck = false;
Task.Run(() =>
{
try
{
Task.Delay(200).Wait();
IgnoreForkBCheck = false;
DateTime highTime = DateTime.Now;
LogUtil.info($"{Name}-开始料叉{IO_Type.ForkB_Tray_Check}监控");
while (!IsStopForkCheck && !IgnoreForkBCheck)
{
if (MoveStop)
{
Task.Delay(50).Wait();
highTime = DateTime.Now;
SetCriticalMsg($"料叉A监控到料盘信号丢失");
continue;
}
bool check = IOValue(IO_Type.ForkB_Tray_Check).Equals(IO_VALUE.HIGH);
if (check)
{
highTime = DateTime.Now;
}
var highinterval = (DateTime.Now - highTime).TotalSeconds;
if (highinterval >= 1)
{
UserPause(true, $"料叉{IO_Type.ForkB_Tray_Check}检测到灭了{highinterval}秒");
Thread.Sleep(500);
MoveAxis.SuddenStop();
LogUtil.error($"料叉{IO_Type.ForkB_Tray_Check}检测到灭了{highinterval}秒,行走机构停止");
}
Task.Delay(50).Wait();
}
LogUtil.info($"{Name}-结束料叉{IO_Type.ForkB_Tray_Check}监控,停止状态={IsStopForkCheck},忽略状态={IgnoreFortACheck}");
}
catch (Exception ex)
{
LogUtil.error("ForkBCheck error", ex);
}
});
}
public void UserPause(bool pause, string msg)
{
if (!enableForkCehck)
{
return;
}
if (pause)
{
LogUtil.info($"{Name}-用户停止:{msg}");
}
else
{
LogUtil.info($"{Name}-用户继续:{msg}");
}
MoveStop = pause;
}
protected override bool CheckWaitResult(DeviceMoveInfo moveInfo, WaitResultInfo wait)
{
return false;
}
/// <summary>
/// 钩子上有抽屉
/// </summary>
/// <returns></returns>
public bool HasDrawerInHook()
{
return IOValue(IO_Type.Hook_A_Check).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Hook_B_Check).Equals(IO_VALUE.HIGH);
}
/// <summary>
/// 1=A上入库料暂存区,2=A下出库料暂存区,3=B上入库暂存区,4=B下出库暂存区
/// </summary>
/// <returns></returns>
public bool CheckInputMiddleAxisInBuff()
{
if (MoveInfo.MoveType.Equals(MoveType.InStore))
{
if (CheckASide())
{
return StoreManager.XLRStore.inputEquip.AxisInWorkingArea(1);
}
else
{
return StoreManager.XLRStore.inputEquip.AxisInWorkingArea(3);
}
}
else if (MoveInfo.MoveType.Equals(MoveType.OutStore))
{
if (CheckASide())
{
return StoreManager.XLRStore.inputEquip.AxisInWorkingArea(2);
}
else
{
return StoreManager.XLRStore.inputEquip.AxisInWorkingArea(4);
}
}
return true;
}
/// <summary>
/// 检查当前面是否A面
/// </summary>
/// <returns></returns>
private bool CheckASide()
{
if (MoveInfo.MoveParam.PosInfo.GetPosSide().Equals("A"))
return true;
return false;
}
/// <summary>
/// 检查当前面是否A面
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
private bool CheckASide(InOutParam param)
{
if (param.PosInfo.GetPosSide().Equals("A"))
return true;
return false;
}
private bool CheckASide(InOutPosInfo posinfo)
{
if (posinfo.GetPosSide().Equals("A"))
return true;
return false;
}
#region 行走机构
/// <summary>
/// 行走机构到待机点P1
/// </summary>
private void MoveAxisToP1(bool isdebugSpeed = false)
{
if (!MoveAxis.IsInPosition(MoveInfo.MoveParam.MoveP.MoveAxis_P1))
{
if (isdebugSpeed)
MoveAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.MoveAxis_P1, Config.MoveAxis_FindPosSpeed);
else
MoveAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.MoveAxis_P1, Config.MoveAxis_P1_Speed);
}
}
private void MoveAxisToSafePos(bool isdebugSpeed = false)
{
if (!MoveAxis.IsInPosition(Config.MoveAxis_SafePos))
{
if (isdebugSpeed)
MoveAxis.AbsMove(MoveInfo, Config.MoveAxis_SafePos, Config.MoveAxis_FindPosSpeed);
else
MoveAxis.AbsMove(MoveInfo, Config.MoveAxis_SafePos, Config.MoveAxis_P1_Speed);
}
}
/// <summary>
/// 行走机构到进出料机构取放点P2
/// </summary>
private void MoveAxisToP2(bool isdebugSpeed = false)
{
if (isdebugSpeed)
MoveAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.MoveAxis_P2, Config.MoveAxis_FindPosSpeed);
else
MoveAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.MoveAxis_P2, Config.MoveAxis_P2_Speed);
}
/// <summary>
/// 行走机构到存储库位取放点位P3
/// </summary>
private void MoveAxisToP3(bool isdebugSpeed = false)
{
if (isdebugSpeed)
MoveAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.MoveAxis_P3, Config.MoveAxis_FindPosSpeed);
else
MoveAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.MoveAxis_P3, Config.MoveAxis_P3_Speed);
}
#endregion
#region 料屉拉取进出轴
/// <summary>
/// 料斗拉取进出轴到料屉库位点P3/P5
/// </summary>
private void PullAxis_Inout_To_P3_P5(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
PullAxis_Inout.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Inout_P3_P5, Config.PullAxis_InOut_FindPosSpeed);
else
PullAxis_Inout.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Inout_P3_P5, Config.PullAxis_Inout_P3_Speed);
}
else
{
if (isdebugSpeed)
PullAxis_Inout.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Inout_P3_P5, Config.PullAxis_InOut_FindPosSpeed);
else
PullAxis_Inout.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Inout_P3_P5, Config.PullAxis_Inout_P5_Speed);
}
}
/// <summary>
/// 料斗拉取进出轴到料屉提取点P2/P4
/// </summary>
private void PullAxis_Inout_To_P2_P4(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
PullAxis_Inout.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Inout_P2_P4, Config.PullAxis_InOut_FindPosSpeed);
else
PullAxis_Inout.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Inout_P2_P4, Config.PullAxis_Inout_P2_Speed);
}
else
{
if (isdebugSpeed)
PullAxis_Inout.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Inout_P2_P4, Config.PullAxis_InOut_FindPosSpeed);
else
PullAxis_Inout.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Inout_P2_P4, Config.PullAxis_Inout_P4_Speed);
}
}
private void PullAxis_Inout_To_P1(bool isdebugSpeed = false)
{
if (isdebugSpeed)
PullAxis_Inout.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Inout_P1, Config.PullAxis_InOut_FindPosSpeed);
else
PullAxis_Inout.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Inout_P1, Config.PullAxis_Inout_P1_Speed);
}
/// <summary>
/// 料斗拉取进出轴到取像点(安全点)
/// </summary>
private void PullAxis_Inout_To_Cam(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
PullAxis_Inout.AbsMove(MoveInfo, Config.PullAxis_Inout_CamA, Config.PullAxis_InOut_FindPosSpeed);
else
PullAxis_Inout.AbsMove(MoveInfo, Config.PullAxis_Inout_CamA, Config.PullAxis_Inout_P1_Speed);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.PullAxis_Inout_A_Check, IO_VALUE.HIGH));
}
else
{
if (isdebugSpeed)
PullAxis_Inout.AbsMove(MoveInfo, Config.PullAxis_Inout_CamB, Config.PullAxis_InOut_FindPosSpeed);
else
PullAxis_Inout.AbsMove(MoveInfo, Config.PullAxis_Inout_CamB, Config.PullAxis_Inout_P1_Speed);
// MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.PullAxis_Inout_B_Check, IO_VALUE.HIGH));
}
}
/// <summary>
/// 进料防护门操作
/// </summary>
/// <param name="open">true:开启</param>
private void BuffAreaInstoreDoor(bool open)
{
if (open)//开门-上升
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UpperArea_InstoreDoor_Up, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UpperArea_InstoreDoor_UpCheck, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UpperArea_InstoreDoor_Down, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UpperArea_InstoreDoor_DownCheck, IO_VALUE.LOW));
IOMove(IO_Type.UpperArea_InstoreDoor_Down, IO_VALUE.LOW);
IOMove(IO_Type.UpperArea_InstoreDoor_Up, IO_VALUE.HIGH);
}
else//关门
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UpperArea_InstoreDoor_Up, IO_VALUE.LOW));
//MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UpperArea_InstoreDoor_UpCheck, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UpperArea_InstoreDoor_Down, IO_VALUE.HIGH));
//MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UpperArea_InstoreDoor_DownCheck, IO_VALUE.HIGH));
IOMove(IO_Type.UpperArea_InstoreDoor_Up, IO_VALUE.LOW);
IOMove(IO_Type.UpperArea_InstoreDoor_Down, IO_VALUE.HIGH);
}
}
/// <summary>
/// 出料防护门操作
/// </summary>
/// <param name="open">true:开启</param>
private void BuffAreaOutstoreDoor(bool open)
{
if (open)//下降-开门
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UnderArea_OutstoreDoor_Up, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UnderArea_OutstoreDoor_UpCheck, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UnderArea_OutstoreDoor_Down, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UnderArea_OutstoreDoor_DownCheck, IO_VALUE.HIGH));
IOMove(IO_Type.UnderArea_OutstoreDoor_Up, IO_VALUE.LOW);
IOMove(IO_Type.UnderArea_OutstoreDoor_Down, IO_VALUE.HIGH);
}
else//上升-关门
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UnderArea_OutstoreDoor_Up, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UnderArea_OutstoreDoor_UpCheck, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UnderArea_OutstoreDoor_Down, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.UnderArea_OutstoreDoor_DownCheck, IO_VALUE.LOW));
IOMove(IO_Type.UnderArea_OutstoreDoor_Down, IO_VALUE.LOW);
IOMove(IO_Type.UnderArea_OutstoreDoor_Up, IO_VALUE.HIGH);
}
}
#region 移栽升降轴
/// <summary>
/// 移栽升降轴到料屉取放点P7/P13
/// </summary>
private void UpdownAxisToP7_P13(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P7_P13, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P7_P13, Config.Updown_P7_Speed);
}
else
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P7_P13, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P7_P13, Config.Updown_P13_Speed);
}
}
/// <summary>
/// 移栽升降轴到料屉上方过渡点P6/P12
/// </summary>
private void UpdownAxisTo_P6_P12(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P6_P12, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P6_P12, Config.Updown_P6_Speed);
}
else
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P6_P12, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P6_P12, Config.Updown_P12_Speed);
}
}
/// <summary>
/// 移栽升降轴到下暂存区放料高点P4/P10
/// </summary>
private void UpdownAxisTo_P4_P10(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P4, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P4, Config.Updown_P4_Speed);
}
else
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P10, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P10, Config.Updown_P10_Speed);
}
}
/// <summary>
/// 移栽升降轴到上暂存区取料高点P2/P8
/// </summary>
private void UpdownAxisTo_P2_P8(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P2, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P2, Config.Updown_P2_Speed);
}
else
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P8, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P8, Config.Updown_P8_Speed);
}
}
/// <summary>
/// 移栽升降轴到上暂存区取料低点P3/P9
/// </summary>
private void UpdownAxisTo_P3_P9(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P3, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P3, Config.Updown_P3_Speed);
}
else
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P9, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P9, Config.Updown_P9_Speed);
}
}
/// <summary>
/// 移栽升降轴到下暂存区放料低点P5/P11
/// </summary>
private void UpdownAxisTo_P5_P11(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P5, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P5, Config.Updown_P5_Speed);
}
else
{
if (isdebugSpeed)
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P11, Config.UpdownAxis_FindPosSpeed);
else
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Updown_P11, Config.Updown_P11_Speed);
}
}
#endregion
#region 移栽X轴
/// <summary>
/// AB面移栽X轴到进出料暂存区取放点P2
/// </summary>
private void XAxis_To_P2(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
XAxis_A.AbsMove(MoveInfo, Config.XAxis_A_P2, Config.XAxis_FindPosSpeed);
else
XAxis_A.AbsMove(MoveInfo, Config.XAxis_A_P2, Config.XAxis_A_P2_Speed);
}
else
{
if (isdebugSpeed)
XAxis_B.AbsMove(MoveInfo, Config.XAxis_B_P2, Config.XAxis_FindPosSpeed);
else
XAxis_B.AbsMove(MoveInfo, Config.XAxis_B_P2, Config.XAxis_B_P2_Speed);
}
}
/// <summary>
/// AB面移栽X轴到料屉库位取放料点P3
/// </summary>
private void XAxis_To_P3(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
XAxis_A.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.XAxis_AB_P3, Config.XAxis_FindPosSpeed);
else
XAxis_A.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.XAxis_AB_P3, Config.XAxis_A_P3_Speed);
}
else
{
if (isdebugSpeed)
XAxis_B.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.XAxis_AB_P3, Config.XAxis_FindPosSpeed);
else
XAxis_B.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.XAxis_AB_P3, Config.XAxis_B_P3_Speed);
}
}
/// <summary>
/// AB面移栽X轴到待机点
/// </summary>
private void XAxis_To_P1(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (!XAxis_A.IsInPosition(Config.XAxis_A_P1))
{
if (isdebugSpeed)
XAxis_A.AbsMove(MoveInfo, Config.XAxis_A_P1, Config.XAxis_FindPosSpeed);
else
XAxis_A.AbsMove(MoveInfo, Config.XAxis_A_P1, Config.XAxis_A_P1_Speed);
}
}
else
{
if (!XAxis_B.IsInPosition(Config.XAxis_B_P1))
{
if (isdebugSpeed)
XAxis_B.AbsMove(MoveInfo, Config.XAxis_B_P1, Config.XAxis_FindPosSpeed);
else
XAxis_B.AbsMove(MoveInfo, Config.XAxis_B_P1, Config.XAxis_B_P1_Speed);
}
}
}
#endregion
#region 压紧轴
/// <summary>
/// AB移栽压紧轴到压紧前点P2
/// </summary>
private void ComAxis_To_P2(bool isdebugSpeed = false)
{
if (CheckASide())
{
if (isdebugSpeed)
ComAxis_A.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.ComAxis_AB_P2, Config.ComAxis_FindPosSpeed);
else
ComAxis_A.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.ComAxis_AB_P2, Config.ComAxis_A_P2_Speed);
}
else
{
if (isdebugSpeed)
ComAxis_B.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.ComAxis_AB_P2, Config.ComAxis_FindPosSpeed);
else
ComAxis_B.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.ComAxis_AB_P2, Config.ComAxis_B_P2_Speed);
}
}
int comAxis_offset = ConfigAppSettings.GetIntValue("Coeff_ComAxis");
/// <summary>
/// AB移栽压紧轴到压紧点P3
/// </summary>
private void ComAxis_To_P3(bool isdebugSpeed = false)
{
int diff = 0;
BoxPosition position = CSVPositionReader<BoxPosition>.GetPositon(MoveInfo.MoveParam.PosInfo.PosId);
if (position != null)
{
var pH = MoveInfo.MoveParam.PosInfo.PlateTotalH==0? MoveInfo.MoveParam.PosInfo.PlateH: MoveInfo.MoveParam.PosInfo.PlateTotalH;
diff = position.BagHigh - pH;
if (diff < 0) diff = 0;
LogInfo($"{MoveInfo.MoveParam.PosInfo.PosId}库位高度:{position.BagHigh},料盘高度:{MoveInfo.MoveParam.PosInfo.PlateH},实际高度:{MoveInfo.MoveParam.PosInfo.PlateTotalH},差值:{diff},系数:{comAxis_offset}," +
$"实际值:{MoveInfo.MoveParam.MoveP.ComAxis_AB_P3 + diff * comAxis_offset}={MoveInfo.MoveParam.MoveP.ComAxis_AB_P3}加{diff * comAxis_offset}");
}
int target = MoveInfo.MoveParam.MoveP.ComAxis_AB_P3 + diff * comAxis_offset;
if (CheckASide())
{
if (isdebugSpeed)
ComAxis_A.AbsMove(MoveInfo, target, Config.ComAxis_FindPosSpeed);
else
ComAxis_A.AbsMove(MoveInfo, target, Config.ComAxis_A_P3_Speed);
}
else
{
if (isdebugSpeed)
ComAxis_B.AbsMove(MoveInfo, target, Config.ComAxis_FindPosSpeed);
else
ComAxis_B.AbsMove(MoveInfo, target, Config.ComAxis_B_P3_Speed);
}
}
#endregion
#region 料屉拉取升降轴
/// <summary>
/// 抽屉待机点
/// </summary>
private void PullAxis_UpdownToP1(bool isdebugSpeed = false)
{
if (isdebugSpeed)
PullAxis_Updown.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Updown_P1, Config.PullAxis_Updown_FindPosSpeed);
else
PullAxis_Updown.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Updown_P1, Config.PullAxis_Updown_P1_Speed);
}
/// <summary>
/// 抽屉高点,料斗拉取升降轴到料屉提取高点P3
/// </summary>
private void PullAxis_UpdownToHighP3(bool isdebugSpeed = false)
{
if (isdebugSpeed)
PullAxis_Updown.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Updown_P3, Config.PullAxis_Updown_FindPosSpeed);
else
PullAxis_Updown.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Updown_P3, Config.PullAxis_Updown_P3_Speed);
}
/// <summary>
/// 添加拉钩是否有抽屉
/// </summary>
/// <param name="hasTray">true:有抽屉</param>
private void AddHookCheck(bool hasTray)
{
if (ignoreHook)
{
return;//暂时屏蔽
}
if (CheckASide())
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Hook_A_Check, hasTray ? IO_VALUE.HIGH : IO_VALUE.LOW));
}
else
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Hook_B_Check, hasTray ? IO_VALUE.HIGH : IO_VALUE.LOW));
}
}
bool ignoreFork
{
get { return ConfigHelper.Config.Get("IgnoreForkSig", false); }
}
/// <summary>
/// 忽略当前料叉状态
/// </summary>
public bool ignoreCurFork = false;
bool ignoreHook
{
get { return ConfigHelper.Config.Get("IgnoreHookSig", true); }
}
private void AddReelCheck(bool hasReel)
{
if (ignoreFork)
{
return;//暂时屏蔽
}
if (CheckASide())
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.ForkA_Tray_Check, hasReel ? IO_VALUE.HIGH : IO_VALUE.LOW));
}
else
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.ForkB_Tray_Check, hasReel ? IO_VALUE.HIGH : IO_VALUE.LOW));
}
}
public int checkForkCnt = 0;
bool isAlarmForkCheck()
{
if (checkForkCnt > 3)
{
return true;
}
return false;
}
/// <summary>
/// 检查料叉上的状态
/// </summary>
/// <param name="hasReel"></param>
/// <returns></returns>
bool CheckReel(bool hasReel)
{
if (ignoreFork)
{
return true;//暂时屏蔽
}
if (ignoreCurFork)
{
return true;
}
checkForkCnt++;
if (CheckASide())
{
return IOValue(IO_Type.ForkA_Tray_Check).Equals(hasReel ? IO_VALUE.HIGH : IO_VALUE.LOW);
}
else
{
return IOValue(IO_Type.ForkB_Tray_Check).Equals(hasReel ? IO_VALUE.HIGH : IO_VALUE.LOW);
}
}
bool CheckBothReel(bool hasReel)
{
if (ignoreFork)
{
return true;//暂时屏蔽
}
if (ignoreCurFork)
{
return true;
}
checkForkCnt++;
return IOValue(IO_Type.ForkA_Tray_Check).Equals(hasReel ? IO_VALUE.HIGH : IO_VALUE.LOW) && IOValue(IO_Type.ForkB_Tray_Check).Equals(hasReel ? IO_VALUE.HIGH : IO_VALUE.LOW);
}
/// <summary>
/// 抽屉水平点,料斗拉取升降轴到料屉水平点P2
/// </summary>
private void PullAxis_UpdownToMiddleP2(bool isdebugSpeed = false)
{
if (isdebugSpeed)
PullAxis_Updown.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Updown_P2, Config.PullAxis_Updown_FindPosSpeed);
else
PullAxis_Updown.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Updown_P2, Config.PullAxis_Updown_P2_Speed);
}
/// <summary>
/// 抽屉低点,料斗拉取升降轴到料屉提取低点P4
/// </summary>
private void PullAxis_UpdownToLowP4(bool isdebugSpeed = false)
{
if (isdebugSpeed)
PullAxis_Updown.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Updown_P4, Config.PullAxis_Updown_FindPosSpeed);
else
PullAxis_Updown.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.PullAxis_Updown_P4, Config.PullAxis_Updown_P4_Speed);
}
#endregion
#region 旋转轴
/// <summary>
/// AB面移栽旋转轴到料屉库位垂直取放料点P3
/// </summary>
private void MiddleAxis_To_P3(bool isdebugSpeed = false)
{
if (CheckASide())
{
MiddleAxis_A.AbsMove(MoveInfo, Config.MiddleAxis_A_P3, Config.MiddleAxis_A_P3_Speed);
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxisOrg(MiddleAxis_A.Config, IO_VALUE.HIGH));
}
else
{
MiddleAxis_B.AbsMove(MoveInfo, Config.MiddleAxis_B_P3, Config.MiddleAxis_B_P3_Speed);
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxisOrg(MiddleAxis_B.Config, IO_VALUE.HIGH));
}
}
/// <summary>
/// AB面移栽旋转轴到水平点P2
/// </summary>
private void MiddleAxis_To_P2(bool isdebugSpeed = false)
{
if (CheckASide())
{
MiddleAxis_A.AbsMove(MoveInfo, Config.MiddleAxis_A_P2, Config.MiddleAxis_A_P2_Speed);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.AHorizontal_Check, IO_VALUE.HIGH));
}
else
{
MiddleAxis_B.AbsMove(MoveInfo, Config.MiddleAxis_B_P2, Config.MiddleAxis_B_P2_Speed);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.BHorizontal_Check, IO_VALUE.HIGH));
}
}
/// <summary>
/// AB面移栽旋转轴到点P1
/// </summary>
private void MiddleAxis_To_P1()
{
if (CheckASide())
{
MiddleAxis_A.AbsMove(MoveInfo, Config.MiddleAxis_A_P1, Config.MiddleAxis_A_P1_Speed);
}
else
{
MiddleAxis_B.AbsMove(MoveInfo, Config.MiddleAxis_B_P1, Config.MiddleAxis_B_P1_Speed);
}
}
#endregion
/// <summary>
/// 复位前 检查抽屉信号状态
/// </summary>
/// <returns>true:可以执行复位</returns>
private bool CheckTrayState(out string msg)
{
msg = "";
bool hookA = false;
bool hookB = false;
if (IOValue(IO_Type.Hook_A_Check).Equals(IO_VALUE.HIGH))
{
LogInfo($"复位前 A侧拉取机构拉钩检测信号亮");
msg += $"A侧拉取机构拉钩检测信号亮,";
hookA = true;
}
else if (IOValue(IO_Type.Hook_B_Check).Equals(IO_VALUE.HIGH))
{
LogInfo($"复位前 B侧拉取机构拉钩检测信号亮");
msg += $"B侧拉取机构拉钩检测信号亮,";
hookB = true;
}
bool atBside = false;
bool atAside = false;
for (int i = 1; i <= trayBColumns.Length; i++)
{
if (i == trayBColumns.Length)
break;
if (GetShieldState(sheidBColmns[i]))
continue;
if (IOValue(trayBColumns[i]).Equals(IO_VALUE.LOW))//&& PullAxis_Inout.GetAclPosition()<=Config.PullAxis_Inout_P1
{
LogUtil.info($"复位前 检测到抽屉在B面[col={i}]信号未亮");
msg += $"抽屉在B面[col={i}]信号未亮";
atBside = true;
}
}
for (int i = 1; i <= trayAColumns.Length; i++)
{
if (i == trayBColumns.Length)
break;
if (GetShieldState(sheidAColmns[i]))
continue;
if (IOValue(trayAColumns[i]).Equals(IO_VALUE.LOW))//&& PullAxis_Inout.GetAclPosition() >= Config.PullAxis_Inout_P1
{
LogUtil.error($"复位前 检测到抽屉在A面[col={i}]信号未亮");
msg += $"抽屉在A面[col={i}]信号未亮";
atAside = true;
}
}
if (hookA && atAside)//A侧有抽屉在轴上
{
return true;
}
else if (hookB && atBside)//B侧有抽屉在轴上
{
return true;
}
else if (!hookA && !atAside)//A侧无抽屉在轴上
{
return true;
}
else if (!hookB && !atBside)//B侧无抽屉在轴上
{
return true;
}
else//信号异常
{
return false;
}
}
/// <summary>
/// 获取当前位置
/// </summary>
/// <param name="PosId"></param>
/// <returns>true表示抽屉挂在轴上</returns>
private bool GetCurLocation()
{
int row = 1;
int col = 1;
string side = "BB";
string PosId;
bool hookA = false;
bool hookB = false;
if (IOValue(IO_Type.Hook_A_Check).Equals(IO_VALUE.HIGH))
{
hookA = true;
LogUtil.info($"复位 A侧拉取机构拉钩检测信号亮,抽屉在拉取机构A侧");
}
else if (IOValue(IO_Type.Hook_B_Check).Equals(IO_VALUE.HIGH))
{
hookB = true;
LogUtil.info($"复位 B侧拉取机构拉钩检测信号亮,抽屉在拉取机构B侧");
}
bool atBside = false;
bool atAside = false;
for (int i = 1; i <= trayBColumns.Length; i++)
{
if (i == trayBColumns.Length)
break;
if (GetShieldState(sheidBColmns[i]))
continue;
if (IOValue(trayBColumns[i]).Equals(IO_VALUE.LOW))//&& PullAxis_Inout.GetAclPosition()<=Config.PullAxis_Inout_P1
{
LogUtil.info($"复位 检测到抽屉在B面[col={i}]");
side = "BB";
atBside = true;
col = i;
}
}
for (int i = 1; i <= trayAColumns.Length; i++)
{
if (i == trayBColumns.Length)
break;
if (GetShieldState(sheidAColmns[i]))
continue;
if (IOValue(trayAColumns[i]).Equals(IO_VALUE.LOW))//&& PullAxis_Inout.GetAclPosition() >= Config.PullAxis_Inout_P1
{
LogUtil.info($"复位 检测到抽屉在A面[col={i}]");
side = "AA";
atAside = true;
col = i;
}
}
row = GetRowByPosition(side);
PosId = $"{CID}{side}{row.ToString().PadLeft(2, '0')}{col.ToString().PadLeft(2, '0')}0101";
MoveInfo.MoveParam = new InOutParam(new InOutPosInfo("Reset", PosId));
MoveInfo.MoveParam.MoveP = new LineMoveP(Config, MoveInfo.MoveParam.PosInfo.PosId);
if (hookA && atAside)
{
return true;
}
else if (hookB && atBside)
{
return true;
}
return false;
}
/// <summary>
/// 根据当前位置获取当前层
/// </summary>
/// <returns></returns>
private int GetRowByPosition(string side)
{
int pullUpdwn = PullAxis_Updown.GetAclPosition();
int errPullUpdwn = 20000;
for (int i = 1; i <= rows; i++)
{
string currow = $"{CID}{side}{i.ToString().PadLeft(2, '0')}010101";
BoxPosition boxPosition = CSVPositionReader<BoxPosition>.GetPositon(currow);
if (boxPosition != null)
{
if ((pullUpdwn >= boxPosition.PullAxis_Updown_P4 - errPullUpdwn) &&
(pullUpdwn <= boxPosition.PullAxis_Updown_P3 + errPullUpdwn))
{
LogInfo($"料斗升降轴当前【{pullUpdwn}】在第{i}层的提取高点P3【{boxPosition.PullAxis_Updown_P3}】和提取低点P4【{boxPosition.PullAxis_Updown_P4}】之间");
return i;
}
}
}
return 1;
}
/// <summary>
/// 获取列屏蔽状态
/// </summary>
/// <param name="name"></param>
/// <returns>true表示屏蔽</returns>
private bool GetShieldState(string name)
{
int res = 0;
switch (name)
{
case "A_Col1_Sig_Shield":
res = Config.A_Col1_Sig_Shield;
break;
case "A_Col2_Sig_Shield":
res = Config.A_Col2_Sig_Shield;
break;
case "A_Col3_Sig_Shield":
res = Config.A_Col3_Sig_Shield;
break;
case "A_Col4_Sig_Shield":
res = Config.A_Col4_Sig_Shield;
break;
case "A_Col5_Sig_Shield":
res = Config.A_Col5_Sig_Shield;
break;
case "A_Col6_Sig_Shield":
res = Config.A_Col6_Sig_Shield;
break;
case "A_Col7_Sig_Shield":
res = Config.A_Col7_Sig_Shield;
break;
case "A_Col8_Sig_Shield":
res = Config.A_Col8_Sig_Shield;
break;
case "A_Col9_Sig_Shield":
res = Config.A_Col9_Sig_Shield;
break;
case "A_Col10_Sig_Shield":
res = Config.A_Col10_Sig_Shield;
break;
case "A_Col11_Sig_Shield":
res = Config.A_Col11_Sig_Shield;
break;
case "A_Col12_Sig_Shield":
res = Config.A_Col12_Sig_Shield;
break;
case "A_Col13_Sig_Shield":
res = Config.A_Col13_Sig_Shield;
break;
case "A_Col14_Sig_Shield":
res = Config.A_Col14_Sig_Shield;
break;
case "A_Col15_Sig_Shield":
res = Config.A_Col15_Sig_Shield;
break;
case "B_Col1_Sig_Shield":
res = Config.B_Col1_Sig_Shield;
break;
case "B_Col2_Sig_Shield":
res = Config.B_Col2_Sig_Shield;
break;
case "B_Col3_Sig_Shield":
res = Config.B_Col3_Sig_Shield;
break;
case "B_Col4_Sig_Shield":
res = Config.B_Col4_Sig_Shield;
break;
case "B_Col5_Sig_Shield":
res = Config.B_Col5_Sig_Shield;
break;
case "B_Col6_Sig_Shield":
res = Config.B_Col6_Sig_Shield;
break;
case "B_Col7_Sig_Shield":
res = Config.B_Col7_Sig_Shield;
break;
case "B_Col8_Sig_Shield":
res = Config.B_Col8_Sig_Shield;
break;
case "B_Col9_Sig_Shield":
res = Config.B_Col9_Sig_Shield;
break;
case "B_Col10_Sig_Shield":
res = Config.B_Col10_Sig_Shield;
break;
case "B_Col11_Sig_Shield":
res = Config.B_Col11_Sig_Shield;
break;
case "B_Col12_Sig_Shield":
res = Config.B_Col12_Sig_Shield;
break;
case "B_Col13_Sig_Shield":
res = Config.B_Col13_Sig_Shield;
break;
case "B_Col14_Sig_Shield":
res = Config.B_Col14_Sig_Shield;
break;
case "B_Col15_Sig_Shield":
res = Config.B_Col15_Sig_Shield;
break;
}
LogInfo(string.Format("列信号屏蔽状态:{0}={1}", name, res == 0 ? "屏蔽" : "开启"));
return res == 0 ? true : false;
}
#endregion
/// <summary>
/// 设置料仓状态
/// </summary>
/// <param name="deviceStatus">设备上报服务端的状态</param>
/// <param name="runStatus">设备显示的状态</param>
private void SetBoxStatus(DeviceStatus deviceStatus, RunStatus runStatus, string lastPosId = "", string lastBarcode = "")
{
this.deviceStatus = deviceStatus;
this.runStatus = runStatus;
if (!string.IsNullOrEmpty(lastPosId))
{
this.lastPosId = lastPosId;
this.lastBarcode = lastBarcode;
}
LogInfo($"设置状态:deviceStatus【{deviceStatus}】,runStatus=【{runStatus}】,lastPosId=【{lastPosId}】lastBarcode=【{lastBarcode}】");
}
private void PullAxisToP1(string InOutType = "入库")
{
if (MoveInfo.MoveStep.Equals(StepEnum.SI_00_StartInstore))
{
MoveInfo.NextMoveStep(StepEnum.SI_01_PullAxis_Ready);
}
if (MoveInfo.MoveStep.Equals(StepEnum.SIB_00_StartInstore))
{
MoveInfo.NextMoveStep(StepEnum.SIB_01_PullAxis_Ready);
}
else if (MoveInfo.MoveStep.Equals(StepEnum.SO_00_StartOutstore))
{
MoveInfo.NextMoveStep(StepEnum.SO_01_PullAxis_Ready);
}
else if (MoveInfo.MoveStep.Equals(StepEnum.SP_00_1_StartPosDebug))
{
MoveInfo.NextMoveStep(StepEnum.SP_00_2_PullAxisReady);
}
//if (!PullAxis_Updown.IsInPosition(Config.PullAxis_Updown_P1))
//{
// PullAxis_Updown.AbsMove(MoveInfo, Config.PullAxis_Updown_P1, Config.PullAxis_Updown_P1_Speed);
//}
if (PullAxis_Inout.IsInPosition(Config.PullAxis_Inout_CamA) || PullAxis_Inout.IsInPosition(Config.PullAxis_Inout_CamB)
|| PullAxis_Inout.IsInPosition(Config.PullAxis_Inout_P1))
{
}
else
{
if (CheckASide())
{
PullAxis_Inout.AbsMove(MoveInfo, Config.PullAxis_Inout_CamA, Config.PullAxis_Inout_P1_Speed);
}
else
{
PullAxis_Inout.AbsMove(MoveInfo, Config.PullAxis_Inout_CamB, Config.PullAxis_Inout_P1_Speed);
}
}
LogInfo($"{InOutType} {MoveInfo.SLog}:料屉拉取进出轴到拍照点");//料屉拉取升降轴到待机点P1、
}
/// <summary>
/// 判断行走机构是否在安全位置
/// </summary>
/// <returns></returns>
public bool IsMoveAxisInSafePos()
{
if (MoveAxis.GetAclPosition() >= Config.MoveAxis_SafePos)
return true;
return false;
}
#region 相机检查库位
#endregion
#region 入库
private DateTime startInStoreTime = DateTime.Now;
public override bool StartInstore(InOutParam param)
{
if (isInSuddenDown || isNoAirpressure_Check ||
(!runStatus.Equals(RunStatus.Runing))
|| (!MoveInfo.MoveType.Equals(MoveType.None)))
{
//LogUtil.error(Name + " 启动入库出错,忙碌或报警中 ,storeStatus=" + runStatus + ",MoveType=" + MoveInfo.MoveType + ",isInSuddenDown=" + isInSuddenDown + ",isNoAirpressure_Check=" + isNoAirpressure_Check);
return false;
}
if (!PreInStoreCheck(param))
{
return false;
}
startInStoreTime = DateTime.Now;
Alarm(AlarmType.None);
LogInfo(" 启动入库【" + param.PosInfo.ToStr() + "】 ");
param.MoveP = new LineMoveP(Config, param.PosInfo.PosId);
// LogInfo("LoadInoutParam:" + JsonHelper.SerializeObject(param.MoveP));
MoveInfo.NewMove(MoveType.InStore, param);
///开始记录
StartRecord();
SetBoxStatus(DeviceStatus.InStoreExecute, RunStatus.Busy, param.PosInfo.PosId, param.PosInfo.barcode);
if (param.PosInfoBack != null)
MoveInfo.NextMoveStep(StepEnum.SIB_00_StartInstore);
else
MoveInfo.NextMoveStep(StepEnum.SI_00_StartInstore);
AxisAlarmFlag = false;
return true;
}
private bool InDoorCheck(InOutParam param)
{
if (param.PosInfo == null)
return false;
if (CheckASide(param))
{
if (IOValue(IO_Type.FeedingA_Instore_UpperArea_ReelCheck).Equals(IO_VALUE.HIGH) && param.PosInfo != null)
{
return true;
}
}
else
{
if (IOValue(IO_Type.FeedingB_Instore_UpperArea_ReelCheck).Equals(IO_VALUE.HIGH) && param.PosInfo != null)
{
return true;
}
}
return false;
}
private bool InDoorCheck(InOutPosInfo posinfo)
{
if (posinfo == null)
return false;
if (CheckASide(posinfo))
{
if (IOValue(IO_Type.FeedingA_Instore_UpperArea_ReelCheck).Equals(IO_VALUE.HIGH) && posinfo != null)
{
return true;
}
}
else
{
if (IOValue(IO_Type.FeedingB_Instore_UpperArea_ReelCheck).Equals(IO_VALUE.HIGH) && posinfo != null)
{
return true;
}
}
return false;
}
/// <summary>
/// 入料口有料
/// </summary>
/// <returns>true:有料</returns>
private bool InDoorSigCheck()
{
if (IOValue(IO_Type.FeedingA_Instore_UpperArea_ReelCheck).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.FeedingB_Instore_UpperArea_ReelCheck).Equals(IO_VALUE.HIGH))
{
return true;
}
return false;
}
protected override void InstoreProcess()
{
if (MoveInfo.IsInWait)
{
PrintAxisSts(MoveInfo);
CheckWait(MoveInfo);
}
if (MoveInfo.IsInWait)
{
return;
}
InstoreBothSideExecute();
InstoreExecute();
}
/// <summary>
/// 打印轴状态
/// </summary>
/// <param name="moveInfo"></param>
private void PrintAxisSts(DeviceMoveInfo moveInfo)
{
List<WaitResultInfo> list = moveInfo.WaitList;
int cutWLcount = list.Count;
if (list.Count <= 0)
{
return;
}
foreach (WaitResultInfo wait in list)
{
if (wait.IsEnd)
{
continue;
}
if (wait.WaitType.Equals(WaitEnum.W001_AxisMove))
{
string msg = "";
{
wait.IsEnd = AxisBean.ACAxisStsInMove(moveInfo, wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
}
}
}
}
#endregion
#region 出库
/// <summary>
/// 出库前验证
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
private bool OutDoorCheck(InOutParam param)
{
if (param.PosInfo == null)
return false;
if (param.PosInfo.GetPosSide().Equals("A"))//A面
{
if (CheckAOutDoor())
{
return true;
}
}
else if (param.PosInfo.GetPosSide().Equals("B"))//B面
{
if (CheckBOutDoor())
{
return true;
}
}
return false;
}
private bool BothOutDoorCheck(InOutParam param)
{
if (param.PosInfo == null || param.PosInfo == null)
return false;
if (CheckAOutDoor() && CheckBOutDoor())
{
return true;
}
return false;
}
/// <summary>
/// 检查A出料口状态
/// </summary>
/// <returns>true:A口可以出料</returns>
private bool CheckAOutDoor()
{
if (BufferDataManager.AOutStoreInfo == null && IOValue(IO_Type.FeedingA_Outstore_UnderArea_ReelCheck).Equals(IO_VALUE.LOW))
{
return true;
}
return false;
}
/// <summary>
/// 检查B出料口状态
/// </summary>
/// <returns>true:B口可以出料</returns>
private bool CheckBOutDoor()
{
if (BufferDataManager.BOutStoreInfo == null && IOValue(IO_Type.FeedingB_Outstore_UnderArea_ReelCheck).Equals(IO_VALUE.LOW))
{
return true;
}
return false;
}
private static object outStoreObject = new object();
FixedSizeStack<string> recentAOutstores = new FixedSizeStack<string>(5);
FixedSizeStack<string> recentBOutstores = new FixedSizeStack<string>(5);
public bool StartExecuctOut(InOutParam param)
{
bool result = false;
result = StartOutstore(param);
if (!result)
{
lock (outStoreObject)
{
if (MoveInfo.MoveType.Equals(MoveType.OutStore) &&
(MoveInfo.MoveParam.PosInfo.PosId.Equals(param.PosInfo.PosId)
|| (MoveInfo.MoveParam.PosInfoBack != null && MoveInfo.MoveParam.PosInfoBack.PosId.Equals(param.PosInfo.PosId))))
{
LogUtil.error(Name + " 出库命令【" + param.PosInfo.ToStr() + "】重复,【" + MoveInfo.MoveParam.PosInfo.PosId + "】出库执行中");
return false;
}
if (recentAOutstores.Contains(param.PosInfo.PosId) || recentBOutstores.Contains(param.PosInfo.PosId))
{
LogUtil.error(Name + " 出库命令【" + param.PosInfo.ToStr() + "】重复,在最近的出库列表");
return false;
}
List<InOutParam> reviceList = new List<InOutParam>();
reviceList.AddRange(waitAOutStoreList);
reviceList.AddRange(waitBOutStoreList);
reviceList = (from m in reviceList where m.PosInfo.PosId.Equals(param.PosInfo.PosId) select m).ToList<InOutParam>();
if (reviceList.Count == 0)
{
LogInfo(" 执行出库【" + param.PosInfo.ToStr() + "】失败,加入等待队列");
if (param.PosInfo.GetPosSide().Equals("A"))
{
waitAOutStoreList.Enqueue(param);
}
else if (param.PosInfo.GetPosSide().Equals("B"))
{
waitBOutStoreList.Enqueue(param);
}
}
}
}
return result;
}
private DateTime startOutStoreTime = DateTime.Now;
/// <summary>
/// 关闭出库前的碗里检查
/// </summary>
public bool CloseOutStoreCheck = false;
public override bool StartOutstore(InOutParam param)
{
//if (InDoorSigCheck())
//{
// return false;
//}
if (!CloseOutStoreCheck)
{
if (!OutDoorCheck(param))
{
return false;
}
}
if (isInSuddenDown || isNoAirpressure_Check
|| !runStatus.Equals(RunStatus.Runing)
|| !MoveInfo.MoveType.Equals(MoveType.None))
{
// LogUtil.error(Name + " 启动出库【" + param.PosInfo.ToStr() + "】失败,忙碌或报警中 ,storeStatus:" + runStatus + ",MoveType:" + MoveInfo.MoveType + ",isInSuddenDown:" + isInSuddenDown + ",isNoAirCheck:" + isNoAirpressure_Check);
return false;
}
if (!param.PosInfo.CheckPosition())
{
SetWarnMsg(Name + " 启动出库【" + param.PosInfo.ToStr() + "】出错,找不到库位信息");
return false;
}
if (recentAOutstores.Contains(param.PosInfo.PosId) || recentBOutstores.Contains(param.PosInfo.PosId))
{
LogUtil.error(Name + " 出库命令【" + param.PosInfo.ToStr() + "】重复,在最近的出库列表");
return false;
}
startOutStoreTime = DateTime.Now;
Alarm(AlarmType.None);
param.MoveP = new LineMoveP(Config, param.PosInfo.PosId);
SetBoxStatus(DeviceStatus.OutStoreExecute, RunStatus.Busy, param.PosInfo.PosId, param.PosInfo.barcode);
MoveInfo.NewMove(MoveType.OutStore, param);
LogInfo("启动出库【" + param.PosInfo.ToStr() + "】 ");
///开始记录
StartRecord();
//LogInfo("LoadInoutParam:" + JsonHelper.SerializeObject(param.MoveP));
MoveInfo.NextMoveStep(StepEnum.SO_00_StartOutstore);
AxisAlarmFlag = false;
return true;
}
protected override void OutstoreProcess()
{
if (MoveInfo.IsInWait)
{
PrintAxisSts(MoveInfo);
CheckWait(MoveInfo);
}
if (MoveInfo.IsInWait)
{
return;
}
OutstoreExecute();
OutstoreExecute_BothSide();
}
#endregion
}
}