DUOStoreBean_Partial.cs
34.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
using DeviceLib;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
partial class DUOStoreBean
{
public int CurrShelfNum = 0;
/// <summary>
/// 料架类型,0=空料架,1=入库料架,2=出库料架
/// </summary>
public int CurrShelfType = 0;
/// <summary>
/// 更新料架信息
/// </summary>
/// <param name="num">料架编号</param>
/// <param name="type">料架类型,0=空料架,1=入库料架,2=出库料架</param>
private void UpdateShelfNum(int num,int type)
{
CurrShelfNum = num;
CurrShelfType = type;
ConfigAppSettings.SaveValue(Setting_Init.CurrShelfType, type);
ConfigAppSettings.SaveValue(Setting_Init.CurrShelfNum, num);
LogUtil.info(Name + "更新料架信息:【" + CurrShelfNum + "】【" + CurrShelfType + "】");
}
protected override bool CheckWaitResult(StoreMoveInfo moveInfo, WaitResultInfo wait)
{
if (wait.WaitType.Equals(WaitEnum.W008_BatchAxis))
{
//等待信号亮或者走到绝对位置才停止
if (IOValue(T1_BatchAxis.TargetIoType).Equals(T1_BatchAxis.TargetIoValue))
{
LogUtil.debug(Name + "CheckWaitResult 检测到" + T1_BatchAxis.TargetIoType + "=" + T1_BatchAxis.TargetIoValue + ",停止运行");
T1_BatchAxis.StopAxisCheckMove();
if (ACServerManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(1))
{
T1_BatchAxis.SuddenStop();
}
return true;
}
else
{
bool isOk = ACServerManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(0);
if (isOk)
{
//TODO 判断是否达到高度,如果未达到,继续上升
T1_BatchAxis.StopAxisCheckMove();
return true;
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W009_ScanCode))
{
if (LastCodeList.Count > 0)
{
return true;
}
}
return false;
}
#region 料架出料
public override bool StartOutStoreMove(InOutParam param)
{
return true;
}
protected override void OutStoreProcess()
{
}
#endregion
#region 料架入料
private bool ShelfNoTray = false;
private int StartMovePosition = 0;
private int EndMovePosition = 0;
private int LastHeight = 0;
private int LastWidth = 0;
private List<string> LastCodeList = new List<string>();
private List<string> YuCodeList = new List<string>();
private bool InShelfInProcess = false;
private bool StartInStoreP()
{
if (IOValue(IO_Type.Line_InCheck).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.LOW) && (!InShelfInProcess))
{
ShelfEnterProcess();
}
if (!MoveInfo.MoveType.Equals(MoveType.None))
{
return false;
}
//判断是否检测到料架
if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
StartInStoreMove(null);
}
return false;
}
private void ShelfEnterProcess()
{
//入口有料架,需要转动链条
Task.Factory.StartNew(delegate
{
InShelfInProcess = true;
try
{
InShelfInProcess = true;
LineRun(null);
//等待进料检测信号
bool result = WaitIo(IO_Type.Line_InCheck, IO_VALUE.LOW, 10000);
}
catch (Exception ex)
{
}
finally
{
InShelfInProcess = false;
LineStop(null);
}
});
}
private void LI_05_WaitTime()
{
//定位工位有料架,等待1秒后再次检测
MoveInfo.NextMoveStep(StoreMoveStep.LI_05_WaitTime);
InOutStoreLog("上料区检测到料架: " + MoveInfo.SLog + ",阻挡1上升,阻挡2上升,转动流水线5秒");
IOMove(IO_Type.Line_Stop1_Wait, IO_VALUE.LOW);
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.LOW);
LineRun(MoveInfo);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WorkCheck, IO_VALUE.HIGH));
}
private void LI_04_LineStart()
{
UpdateShelfNum(GetShelfNum(), 1);
if (IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
LI_05_WaitTime();
}
else if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_04_LineStart);
InOutStoreLog("入料检测: " + MoveInfo.SLog + " 上料等待区有料架 ,阻挡1下降500,阻挡2上升,流水线转动 ,等待料架到达上料区");
IOMove(IO_Type.Line_Stop1_Wait, IO_VALUE.HIGH, false, 500);//进料阻挡下降
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.LOW);//缓冲阻挡前进1000
LineRun(MoveInfo);
//等待指定时间
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WorkCheck, IO_VALUE.HIGH));
}
else
{
if (!InShelfInProcess)
{
LineStop(null);
}
MoveEndP();
LogUtil.info(" 未检测到料架,入料结束");
}
}
public override bool StartInStoreMove(InOutParam param)
{
//判断是哪个工位有料架
if (IOValue(IO_Type.Line_WorkCheck).Equals(IO_VALUE.HIGH))
{
if (CurrShelfNum < 0 || CurrShelfType.Equals(1))
{
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(MoveType.InStore,new InOutParam(MoveType.InStore));
LI_05_WaitTime();
return true;
}
else if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH))
{
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(MoveType.InStore, new InOutParam(MoveType.InStore));
//先将当前料架送出
LI_31_BatchAxisToP1();
}
}
else if (IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.HIGH))
{
runStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(MoveType.InStore, new InOutParam(MoveType.InStore));
if (T1_BatchAxis.IsInPosition(Config.BatchAxis_P1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_02_HoisterBack);
InOutStoreLog("检测到料架:取料提升机构后退端");
hoisterCylinder.StartBack(MoveInfo);
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_01_BatchAxisToP1);
InOutStoreLog("检测到料架,提升轴先返回P1");
T1_BatchAxis.AbsMove(MoveInfo, Config.BatchAxis_P1, Config.BatchAxis_P1Speed);
}
return true;
}
return false ;
}
protected override void InStoreProcess()
{
if (MoveInfo.IsInWait)
{
CheckWait();
}
if (MoveInfo.IsInWait)
{
return;
}
if (MoveInfo.IsStep(StoreMoveStep.LI_01_BatchAxisToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_02_HoisterBack);
InOutStoreLog("检测到料架:取料提升机构后退端");
hoisterCylinder.StartBack(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_02_HoisterBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_03_LocationDown);
InOutStoreLog("入料检测:定位气缸下降");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_03_LocationDown))
{
LI_04_LineStart();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_04_LineStart))
{
LI_04_LineStart();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_05_WaitTime))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_06_TopUp);
InOutStoreLog("入料检测: 顶升气缸上升");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_06_TopUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_07_HoisterForward);
InOutStoreLog("入料检测:取料提升机构前进");
hoisterCylinder.StartForward(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_07_HoisterForward))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_08_AxisUpToP2);
InOutStoreLog("入料检测:上料轴开始慢速上升到P2点,等待检测到料盘");
BatchAxisToP2(true);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_08_AxisUpToP2))
{
CheckHasTray();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_09_ScanCode))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_11_AxisToTray);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog("入料检测:有料盘:升降轴到料串高点P2,旋转轴到料串位置P4");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P4, Config.MiddleAxis_P4Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_11_AxisToTray))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_12_UpdownAxisToP3);
InOutStoreLog("取料:升降轴到料串低点P1");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P1, Config.UpdownAxis_P1Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_12_UpdownAxisToP3))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_13_CylinderTighten);
InOutStoreLog("取料:夹爪气缸夹紧");
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Relax, IO_Type.ClampCylinder_Clamp);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_13_CylinderTighten))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_14_UpdownToP1);
InOutStoreLog("取料:升降轴到料串高点P2");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_14_UpdownToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_15_WaitNoCheck);
InOutStoreLog("取料:等待没有提升机构料盘检测");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.BatchAxis_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_15_WaitNoCheck))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_16_BatchAxisToP2);
InOutStoreLog("取料:批量轴到P2,计算高度,");
BatchAxisToP2(false);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_16_BatchAxisToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_17_SaveSize);
InOutStoreLog("取料:记录高度尺寸");
LastWidth = GetWidth();
LastHeight = GetHeight();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_17_SaveSize))
{
LI_18_GetPosID();
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_18_GetPosID))
{
if (getPosTask.IsCompleted && LastPosParam != null)
{
if (LastPosParam.InStoreNg)
{
int box = GetInstoreNgBox();
LastPosParam.TargetBox = box;
}
else
{
int storeId = LastPosParam.GetStoreId();
if (storeId.Equals(1))
{
LastPosParam.TargetBox = 1;
}
else
{
LastPosParam.TargetBox = 2;
}
}
MoveInfo.NextMoveStep(StoreMoveStep.LI_21_WaitToBox);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog("料盘移栽:" + LastPosParam.ToStr() + " 等待料仓门口无信号");
ClearTimeoutAlarm("获取库位号超时");
}
else if (MoveInfo.IsTimeOut(120))
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 获取库位号超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, ID * 1000 + 30);
Alarm(AlarmType.IoSingleTimeOut);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_21_WaitToBox))
{
int storeId = LastPosParam.GetStoreId();
if (IOManager.IOValue(IO_Type.InDoor_Check, storeId).Equals(IO_VALUE.LOW))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_22_ToBoxDoor);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
//判断是左侧还是右侧
if (LastPosParam.TargetBox.Equals(1))
{
InOutStoreLog("料盘移栽:获取库位号完成, BOX " + storeId + " 升降轴到料门口高点[" + Config.UpdownAxis_P4 + "],旋转轴到料仓门口 [" + Config.MiddleAxis_P2 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P4, Config.UpdownAxis_P4Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P2, Config.MiddleAxis_P2Speed);
}
else
{
InOutStoreLog("料盘移栽:获取库位号完成, BOX " + storeId + " 升降轴到料门口高点[" + Config.UpdownAxis_P6 + "],旋转轴到料仓门口 [" + Config.MiddleAxis_P3 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P6, Config.UpdownAxis_P6Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P3, Config.MiddleAxis_P3Speed);
}
ClearTimeoutAlarm("入料口无料盘");
}
else if (MoveInfo.IsTimeOut(120))
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 等待BOX_" + storeId + " 入料口无料盘 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, ID * 1000 + 30);
Alarm(AlarmType.IoSingleTimeOut);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_22_ToBoxDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_23_UpdownDown);
YuScanCode();
if (LastPosParam.TargetBox.Equals(1))
{
InOutStoreLog("料盘移栽: 升降轴到料门口低点[" + Config.UpdownAxis_P3 + "],开始预扫码");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P3, Config.UpdownAxis_P3Speed);
}
else
{
InOutStoreLog("料盘移栽: 升降轴到料门口低点[" + Config.UpdownAxis_P5 + "],开始预扫码");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P5, Config.UpdownAxis_P5Speed);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_23_UpdownDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_24_CylinderRelax);
InOutStoreLog("料盘移栽: 上料气缸放松");
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Clamp, IO_Type.ClampCylinder_Relax);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_24_CylinderRelax))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_25_UpdownUp);
if (LastPosParam.TargetBox.Equals(1))
{
InOutStoreLog("料盘移栽: 升降轴到料门口高点[" + Config.UpdownAxis_P4 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P4, Config.UpdownAxis_P4Speed);
}
else
{
InOutStoreLog("料盘移栽: 升降轴到料门口高点[" + Config.UpdownAxis_P6 + "]");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P6, Config.UpdownAxis_P6Speed);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_25_UpdownUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_26_AxisToWait);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog("料盘移栽:旋转轴返回待机点P1,升降轴到料串高点P2");
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P1, Config.MiddleAxis_P1Speed);
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_26_AxisToWait))
{
CheckHasTray();
}
#region 送出料架处理
else if (MoveInfo.IsStep(StoreMoveStep.LI_31_BatchAxisToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_32_HoisterBack);
InOutStoreLog("送出料架:升降盘定位气缸后退");
hoisterCylinder.StartBack(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_32_HoisterBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_33_TopCylinderDown);
InOutStoreLog("送出料架:顶升气缸下降");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Up);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_33_TopCylinderDown))
{
//判断是否需要送出料架,如果入口和等待区无料架,暂不送出
if (IOValue(IO_Type.Line_InCheck).Equals(IO_VALUE.LOW) && IOValue(IO_Type.Line_WaitCheck).Equals(IO_VALUE.LOW))
{
InOutStoreLog("送出料架:入口和等待区暂无料架,不需要送出料架");
MoveEndP();
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_34_WorkStopDown);
InOutStoreLog("送出料架:上料阻挡下降1秒,流水线开始转动");
UpdateShelfNum(-1, -1);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
LineRun(MoveInfo);
IOMove(IO_Type.Line_Stop2_Work, IO_VALUE.HIGH, false, 1500);
}
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_34_WorkStopDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_35_WaitShelfGo);
InOutStoreLog("送出料架:等待上料无料架");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Line_WaitCheck, IO_VALUE.LOW));
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_35_WaitShelfGo))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_36_LineRun);
InOutStoreLog("送出料架:流水线再转动3秒");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
LineRun(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_36_LineRun))
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_37_LineStop);
InOutStoreLog("送出料架:流水线停止转动");
LineStop(MoveInfo);
}
else if (MoveInfo.IsStep(StoreMoveStep.LI_37_LineStop))
{
LineStop(MoveInfo);
MoveEndP();
}
#endregion
}
private int GetInstoreNgBox()
{
//空闲且门口无料盘
foreach(BoxBean box in BoxMap.Values)
{
if (box.MoveInfo.MoveType.Equals(MoveType.None) && IOManager.IOValue(IO_Type.InDoor_Check, box.ID).Equals(IO_VALUE.LOW))
{
return box.ID;
}
}
//忙碌且目标是出料口
foreach (BoxBean box in BoxMap.Values)
{
if (box.MoveInfo.MoveType.Equals(MoveType.None))
{
if (IOManager.IOValue(IO_Type.InDoor_Check, box.ID).Equals(IO_VALUE.LOW))
{
return box.ID;
}
}
else if (box.MoveInfo.MoveParam.TargetPosition.Equals(1))
{
return box.ID;
}
}
return 1;
}
protected void ClearTimeoutAlarm(string msg)
{
if (isInSuddenDown || isNoAirCheck)
{
return;
}
if (WarnMsg.Contains(msg) && alarmType.Equals(AlarmType.IoSingleTimeOut))
{
LogUtil.info(Name + "清理信号超时报警【" + WarnMsg + "】 ");
alarmType = AlarmType.None;
SetWarnMsg("");
}
}
private Task getPosTask = null;
private string lastcode = "";
private InOutParam LastPosParam = null;
private void LI_18_GetPosID()
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_18_GetPosID);
InOutStoreLog("料盘移栽:从服务器获取入库库位号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
LastPosParam = null;
string code = CodeManager.ProcessCode(LastCodeList);
lastcode = code;
getPosTask = Task.Factory.StartNew(delegate
{
//更新托盘条码信息
try
{
int count = 1;
while (MoveInfo.MoveType.Equals(MoveType.InStore))
{
//从服务器获取库位号
GetPosResult result = StoreManager.GetPosId(Name, LastCodeList, LastHeight, LastWidth, CurrShelfNum);
if (result.IsTimeOut)
{
LogUtil.error(Name + "【" + code + "】第[" + count + "]次 LI_18_GetPosID 超时,等待1s后重新获取");
Thread.Sleep(1000);
}
else if (result.Result.Equals(99) || result.Result.Equals(100))
{
LogUtil.error(Name + "【" + code + "】第[" + count + "]次 LI_18_GetPosID 结果【" + result.Result + "】,等待3s后重新获取");
Thread.Sleep(3000);
}
else if (!result.Msg.Equals(""))
{
LastPosParam = result.Param;
LogUtil.error(Name + "【" + code + "】第[" + count + "]次 LI_18_GetPosID 入库NG:" + result.Msg);
break;
}
else
{
LastPosParam = result.Param;
break;
}
count++;
}
}
catch (Exception ex)
{
LogUtil.error(Name + "【" + code + "】获取库位号报错:" + ex.ToString());
}
});
MoveInfo.MoveParam = LastPosParam;
}
private void LI_11_AxisToTray()
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_11_AxisToTray);
InOutStoreLog("入料检测:有料盘:升降轴到料串高点P2,旋转轴到料串位置P4");
T3_UpdownAxis.AbsMove(MoveInfo, Config.UpdownAxis_P2, Config.UpdownAxis_P2Speed);
T2_MiddleAxis.AbsMove(MoveInfo, Config.MiddleAxis_P4, Config.MiddleAxis_P4Speed);
}
private void LI_09_ScanCode()
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_09_ScanCode);
LastCodeList = new List<string>();
if (YuCodeList.Count > 0)
{
InOutStoreLog("入料检测:开始扫码:使用预扫码");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
LastCodeList = new List<string>(YuCodeList);
YuCodeList = new List<string>();
LI_11_AxisToTray();
}
else
{
InOutStoreLog("料盘移栽" + MoveInfo.SLog + ":开始扫码");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitScanCode());
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(7000));
try
{
Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
if (LastCodeList.Count <= 0)
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name, 3000);
}
return LastCodeList;
});
}
catch (Exception ex)
{
LogUtil.error("FI_13_ScanCode扫码出错:", ex);
}
}
}
private void YuScanCode()
{
//TODO 此处需要等待空托盘
if (ShelfNoTray.Equals(false))
{
InOutStoreLog("料盘移栽" + MoveInfo.SLog + ": ,预扫码");
//还有料盘,直接扫码
YuCodeList = new List<string>();
List<string> bijiaoList = new List<string>(LastCodeList);
try
{
Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{
Thread.Sleep(500);
YuCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name.Trim() + "预扫码");
bool isCanUse = true;
//判断是否可用
foreach (string nC in YuCodeList)
{
foreach (string n in bijiaoList)
{
if (nC.Length > 15 && nC.Equals(n))
{
LogUtil.error(Name + "预扫码结果【" + nC + "】与上个条码【" + n + "】重复,预扫码不可用");
isCanUse = false;
break;
}
}
}
if (!isCanUse)
{
YuCodeList = new List<string>();
}
//if (!CodeManager.HasRightCode(YuCodeList.ToArray()))
//{
// YuCodeList = new List<string>();
//}
return YuCodeList;
});
}
catch (Exception ex)
{
LogUtil.error(" 为下一盘料扫码出错:", ex);
}
}
}
private void CheckHasTray()
{
if (IOValue(IO_Type.BatchAxis_Check).Equals(IO_VALUE.HIGH) && ShelfNoTray.Equals(false))
{
LI_09_ScanCode();
}
else
{
if (ShelfNoTray.Equals(false))
{
//判断当前位置是否在指定的位置
int currP = T1_BatchAxis.GetAclPosition();
int chaz = Math.Abs(currP - Config.BatchAxis_P2);
if (chaz > T1_BatchAxis.Config.CanErrorCountMax)
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_08_AxisUpToP2);
InOutStoreLog(" CheckHasTray:上料轴开始慢速上升到P2点,等待检测到料盘");
ShelfNoTray = false;
BatchAxisToP2(false);
return;
}
}
//无料盘
ShelfNoTray = true;
LI_31_BatchAxisToP1();
}
}
private void LI_31_BatchAxisToP1()
{
MoveInfo.NextMoveStep(StoreMoveStep.LI_31_BatchAxisToP1);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
InOutStoreLog("料盘移栽" + MoveInfo.SLog + ":未检测到料盘,提升伺服到P1点 ");
UpdateShelfNum(CurrShelfNum, 0);
T1_BatchAxis.SuddenStop();
T1_BatchAxis.AbsMove(MoveInfo, Config.BatchAxis_P1, Config.BatchAxis_P2Speed);
}
private void BatchAxisToP2(bool isFirstMove = true)
{
int targetP2 = Config.BatchAxis_P2;
int targetSpeed = Config.BatchAxis_P2Speed;
if (!isFirstMove)
{
int currPosition = T1_BatchAxis.GetAclPosition();
if (currPosition != -1)
{
targetP2 = currPosition + Config.BatchAxis_ChangeValue * 80;
if (targetP2 > Config.BatchAxis_P2)
{
targetP2 = Config.BatchAxis_P2;
}
LogUtil.info(Name + " BatchAxisToP2 目标P2: " + targetP2 + "(" + currPosition + ")");
}
//targetSpeed = Config.BatchAxis_P3Speed / 2;
}
MoveInfo.TimeOutSeconds = 200;
MoveInfo.CanWhileCount = 0;
// 需要增加定时器,获取验证信号并停止伺服
StartMovePosition = T1_BatchAxis.GetAclPosition();
MoveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxisMove(Config.T1_Batch_Axis, targetP2, targetSpeed));
Config.T1_Batch_Axis.TargetPosition = targetP2;
T1_BatchAxis.AbsMove(null, targetP2, targetSpeed);
//开始检测信号
T1_BatchAxis.BatchAxisStartCheck(IO_Type.BatchAxis_Check, IO_VALUE.HIGH);
}
private int GetHeight()
{
LastHeight = 0;
int AxisChangeValue = Config.BatchAxis_ChangeValue;
//计算高度
EndMovePosition = T1_BatchAxis.GetAclPosition();
bool isLast = false;
int chaz = Math.Abs(EndMovePosition - Config.BatchAxis_P2);
if (chaz < T1_BatchAxis.Config.CanErrorCountMax)
{
isLast = true;
}
float height = (float)Math.Ceiling(1F * Math.Abs(EndMovePosition - StartMovePosition) / AxisChangeValue);
string buchongStr = "";
if (isLast)
{
buchongStr = "(最后一盘料已补充5)";
height += 5;
}
//如果检测出<=15,都按照8计算
if (height <= 15)
{
LastHeight = 8;
}
else
{
List<int> heightList = new List<int> { 8, 12, 16, 20 };
heightList = (from m in heightList orderby m descending select m).ToList<int>();
float minCha = height;
foreach (int h in heightList)
{
//取差值最小的接近值
float cha = Math.Abs(h - (height - 4));
if (cha < minCha)
{
LastHeight = h;
minCha = cha;
}
}
}
if (LastHeight <= 8) { LastHeight = 8; }
string code = CodeManager.ProcessCode(LastCodeList);
string msg = Name + " 计算盘高:上升前 [" + StartMovePosition + "]实时[ " + EndMovePosition + "]差值[" + (EndMovePosition - StartMovePosition) + "]系数[" + AxisChangeValue + "] 计算后" + buchongStr + "[" + height + "]" + ",归类为【" + LastHeight + "mm】条码【" + code + "】";
LogUtil.info(msg);
return LastHeight;
}
public int GetWidth()
{
return 7;
}
#endregion
}
}