InputEquip.cs
34.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
using Asa;
using HuichuanLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public partial class InputEquip : EquipBase
{
public InputEquip_Config Config;
public AxisBean MiddleAxis = null;
public AxisBean UpdownAxis = null;
public AxisBean InOutAxis = null;
public AxisBean[] moveAxisArray;
public BatchMoveBean BatchMove_A = null;
public BatchMoveBean BatchMove_B = null;
public AxisBean BatchAxis_A = null;
public AxisBean BatchAxis_B = null;
public ClampJawBean ClampJaw = null;
public bool AutoInput = ConfigAppSettings.GetIntValue(Setting_Init.AutoInput).Equals(1);
public int DefautTargetP = 1;
public InputEquip(string cid, InputEquip_Config config)
{
Name = (" " + "上料机构" + " ").ToUpper();
if (config.BatchAxis_P4Speed <= 0)
{
config.BatchAxis_P4Speed = config.BatchAxis_P2Speed;
LogUtil.info(Name + "未配置 BatchAxis_P4Speed,使用 BatchAxis_P2Speed 的值" + config.BatchAxis_P2Speed);
}
this.DeviceID = config.Id;
baseConfig = config;
this.Config = config;
string[] offsetMap = ConfigAppSettings.GetValue(Setting_Init.ReelHeightOffset).Split('#');
foreach (var item in offsetMap)
{
string[] maps = item.Split('=');
if (maps != null && maps.Length == 2)
reelHeightOffset.Add(int.Parse(maps[0]), int.Parse(maps[1]));
}
IsDebug = config.IsDebug.Equals(1);
Init();
ledProcessTimer.Elapsed += LedProcess;
IoCheckTimer.Elapsed += IoCheckTimerProcess;
MiddleAxis = new AxisBean(config.TakeAxis_Middle, Name, true);
UpdownAxis = new AxisBean(config.TakeAxis_Updown, Name, true);
InOutAxis = new AxisBean(config.TakeAxis_Inout, Name, true);
BatchAxis_A = new AxisBean(config.BatchAxis_A, Name, true);
BatchAxis_B = new AxisBean(config.BatchAxis_B, Name, true);
moveAxisArray = new AxisBean[] { MiddleAxis, UpdownAxis, InOutAxis };
if (config.UseClampJaw.Equals(1))
{
ClampJaw = new ClampJawBean(StoreManager.Config.CLAW_Input);
}
MoveInfo = new DeviceMoveInfo(Name);
BatchMove_A = new BatchMoveBean(Config, BatchAxis_A, 1);
BatchMove_B = new BatchMoveBean(config, BatchAxis_B, 2);
addLastDI(IO_Type.Airpressure_Check, IO_VALUE.LOW);
addLastDI(IO_Type.SuddenStop_BTN, IO_VALUE.LOW);
addLastDI(IO_Type.Reset_BTN, IO_VALUE.LOW);
if (config.MiddleOffsetValue < 30000)
{
config.MiddleOffsetValue = 40000;
}
runStatus = RunStatus.Wait;
alarmRedLedType = AlarmType.IoSingleTimeOut;
}
#region 启动,复位,停止 处理
public override bool StartRun()
{
if (CanStartRun().Equals(false))
{
return false;
}
if (!OpenAllAxis())
{
CloseAllAxis();
return false;
}
SetAllTimer(false);
MoveInfo.EndMove();
LogInfo("StartRun : 开始启动 ");
runStatus = RunStatus.HomeMoving;
MoveInfo.NewMove(MoveType.RHome, new InOutParam());
if (!BatchMove_A.Reset())
{
runStatus = RunStatus.Wait;
MoveInfo.EndMove();
SetWarnMsg("启动失败:A料口启动失败");
LogUtil.error("复位失败:A料口启动失败");
return false;
}
if (!BatchMove_B.Reset())
{
runStatus = RunStatus.Wait;
MoveInfo.EndMove();
SetWarnMsg("启动失败:B料口启动失败");
LogUtil.error("复位失败:B料口启动失败");
return false;
}
StartReset();
SetAllTimer(true);
return true;
}
public override bool Reset()
{
SetAllTimer(false);
StopMove();
if (!OpenAllAxis())
{
CloseAllAxis();
SetAllTimer(true);
return false;
}
LogInfo("Reset 开始重置 ");
runStatus = RunStatus.Reset;
MoveInfo.NewMove(MoveType.Reset, new InOutParam());
if (!BatchMove_A.Reset())
{
SetWarnMsg("复位失败:A料口复位失败");
MoveInfo.EndMove();
LogUtil.error("复位失败:A料口复位失败");
return false;
}
if (!BatchMove_B.Reset())
{
SetWarnMsg("复位失败:B料口复位失败");
MoveInfo.EndMove();
LogUtil.error("复位失败:B料口复位失败");
return false;
}
StartReset();
SetAllTimer(true);
return true;
}
private void StartReset()
{
//复位时设置状态为none
AgvClient.SetStatus(Config.AgvName_B);
AgvClient.SetStatus(Config.AgvName_A);
SetWarnMsg("");
alarmType = AlarmType.None;
isInSuddenDown = false;
isNoAirpressure_Check = false;
MoveInfo.NextMoveStep(StepEnum.IR01_Wait);
LogInfo($"复位 {MoveInfo.SLog} :批量轴开始复位");
}
protected override void ResetProcess()
{
if (MoveInfo.IsInWait)
{
CheckWait(MoveInfo);
}
if (MoveInfo.IsInWait)
{
return;
}
if (MoveInfo.IsStep(StepEnum.IR01_Wait))
{
// 1,处于A,B,NG料口是,可以直接回取料升降轴。
// 2,处于A, B两个暂存区时,升降轴先运动到该暂存区的取放料高点,旋转轴再回原点或待机点。
//验证旋转轴位置 TODO
int updownP = UpdownAxis.GetAclPosition();
int middleP = MiddleAxis.GetAclPosition();
int middleWucha = 20000;
int updownWucha = 20000;
//旋转轴在A暂存区
if (MiddleAxis.IsInPosition(Config.Middle_P4_AUpper, middleWucha) || MiddleAxis.IsInPosition(Config.Middle_P7_AUnder, middleWucha))
{
//如果升降轴低于下方高点
if (updownP < Config.Updown_P6_AUnderH + updownWucha)
{
MoveInfo.NextMoveStep(StepEnum.IR02_UpdownUpMove);
LogInfo($"复位 {MoveInfo.SLog}:当前旋转轴在 A侧暂存区{middleP},升降轴当前位置{updownP},低于下方高点,升降轴先到P6:{Config.Updown_P6_AUnderH}");
UpdownAxis.AbsMove(MoveInfo, Config.Updown_P6_AUnderH, Config.Updown_P6_Speed);
}
//升降轴高于上方低点
else if (updownP > Config.Updown_P5_AUpperL7 - updownWucha)
{
MoveInfo.NextMoveStep(StepEnum.IR02_UpdownUpMove);
LogInfo($"复位 {MoveInfo.SLog}:当前旋转轴在 A侧暂存区{middleP},升降轴当前位置{updownP},高于上方低点,升降轴到上方高点P4:{Config.Updown_P4_AUpperH}");
UpdownAxis.AbsMove(MoveInfo, Config.Updown_P4_AUpperH, Config.Updown_P4_Speed);
}
else
{
SetWarnMsg($"复位失败,当前旋转轴位置{middleP},升降轴位置{updownP},无法判断位于A侧暂存区上方或下方");
Alarm(AlarmType.SuddenStop);
}
}
else if (MiddleAxis.IsInPosition(Config.Middle_P5_BUpper, middleWucha) || MiddleAxis.IsInPosition(Config.Middle_P8_BUnder, middleWucha))
{
//如果升降轴低于下方高点
if (updownP < Config.Updown_P12_BUnderH + updownWucha)
{
MoveInfo.NextMoveStep(StepEnum.IR02_UpdownUpMove);
LogInfo($"复位 {MoveInfo.SLog}:当前旋转轴在 B侧暂存区{middleP},升降轴当前位置{updownP},低于下方高点,升降轴先到12:{Config.Updown_P12_BUnderH}");
UpdownAxis.AbsMove(MoveInfo, Config.Updown_P12_BUnderH, Config.Updown_P12_BUnderH);
}
//升降轴高于上方低点
else if (updownP > Config.Updown_P11_BUpperL7 - updownWucha)
{
MoveInfo.NextMoveStep(StepEnum.IR02_UpdownUpMove);
LogInfo($"复位 {MoveInfo.SLog}:当前旋转轴在 B侧暂存区{middleP},升降轴当前位置{updownP},高于上方低点,升降轴到上方高点P10:{Config.Updown_P10_BUpperH}");
UpdownAxis.AbsMove(MoveInfo, Config.Updown_P10_BUpperH, Config.Updown_P10_Speed);
}
else
{
SetWarnMsg($"复位失败,当前旋转轴位置{middleP},升降轴位置{updownP},无法判断位于A侧暂存区上方或下方");
Alarm(AlarmType.SuddenStop);
}
}
else
{
if (InOutAxis.IsNeedHome)
{
MoveInfo.NextMoveStep(StepEnum.IR02_1_InoutHome);
LogInfo($"复位{MoveInfo.SLog}:进出轴回原点");
InOutAxis.HomeMove(MoveInfo);
}
else
{
IR02_1_InoutToP1();
}
}
}
else if (MoveInfo.IsStep(StepEnum.IR02_UpdownUpMove))
{
if (InOutAxis.IsNeedHome)
{
MoveInfo.NextMoveStep(StepEnum.IR02_1_InoutHome);
LogInfo($"复位{MoveInfo.SLog}:进出轴回原点");
InOutAxis.HomeMove(MoveInfo);
}
else
{
IR02_1_InoutToP1();
}
}
else if (MoveInfo.IsStep(StepEnum.IR02_1_InoutHome))
{
IR02_1_InoutToP1();
}
else if (MoveInfo.IsStep(StepEnum.IR02_2_InoutToP1))
{
if (MiddleAxis.IsNeedHome)
{
MoveInfo.NextMoveStep(StepEnum.IR03_MiddleHome);
LogInfo($"复位{MoveInfo.SLog}:旋转轴回原点");
MiddleAxis.HomeMove(MoveInfo);
}
else
{
IR04_MiddleToP1();
}
}
else if (MoveInfo.IsStep(StepEnum.IR03_MiddleHome))
{
IR04_MiddleToP1();
}
else if (MoveInfo.IsStep(StepEnum.IR04_MiddleToP1))
{
//旋转轴到达P1结束,设置反向补偿间隙
HCBoardManager.SetAxBacklash(MiddleAxis.Config.GetAxisValue(), Config.MiddleAxis_Reverse_Offset, MiddleAxis.Config.HomeLowSpeed, -1);
LogInfo($"复位{MoveInfo.SLog}:旋转轴回待机点P1完成,设置反向补偿:axisNo【{MiddleAxis.Config.GetAxisValue()}】补偿值【{Config.MiddleAxis_Reverse_Offset}】速度【{MiddleAxis.Config.HomeLowSpeed}】");
if (UpdownAxis.IsNeedHome)
{
MoveInfo.NextMoveStep(StepEnum.IR05_UpdownHome);
LogInfo($"复位{MoveInfo.SLog}:升降轴原点返回");
UpdownAxis.HomeMove(MoveInfo);
}
else
{
IR06_UpdownToP1();
}
}
else if (MoveInfo.IsStep(StepEnum.IR05_UpdownHome))
{
IR06_UpdownToP1();
}
else if (MoveInfo.IsStep(StepEnum.IR06_UpdownToP1))
{
MoveInfo.NextMoveStep(StepEnum.IR07_ClampRelax);
LogInfo($"复位{MoveInfo.SLog}:夹爪气缸放松");
ClampRelax(MoveInfo, MoveInfo.MoveParam.PosInfo.barcode);
}
else if (MoveInfo.IsStep(StepEnum.IR07_ClampRelax))
{
MoveInfo.NextMoveStep(StepEnum.IR08_WaitBatchMove);
LogInfo($"复位{MoveInfo.SLog}:等待左右批量轴模块复位完成");
}
else if (MoveInfo.IsStep(StepEnum.IR08_WaitBatchMove))
{
if ((BatchMove_A.MoveInfo.MoveType.Equals(MoveType.Reset).Equals(false))
&& (BatchMove_B.MoveInfo.MoveType.Equals(MoveType.Reset).Equals(false)))
{
LogInfo("复位完成");
runStatus = RunStatus.Runing;
MoveInfo.EndMove();
}
else if (MoveInfo.IsTimeOut(180))
{
if (BatchMove_A.MoveInfo.MoveType.Equals(MoveType.Reset))
{
WarnMsg = Name + "等待" + BatchMove_A.Name + "复位完成超时[" + MoveInfo.TimeOutSeconds + "]秒";
LogUtil.error(WarnMsg, MoveInfo.ErrorLogType, MoveInfo.logSeconds());
Alarm(AlarmType.IoSingleTimeOut);
}
else
{
WarnMsg = Name + "等待" + BatchMove_B.Name + "复位完成超时[" + MoveInfo.TimeOutSeconds + "]秒";
LogUtil.error(WarnMsg);
Alarm(AlarmType.IoSingleTimeOut);
}
}
}
}
private void IR06_UpdownToP1()
{
MoveInfo.NextMoveStep(StepEnum.IR06_UpdownToP1);
LogInfo($"复位{MoveInfo.SLog}:升降轴到P1:" + Config.Updown_P1 + ",夹爪原点返回");
UpdownAxis.AbsMove(MoveInfo, Config.Updown_P1, Config.Updown_P1_Speed);
if (Config.UseClampJaw.Equals(1))
{
ClampJaw.GoHome(MoveInfo);
}
else
{
//吸盘放松
ClampRelax(MoveInfo);
}
}
/// <summary>
/// 夹爪张开,夹住料盘
/// </summary>
/// <param name="moveInfo"></param>
private void ClampPush(DeviceMoveInfo moveInfo = null)
{
//IOManager.IOMove(IO_Type.ClampWork, IO_VALUE.HIGH);
//if (moveInfo != null)
//{
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.ClampWork, IO_VALUE.HIGH));
// moveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
//}
IOManager.IOMove(IO_Type.Cylinder_Relax, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.Cylinder_Clamp, IO_VALUE.HIGH);
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Cylinder_Relax, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Cylinder_Clamp, IO_VALUE.HIGH));
moveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
}
}
/// <summary>
/// 夹爪放松,释放料盘
/// </summary>
/// <param name="moveInfo"></param>
private void ClampRelax(DeviceMoveInfo moveInfo = null)
{
//IOManager.IOMove(IO_Type.ClampWork, IO_VALUE.LOW);
//if (moveInfo != null)
//{
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.ClampWork, IO_VALUE.LOW));
// moveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
//}
IOManager.IOMove(IO_Type.Cylinder_Clamp, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.Cylinder_Relax, IO_VALUE.HIGH);
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Cylinder_Relax, IO_VALUE.HIGH));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Cylinder_Clamp, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
}
}
private void IR02_1_InoutToP1()
{
MoveInfo.NextMoveStep(StepEnum.IR02_2_InoutToP1);
LogInfo($"复位{MoveInfo.SLog}:进出轴到待机点:" + Config.Inout_P1);
InOutAxis.AbsMove(MoveInfo, Config.Inout_P1, Config.Inout_P1_Speed);
}
private void IR04_MiddleToP1()
{
MoveInfo.NextMoveStep(StepEnum.IR04_MiddleToP1);
LogInfo($"复位{MoveInfo.SLog}:旋转轴到待机点:" + Config.Middle_P1);
MiddleAxis.AbsMove(MoveInfo, Config.Middle_P1, Config.Middle_P1_Speed);
}
internal override void StopMove()
{
//StopMove时设置状态为none
AgvClient.SetStatus(Config.AgvName_A);
AgvClient.SetStatus(Config.AgvName_B);
MoveInfo.EndMove();
BatchMove_A.StopMove();
BatchMove_B.StopMove();
UpdownAxis.SuddenStop();
MiddleAxis.SuddenStop();
CloseAllAxis();
}
public override void StopRun()
{
SetAllTimer(false);
runStatus = RunStatus.Wait;
StopMove();
}
#endregion
protected override void BaseTimerProcess()
{
if (isInSuddenDown || isNoAirpressure_Check)
{
return;
}
SecurityAccessProcess();
BusyMoveProcess();
IOTimeOutProcess();
//判断流水线打开了才可以运行
List<BatchMoveBean> BatchMoveList = new List<BatchMoveBean>() { BatchMove_A, BatchMove_B };
if (!MoveStop)
{
if (MoveInfo.MoveType.Equals(MoveType.None) && NoErrorAlarm())
{
if (CheckStartOutPos("A下暂存区", BufferDataManager.AOutStoreInfo, IO_Type.FeedingA_Outstore_UnderArea_ReelCheck, BatchMoveList))
{
}
else if (CheckStartOutPos("B下暂存区", BufferDataManager.BOutStoreInfo, IO_Type.FeedingB_Outstore_UnderArea_ReelCheck, BatchMoveList))
{
}
else
{
//如果有物料且不能放料,需要送一个料串离开
if (BufferDataManager.AOutStoreInfo != null)
{
CheckStartOutPos("A下暂存区", BufferDataManager.AOutStoreInfo, IO_Type.FeedingA_Outstore_UnderArea_ReelCheck, BatchMoveList, true);
}
else if (BufferDataManager.BOutStoreInfo != null)
{
CheckStartOutPos("B下暂存区", BufferDataManager.BOutStoreInfo, IO_Type.FeedingB_Outstore_UnderArea_ReelCheck, BatchMoveList, true);
}
}
}
if (MoveInfo.MoveType.Equals(MoveType.None) && NoErrorAlarm())
{
//若左侧或右侧在等待扫码结束的状态,需要开始去取料
foreach (BatchMoveBean moveBean in BatchMoveList)
{
if (moveBean.MoveInfo.MoveType.Equals(MoveType.InStore) && moveBean.MoveInfo.IsStep(StepEnum.IB13_ScanOK))
{
LogInfo(moveBean.Name + "开始取料:" + moveBean.GetInstoreParam().PosInfo.ToStr());
StartInstore(moveBean.GetInstoreParam());
break;
}
}
}
}
foreach (BatchMoveBean moveBean in BatchMoveList)
{
moveBean.TimerProcess();
}
if (NoErrorAlarm())
{
CheckAxisAlarm();
}
}
private bool CheckStartOutPos(string posType, InOutPosInfo posInfo, String ioType, List<BatchMoveBean> BatchMoveList, bool shelfAutoLeave = false)
{
DoorInfo doorinfo =null;
if (posInfo != null && IOValue(ioType).Equals(IO_VALUE.HIGH))
{
foreach (BatchMoveBean moveBean in BatchMoveList)
{
var curhSerial = moveBean.MoveInfo.MoveParam?.PosInfo?.hSerial;
if (!string.IsNullOrEmpty(curhSerial) && curhSerial != posInfo.hSerial) {
LogInfo($"{posType}当前料串的 hSerial:{curhSerial},与准备出库到料串 hSerial:{posInfo.hSerial} 不符");
moveBean.ShelfNeedLeave = true;
}
else if (moveBean.MoveInfo.MoveType== MoveType.InStore && moveBean.MoveInfo.MoveStep== StepEnum.IS23_WaitAgv) {
moveBean.MoveInfo.NextMoveStep(StepEnum.IB20_InStoreEnd);
moveBean.StartOutstore();
return true;
}
else if (moveBean.ShelfReadyOut(posInfo, shelfAutoLeave))
{
InOutParam param = new InOutParam(posInfo.ToCopy());
param.ShelfType = moveBean.ShelfType;
LogInfo($"{posType}物料{param.PosInfo.ToStr()},准备出库到料串{param.ShelfType}");
StartOutstore(param);
return true;
}
if (moveBean.MoveInfo.MoveType == MoveType.None) {
doorinfo = moveBean.doorInfo;
}
}
if (doorinfo != null) {
doorinfo.status = doorStatusE.needBox;
doorinfo.hasContainer = false;
}
}
return false;
}
internal bool CanStartWork()
{
//是否可以开始新的料串入料
if (BatchMove_A.MoveInfo.MoveType.Equals(MoveType.InStore))
{
StepEnum step = BatchMove_A.MoveInfo.MoveStep;
if (step < StepEnum.IB21_BatchToP1)
{
return false;
}
}
else if (BatchMove_B.MoveInfo.MoveType.Equals(MoveType.InStore))
{
StepEnum step = BatchMove_B.MoveInfo.MoveStep;
if (step < StepEnum.IB21_BatchToP1)
{
return false;
}
}
return true;
}
private DateTime checkAlarmTime = DateTime.Now;
private void CheckAxisAlarm()
{
if (alarmType.Equals(AlarmType.AxisAlarm) || alarmType.Equals(AlarmType.AxisMoveError))
{
return;
}
TimeSpan span = DateTime.Now - checkAlarmTime;
//在回原点,复位,出入库时,检测报警间隔减小
if (MoveInfo.MoveType.Equals(MoveType.None))
{
if (span.TotalSeconds < 5)
{
return;
}
}
else if (span.TotalSeconds < 1)
{
return;
}
checkAlarmTime = DateTime.Now;
foreach (AxisBean axisInfo in moveAxisArray)
{
if (AxisIsAlarm(axisInfo))
{
return;
}
}
if (AxisIsAlarm(BatchMove_A.BatchAxis, false))
{
BatchMove_A.WarnMsg = WarnMsg;
BatchMove_A.Alarm(AlarmType.AxisAlarm);
return;
}
if (AxisIsAlarm(BatchMove_B.BatchAxis, false))
{
BatchMove_B.WarnMsg = WarnMsg;
BatchMove_B.Alarm(AlarmType.AxisAlarm);
return;
}
}
public bool OpenAllAxis(bool isCheck = true)
{
foreach (AxisBean axis in moveAxisArray)
{
string outMsg = "";
if (!axis.Open(true, out outMsg))
{
LogUtil.info(outMsg);
return false;
}
}
return true;
}
public void CloseAllAxis()
{
foreach (AxisBean axis in moveAxisArray)
{
axis.SuddenStop();
axis.ServoOff();
}
}
public void ClampWork(DeviceMoveInfo moveInfo, bool isCheck, params string[] codes)
{
if (Config.UseClampJaw.Equals(1))
{
ClampJaw.Push(moveInfo, isCheck, codes);
}
else
{
//吸盘工作
ClampPush(moveInfo);
}
}
public void ClampRelax(DeviceMoveInfo moveInfo, params string[] codes)
{
if (Config.UseClampJaw.Equals(1))
{
ClampJaw.Relax(moveInfo, codes);
}
else
{
//吸盘放松
ClampRelax(moveInfo);
}
}
public bool IsNoReelAlarm()
{
if (runStatus.Equals(RunStatus.Busy) && alarmType.Equals(AlarmType.IoSingleTimeOut))
{
if (MoveInfo.MoveType.Equals(MoveType.InStore) && MoveInfo.MoveStep.Equals(StepEnum.II08_ClampWork))
{
return true;
}
else if (MoveInfo.MoveType.Equals(MoveType.OutStore) && MoveInfo.MoveStep.Equals(StepEnum.IO05_ClampWork))
{
return true;
}
else if (MoveInfo.MoveType.Equals(MoveType.OutStore) && MoveInfo.MoveStep.Equals(StepEnum.IO15_ClampWork))
{
return true;
}
}
return false;
}
/// <summary>
/// 判断旋转轴是否在暂存区,返回true表示在暂存区
/// </summary>
/// <param name="areaNum">1=A上暂存区,2=A下暂存区,3=B上暂存区,4=B下暂存区</param>
/// <returns></returns>
public bool AxisInWorkingArea(params int[] areaNums)
{
return false;
//int updownP = UpdownAxis.GetAclPosition();
//int middleP = MiddleAxis.GetAclPosition();
//int middleWucha = 20000;
//int updownWucha = 20000;
////旋转轴在A暂存区
//if (MiddleAxis.IsInPosition(Config.Middle_P4_AUpper, middleWucha) || MiddleAxis.IsInPosition(Config.Middle_P7_AUnder, middleWucha))
//{
// //如果升降轴低于下方高点
// if (updownP > Config.Updown_P6_AUnderH - updownWucha)
// {
// //在A下暂存区
// if (areaNums.Contains(2))
// {
// return true;
// }
// }
// //升降轴高于上方低点
// else if (updownP < Config.Updown_P5_AUpperL7 + updownWucha)
// {
// if (areaNums.Contains(1))
// {
// return true;
// }
// }
// else
// {
// if (areaNums.Contains(1) || areaNums.Contains(2))
// {
// return true;
// }
// }
//}
//else if (MiddleAxis.IsInPosition(Config.Middle_P5_BUpper, middleWucha) || MiddleAxis.IsInPosition(Config.Middle_P8_BUnder, middleWucha))
//{
// //如果升降轴低于下方高点
// if (updownP > Config.Updown_P12_BUnderH - updownWucha)
// {
// if (areaNums.Contains(4))
// {
// return true;
// }
// }
// //升降轴高于上方低点
// else if (updownP < Config.Updown_P11_BUpperL7 + updownWucha)
// {
// if (areaNums.Contains(3))
// {
// return true;
// }
// }
// else
// {
// if (areaNums.Contains(3) || areaNums.Contains(4))
// {
// return true;
// }
// }
//}
//return false;
}
/// <summary>
/// 判断旋转轴是否在料串上方
/// </summary>
/// <param name="shelfType">1=A侧料串,2=B侧料串</param>
/// <returns></returns>
public bool AxisIsInShelfUp(int shelfType)
{
//int middleP = MiddleAxis.GetAclPosition();
//int middleWucha = 20000;
////旋转轴在A暂存区
//if (MiddleAxis.IsInPosition(Config.Middle_P2_ATake, middleWucha))
//{
// if (shelfType.Equals(1))
// {
// return true;
// }
//}
//else if (MiddleAxis.IsInPosition(Config.Middle_P3_BTake, middleWucha))
//{
// if (shelfType.Equals(2))
// {
// return true;
// }
//}
return false;
}
//光栅状态:0正常。1=安全门禁打开,已停止运动
private int CurrSecurityAccess = 0;
protected void SecurityAccessProcess()
{
try
{
if (!baseConfig.DIList.ContainsKey(IO_Type.SafetyRasterSignal))
{
return;
}
if (CurrSecurityAccess.Equals(0))
{
if (BatchMove_A.ProcessShelfEnter || BatchMove_A.ProcessShelfOut)
{
return;
}
if (BatchMove_B.ProcessShelfEnter || BatchMove_B.ProcessShelfOut)
{
return;
}
if (StoreManager.DisSecurityAccess)
{
}
else if (IOValue(IO_Type.Feeding_LDoor_Limit).Equals(IO_VALUE.LOW))
{
SecurityAccessStop("左侧防护门被打开");
}
else if (IOValue(IO_Type.Feeding_RDoor_Limit).Equals(IO_VALUE.LOW))
{
SecurityAccessStop("右侧防护门被打开");
}
else if (IOValue(IO_Type.SafetyRasterSignal).Equals(IO_VALUE.LOW))
{
SecurityAccessStop("光栅被遮挡");
}
}
else if (CurrSecurityAccess.Equals(1))
{
if (IOValue(IO_Type.SafetyRasterSignal).Equals(IO_VALUE.HIGH))
{
SecurityAccessReset();
}
}
}
catch (Exception ex)
{
LogUtil.error(Name + " 出错 :" + ex.ToString());
}
}
private void SecurityAccessStop(string rason)
{
if (!baseConfig.DIList.ContainsKey(IO_Type.SafetyRasterSignal))
{
return;
}
CurrSecurityAccess = 1;
if (alarmType > (AlarmType.IoSingleTimeOut))
{
return;
}
//ConfigIO di = baseConfig.DIList[IO_Type.SafetyRasterSignal];
//LogUtil.info($"{Name }光栅被遮挡,停止当前运动{MoveInfo.MoveType},MoveStop={MoveStop},报警急停");
//SetWarnMsg("光栅被遮挡,报警急停");
//Alarm(AlarmType.SuddenStop);
MoveStop = true;
BatchMove_A.MoveStop = true;
BatchMove_B.MoveStop = true;
string msg = "";
MiddleAxis.SuddenStop();
UpdownAxis.SuddenStop();
msg += $"停止轴{MiddleAxis.Config.Explain},{UpdownAxis.Config.Explain};";
if (MoveInfo.MoveType.Equals(MoveType.None))
{
SetWarnMsg(rason+",暂停运动");
LogUtil.info($"{Name}{rason},暂停运动,MoveStop={MoveStop},{msg},稍后复位");
}
else
{
SetWarnMsg(rason + ",暂停当前运动");
LogUtil.info($"{Name}{rason},停止当前运动{MoveInfo.MoveType},{MoveInfo.MoveStep},{msg},稍后复位");
}
}
private void SecurityAccessReset()
{
if (!baseConfig.DIList.ContainsKey(IO_Type.SafetyRasterSignal))
{
return;
}
CurrSecurityAccess = 0;
MoveStop = false;
BatchMove_A.MoveStop = false;
BatchMove_B.MoveStop = false;
ConfigIO di = baseConfig.DIList[IO_Type.SafetyRasterSignal];
if (alarmType > (AlarmType.IoSingleTimeOut))
{
return;
}
//光栅恢复处理
if (WarnMsg.Contains("光栅被遮挡,暂停"))
{
SetWarnMsg("");
}
if (!MoveInfo.MoveType.Equals(MoveType.None))
{
MoveInfo.LastSetpTime = DateTime.Now;
LogUtil.info($"{Name}光栅已恢复,恢复当前运动{MoveInfo.MoveType},{MoveInfo.MoveStep} ");
}
else
{
LogUtil.info($"{Name}光栅已恢复,取消暂停运动");
}
}
}
}