LineBean_Partial.cs
58.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
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
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
partial class LineBean
{
#region 定时处理方法
public bool LineCanRun()
{
return true;
}
public bool CanProcessLine(bool isCheckSleep = true)
{
if (runStatus <= LineRunStatus.Wait)
{
return false ;
}
if (LineCanRun() &&
IOManager.IOValue(IO_Type.DriveMotor_Run1, 0).Equals(IO_VALUE.HIGH) &&
IOManager.IOValue(IO_Type.DriveMotor_Run2, 0).Equals(IO_VALUE.HIGH) &&
IOManager.IOValue(IO_Type.DriveMotor_Run3, 0).Equals(IO_VALUE.HIGH) &&
IOManager.IOValue(IO_Type.DriveMotor_Run4, 0).Equals(IO_VALUE.HIGH))
{
return true;
}
return false;
}
private DateTime preIoTimerOutTime = DateTime.Now;
private void IOTimeOutProcess()
{
try
{
TimeSpan span = DateTime.Now - preIoTimerOutTime;
if (span.TotalSeconds > 1 && alarmType.Equals(LineAlarmType.IoSingleTimeOut))
{
preIoTimerOutTime = DateTime.Now;
if (runStatus < LineRunStatus.Runing || isInSuddenDown || isNoAirCheck)
{
return;
}
//若BOX和移栽都没有在等待Io的过程中则此Io超时异常可能已经处理过
if (MoveInfo.IsInWait.Equals(false) && SW41_MoveInfo.IsInWait.Equals(false) && SW23_MoveInfo.IsInWait.Equals(false))
{
LogUtil.info(Name + "清理信号超时报警【" + WarnMsg + "】 ");
alarmType = LineAlarmType.None;
SetWarnMsg("");
}
}
}
catch (Exception ex)
{
LogUtil.error("IOTimeOutProcess出错:", ex);
}
}
private DateTime preRWTime = DateTime.Now;
private void CheckWait(LineMoveInfo checkWaitInfo)
{
try
{
List<WaitResultInfo> list = checkWaitInfo.WaitList;
if (list.Count <= 0)
{
checkWaitInfo.EndStepWait();
return;
}
//当等待超过一分钟时,需要打印提示
TimeSpan span = DateTime.Now - checkWaitInfo.LastSetpTime;
string NotOkMsg = "";
bool isOk = true;
if (checkWaitInfo.OneWaitCanEndStep)
{
isOk = false;
}
foreach (WaitResultInfo wait in list)
{
if (wait == null)
{
LogUtil.error(Name + "[" + checkWaitInfo.MoveType + "][" + checkWaitInfo.MoveStep + "] wait == null 跳过此项等待");
continue;
}
if (wait == null || wait.IsEnd)
{
continue;
}
NotOkMsg = " [" + wait.ToStr() + "] ";
if (wait.WaitType.Equals(WaitEnum.W002_IOValue))
{
NotOkMsg = " [" + Config.GetDisplayName(wait.IoType) + "=" + wait.IoValue + "] ";
wait.IsEnd = IOValue(wait.IoType).Equals(wait.IoValue);
if (!wait.IsEnd)
{
TimeSpan rwSpan = DateTime.Now - preRWTime;
//一分钟还未检测到
if (span.TotalSeconds > LineManager.Config.IOSingle_TimerOut && NoAlarm())
{
ConfigIO io = baseConfig.getWaitIO(wait.IoType);
string warnMsg= checkWaitInfo.Name + "[" + checkWaitInfo.MoveStep + "]等待" + NotOkMsg + " 超时";
SetWarnMsg(warnMsg, checkWaitInfo.GetStepDes()+"_超时报警", checkWaitInfo);
Alarm(LineAlarmType.IoSingleTimeOut);
}
//超过报警时长
else if (rwSpan.TotalSeconds > 5 && span.TotalSeconds > 6 && span.TotalSeconds < LineManager.Config.IOSingle_TimerOut * 2)
{
preRWTime = DateTime.Now;
string msg = checkWaitInfo.Name + " " + NotOkMsg + "已等待 " + Math.Round(span.TotalSeconds, 1) + "秒,重写DO:";
bool isLog = false;
foreach (WaitResultInfo ww in list)
{
if (ww != null && ww.WaitType.Equals(2) && baseConfig.DOList.ContainsKey(ww.IoType))
{
if (IOManager.DOValue(ww.IoType, baseConfig.Id).Equals(ww.IoValue).Equals(false))
{
isLog = true;
IOMove(ww.IoType, ww.IoValue);
msg += ww.ToStr() + ",";
}
}
}
if (isLog)
{
LogUtil.error(msg);
}
}
if (!checkWaitInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W003_Time))
{
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
}
else if (wait.WaitType.Equals(WaitEnum.W008_InStoreCheckOK))
{
string posId = checkWaitInfo.MoveParam.PosId;
int id = checkWaitInfo.MoveParam.GetStoreId();
wait.IsEnd = LineServer.RightInPosId(id, posId);
}
else if (wait.WaitType.Equals(WaitEnum.W009_BoxCanInstore))
{
int storeId = checkWaitInfo.MoveParam.GetStoreId();
wait.IsEnd = LineServer.BoxCanReviceTray(storeId,out NotOkMsg);
}
else if (wait.WaitType.Equals(WaitEnum.W010_SWCanTopUp))
{
wait.IsEnd = SwCanUpMove(wait.TargetPosition);
}
if (wait.IsEnd)
{
if (checkWaitInfo.OneWaitCanEndStep)
{
isOk = true;
break;
}
}
else
{
if (!checkWaitInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
if (isOk)
{
checkWaitInfo.EndStepWait();
ClearStepAlarm(checkWaitInfo.GetStepDes());
}
else if (span.TotalSeconds > checkWaitInfo.TimeOutSeconds)
{
string wanMsg = checkWaitInfo.Name + "[" + checkWaitInfo.MoveStep + "][" + NotOkMsg + "]已等待[" + Math.Round(span.TotalSeconds, 1) + "]秒";
SetWarnMsg(wanMsg, checkWaitInfo.GetStepDes()+"_超时报警" , checkWaitInfo);
Alarm(LineAlarmType.IoSingleTimeOut);
}
}
catch (Exception ex)
{
LogUtil.error(checkWaitInfo.Name + " [" + checkWaitInfo.MoveStep + "] CheckWait 出错:", ex);
//如果是空指针异常,并且MoveStep=SW06_TopCylinderUp,单独处理
// [2020-08-10 13:32:45,352] [132] ERROR 横移轨道-41 [SW06_TopCylinderUp]
// CheckWait 出错:
//System.IndexOutOfRangeException: 索引超出了数组界限。
// 在 System.Collections.Generic.List`1.Enumerator.MoveNext()
// 在 OnlineStore.DeviceLibrary.LineBean.CheckWait(LineMoveInfo checkWaitInfo) 位置 E:\VSSource\RC1250_佳士达\RC1250-AssemblyLine\source\DeviceLibrary\assemblyLine\LineBean_Partial.cs:行号 89
if (ex is System.IndexOutOfRangeException)
{
if (checkWaitInfo.MoveStep.Equals(LineMoveStep.SW06_TopCylinderUp))
{
LogUtil.error(checkWaitInfo.Name + " 当前步骤:SW06_TopCylinderUp,IndexOutOfRangeException异常,自动回到上一个步骤 SW05_LocationDown,等待500 重新开始 ");
checkWaitInfo.NextMoveStep(LineMoveStep.SW05_LocationDown);
checkWaitInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
}
}
}
}
#endregion
#region 出库
public override bool StartOutStoreMove(InOutParam param)
{
return true;
}
protected override void OutStoreProcess()
{
}
#endregion
#region 入库
public override bool StartInStoreMove(InOutParam param)
{
return true;
}
protected override void InStoreProcess()
{
}
#endregion
#region IO操作
private void InOutLog(string msg)
{
LogUtil.debug(Name + msg);
}
private bool IsDoValue(string ioType, IO_VALUE value)
{
if (IOManager.DOValue(ioType, 0).Equals(value))
{
return true;
}
return false;
}
#endregion
#region 横移处理-
internal int SW23WaitTrayNum = -1;
internal int SW41WaitTrayNum = -1;
internal int Sw41TrayNum = 0;
internal int Sw23TrayNum = 0;
private void Equip_TrayPEndEvent(int swNum, int trayNum)
{
try
{
if (swNum <= 0 || this.runStatus <= (LineRunStatus.Wait))
{
return;
}
if (swNum.Equals(2))
{
if (SW23_MoveInfo.MoveType.Equals(LineMoveType.None))
{
Sw23TrayNum = trayNum;
SW23_MoveInfo.NewMove(LineMoveType.InStore);
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW03_WaitTime);
SW23WaitTrayNum = -1;
SW23_SW04_WaitCanUp();
}
else
{
SW23WaitTrayNum = trayNum;
LogUtil.debug(Name+"Equip_TrayPEndEvent【" + swNum + "】【" + trayNum + "】失败,SW23_MoveInfo 忙碌中,记录 SW23WaitTrayNum=" + SW23WaitTrayNum);
}
}
else if (swNum.Equals(4))
{
if (SW41_MoveInfo.MoveType.Equals(LineMoveType.None))
{
Sw41TrayNum = trayNum;
SW41_MoveInfo.NewMove(LineMoveType.InStore);
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW03_WaitTime);
SW41WaitTrayNum = -1;
SW41_SW04_WaitCanUp();
}
else
{
SW41WaitTrayNum = trayNum;
LogUtil.debug(Name + "Equip_TrayPEndEvent【" + swNum + "】【" + trayNum + "】失败,SW41_MoveInfo 忙碌中,记录 SW41WaitTrayNum =" + SW41WaitTrayNum);
}
}
}
catch (Exception ex)
{
LogUtil.error(Name + "Equip_TrayPEndEvent出错:", ex);
}
}
/// <summary>
/// 入料三和出料四使用,判断是否可以开始处理托盘
/// 横移无处理,上料机构和出料机构判断使用
/// </summary>
internal bool SwNoProcess(int sidesWayNum)
{
//20200228修改,横移机构可以同时存在两个托盘
try
{
if (runStatus <= LineRunStatus.Wait || sidesWayNum <= 0)
{
return true;
}
if (sidesWayNum.Equals(2) && SW23WaitTrayNum < 0)
{
if (SW23_MoveInfo.MoveType.Equals(LineMoveType.None))
{
return true;
}
else if (SW23_MoveInfo.MoveStep <= (LineMoveStep.SW13_WaitTrayGo)
&& SW23_MoveInfo.MoveStep >= (LineMoveStep.SW10_WatOutFixture2)
)
{
if (CylinderIsOk(IO_Type.SW2_TopCylinder_Up, IO_Type.SW2_TopCylinder_Down))
{
return true;
}
else
{
CylinderMove(null, IO_Type.SW2_TopCylinder_Up, IO_Type.SW2_TopCylinder_Down);
}
}
}
else if (sidesWayNum.Equals(3) && SW23WaitTrayNum < 0 && runStatus <= LineRunStatus.Wait)
{
return true;
}
else if (sidesWayNum.Equals(4) && SW41WaitTrayNum < 0)
{
if (SW41_MoveInfo.MoveType.Equals(LineMoveType.None))
{
return true;
}
else if (SW41_MoveInfo.MoveStep <= (LineMoveStep.SW13_WaitTrayGo)
&& SW41_MoveInfo.MoveStep >= (LineMoveStep.SW10_WatOutFixture2))
{
if (CylinderIsOk(IO_Type.SW4_TopCylinder_Up, IO_Type.SW4_TopCylinder_Down))
{
return true;
}
else
{
CylinderMove(null, IO_Type.SW4_TopCylinder_Up, IO_Type.SW4_TopCylinder_Down);
}
}
}
else if (sidesWayNum.Equals(1) && SW41WaitTrayNum < 0 && runStatus <= LineRunStatus.Wait)
{
return true;
}
}
catch (Exception ex)
{
LogUtil.error("SwNoProcess [" + sidesWayNum + "] error :" + ex.ToString());
}
return false;
}
/// <summary>
/// 横移机构横移顶升之前判断
/// 等待横移机构是否可以开始顶升上升横移
/// </summary>
internal bool SwCanUpMove(int sidesWayNum)
{
//20200228修改,横移机构可以同时存在两个托盘
try
{
if (LineManager.Line.runStatus <= LineRunStatus.Wait || sidesWayNum <= 0)
{
return true;
}
if (sidesWayNum.Equals(3))
{
LineMoveInfo moveInfo = FeedingEquipMap[104].SecondMoveInfo;
if (IOValue(IO_Type.SW3_TrayCheck).Equals(IO_VALUE.LOW) && moveInfo.MoveType.Equals(LineMoveType.None))
{
return true;
}
}
else if (sidesWayNum.Equals(1))
{
LineMoveInfo moveInfo = FeedingEquipMap[101].SecondMoveInfo;
if (IOValue(IO_Type.SW1_TrayCheck).Equals(IO_VALUE.LOW) && moveInfo.MoveType.Equals(LineMoveType.None))
{
return true;
}
}
}
catch (Exception ex)
{
LogUtil.error("SwCanUpMove [" + sidesWayNum + "] error :" + ex.ToString());
}
return false;
}
private static LineMoveInfo SW41_MoveInfo = null;
private static LineMoveInfo SW23_MoveInfo = null;
private void SideWayStop()
{
sw23WaitWatch.Stop();
sw41WaitWatch.Stop();
SW41_MoveInfo.EndMove();
SW23_MoveInfo.EndMove();
IOMove(IO_Type.SW1_MotorRun, IO_VALUE.LOW);
IOMove(IO_Type.SW2_MotorRun, IO_VALUE.LOW);
IOMove(IO_Type.SW3_MotorRun, IO_VALUE.LOW);
IOMove(IO_Type.SW4_MotorRun, IO_VALUE.LOW);
}
private Stopwatch sw41WaitWatch = new Stopwatch();
private Stopwatch sw23WaitWatch = new Stopwatch();
private bool sdIsInprocess = false;
private DateTime sdlastProTime = DateTime.Now;
private DateTime lastSw2StopDownTime = DateTime.Now;
private DateTime lastSw4StopDownTime = DateTime.Now;
private void SideWayTimerProcess()
{
TimeSpan span = DateTime.Now - sdlastProTime;
if (sdIsInprocess && span.TotalSeconds < 5)
{
return;
}
try
{
sdIsInprocess = true;
sdlastProTime = DateTime.Now;
//流水线转动中,并且在忙碌或出入库处理中,需要处理移栽
if (!CanProcessLine())
{
sw41WaitWatch.Stop();
sw23WaitWatch.Stop();
sdIsInprocess = false;
return;
}
if ((!LineStopRun) || hasTray() )
{
if (SW23_MoveInfo.MoveType.Equals(LineMoveType.None) && SW23WaitTrayNum >= 0)
{
Equip_TrayPEndEvent(2, SW23WaitTrayNum);
}
if (SW41_MoveInfo.MoveType.Equals(LineMoveType.None) && SW41WaitTrayNum >= 0)
{
Equip_TrayPEndEvent(4, SW41WaitTrayNum);
}
}
if (SW41_MoveInfo.MoveType.Equals(LineMoveType.None) && ProvidingEquipMap[204].runStatus <= LineRunStatus.Wait)
{
if ((!LineStopRun) || hasTray())
{
if (IOValue(IO_Type.SW4_TrayCheck).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.SW1_TrayCheck).Equals(IO_VALUE.LOW) &&
TrayManager.LineCanMoveSW(4) && TrayManager.LineCanMoveSW(1))
{
if (TrayManager.checkWatch(sw41WaitWatch, TrayManager.SwTrayWaitTime, true))
{
SW41_MoveInfo.NewMove(LineMoveType.InStore);
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW03_WaitTime);
UpateSw41TrayNum();
SWLog("横移轨道41:检测到SW4_TrayCheck,再次检测,更新托盘号 [" + Sw41TrayNum + "] ");
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW4_TrayCheck, IO_VALUE.HIGH));
}
}
else if (IOValue(IO_Type.SW4_StopCheck).Equals(IO_VALUE.HIGH) &&
IOValue(IO_Type.SW4_StopDown).Equals(IO_VALUE.LOW) &&
IOValue(IO_Type.SW4_TrayCheck).Equals(IO_VALUE.LOW) &&
IOValue(IO_Type.SW1_TrayCheck).Equals(IO_VALUE.LOW) &&
(DateTime.Now - lastSw4StopDownTime).TotalSeconds > 2 &&
TrayManager.LineCanMoveSW(4) && TrayManager.LineCanMoveSW(1))
{
if (TrayManager.checkWatch(sw41WaitWatch, TrayManager.SwTrayWaitTime, true))
{
SW41_MoveInfo.NewMove(LineMoveType.InStore);
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW00_Wait);
// UpateSw41TrayNum();
LogUtil.info(Name + "横移轨道41:检测到SW4_StopCheck, 开始处理托盘 ");
//阻挡气缸下降500毫秒然后上升
lastSw4StopDownTime = DateTime.Now;
}
}
else
{
sw41WaitWatch.Stop();
}
}
}
else
{
sw41WaitWatch.Stop();
SideWay41BusyProcess();
}
if (SW23_MoveInfo.MoveType.Equals(LineMoveType.None) && FeedingEquipMap[103].runStatus <= LineRunStatus.Wait)
{
if ((!LineStopRun) || hasTray())
{
//检测到阻挡夹具信号后,阻挡气缸下降,等待有夹具信号,阻挡气缸上升,
//顶升气缸上升到位,开始流水线转动,检测到出口信号后,停止转动,顶升气缸下降,阻挡4下降,盘通过
if (IOValue(IO_Type.SW2_TrayCheck).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.SW3_TrayCheck).Equals(IO_VALUE.LOW) &&
TrayManager.LineCanMoveSW(2) && TrayManager.LineCanMoveSW(3))
{
if (TrayManager.checkWatch(sw23WaitWatch, TrayManager.SwTrayWaitTime, true))
{
SW23_MoveInfo.NewMove(LineMoveType.InStore);
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW03_WaitTime);
UpateSw23TrayNum();
SWLog("横移轨道23:检测到SW2_TrayCheck,再次检测,更新托盘号 [" + Sw23TrayNum + "] ");
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW2_TrayCheck, IO_VALUE.HIGH));
}
}
else if (IOValue(IO_Type.SW2_StopCheck).Equals(IO_VALUE.HIGH) &&
IOValue(IO_Type.SW2_StopDown).Equals(IO_VALUE.LOW) &&
IOValue(IO_Type.SW2_TrayCheck).Equals(IO_VALUE.LOW) &&
IOValue(IO_Type.SW3_TrayCheck).Equals(IO_VALUE.LOW) &&
(DateTime.Now - lastSw2StopDownTime).TotalSeconds > 2 &&
TrayManager.LineCanMoveSW(2) && TrayManager.LineCanMoveSW(3))
{
if (TrayManager.checkWatch(sw23WaitWatch, TrayManager.SwTrayWaitTime, true))
{
SW23_MoveInfo.NewMove(LineMoveType.InStore);
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW00_Wait);
// UpateSw23TrayNum();
LogUtil.info(Name + "横移轨道23:检测到SW2_StopCheck, 开始处理托盘 ");
//阻挡气缸下降500毫秒然后上升
lastSw2StopDownTime = DateTime.Now;
}
}
else
{
sw23WaitWatch.Stop();
}
}
}
else
{
sw23WaitWatch.Stop();
SideWay23BusyProcess();
}
}
catch (Exception ex)
{
LogUtil.error(Name + "SideWayTimerProcess 出错:", ex);
}
sdIsInprocess = false;
}
private void UpateSw41TrayNum()
{
Sw41TrayNum = 0;
if (ProvidingEquipMap.ContainsKey(204))
{
ProvidingEquip eq = ProvidingEquipMap[204];
if (eq.runStatus >= LineRunStatus.HomeMoving)
{
Sw41TrayNum = eq.currTrayNum;
}
else
{
Sw41TrayNum = RFIDManager.GetTrayNum(204, true);
SServerManager.updateTray(Sw41TrayNum);
}
}
}
private void UpateSw23TrayNum()
{
Sw23TrayNum = 0;
if (FeedingEquipMap.ContainsKey(103))
{
FeedingEquip eq = FeedingEquipMap[103];
if (eq.runStatus >= LineRunStatus.HomeMoving)
{
Sw23TrayNum = eq.currTrayNum;
}
else
{
Sw23TrayNum = RFIDManager.GetTrayNum(103, true);
SServerManager.updateTray(Sw23TrayNum);
}
}
}
private void SideWay41BusyProcess()
{
if (SW41_MoveInfo.IsInWait)
{
CheckWait(SW41_MoveInfo);
}
if (SW41_MoveInfo.IsInWait)
{
return;
}
if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW00_Wait))
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW01_StopDown);
LogUtil.info(Name + "横移轨道41: 阻挡气缸下降 等待 SW4_StopCheck=0");
IOMove(IO_Type.SW4_StopDown, IO_VALUE.HIGH);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW4_StopCheck, IO_VALUE.LOW));
//SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.StopDownWaitTime));
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW01_StopDown))
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW02_WaitCheckTime);
SWLog("横移轨道41: 等待横移4托盘检测信号 , SW011_WaitCheckTime ");
IOMove(IO_Type.SW4_StopDown, IO_VALUE.LOW);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW4_TrayCheck, IO_VALUE.HIGH));
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW02_WaitCheckTime))
{
UpateSw41TrayNum();
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW03_WaitTime);
SWLog("横移轨道41: 等待横移4托盘检测信号 , SW012_WaitTime " + TrayManager.SwTrayWaitTime+",更新托盘号【"+Sw41TrayNum+"】");
CheckAndMove(IO_Type.SW4_StopDown, IO_VALUE.LOW);
// SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.SwTrayWaitTime));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW4_TrayCheck, IO_VALUE.HIGH));
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW03_WaitTime))
{
if (IOValue(IO_Type.SW4_TrayCheck).Equals(IO_VALUE.HIGH))
{
SW41_SW04_WaitCanUp();
}
else
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW03_WaitTime);
SWLog("横移轨道41: 等待横移4托盘检测信号 , SW012_WaitTime " + TrayManager.SwTrayWaitTime);
CheckAndMove(IO_Type.SW4_StopDown, IO_VALUE.LOW);
// SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.SwTrayWaitTime));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW4_TrayCheck, IO_VALUE.HIGH));
}
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW04_WaitCanUp))
{
SW41_SW05_LocationDown();
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW05_LocationDown))
{
SW41_SW06_TopCylinderUp();
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW06_TopCylinderUp))
{
SW41_SW07_WaitNoTray();
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW07_WaitNoTray))
{
SW41_SW08_DriveMotorMove();
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW08_DriveMotorMove))
{
if (IOValue(IO_Type.SW4_TrayCheck).Equals(IO_VALUE.LOW) && IOValue(IO_Type.SW1_TrayCheck).Equals(IO_VALUE.HIGH))
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW09_WaitOutCheck);
SWLog("横移轨道41:收到SW1_TrayCheck,先顶升4下降 ");
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
CylinderMove(null, IO_Type.SW4_TopCylinder_Up, IO_Type.SW4_TopCylinder_Down);
// SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW1_TrayCheck, IO_VALUE.HIGH));
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW10_WatOutFixture2);
SWLog("横移轨道41:再次验证托盘是否在出口处,停止横移4的皮带线 ");
// SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW1_TrayCheck, IO_VALUE.HIGH));
//需要停止横移4的皮带线
IOMove(IO_Type.SW4_MotorRun, IO_VALUE.LOW);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW4_MotorRun, IO_VALUE.LOW));
}
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW09_WaitOutCheck))
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW10_WatOutFixture2);
SWLog("横移轨道41:再次验证托盘是否在出口处,停止横移4的皮带线 ");
//SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW1_TrayCheck, IO_VALUE.HIGH));
//需要停止横移4的皮带线
IOMove(IO_Type.SW4_MotorRun, IO_VALUE.LOW);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW4_MotorRun, IO_VALUE.LOW));
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW10_WatOutFixture2))
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW11_TopDown);
SWLog("横移轨道41:托盘已到达出口,顶升气缸下降,判断入料1是否需要此托盘 ");
// CylinderMove(SW41_MoveInfo, IO_Type.SW4_TopCylinder_Up, IO_Type.SW4_TopCylinder_Down);
//Thread.Sleep(50);
if (!CheckTrayIsNeed(101, Sw41TrayNum))
{
CylinderMove(SW41_MoveInfo, IO_Type.SW1_TopCylinder_Up, IO_Type.SW1_TopCylinder_Down);
}
//CylinderMove(SW41_MoveInfo, IO_Type.SW4_TopCylinder_Up, IO_Type.SW4_TopCylinder_Down);
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW11_TopDown))
{
bool result = false;
bool topCylinderDown = true;
//如果顶升1没有下降,才判断是否需要入库
if (IOValue(IO_Type.SW1_TopCylinder_Down).Equals(IO_VALUE.LOW) && IOValue(IO_Type.SW1_TopCylinder_Up).Equals(IO_VALUE.HIGH))
{
topCylinderDown = false;
result = FeedingEquipMap[101].CanStartCheckOut(Sw41TrayNum);
}
if (result)
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW13_WaitTrayGo);
SWLog("横移轨道41:关闭皮带电机,不需要等待 托盘离开");
IOMove(IO_Type.SW4_MotorRun, IO_VALUE.LOW);
IOMove(IO_Type.SW1_MotorRun, IO_VALUE.LOW);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW4_MotorRun, IO_VALUE.LOW));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW1_MotorRun, IO_VALUE.LOW));
}
else
{
//启动入库失败,需要下降顶升气缸
if (topCylinderDown)
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW12_WaitTime);
SWLog("横移轨道41:关闭皮带电机,等待1秒后,关闭横移电机 ");
IOMove(IO_Type.SW4_MotorRun, IO_VALUE.LOW);
IOMove(IO_Type.SW1_MotorRun, IO_VALUE.LOW);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
else
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW11_TopDown);
SWLog("横移轨道41:托盘已到达出口,重新顶升气缸下降 ");
CylinderMove(SW41_MoveInfo, IO_Type.SW1_TopCylinder_Up, IO_Type.SW1_TopCylinder_Down);
}
}
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW12_WaitTime))
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW13_WaitTrayGo);
SWLog("横移轨道41:关闭皮带电机,等待SW1_TrayCheck=0,关闭横移电机 ");
IOMove(IO_Type.SW4_MotorRun, IO_VALUE.LOW);
IOMove(IO_Type.SW1_MotorRun, IO_VALUE.LOW);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW1_TrayCheck, IO_VALUE.LOW));
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW13_WaitTrayGo))
{
lastSw4StopDownTime = DateTime.Now.AddSeconds(-2);
SW41_MoveInfo.EndMove();
CylinderMove(null, IO_Type.SW1_TopCylinder_Down, IO_Type.SW1_TopCylinder_Up);
SWLog("横移轨道41:横移结束 ,横移1顶升上升 ");
}
}
private void SW41_SW08_DriveMotorMove()
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW08_DriveMotorMove);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
SWLog("横移轨道41:开始转动电机 ,等待1000,SW4_TrayCheck=0, SW1_TrayCheck=1 ");
IOMove(IO_Type.SW4_MotorRun, IO_VALUE.HIGH);
IOMove(IO_Type.SW1_MotorRun, IO_VALUE.HIGH);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW4_MotorRun, IO_VALUE.HIGH));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW1_MotorRun, IO_VALUE.HIGH));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW1_TrayCheck, IO_VALUE.HIGH));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW4_TrayCheck, IO_VALUE.LOW));
}
private void SW41_SW07_WaitNoTray()
{
if (IOValue(IO_Type.SW1_TrayCheck).Equals(IO_VALUE.LOW))
{
SW41_SW08_DriveMotorMove();
}
else
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW07_WaitNoTray);
SWLog("横移轨道41: 等待 SW1_TrayCheck=0 ");
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW1_TrayCheck, IO_VALUE.LOW));
}
}
private void SW41_SW06_TopCylinderUp()
{
if (CylinderIsOk(IO_Type.SW4_TopCylinder_Down, IO_Type.SW4_TopCylinder_Up) &&
CylinderIsOk(IO_Type.SW1_TopCylinder_Down, IO_Type.SW1_TopCylinder_Up))
{
SW41_SW07_WaitNoTray();
}
else
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW06_TopCylinderUp);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
SWLog("横移轨道41:顶升气缸上升 ,至少等待1000 ");
IOMove(IO_Type.SW4_StopDown, IO_VALUE.LOW);
CylinderMove(SW41_MoveInfo, IO_Type.SW4_TopCylinder_Down, IO_Type.SW4_TopCylinder_Up);
CylinderMove(SW41_MoveInfo, IO_Type.SW1_TopCylinder_Down, IO_Type.SW1_TopCylinder_Up);
}
}
private void SW41_SW05_LocationDown()
{
if (CylinderIsOk(IO_Type.SW4_LocationCylinder_Up, IO_Type.SW4_LocationCylinder_Down) &&
CylinderIsOk(IO_Type.SW1_LocationCylinder_Up, IO_Type.SW1_LocationCylinder_Down))
{
SW41_SW06_TopCylinderUp();
}
else
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW05_LocationDown);
SWLog("横移轨道41:定位气缸下降 ");
CylinderMove(SW41_MoveInfo, IO_Type.SW4_LocationCylinder_Up, IO_Type.SW4_LocationCylinder_Down);
CylinderMove(SW41_MoveInfo, IO_Type.SW1_LocationCylinder_Up, IO_Type.SW1_LocationCylinder_Down);
}
}
private void SW41_SW04_WaitCanUp()
{
if (IOValue(IO_Type.SW4_TrayCheck).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.SW1_TrayCheck).Equals(IO_VALUE.LOW) && SwCanUpMove(1))
{
SW41_SW05_LocationDown();
}
else
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW04_WaitCanUp);
SWLog("横移轨道41: 等待横移4托盘检测信号 ,SW4_StopDown上升 ,等待横移1(上料1)无托盘处理 ");
CheckAndMove(IO_Type.SW4_StopDown, IO_VALUE.LOW);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW4_TrayCheck, IO_VALUE.HIGH));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW1_TrayCheck, IO_VALUE.LOW));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitSWCanTopUp(1));
}
}
private bool CheckTrayIsNeed(int deviceId, int trayNum)
{
//横移1对应入料1
if (FeedingEquipMap.ContainsKey(deviceId))
{
FeedingEquip equip = FeedingEquipMap[deviceId];
if (equip.runStatus >= LineRunStatus.Runing)
{
if (equip.CurrTrayIsNeed(trayNum, false))
{
return true;
}
}
}
return false;
}
private void SideWay23BusyProcess()
{
if (SW23_MoveInfo.IsInWait)
{
CheckWait(SW23_MoveInfo);
}
if (SW23_MoveInfo.IsInWait)
{
return;
}
if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW00_Wait))
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW01_StopDown);
LogUtil.info(Name + "横移轨道23:阻挡气缸下降 等待 SW2_StopCheck=0 ");
IOMove(IO_Type.SW2_StopDown, IO_VALUE.HIGH);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW2_StopCheck, IO_VALUE.LOW));
// SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.StopDownWaitTime));
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW01_StopDown))
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW02_WaitCheckTime);
SWLog("横移轨道23: 等待横移4托盘检测信号 , SW011_WaitCheckTime ");
IOMove(IO_Type.SW2_StopDown, IO_VALUE.LOW);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW2_TrayCheck, IO_VALUE.HIGH));
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW02_WaitCheckTime))
{
UpateSw23TrayNum();
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW03_WaitTime);
SWLog("横移轨道23: 等待横移4托盘检测信号 , SW012_WaitTime " + TrayManager.SwTrayWaitTime + ",更新托盘号【" + Sw23TrayNum + "】");
CheckAndMove(IO_Type.SW2_StopDown, IO_VALUE.LOW);
// SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.SwTrayWaitTime));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW2_TrayCheck, IO_VALUE.HIGH));
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW03_WaitTime))
{
if (IOValue(IO_Type.SW2_TrayCheck).Equals(IO_VALUE.HIGH))
{
SW23_SW04_WaitCanUp();
}
else
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW03_WaitTime);
SWLog("横移轨道23: 等待横移4托盘检测信号 , SW012_WaitTime " + TrayManager.SwTrayWaitTime);
CheckAndMove(IO_Type.SW2_StopDown, IO_VALUE.LOW);
// SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(TrayManager.SwTrayWaitTime));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW2_TrayCheck, IO_VALUE.HIGH));
}
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW04_WaitCanUp))
{
SW23_SW05_LocationDown();
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW05_LocationDown))
{
SW23_SW06_TopCylinderUp();
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW06_TopCylinderUp))
{
SW23_SW07_WaitNoTray();
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW07_WaitNoTray))
{
SW23_SW08_DriveMotorMove();
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW08_DriveMotorMove))
{
if (IOValue(IO_Type.SW2_TrayCheck).Equals(IO_VALUE.LOW) && IOValue(IO_Type.SW3_TrayCheck).Equals(IO_VALUE.HIGH))
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW09_WaitOutCheck);
SWLog("横移轨道23:收到 SW3_TrayCheck,先顶升2下降, ");
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
CylinderMove(null, IO_Type.SW2_TopCylinder_Up, IO_Type.SW2_TopCylinder_Down);
//SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW3_TrayCheck, IO_VALUE.HIGH));
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW10_WatOutFixture2);
SWLog("横移轨道23:再次验证托盘是否在出口处 ,停止横移2的皮带线 ");
// SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW3_TrayCheck, IO_VALUE.HIGH));
IOMove(IO_Type.SW2_MotorRun, IO_VALUE.LOW);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW2_MotorRun, IO_VALUE.LOW));
}
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW09_WaitOutCheck))
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW10_WatOutFixture2);
SWLog("横移轨道23:再次验证托盘是否在出口处 ,停止横移2的皮带线 ");
// SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW3_TrayCheck, IO_VALUE.HIGH));
IOMove(IO_Type.SW2_MotorRun, IO_VALUE.LOW);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW2_MotorRun, IO_VALUE.LOW));
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW10_WatOutFixture2))
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW11_TopDown);
SWLog("横移轨道23:托盘已到达出口,顶升气缸下降 ");
// CylinderMove(SW23_MoveInfo, IO_Type.SW2_TopCylinder_Up, IO_Type.SW2_TopCylinder_Down);
//Thread.Sleep(50);
if (!CheckTrayIsNeed(104, Sw23TrayNum))
{
CylinderMove(SW23_MoveInfo, IO_Type.SW3_TopCylinder_Up, IO_Type.SW3_TopCylinder_Down);
}
//CylinderMove(SW23_MoveInfo, IO_Type.SW2_TopCylinder_Up, IO_Type.SW2_TopCylinder_Down);
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW11_TopDown))
{
bool result = false;
bool topCylinderDown = true;
//如果顶升1没有下降,才判断是否需要入库
if (IOValue(IO_Type.SW3_TopCylinder_Down).Equals(IO_VALUE.LOW) && IOValue(IO_Type.SW3_TopCylinder_Up).Equals(IO_VALUE.HIGH))
{
topCylinderDown = false;
result = FeedingEquipMap[104].CanStartCheckOut(Sw23TrayNum);
}
if (result)
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW13_WaitTrayGo);
SWLog("横移轨道23:关闭皮带电机,需要紧急出料,不需要等待 托盘离开");
IOMove(IO_Type.SW2_MotorRun, IO_VALUE.LOW);
IOMove(IO_Type.SW3_MotorRun, IO_VALUE.LOW);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW2_MotorRun, IO_VALUE.LOW));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW3_MotorRun, IO_VALUE.LOW));
}
else
{
if (topCylinderDown)
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW12_WaitTime);
SWLog("横移轨道23:关闭皮带电机,等待1秒钟,关闭横移电机 ");
IOMove(IO_Type.SW2_MotorRun, IO_VALUE.LOW);
IOMove(IO_Type.SW3_MotorRun, IO_VALUE.LOW);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
else
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW11_TopDown);
SWLog("横移轨道23:托盘已到达出口,重新顶升气缸下降 ");
CylinderMove(SW23_MoveInfo, IO_Type.SW3_TopCylinder_Up, IO_Type.SW3_TopCylinder_Down);
}
}
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW12_WaitTime))
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW13_WaitTrayGo);
SWLog("横移轨道23:关闭皮带电机,等待SW3_TrayCheck=0,关闭横移电机 ");
IOMove(IO_Type.SW2_MotorRun, IO_VALUE.LOW);
IOMove(IO_Type.SW3_MotorRun, IO_VALUE.LOW);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW3_TrayCheck, IO_VALUE.LOW));
}
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW13_WaitTrayGo))
{
lastSw2StopDownTime = DateTime.Now.AddSeconds(-2);
SW23_MoveInfo.EndMove();
CylinderMove(null, IO_Type.SW3_TopCylinder_Down, IO_Type.SW3_TopCylinder_Up);
SWLog("横移轨道23:横移结束,横移3顶升上升 ");
}
}
private void SW23_SW08_DriveMotorMove()
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW08_DriveMotorMove);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
SWLog("横移轨道23:开始转动电机 ,等待1000,SW2_TrayCheck=0, SW3_TrayCheck=1 ");
IOMove(IO_Type.SW2_MotorRun, IO_VALUE.HIGH);
IOMove(IO_Type.SW3_MotorRun, IO_VALUE.HIGH);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW2_MotorRun, IO_VALUE.HIGH));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW3_MotorRun, IO_VALUE.HIGH));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW3_TrayCheck, IO_VALUE.HIGH));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW2_TrayCheck, IO_VALUE.LOW));
}
private void SW23_SW07_WaitNoTray()
{
if (IOValue(IO_Type.SW3_TrayCheck).Equals(IO_VALUE.LOW))
{
SW23_SW08_DriveMotorMove();
}
else
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW07_WaitNoTray);
SWLog("横移轨道23: 等待 SW3_TrayCheck=0 ");
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW3_TrayCheck, IO_VALUE.LOW));
}
}
private void SW23_SW06_TopCylinderUp()
{
if (CylinderIsOk(IO_Type.SW2_TopCylinder_Down, IO_Type.SW2_TopCylinder_Up) &&
CylinderIsOk(IO_Type.SW3_TopCylinder_Down, IO_Type.SW3_TopCylinder_Up))
{
SW23_SW07_WaitNoTray();
}
else
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW06_TopCylinderUp);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
SWLog("横移轨道23:顶升气缸上升 ,至少等待1000 ");
IOMove(IO_Type.SW2_StopDown, IO_VALUE.LOW);
CylinderMove(SW23_MoveInfo, IO_Type.SW2_TopCylinder_Down, IO_Type.SW2_TopCylinder_Up);
CylinderMove(SW23_MoveInfo, IO_Type.SW3_TopCylinder_Down, IO_Type.SW3_TopCylinder_Up);
}
}
private void SW23_SW05_LocationDown()
{
if (CylinderIsOk(IO_Type.SW2_LocationCylinder_Up, IO_Type.SW2_LocationCylinder_Down) &&
CylinderIsOk(IO_Type.SW3_LocationCylinder_Up, IO_Type.SW3_LocationCylinder_Down))
{
SW23_SW06_TopCylinderUp();
}
else
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW05_LocationDown);
SWLog("横移轨道23:定位气缸下降 ");
CylinderMove(SW23_MoveInfo, IO_Type.SW2_LocationCylinder_Up, IO_Type.SW2_LocationCylinder_Down);
CylinderMove(SW23_MoveInfo, IO_Type.SW3_LocationCylinder_Up, IO_Type.SW3_LocationCylinder_Down);
}
}
private void SW23_SW04_WaitCanUp()
{
if (IOValue(IO_Type.SW2_TrayCheck).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.SW3_TrayCheck).Equals(IO_VALUE.LOW) && SwCanUpMove(3))
{
SW23_SW05_LocationDown();
}
else
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW04_WaitCanUp);
SWLog("横移轨道23: 等待横移4托盘检测信号 ,SW2_StopDown上升 ,等待横移3(上料4)处无托盘 ");
CheckAndMove(IO_Type.SW2_StopDown, IO_VALUE.LOW);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW2_TrayCheck, IO_VALUE.HIGH));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW3_TrayCheck, IO_VALUE.LOW));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitSWCanTopUp(3));
}
}
private void SWLog(string msg)
{
LogUtil.debug(Name + msg);
}
#endregion
#region 料仓出入库逻辑处理
/// <summary>--
/// BOX出入库完成事件
/// </summary>
public void boxBean_OutStoreEnd(int storeId, InOutParam param)
{
MoveEquip moveEquip = GetMoveByDId(storeId);
string posId = param != null ? param.PosId : "";
if (moveEquip.IsDebug)
{
LogUtil.error(param.ToStr() + " 已经完成出库," + moveEquip.Name + "当前正在调试中,不继续操作!");
return;
}
//料仓出库完成,移栽装置开始出库检测
if (moveEquip.IsDebug == false && moveEquip.MoveInfo.MoveType == LineMoveType.None && moveEquip.runStatus == LineRunStatus.Runing)
{
LogUtil.info(param.ToStr() + " 已经完成出库,开始" + moveEquip.Name + "出库!");
bool result = moveEquip.StartOutStoreMove(param);
if (!result)
{
LogUtil.info(Name + " 执行出库【" + param.ToStr() + "】失败, 加入等待队列");
moveEquip.AddWaitOutInfo(param);
}
}
else if (moveEquip.MoveInfo.MoveType.Equals(LineMoveType.OutStore) && moveEquip.MoveInfo.MoveParam != null && moveEquip.MoveInfo.MoveParam.PosId.Equals(posId))
{
LogUtil.info(param.ToStr() + "已经完成出库," + moveEquip.Name + "正在【" + posId + "】出库中,库位号重复,不处理!");
}
else
{
LogUtil.info(param.ToStr() + "已经完成出库," + moveEquip.Name + "正在忙碌中,把出库信息放入列表中!");
moveEquip.AddWaitOutInfo(param);
}
}
/// <summary>
/// 判断移栽当前是否处于可出库状态
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public bool CanOutStore(int id)
{
if (!NoErrorAlarm())
{
return false;
}
//if (!MoveEquipMap.ContainsKey(id))
//{
// return false;
//}
MoveEquip move = GetMoveByDId(id);
if (move == null)
{
return false;
}
if (!move.NoAlarm() || move.waitInStoreList.Count > 0 || move.IsDebug || move.waitOutStoreList.Count > 0)
{
return false;
}
if (runStatus.Equals(LineRunStatus.Runing) || runStatus.Equals(LineRunStatus.Busy))
{
if (move.MoveInfo.MoveType.Equals(LineMoveType.None) && move.runStatus.Equals(LineRunStatus.Runing))
{
//如果移栽已拦截到自己入库的托盘,不能出库
if(move.SecondMoveInfo.MoveType.Equals(LineMoveType.CheckFixture)&&
move.SecondMoveInfo.MoveStep>=LineMoveStep.MIO_05_WaitTime &&
move.SecondMoveInfo.MoveStep<= LineMoveStep.MO_14_TopDown
)
{
return false;
}
return true;
}
//前进后退气缸后退以后才可以出库
else if (move.runStatus.Equals(LineRunStatus.Busy) && move.MoveInfo.MoveType.Equals(LineMoveType.OutStore))
{
if (move.MoveInfo.MoveStep >= (LineMoveStep.MO_62_CylinderDown))
{
return true;
}
else if (move.MoveInfo.MoveStep.Equals(LineMoveStep.MO_61_CylinderAfter) && move.MoveInfo.IsInWait.Equals(false)
&&move.CylinderIsOk(IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After))
{
return true;
}
}
}
return false;
}
/// <summary>
/// 判断指定的移栽是否可以入库
/// </summary>
/// <returns></returns>
public bool CanIntore(int id)
{
if (!NoErrorAlarm())
{
return false;
}
//if (!MoveEquipMap.ContainsKey(id))
//{
// return false;
//}
MoveEquip move = GetMoveByDId(id);
if (move == null)
{
return false;
}
if (move.IsDebug)
//if (!move.NoErrorAlarm() || move.IsDebug || move.waitOutStoreList.Count > 0)
{
return false;
}
if (move.StopInstore)
{
return false;
}
if (runStatus > LineRunStatus.Wait && move.runStatus > LineRunStatus.Wait)
{
return true;
}
//if (runStatus.Equals(LineRunStatus.Runing) || runStatus.Equals(LineRunStatus.Busy))
//{
// if ((move.MoveInfo.MoveType.Equals(LineMoveType.None) || move.MoveInfo.MoveType.Equals(LineMoveType.InStore))
// && (move.runStatus.Equals(LineRunStatus.Runing) || move.runStatus.Equals(LineRunStatus.Busy)))
// {
// return true;
// }
//}
// LogUtil.error("runStatus【" + runStatus + "】,move.MoveInfo.MoveType【" + move.MoveInfo.MoveType + "】,move.runStatus【" + move.runStatus + "】 ");
return false;
}
/// <summary>
/// 判断指定的皮带线是否可用
/// </summary>
/// <param name="lineNum"></param>
/// <returns></returns>
internal bool ProvidingCanUse(List<int> lineList)
{
//有一条线可用就返回true
foreach (int lineNum in lineList)
{
int deviceN = 200 + lineNum;
if (ProvidingEquipMap.ContainsKey(deviceN))
{
ProvidingEquip pro = ProvidingEquipMap[deviceN];
if (pro.runStatus >= LineRunStatus.HomeMoving && pro.isInSuddenDown.Equals(false) && pro.isNoAirCheck.Equals(false))
{
return true;
}
}
}
return false;
}
/// <summary>
/// 判断出料流水线是否可以开始出料
/// </summary>
internal bool DLineStartOut(int dlineId, int LineNum)
{
foreach (DischargeLine line in DisLineMap.Values)
{
if ((line.DeviceID % 100).Equals(dlineId))
{
if (line.CanStartOut(LineNum))
{
return true;
}
}
}
return false;
}
#endregion
}
}