MainMachine.cs
53.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
using CodeLibrary;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceLibrary
{
public partial class MainMachine : IRobot
{
public string Name { get; set; } = "SMD BOX MIMO G2";
private bool _canRunning = true;
public bool canRunning
{
get { return _canRunning; }
set
{
if (_canRunning != value)
{
Msg.setlogones();
}
_canRunning = value;
}
}
public bool isBusy { get; set; } = false;
public bool isAlarm { get; set; } = false;
public RunStatus runStatus { get; set; } = RunStatus.Stop;
public Robot_Config Config { get; set; }
public volatile bool UserPause = false;
public volatile bool ShowIgnoreFixtureAlarm = false;
public MoveInfo ResetMoveInfo;
/// <summary>
/// 右侧移动信息
/// </summary>
public MoveInfo StringMoveInfo;
public MoveInfo ClampMoveInfo;
public MoveInfo StoreMoveInfo;
public MoveInfo AIOTMoveInfo;
public delegate void ProcessMsg(List<Msg> msg);
public event ProcessMsg ProcessMsgEvent;
public AxisBean Middle_Axis;
public AxisBean UpDown_Axis;
internal AxisBean InOut_Axis;
internal AxisBean Comp_Axis;
internal AxisBean Batch_Axis;
internal AxisBean Clamp_Axis;
public LineRunMonitor Line;
public CylinderManger SingleDoor;
public CylinderManger FlipDoor;
public LiftMonitor MotorFlipDoorA;
public LiftMonitor MotorFlipDoorB;
public LiftMonitor StringDoor;
ReelTransport boxTransport;
public bool boxTransportIsFree { get => boxTransport.IsComplateOrFree; }
public event Action<string, StoreMoveType, bool> InOutEndProcessEvent;
ServerCommunication ServerCM;
/// <summary>
/// 开始运行的时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 是否在急停中
/// </summary>
public bool isInSuddenDown = false;
/// <summary>
/// 是否启用上料提升轴的料叉检测
/// </summary>
public bool EnableBatchFixCheck { get { return Setting_Init.Enable_BatchFixCheck; } }
public MainMachine(Robot_Config _config)
{
Config = _config;
crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
StringMoveInfo = new MoveInfo($"料串进出机构");
StringMoveInfo.SetStateDelegate(StringProcessState);
ClampMoveInfo = new MoveInfo($"取放料机构");
ClampMoveInfo.SetStateDelegate(ClampState);
StoreMoveInfo = new MoveInfo($"进出库调度");
StoreMoveInfo.SetStateDelegate(StoreState);
ResetMoveInfo = new MoveInfo($"重置");
AIOTMoveInfo = new MoveInfo($"出入库测试");
#region 初始化led灯
RunningLed = new Led(Config.DOList[IO_Type.Run_Led].GetIOAddr(), LedColor.green);
StandbyLed = new Led(Config.DOList[IO_Type.Standby_Led].GetIOAddr(), LedColor.yellow);
AlarmLed = new Led(Config.DOList[IO_Type.Alarm_Led].GetIOAddr(), LedColor.red);
//NG_Led = new Led(Config.DOList[IO_Type.MaterialNG_Led].GetIOAddr());
#endregion
#region 初始化伺服轴
Middle_Axis = new AxisBean(Config.Middle_Axis, Name);
Middle_Axis.interference += Middle_Axis_interference;
UpDown_Axis = new AxisBean(Config.UpDown_Axis, Name);
UpDown_Axis.interference += UpDown_Axis_interference;
InOut_Axis = new AxisBean(Config.InOut_Axis, Name);
Comp_Axis = new AxisBean(Config.Comp_Axis, Name);
Batch_Axis = new AxisBean(Config.Batch_Axis, Name);
Clamp_Axis = new AxisBean(Config.Clamp_Axis, Name);
Clamp_Axis.interference += Clamp_Axis_interference;
Crc_LanguageChangeEvent(null, EventArgs.Empty);
#endregion
Line = new LineRunMonitor($"料串进出机构", Config.DOList[IO_Type.LineRun].GetIOAddr(), Config.DOList[IO_Type.LineRev].GetIOAddr(), (int)(Setting_Init.StringDoor_InOut_Roller_Mode.Val));
SingleDoor = new CylinderManger($"单料门", IO_Type.NGDoor_Open, IO_Type.NGDoor_Close);
//检测翻板门是否为鸣志点击伺服控制
if (Config.FlipDoor_L_Axis == null && Config.FlipDoor_R_Axis == null)
{
FlipDoor = new CylinderManger($"翻板托盘", IO_Type.ReelFlipDoor_Work, IO_Type.ReelFlipDoor_Home);
var c = RobotManage.Config.configList.Find(x => x.ProName == "FlipDoorSpeed");
if (c != null)
RobotManage.Config.configList.Remove(c);
LogUtil.info("加载翻板门类型为:气缸");
}
else if (Config.FlipDoor_L_Axis != null && Config.FlipDoor_R_Axis != null)
{
RobotManage.Config.DOList.Remove(IO_Type.ReelFlipDoor_Work);
RobotManage.Config.DOList.Remove(IO_Type.ReelFlipDoor_Home);
string safetyLightCurtains = "";
if (Setting_Init.Disable_SafetyLightCurtains)
{
safetyLightCurtains = IO_Type.SuddenStop_BTN;
}
else
{
safetyLightCurtains = IO_Type.SafetyLightCurtains;
}
MotorFlipDoorB = new LiftMonitor(IO_Type.ReelFlipDoor_L_Home, IO_Type.ReelFlipDoor_L_Work, safetyLightCurtains, null, new AxisBean(Config.FlipDoor_L_Axis, Name), Config.FlipDoorLength, Config.FlipDoorLength_speed, 0, "B翻转门");
MotorFlipDoorA = new LiftMonitor(IO_Type.ReelFlipDoor_R_Home, IO_Type.ReelFlipDoor_R_Work, safetyLightCurtains, null, new AxisBean(Config.FlipDoor_R_Axis, Name), Config.FlipDoorLength, Config.FlipDoorLength_speed, 0, "A翻转门");
MotorFlipDoorB.SlowAftPause = true;
MotorFlipDoorB.SlowAftPause = true;
LogUtil.info("加载翻板门类型为:步进");
}
else
{
throw new Exception("料仓翻板门配置错误");
}
//检测料串门是否为鸣志电机控制
if (Config.StringDoor_Axis != null)
{
RobotManage.Config.DOList.Remove(IO_Type.StringDoor_Open);
RobotManage.Config.DOList.Remove(IO_Type.StringDoor_Close);
var sf = "";
if (Setting_Init.StringDoor_X08IsStringDoor_SafetyLightCurtains)
sf = IO_Type.AGV_OnPosition;
StringDoor = new LiftMonitor(IO_Type.StringDoor_Open, IO_Type.StringDoor_Close, sf, IO_Type.StringDoor_Axis_Break, new AxisBean(Config.StringDoor_Axis, Name), Config.StringDoorLength, Config.StringDoorLength_speed, 0, "折叠门", true);
StringDoor.DownOverTimeMS = Setting_Init.StringDoor_DownOverTimeMS;
StringDoor.UpOverTimeMS = Setting_Init.StringDoor_UpOverTimeMS;
StringDoor.ResumeWaitTimeSec = 5;
LogUtil.info("加载料串门类型为:步进");
}
else
LogUtil.info("加载料串门类型为:气缸");
if (!Setting_Init.StringDoor_X08IsStringDoor_SafetyLightCurtains)
{
RobotManage.Config.DIList.Remove(IO_Type.AGV_OnPosition);
}
if (Setting_Init.Disable_DoorSafeCheck)
{
RobotManage.Config.DIList.Remove(IO_Type.LeftDoorClose_Check);
RobotManage.Config.DIList.Remove(IO_Type.RightDoorClose_Check);
RobotManage.Config.DIList.Remove(IO_Type.BackDoorClose_Check);
RobotManage.Config.DOList.Remove(IO_Type.DoorSafe_Disable);
}
if (!ConfigHelper.Config.Get("Device_IO_HasX29", true))
{
RobotManage.Config.DIList.Remove(IO_Type.NGDoor_Tray_Check);
}
if (!ConfigHelper.Config.Get("Device_IO_HasX20", true))
{
RobotManage.Config.DIList.Remove(IO_Type.WidthCheck_15);
}
boxTransport = new ReelTransport(Config, this);
boxTransport.InOutEndProcessEvent += delegate (string posid, StoreMoveType storeMoveType, bool arg4)
{
InOutEndProcessEvent?.Invoke(posid, storeMoveType, arg4);
};
//BoxTransport_InOutEndProcessEvent;
//ProcessMsgEvent += MainMachine_ProcessMsgEvent;
//Setting_Init.Disable_StringDoor = false;
AlarmBuzzer.SetOnOffAction(() => { IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.HIGH); }, () => { IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.LOW); });
IOMonitor.RegisterIO(IO_Type.SuddenStop_BTN, Config, IO_VALUE.LOW, SuddenStop_BTN, 2500, 100);
IOMonitor.RegisterIO(IO_Type.Reset_BTN, Config, IO_VALUE.HIGH, Reset_BTN, 2500, 100);
IOMonitor.RegisterIO(IO_Type.AutoRun_Single, Config, IO_VALUE.HIGH, Run_BTN, 2500, 100);
if (!Setting_Init.Disable_SafetyLightCurtains)
IOMonitor.RegisterIO(IO_Type.SafetyLightCurtains, Config, IO_VALUE.LOW, DeviceSuddenStop, 1, 1);
LedProcessInit();
Setting_Init.CamTestReel_debug = false;
initAgv();
ServerCM = new ServerCommunication();
}
private void Crc_LanguageChangeEvent(object sender, EventArgs e)
{
StringMoveInfo.Name = crc.GetString(L.string_inout_equipment, "料串进出机构");
ClampMoveInfo.Name = crc.GetString(L.clamp_equipment, "取放料机构");
StoreMoveInfo.Name = crc.GetString(L.store_manage_equipment, "进出库调度");
ResetMoveInfo.Name = crc.GetString(L.reset_equipment, "重置");
AIOTMoveInfo.Name = crc.GetString(L.autotest_inout_equipment, "出入库测试");
}
private (bool, string) Clamp_Axis_interference(int from, int to)
{
if (to > Config.Clamp_P3)
{
if (IOValue(IO_Type.ReelFlipDoor_L_Home).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.ReelFlipDoor_R_Home).Equals(IO_VALUE.HIGH))
return (false, "");
else
return (true, crc.GetString(L.Clamp_Axis_interference_01, "翻板门不在垂直端,不允许下降取料轴"));
if (IOValue(IO_Type.StringPosChecker_Home).Equals(IO_VALUE.HIGH))
return (false, "");
else
return (true, crc.GetString(L.Clamp_Axis_interference_02, "上料定位臂不在避让端,不允许下降取料轴"));
}
else if (to >= Config.Clamp_P3)
{
if (IOValue(IO_Type.ReelFlipDoor_L_Home).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.ReelFlipDoor_R_Home).Equals(IO_VALUE.HIGH))
return (false, "");
else
return (true, crc.GetString(L.Clamp_Axis_interference_03, "翻板门不在垂直端,不允许下降取料轴"));
}
return (false, "");
}
private (bool, string) Middle_Axis_interference(int from, int to)
{
if (RobotManage.DisableUpdownProtect)
return (false, "");
if (InOut_Axis.IsInPosition(Config.InOut_P1))
return (false, "");
return (true, crc.GetString(L.Middle_Axis_interference_01, "进出轴不在待机点时无法移动旋转轴"));
}
private (bool, string) UpDown_Axis_interference(int from, int to)
{
if (RobotManage.DisableUpdownProtect)
return (false, "");
if (InOut_Axis.IsInPosition(Config.InOut_P1))
return (false, "");
return (true, crc.GetString(L.UpDown_Axis_interference_01, "进出轴不在待机点时无法移动升降轴"));
}
public bool hasAlarm = false;
/// <summary>
/// 整机启动变量,设置为false后将退出线程,只在停止时调用
/// </summary>
bool mstart = true;
public void Run()
{
mstart = true;
while (mstart)
{
try
{
canRunning = DeviceCheck();
if (canRunning)
{
BtnProcess();
canRunning = SafeCheck();
//if (canRunning && !lastSafeCheckStatus){}
//lastSafeCheckStatus = canRunning;
}
Thread.Sleep(200);
if (!canRunning || !mstart)
continue;
if (runStatus == RunStatus.Running)
{
ioMonitor();
AGVProcess();
StringProcess();
ClampProcess();
boxTransport.Process();
if (AutoInOutTest)
AutoInOutTestProcess();
else
StoreProcess();
}
else if (runStatus == RunStatus.HomeReset)
{
HomeReset();
}
}
catch (Exception ex)
{
Msg.add(ex.ToString(), MsgLevel.warning);
Msg.setlogones();
}
finally
{
var m = Msg.get();
ProcessMsgEvent?.Invoke(m);
ServerCM.ProcessMsg(m);
StoreStatus currnetstoreStatus = StoreStatus.None;
if (m.Find((aa) => aa.msgLevel == MsgLevel.alarm) == null)
{
hasAlarm = false;
AlarmBuzzer.OFF();
if (ServerCM.storeStatus != StoreStatus.InStoreExecute
&& ServerCM.storeStatus != StoreStatus.OutStoreExecute
&& ServerCM.storeStatus != StoreStatus.ResetMove && ServerCM.storeStatus != StoreStatus.StoreOnline)
{
LogUtil.info($"test storeStatus is {ServerCM.storeStatus} change to StoreOnline");
currnetstoreStatus = StoreStatus.StoreOnline;
}
}
else
{
hasAlarm = true;
AlarmBuzzer.ON();
currnetstoreStatus = isInSuddenDown ? StoreStatus.SuddenStop : StoreStatus.Warning;
}
//ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
if (!UserPause && mstart)
{
Msg.clear();
}
//else
// currnetstoreStatus = StoreStatus.Debugging;
if (currnetstoreStatus != StoreStatus.None)
ServerCM.storeStatus = currnetstoreStatus;
}
}
RobotManage.isRunning = false;
RobotManage.UserPause($"isRunning = false", false);
LogUtil.info("主线程已退出.");
}
public void Start()
{
ServerCM.StartConnectServer();
Run();
}
public void Stop()
{
LogUtil.info("开始停止系统2.");
mstart = false;
AutoInOutTest = false;
ClearOutJob();
ServerCM.StopConnectServer();
Thread.Sleep(300);
Alarm(AlarmType.None);
StopMove(true);
IOMove(IO_Type.LineRun, IO_VALUE.LOW);
IOMove(IO_Type.LineRev, IO_VALUE.LOW);
LedProcess(null);
CloseRgbLed();
SoundsController.StopPlay();
LogUtil.info("开始停止系统3.");
}
public void BeginHomeReset(bool firstRun = false)
{
if (!firstRun)
{
StopMove();
Thread.Sleep(500);
}
OpenAllServo();
AxisBean.List.ForEach((x) => { AxisManager.AlarmClear(x.Config.DeviceName, x.Config.GetAxisValue()); });
Alarm(AlarmType.None);
runStatus = RunStatus.HomeReset;
ResetMoveInfo.NewMove(MoveStep.H01_HomeReset);
ResetMoveInfo.log("开始回原,记录最后一次回原时间");
RobotManage.LastResetTime = DateTime.Now;
ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
public void OpenSingleDoor(MoveInfo moveInfo)
{
if (!RobotManage.DisableSingleDoor)
{
SingleDoor.ToHigh(moveInfo);
}
else
{
LogUtil.info($"单料门已屏蔽,不开门");
}
}
public void CloseSingleDoor(MoveInfo moveInfo)
{
if (!RobotManage.DisableSingleDoor)
{
SingleDoor.ToLow(moveInfo);
}
else
{
LogUtil.info($"单料门已屏蔽,不关门");
}
}
//强制回原
bool forceHome = true;
void HomeReset()
{
if (CheckWait(ResetMoveInfo))
return;
switch (ResetMoveInfo.MoveStep)
{
case MoveStep.H01_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset_01);
ServerCM.storeStatus = StoreStatus.ResetMove;
ShowIgnoreFixtureAlarm = false;
if (IOValue(IO_Type.StringBack_Check).Equals(IO_VALUE.LOW) && IOValue(IO_Type.StringFront_Check).Equals(IO_VALUE.LOW))
{
ResetMoveInfo.log("复位时没有料串");
}
else if (!Setting_Init.StringDoor_X08IsStringDoor_SafetyLightCurtains)
{
if (IOValue(IO_Type.StringFront_Check).Equals(IO_VALUE.HIGH))
{
Msg.add(crc.GetString(L.string_not_onposition, "回原时X09,X10信号异常,料串可能不在正确位置,请检查."), MsgLevel.alarm);//0429
RobotManage.UserPause($"回原时X09,X10信号异常,料串可能不在正确位置,请检查");
return;
}
}
if (EnableBatchFixCheck)
{
if (IOValue(IO_Type.StringBack_Check).Equals(IO_VALUE.HIGH))
{
if (IOValue(IO_Type.Laser_Location).Equals(IO_VALUE.LOW))
{
ResetMoveInfo.log($"料串未成功放入料叉上,请检查");
Msg.add(crc.GetString(L.bacth_no_fix, "料串未成功放入料叉上,请检查"), MsgLevel.warning);
RobotManage.UserPause(crc.GetString(L.bacth_no_fix, "料串未成功放入料叉上,请检查"), true);
return;
}
}
}
StringDoorClose(null);
break;
case MoveStep.H02_HomeReset_01:
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset);
ResetMoveInfo.log("进出轴,批量轴回原,料串检测杆退回避让端");
InOut_Axis.HomeMove(ResetMoveInfo, forceHome);
Batch_Axis.HomeMove(null, forceHome);
Batch_Axis.MonitorAxisLoadRate(Setting_Init.LoadRateLimit_BatchMaxLoadRate);
CylinderMove(ResetMoveInfo, IO_Type.StringPosChecker_Home, IO_Type.StringPosChecker_Work, IO_VALUE.LOW);
Msg.add("", MsgLevel.info, ErrInfo.X09_Clear);
//SingleDoor.ToLow(ResetMoveInfo);
CloseSingleDoor(ResetMoveInfo);
break;
case MoveStep.H02_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H03_HomeReset);
ResetMoveInfo.log("夹爪轴回原");
Clamp_Axis.HomeMove(ResetMoveInfo, forceHome);
break;
case MoveStep.H03_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H04_HomeReset);
ResetMoveInfo.log("旋转轴,升降轴,回原,料叉P1待机点");
InOut_Axis.AbsMove(ResetMoveInfo, Config.InOut_P1, Config.InOut_P1_speed);
Middle_Axis.HomeMove(ResetMoveInfo, forceHome);
UpDown_Axis.HomeMove(ResetMoveInfo, forceHome);
Batch_Axis.HomeMove(ResetMoveInfo, forceHome);
Batch_Axis.MonitorAxisLoadRate(Setting_Init.LoadRateLimit_BatchMaxLoadRate);
//OpenFlipDoor(ResetMoveInfo);
break;
case MoveStep.H04_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H05_HomeReset);
ResetMoveInfo.log("夹爪轴,P1待机点");
Clamp_Axis.AbsMove(ResetMoveInfo, Config.Clamp_P1, Config.Clamp_P1_speed);
Line.LineRun("n", false, 5);
ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
break;
case MoveStep.H05_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H06_HomeReset);
ResetMoveInfo.log("旋转轴,升降轴,到P1待机点");
Middle_Axis.AbsMove(ResetMoveInfo, Config.Middle_P1, Config.Middle_P1_speed);
UpDown_Axis.AbsMove(ResetMoveInfo, Config.UpDown_P1, Config.UpDown_P1_speed);
Batch_Axis.AbsMove(ResetMoveInfo, Config.Batch_P1, Config.Batch_P1_speed);
break;
case MoveStep.H06_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H07_HomeReset);
ResetMoveInfo.log("压紧轴回原");
Comp_Axis.HomeMove(ResetMoveInfo, forceHome);
break;
case MoveStep.H07_HomeReset:
if (GetWidth() > 0)
{
ResetMoveInfo.NextMoveStep(MoveStep.H08_HomeReset);
ResetMoveInfo.log("夹爪上有料盘,送到NG口");
}
else if (IOValue(IO_Type.ReelFlipDoor_L_Home).Equals(IO_VALUE.LOW) && IOValue(IO_Type.ReelFlipDoor_R_Home).Equals(IO_VALUE.LOW) && NGDoor_Tray_Test_Reel.HasValue && NGDoor_Tray_Test_Reel.Value)
{
ResetMoveInfo.NextMoveStep(MoveStep.H12_HomeReset);
ResetMoveInfo.log("反转托盘上有料盘,送到NG口");
}
else
{
if (IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
{
ResetMoveInfo.NextMoveStep(MoveStep.HEND_HomeReset);
ResetMoveInfo.log("叉子上有料,不去进行超声感应器检测");
}
else if (RobotManage.NeedSensorPro())
{
ResetMoveInfo.NextMoveStep(MoveStep.H21_HomeStartCheck);
ResetMoveInfo.log("夹爪上没有料盘,开始去进行超声感应器检测");
}
else
{
ResetMoveInfo.NextMoveStep(MoveStep.HEND_HomeReset);
ResetMoveInfo.log("夹爪上上没有料盘");
}
}
break;
case MoveStep.H08_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H09_HomeReset);
CloseFlipDoor(ResetMoveInfo);
break;
case MoveStep.H09_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H10_HomeReset);
ResetMoveInfo.log("夹爪轴下降到NG托盘位置 p3");
Clamp_Axis.AbsMove(ResetMoveInfo, Config.Clamp_P3 - 50 * Config.Clamp_PoToMM, Config.Clamp_P3_speed);
break;
case MoveStep.H10_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H11_HomeReset);
ResetMoveInfo.log("释放夹爪");
CylinderMove(StringMoveInfo, IO_Type.Clamping_Relax, IO_Type.Clamping_Work, IO_VALUE.LOW);
break;
case MoveStep.H11_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H12_HomeReset);
ResetMoveInfo.log("收回夹爪轴到P1");
Clamp_Axis.AbsMove(ResetMoveInfo, Config.Clamp_P1, Config.Clamp_P1_speed);
break;
case MoveStep.H12_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H13_HomeReset);
ResetMoveInfo.log("打开NG口门");
//CylinderMove(null, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.HIGH);
// SingleDoor.ToHigh(null);
OpenSingleDoor(null);
break;
case MoveStep.H13_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H14_HomeReset);
var h = NGDoor_Tray_Test_Reel;
if (!h.HasValue)
{
Msg.add(crc.GetString(L.x29_low_no_reel, "检测相机打开失败."), MsgLevel.alarm);
}
else if (!h.Value)
{
Msg.add(crc.GetString(L.x29_low_no_reel, "传感器未检测到单料口料盘."), MsgLevel.alarm);
RobotManage.UserPause(crc.GetString("x29_low_no_reel", "传感器未检测到单料口料盘."));
}
//CylinderMove(ResetMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.HIGH);
//SingleDoor.ToHigh(ResetMoveInfo);
OpenSingleDoor(ResetMoveInfo);
break;
case MoveStep.H14_HomeReset:
h = NGDoor_Tray_Test_Reel;
if (!h.HasValue)
{
Msg.add(crc.GetString(L.x29_low_no_reel, "检测相机打开失败."), MsgLevel.alarm);
}
else
if (h.Value)
{
Msg.add(crc.GetString(L.x29_higt_has_reel, "系统启动检测到有无信息料盘,等待取走单料口料盘"), MsgLevel.alarm);
ShowColor(Color.White, "waitTask");
if (Setting_Init.CamTestReel_Ability)
{
//ResetMoveInfo.NextMoveStep(MoveStep.H14_HomeReset);
//ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
if (Setting_Init.Enable_SingleDoor_ManualClose)
{
RobotManage.UserPause(crc.GetString("please_take_ngdoor_reel", "等待取走单口料盘"));
}
}
else
{
RobotManage.UserPause($"系统启动检测到有无信息料盘,等待取走单料口料盘");
}
}
else
{
ResetMoveInfo.NextMoveStep(MoveStep.H15_HomeReset);
ResetMoveInfo.log("料盘已取走");
}
break;
case MoveStep.H15_HomeReset:
if (isSafetyLightCurtainsTrigget())
{
Msg.add(crc.GetString(L.wait_put_reel_into_ngdoor, "等待阻挡物离开光栅"), MsgLevel.warning);
}
else
{
ResetMoveInfo.NextMoveStep(MoveStep.H16_HomeReset);
}
break;
case MoveStep.H16_HomeReset:
h = NGDoor_Tray_Test_Reel;
if (!h.HasValue)
{
Msg.add(crc.GetString(L.x29_low_no_reel, "检测相机打开失败."), MsgLevel.alarm);
}
else
if (!isSafetyLightCurtainsTrigget() && h.Value)
{
ResetMoveInfo.log("NG口还是检测到料盘");
ResetMoveInfo.NextMoveStep(MoveStep.H14_HomeReset);
}
else if (!isSafetyLightCurtainsTrigget() && !h.Value)
{
if (RobotManage.NeedSensorPro())
{
ResetMoveInfo.NextMoveStep(MoveStep.H21_HomeStartCheck);
ResetMoveInfo.log("关门NG口门,开始去进行超声感应器检测");
}
else
{
ResetMoveInfo.NextMoveStep(MoveStep.HEND_HomeReset);
ResetMoveInfo.log("关门NG口门");
}
CloseSingleDoor(ResetMoveInfo);
OpenFlipDoor(ResetMoveInfo);
}
else
{
Msg.add(crc.GetString(L.wait_put_reel_into_ngdoor, "等待阻挡物离开光栅"), MsgLevel.warning);
}
break;
#region 声波传感器检测
case MoveStep.H21_HomeStartCheck:
FixPos = BoxStorePosition.GetFixPos(Config, new ReelParam("", 7, 8));
if (FixPos == null)
{
ResetMoveInfo.NextMoveStep(MoveStep.HEND_HomeReset);
ResetMoveInfo.log("未找到校准库位,不进行声波传感器检测");
}
else
{
ResetMoveInfo.NextMoveStep(MoveStep.H22_HomeCheck);
Middle_Axis.AbsMove(ResetMoveInfo, FixPos.Middle_P2, Config.Middle_P2_speed);
ResetMoveInfo.log($"{FixPos.posid} 旋转轴去取料点P2【{FixPos.Middle_P2}】【{Config.Middle_P2_speed}】");
UpDown_Axis.AbsMove(ResetMoveInfo, FixPos.UpDown_PH, Config.UpDown_P1_speed);
ResetMoveInfo.log($" {FixPos.posid}升降轴去取料高点【{FixPos.UpDown_PH}】【{Config.UpDown_P1_speed}】");
Comp_Axis.AbsMove(ResetMoveInfo, FixPos.Comp_PL, Config.Comp_P2_speed);
ResetMoveInfo.log($"{FixPos.posid}:压紧轴去压紧低点【{FixPos.Comp_PL}】【{Config.Comp_P2_speed}】");
}
break;
case MoveStep.H22_HomeCheck:
ResetMoveInfo.NextMoveStep(MoveStep.H23_HomeCheck);
InOut_Axis.AbsMove(ResetMoveInfo, FixPos.InOut_P2, Config.InOut_P2_speed);
InOut_Axis.SensorDetection(Setting_Init.Device_WeightSensor_MaxValue);
ResetMoveInfo.log($"{FixPos.posid}:进出轴去取料点【{FixPos.InOut_P2}】【{Config.InOut_P2_speed}】");
break;
case MoveStep.H23_HomeCheck:
ResetMoveInfo.NextMoveStep(MoveStep.H24_HomeCheck);
Comp_Axis.AbsMove(ResetMoveInfo, FixPos.Comp_PH, Config.Comp_P2_speed);
ResetMoveInfo.log($"{FixPos.posid}:压紧轴去压紧高点【{FixPos.Comp_PH}】【{Config.Comp_P2_speed}】");
UpDown_Axis.AbsMove(ResetMoveInfo, FixPos.UpDown_PL, Config.UpDown_P3_speed / 2);
ResetMoveInfo.log($"{FixPos.posid}:升降轴去取料低点【{FixPos.UpDown_PL}】【{Config.UpDown_P3_speed / 2}】");
break;
case MoveStep.H24_HomeCheck:
ResetMoveInfo.NextMoveStep(MoveStep.H25_HomeCheck);
ResetMoveInfo.log($"{FixPos.posid}:等待500ms进行声波传感器检测");
ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
break;
case MoveStep.H25_HomeCheck:
bool checkOk = RobotManage.SensorProcess();
if (checkOk)
{
ResetMoveInfo.NextMoveStep(MoveStep.H27_HomeCheck);
InOut_Axis.AbsMove(ResetMoveInfo, Config.InOut_P1, Config.InOut_P1_speed);
ResetMoveInfo.log($"{FixPos.posid}:声波传感器OK,进出轴返回待机点【{Config.InOut_P1}】【{Config.InOut_P1_speed}】");
}
else
{
//直接到报警步骤
ResetMoveInfo.NextMoveStep(MoveStep.H31_HomeError);
ResetMoveInfo.log($"{FixPos.posid}:声波传感器误差过大,需要报警");
}
break;
case MoveStep.H27_HomeCheck:
ResetMoveInfo.NextMoveStep(MoveStep.H28_HomeCheck);
ResetMoveInfo.log("旋转轴,升降轴,压紧轴,到P1待机点");
Middle_Axis.AbsMove(ResetMoveInfo, Config.Middle_P1, Config.Middle_P1_speed);
UpDown_Axis.AbsMove(ResetMoveInfo, Config.UpDown_P1, Config.UpDown_P1_speed);
Comp_Axis.AbsMove(ResetMoveInfo, Config.Comp_P1, Config.Comp_P1_speed);
break;
case MoveStep.H28_HomeCheck:
ResetMoveInfo.NextMoveStep(MoveStep.HEND_HomeReset);
ResetMoveInfo.log("声波传感器检测OK");
break;
case MoveStep.H31_HomeError:
ResetMoveInfo.NextMoveStep(MoveStep.H31_HomeError);
ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
Msg.add(crc.GetString("shengboError", "声波传感器误差过大,请检查后重新复位"), MsgLevel.alarm);
ResetMoveInfo.log(crc.GetString("shengboError", "声波传感器误差过大,请检查后重新复位"));
break;
// H22_HomeCheck,//旋转轴到校准为止,升降轴到高点,压紧轴压紧
//H23_HomeCheck,//进出轴进入
//H24_HomeCheck,//升降轴下降,压紧轴放松
//H25_HomeCheck,//等待500毫秒
//H26_HomeCheck,//开始检测
//H27_HomeCheck,//进出轴返回待机点
//H28_HomeCheck,//旋转轴升降轴到待机点
//H31_HomeError,//检测错误,报警
#endregion
case MoveStep.HEND_HomeReset:
//forceHome = false;
StringMoveInfo.NewMove(MoveStep.Wait);
StoreMoveInfo.NewMove(MoveStep.Wait);
ClampMoveInfo.NewMove(MoveStep.Wait);
boxTransport.Reset();
ResetMoveInfo.log("回原完成");
ResetMoveInfo.EndMove();
OutSingleJobList.ClearLastPosid("");
OutStoreJobList.ClearLastPosid("");
if (IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH) && boxTransport.IsComplateOrFree && ClampMoveInfo.MoveStep == MoveStep.Wait)
{
StoreMoveInfo.NewMove(MoveStep.StoreOut_NGPre);
StoreMoveInfo.MoveParam.PosID = "NG";
StoreMoveInfo.MoveParam.PlateH = 72;
StoreMoveInfo.MoveParam.PlateW = 7;
StoreMoveInfo.MoveParam.IsNg = true;
StoreMoveInfo.MoveParam.NgMsg = crc.GetString(L.tray_detect_reel_01, "料叉传感器感应到有料,请人工确认");
StoreMoveInfo.log($"开始无信息料盘出库");
ServerCM.storeStatus = StoreStatus.OutStoreExecute;
CloseFlipDoor(StoreMoveInfo);
}
else if ((RobotManage.HasReelInFixPos(out ReelParam reelParam))
&& boxTransport.IsComplateOrFree
&& ClampMoveInfo.MoveStep == MoveStep.Wait && Setting_Init.Enable_Fixpos
&& IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.LOW))
{
var pos = BoxStorePosition.GetFixPos(Config, reelParam);
if (pos != null)
{
LogUtil.info($"复位完成,校准库位出库:{pos.posid}");
RobotManage.mainMachine.AddSingleStoreTask(pos.posid, reelParam.PlateW, reelParam.PlateH);
RobotManage.ClearReelInFixPos();
CloseFlipDoor(StoreMoveInfo);
}
else
{
RobotManage.ClearReelInFixPos();
}
}
runStatus = RunStatus.Running;
ServerCM.storeStatus = StoreStatus.StoreOnline;
break;
#region 交叉检查处理
case MoveStep.CH01_StartTo:
ResetMoveInfo.NextMoveStep(MoveStep.CH02_InoutToP1);
ResetMoveInfo.log($"料叉检查:进出轴返回待机点P1 {Config.InOut_P1}");
InOut_Axis.AbsMove(ResetMoveInfo, Config.InOut_P1, Config.InOut_P1_speed);
break;
case MoveStep.CH02_InoutToP1:
ResetMoveInfo.NextMoveStep(MoveStep.CH03_ToTarget);
ResetMoveInfo.log($"料叉检查:旋转轴到P2 {Config.Middle_P2} ,升降轴到P2:{Config.UpDown_P2}");
Middle_Axis.AbsMove(ResetMoveInfo, Config.Middle_P2, Config.Middle_P2_speed);
UpDown_Axis.AbsMove(ResetMoveInfo, Config.UpDown_P2, Config.UpDown_P2_speed);
break;
case MoveStep.CH03_ToTarget:
ResetMoveInfo.NextMoveStep(MoveStep.CH04_OpenDoor);
ResetMoveInfo.log($"料叉检查:打开NG门 ");
OpenSingleDoor(ResetMoveInfo);
break;
case MoveStep.CH04_OpenDoor:
ResetMoveInfo.NextMoveStep(MoveStep.CH05_InoutToP2);
ResetMoveInfo.log($"料叉检查:进出轴去P2 {Config.InOut_P2}");
InOut_Axis.AbsMove(ResetMoveInfo, Config.InOut_P2, Config.InOut_P2_speed);
break;
case MoveStep.CH05_InoutToP2:
ResetMoveInfo.NextMoveStep(MoveStep.CH06_WaitCheck);
ResetMoveInfo.log($"料叉检查:进出轴已到位,请检查料叉 ");
Msg.add(crc.GetString("CH06_WaitCheck", "料叉已到位,请检查"), MsgLevel.warning);
break;
case MoveStep.CH06_WaitCheck:
ResetMoveInfo.NextMoveStep(MoveStep.CH06_WaitCheck);
ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
Msg.add(crc.GetString("CH06_WaitCheck", "料叉已到位,请检查"), MsgLevel.warning);
break;
case MoveStep.CH07_CheckOk:
ResetMoveInfo.NextMoveStep(MoveStep.CH08_InoutBack);
ResetMoveInfo.log($"料叉检查:检查完成,进出轴返回待机点P1 {Config.InOut_P1}");
InOut_Axis.AbsMove(ResetMoveInfo, Config.InOut_P1, Config.InOut_P1_speed);
break;
case MoveStep.CH08_InoutBack:
ResetMoveInfo.NextMoveStep(MoveStep.CH09_CloseDoor);
ResetMoveInfo.log($"料叉检查:检查完成,关闭门");
CloseSingleDoor(ResetMoveInfo);
break;
case MoveStep.CH09_CloseDoor:
ResetMoveInfo.log("检查完成");
ResetMoveInfo.EndMove();
runStatus = RunStatus.Running;
ServerCM.storeStatus = StoreStatus.StoreOnline;
break;
#endregion
}
}
public bool CheckOk()
{
if (ResetMoveInfo.IsStep(MoveStep.CH06_WaitCheck))
{
ResetMoveInfo.NextMoveStep(MoveStep.CH07_CheckOk);
ResetMoveInfo.log($"确认检测完成 ");
return true;
}
return false;
}
public void StartToCheck()
{
runStatus = RunStatus.HomeReset;
ServerCM.storeStatus = StoreStatus.ResetMove;
ResetMoveInfo.NewMove(MoveStep.CH01_StartTo);
ResetMoveInfo.log("开始料叉检查");
RobotManage.LastResetTime = DateTime.Now;
ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
private BoxStorePosition FixPos = null;
//bool _IgnoreSafecheck = false;
public bool IgnoreSafecheck
{
get => IOValue(IO_Type.DoorSafe_Disable).Equals(IO_VALUE.HIGH); set
{
if (value)
{
IOMove(IO_Type.DoorSafe_Disable, IO_VALUE.HIGH);
}
else
{
IOMove(IO_Type.DoorSafe_Disable, IO_VALUE.LOW);
}
}
}
public bool IgnoreGratingSignal = false;
bool lastSafeCheckStatus = true;
bool lastStringSafetyStatus = true;
/// <summary>
/// 料串门光栅触发处理方式
/// </summary>
int stringdoorSafetyProcStrategy = Setting_Init.StringDoor_SafetyLightCurtainsProcStrategy;
bool SafeCheck()
{
bool ok = true;
var ignorestring = "[" + crc.GetString(L.ignored, "已忽略") + "]";
//if (IOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.LOW))
//{
// if (!IgnoreSafecheck)// && IOValue(IO_Type.NGDoor_Open).Equals(IO_VALUE.HIGH))
// {
// ok = false;
// DeviceSuddenStop();
// }
// Msg.add(crc.GetString(L.SafetyLight_is_block, "安全光栅被遮挡") + (ok ? ignorestring : ""), MsgLevel.warning);
//}
if (Setting_Init.StringDoor_X08IsStringDoor_SafetyLightCurtains)
{
//IOValue(IO_Type.StringFront_Check).Equals(IO_VALUE.LOW) &&
if (IOValue(IO_Type.AGV_OnPosition).Equals(IO_VALUE.LOW) && IOValue(IO_Type.StringDoor_Close).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("guangshanzhedang", "料串门光栅被遮挡"), MsgLevel.warning);
if (isManualOuting())
{
}
else if (lastStringSafetyStatus)
{
lastStringSafetyStatus = false;
StringDoorPause();
}
}
if (IOValue(IO_Type.AGV_OnPosition).Equals(IO_VALUE.LOW) && StringMoveInfo.MoveStep != MoveStep.Wait)
{
if (stringdoorSafetyProcStrategy == 0)
{
ok = false;
DeviceSuddenStop();
}
}
if (IOValue(IO_Type.AGV_OnPosition).Equals(IO_VALUE.HIGH))
{
if (stringdoorSafetyProcStrategy == 1)
{
if (!lastStringSafetyStatus)
{
StringDoor.ResumeSingle();
lastStringSafetyStatus = true;
}
}
}
}
if (!Setting_Init.Disable_DoorSafeCheck)
{
if (IOValue(IO_Type.LeftDoorClose_Check).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck)
{
ok = false;
DeviceSuddenStop();
}
Msg.add(crc.GetString(L.left_safedoor_not_close, "左侧防护门没有关闭") + (ok ? ignorestring : ""), MsgLevel.warning);
}
if (IOValue(IO_Type.RightDoorClose_Check).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck)
{
ok = false;
DeviceSuddenStop();
}
Msg.add(crc.GetString(L.right_safedoor_not_close, "右侧防护门没有关闭") + (ok ? ignorestring : ""), MsgLevel.warning);
}
if (IOValue(IO_Type.BackDoorClose_Check).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck)
{
ok = false;
DeviceSuddenStop();
}
Msg.add(crc.GetString(L.back_safedoor_not_close, "后侧防护门没有关闭") + (ok ? ignorestring : ""), MsgLevel.warning);
}
}
if (!lastSafeCheckStatus && ok)
{
if (!AxisBean.RunMultiAxis(true, out string msg, AxisBean.List))
{
ok = false;
Msg.add(msg, MsgLevel.warning);
}
SafetyDevice.ResumeAll();
//StringDoor.ResumeSingle();
}
lastSafeCheckStatus = ok;
return ok;
}
void DeviceSuddenStop()
{
if (lastSafeCheckStatus)
{
AxisBean.StopMultiAxis(AxisBean.List);
MoveInfo.List.ForEach((m) => { m.CanWhileCount = 5; });
SafetyDevice.PauseAll();
StringDoorPause();
if (runStatus == RunStatus.HomeReset)
{
ResetMoveInfo.NewMove(MoveStep.H01_HomeReset);
}
}
}
//bool lastStringDoorSafetyStatus = true;
//void StringDoorSuddenStop()
//{
// if (lastStringDoorSafetyStatus)
// {
// AxisBean axis = StringDoor.axisBean;
// AxisBean.StopMultiAxis(new List<AxisBean> { axis });
// StringDoor.Pause();
// if (runStatus == RunStatus.HomeReset)
// {
// ResetMoveInfo.NewMove(MoveStep.H01_HomeReset);
// }
// lastStringDoorSafetyStatus = false;
// }
//}
/// <summary>
/// 最后一次气压检测变为0的时间
/// </summary>
DateTime lastAirCloseTime = DateTime.MinValue;
internal DateTime checkAlarmTime = DateTime.Now;
bool SafetyLightStop
{
get
{
if (RobotManage.Config.DOList.ContainsKey(IO_Type.DoorSafe_Disable))
return IOValue(IO_Type.DoorSafe_Disable).Equals(IO_VALUE.LOW) && isSafetyLightCurtainsTrigget();
else
return isSafetyLightCurtainsTrigget();
}
}
/// <summary>
/// 光栅是否触发
/// </summary>
/// <returns></returns>
bool isSafetyLightCurtainsTrigget()
{
if (Setting_Init.Disable_SafetyLightCurtains)
return false;
else
return IOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.LOW);
}
public bool DeviceCheck()
{
bool ok = true;
isInSuddenDown = IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW);
if (SafetyLightStop)
{
DeviceSuddenStop();
lastSafeCheckStatus = false;
Msg.add(crc.GetString(L.SafetyLight_is_block, "安全光栅被遮挡"), MsgLevel.warning);
return false;
}
if (UserPause)
{
Msg.add(crc.GetString(L.system_pause, "系统暂停"), MsgLevel.warning);
DeviceSuddenStop();
lastSafeCheckStatus = false;
ok = false;
return ok;
}
else if (isInSuddenDown)
{
//Alarm(AlarmType.SuddenStop);
Msg.add(crc.GetString(L.in_suddenstop, "急停中"), MsgLevel.alarm);
DeviceSuddenStop();
lastSafeCheckStatus = false;
ok = false;
}
else if (alarmType != AlarmType.None)
{
//if (IOValue(IO_Type.Right_BTN).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Left_BTN).Equals(IO_VALUE.HIGH))
//{
// Alarm(AlarmType.None);
//}
//else
{
Msg.add(crc.GetString(L.system_need_reset, "系统需要重置"), MsgLevel.alarm, ErrInfo.SuddenStop);
ok = false;
}
}
if (RobotManage.InoutDebugMode)
{
Msg.add(crc.GetString(L.store_inout_debug_mode, "进出库调试模式"), MsgLevel.info);
//ok = false;
}
if (IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW))
{
if (lastAirCloseTime == DateTime.MinValue)
lastAirCloseTime = DateTime.Now;
TimeSpan span = DateTime.Now - lastAirCloseTime;
if (span.TotalSeconds > RobotManage.Config.AirCheckSeconds)
{
ok = false;
Msg.add(crc.GetString(L.airpressure_not_enough, "气压不足"), MsgLevel.warning);
}
}
else
{
lastAirCloseTime = DateTime.MinValue;
}
if (alarmType != AlarmType.SuddenStop)
{
TimeSpan span = DateTime.Now - checkAlarmTime;
if (span.TotalSeconds > 2)
{
checkAlarmTime = DateTime.Now;
foreach (ConfigMoveAxis configMoveAxis in Config.moveAxisList)
{
if (AxisManager.GetAlarmStatus(configMoveAxis.DeviceName, configMoveAxis.GetAxisValue()) == 1)
{
Task.Delay(100).Wait();
if (!SafetyLightStop && lastSafeCheckStatus)
{
Msg.add(crc.GetString(configMoveAxis.ProName, configMoveAxis.Explain) + $"[{configMoveAxis.GetAxisValue()}]:"
+ crc.GetString(L.motion_alarm, "运动报警"), MsgLevel.alarm, ErrInfo.SuddenStop);
ok = false;
}
LogUtil.error(string.Join(",", HuichuanLibrary.HCBoardManager.GetAxisErrorDetail(configMoveAxis.GetAxisValue())));
}
}
}
}
return ok;
}
public void IgnoreX09()
{
boxTransport.IgnoreX09 = true;
LogUtil.info("按下X09忽略");
}
#region 监控上报
System.Threading.Timer uploadVideotimer;
void uploadVideo(object o)
{
if (Monitor.TryEnter(uploadVideotimer))
{
string[] camnames = Setting_Init.UploadVideo_IPCameraNames;
try
{
if (camnames != null && camnames.Length > 0)
{
for (int i = 0; i < camnames.Length; i++)
{
string base64 = ipCam.GetImgBase64(camnames[i]);
if (!string.IsNullOrEmpty(base64))
{
SMF.UploadVideo($"{Setting_Init.App_CID}_{i + 1}", base64);
}
Thread.Sleep(200);
}
}
}
catch (Exception e)
{
LogUtil.error($"{Name} 上传监控图片异常", e);
}
finally
{
Monitor.Exit(uploadVideotimer);
}
}
}
public IPCamera ipCam;
public void UploadVideoProcessInit()
{
if (!Setting_Init.Enable_UploadVideo) return;
ipCam = new IPCamera();
uploadVideotimer = new System.Threading.Timer(new TimerCallback(uploadVideo), null, 0, 500);
GC.KeepAlive(uploadVideotimer);
LogUtil.info($"{Name} 初始化上传监控模块");
}
#endregion
}
}