MainMachine_Store.cs
40.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
using Newtonsoft.Json;
using OnlineStore;
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 DeviceLibrary
{
partial class MainMachine
{
public const string LabelP = "LabelP";
public const string RFIDP = "RFIDP";
StoreJobList OutStoreJobList = new StoreJobList(crc.GetString("Res0108", "批量"));
public bool HasJob { get => OutStoreJobList.Count > 0; }
public void AddOutStoreTask(string warecode, string posId, bool ngReel, string ngMsg)
{
JobInfo jobInfo = new JobInfo(warecode, posId);
jobInfo.isNG = ngReel;
jobInfo.NgMsg = ngMsg;
OutStoreJobList.Enqueue(jobInfo);
LogUtil.info($"添加出库任务队列: {posId},当前任务数量: {OutStoreJobList.Count}");
}
public bool IsInStoreReady { get => true; }
List<string> nglist = new List<string>();
/// <summary>
/// 是否新入抽屉
/// </summary>
public bool newDrawer = true;
void StoreDemoProcess()
{
if (CheckWait(StoreMoveInfo))
return;
//常规上料扫码流程
switch (StoreMoveInfo.MoveStep)
{
case MoveStep.Wait:
StoreMoveInfo.MoveParam.ReelOnFixture = false;
if (Setting_Init.Device_step_by_step_mode)
{
StoreMoveInfo.log("当前单步模式");
return;
}
if (IOValue(IO_Type.Taking_Clamp).Equals(IO_VALUE.LOW))
{
if (Setting_Init.Runtime_Step >= Runtime_StepE.LabelProcess && Setting_Init.Runtime_Step <= Runtime_StepE.LabelPasteFinish)
{
StoreMoveInfo.log("检测到上次正在贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid + "," + Setting_Init.Runtime_FromPosid);
//if (Setting_Init.Runtime_Step >= Runtime_StepE.Printed && Setting_Init.Runtime_Step < Runtime_StepE.LabelPasteFinish)
//{
// StoreMoveInfo.log("检测到上次正在贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid + "," + Setting_Init.Runtime_FromPosid);
// Msg.add(crc.GetString("Res0133", "重置前物料正在贴标,无法继续,请手动处理"), MsgLevel.warning, ErrInfo.LabelInPaste);
// RobotManage.UserPause(crc.GetString("Res0133", "重置前物料正在贴标,无法继续,请手动处理"));
// return;
//}
LabelingMoveInfo.MoveParam.IsNg = true;
LabelingMoveInfo.MoveParam.NgMsg = crc.GetString("Res0182.e64e34d1", "重置前物料正在贴标,NG处理");
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
//if (!string.IsNullOrEmpty(Setting_Init.Runtime_FromPosid))
//{
// LabelingMoveInfo.NewMove(MoveStep.Labeling01);
// StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
//}
//else
//{
// Msg.add(crc.GetString("Res0133", "重置前物料正在贴标,无法继续,请手动处理"), MsgLevel.warning, ErrInfo.LabelInPaste);
// RobotManage.UserPause(crc.GetString("Res0133", "重置前物料正在贴标,无法继续,请手动处理"));
//}
return;
}
else if (Setting_Init.Runtime_Step == Runtime_StepE.LabelPasteFinish)
{
StoreMoveInfo.log("检测到上次已完成贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid + "," + Setting_Init.Runtime_RFID);
StoreMoveInfo.NewMove(MoveStep.StoreIn03);
if (Setting_Init.Runtime_Posid.Val == "NG")
LabelingMoveInfo.MoveParam.IsNg = true;
LabelingMoveInfo.MoveParam.PosID = Setting_Init.Runtime_Posid;
LabelingMoveInfo.MoveParam.RFID = Setting_Init.Runtime_RFID;
StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_Posid;
StoreMoveInfo.MoveParam.RFID = Setting_Init.Runtime_RFID;
return;
}
else if (OutStoreJobList.Dequeue(out JobInfo jobInfo))
{
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
StoreMoveInfo.NewMove(MoveStep.StoreOut10);
StoreMoveInfo.MoveParam.PosID = jobInfo.PosId;
StoreMoveInfo.MoveParam.WareCode = jobInfo.WareNum;
StoreMoveInfo.MoveParam.PlateH = jobInfo.plateH;
StoreMoveInfo.MoveParam.PlateW = jobInfo.plateW;
StoreMoveInfo.log($"开始出库任务:" + jobInfo.ToStr());
ServerCM.storeStatus = StoreStatus.OutStoreExecute;
}
else if (IOValue(IO_Type.Entry_Drawer_Lock).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.Entry_Drawer).Equals(IO_VALUE.HIGH))
{
//NGInfoList = new List<ReelParam>();
//StoreMoveInfo.NewMove(MoveStep.StoreIn01);
//StoreMoveInfo.log($"检测到入库抽屉已锁定");
}
Setting_Init.Runtime_Step = Runtime_StepE.None;
if (ServerCM.selfAudit)
{
selfAuditMode = true;
}
return;
}
if (Setting_Init.Runtime_Step != Runtime_StepE.None)
StoreMoveInfo.log("Runtime_Step:" + Setting_Init.Runtime_Step);
if (Setting_Init.Runtime_Step == Runtime_StepE.InToLabel)
{
StoreMoveInfo.log("检测到上次正在准备去贴标:" + Setting_Init.Runtime_Posid);
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
var acto = CSVPositionReader<ACStorePosition>.GetPositon(LabelP);
StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_Posid;
StoreMoveInfo.MoveParam.ReelOnFixture = true;
boxTransport.Start(new BoxStorePosition(Config, acto, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, acto, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
StoreMoveInfo.log($"开始转运入贴标机构");
}
else if (Setting_Init.Runtime_Step == Runtime_StepE.InToStore)
{
StoreMoveInfo.log("检测到上次正在准备去库位:" + Setting_Init.Runtime_Posid);
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn04);
StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_Posid;
StoreMoveInfo.MoveParam.RFID = Setting_Init.Runtime_RFID;
StoreMoveInfo.MoveParam.ReelOnFixture = true;
}
else if (Setting_Init.Runtime_Step == Runtime_StepE.Out)
{
StoreMoveInfo.log("检测到上次正在出库:" + Setting_Init.Runtime_Posid + "," + Setting_Init.Runtime_WareCode);
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut10_1);
StoreMoveInfo.MoveParam.ReelOnFixture = true;
StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_Posid;
StoreMoveInfo.MoveParam.WareCode = Setting_Init.Runtime_WareCode;
}
break;
case MoveStep.StoreIn01:
string inposid;
var slist = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
foreach (var o in nglist.ToArray())
{
if (slist.Contains(o))
slist.Remove(o);
}
if (slist.Count == 0)
{
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
//IOMove(IO_Type.Entry_Drawer_Lock, IO_VALUE.LOW);
StoreMoveInfo.log($"没有检测到有入库物料");
return;
}
else
{
inposid = slist[0];
StoreMoveInfo.log($"检测到入库位有料:{inposid}, 其他有料入库位:{string.Join(",", slist)}");
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
var from = CSVPositionReader<ACStorePosition>.GetPositon(inposid);
var to = CSVPositionReader<ACStorePosition>.GetPositon(LabelP);
StoreMoveInfo.MoveParam.PosID = inposid;
Setting_Init.Runtime_FromPosid = inposid;
//StoreMoveInfo.MoveParam.ReelOnFixture = false;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
StoreMoveInfo.log($"开始转运入贴标机构");
ServerCM.storeStatus = StoreStatus.InStoreExecute;
break;
case MoveStep.StoreIn02:
if (boxTransport.IsComplateOrFree)
{
if (LabelingMoveInfo.MoveStep == MoveStep.Wait)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
LabelingMoveInfo.NewMove(MoveStep.Labeling01);
StoreMoveInfo.log($"等待贴标完成");
if (Setting_Init.Device_step_by_step_mode)
RobotManage.UserPause();
}
else
{
StoreMoveInfo.log($"等待贴标机构空闲");
}
}
break;
case MoveStep.StoreIn03:
if (LabelingMoveInfo.MoveStep == MoveStep.Wait)
{
StoreMoveInfo.MoveParam = LabelingMoveInfo.MoveParam.clone();
if (StoreMoveInfo.MoveParam.IsNg)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn08);
StoreMoveInfo.log($"收到完成贴标NG");
}
//else if (StoreMoveInfo.MoveParam.usedCount >= 1)
//{
// StoreMoveInfo.NextMoveStep(MoveStep.StoreIn08);
// StoreMoveInfo.log($"该物料已入过库");
// StoreMoveInfo.MoveParam.IsNg = true;
// StoreMoveInfo.MoveParam.NgMsg = "The material has been stocked, and is not allowed to stock again.";
//}
else
{
if (string.IsNullOrEmpty(LabelingMoveInfo.MoveParam.PosID))
{
Msg.add(crc.GetString("Res0138", "等待服务器返回库位"), MsgLevel.info);
StoreMoveInfo.log($"等待服务器返回库位");
return;
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn04);
StoreMoveInfo.log($"收到完成贴标");
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreExecute);
if (Setting_Init.Device_step_by_step_mode)
RobotManage.UserPause();
}
}
else
{
StoreMoveInfo.log($"等待贴标完成");
}
break;
case MoveStep.StoreIn04:
if (boxTransport.IsComplateOrFree)
{
//var outposid= StoreMoveInfo.MoveParam.PosID;
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn05);
from = CSVPositionReader<ACStorePosition>.GetPositon(LabelP);
to = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
//StoreMoveInfo.MoveParam.PosID = outposid;
//StoreMoveInfo.MoveParam.ReelOnFixture = false;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
StoreMoveInfo.log($"开始转运到RFID位置");
}
break;
case MoveStep.StoreIn05:
if (!boxTransport.IsComplateOrFree)
break;
Setting_Init.Runtime_Step = Runtime_StepE.None;
if (StoreMoveInfo.MoveParam.usedCount == 0 && !Setting_Init.Device_Disable_RFID_Check || Setting_Init.Module_No.Val == Module_SO.SO21637)
{
if (StoreMoveInfo.MoveParam.RFID.Length > 16)
StoreMoveInfo.MoveParam.RFID = StoreMoveInfo.MoveParam.RFID.Substring(0, 16);
StoreMoveInfo.Msg(crc.GetString("Res0185.7b3d057f", "正在写入RFID"), MsgLevel.info);
ServerCM.RfidMsg = crc.GetString("Res0185.7b3d057f", "正在写入RFID");
bool writeok = false;
var r = RobotManage.RFID.ReOpen();
var r1 = RobotManage.RFID2?.ReOpen();
StoreMoveInfo.log("连接rfid:" + r + "rfid2:" + r1);
for (int i = 0; i < 15; i++)
{
if (string.IsNullOrEmpty(StoreMoveInfo.MoveParam.RFID))
break;
var epc = StoreMoveInfo.MoveParam.RFID.PadRight(16);
RobotManage.RFID.WriteByte(550, new byte[] { 0x40, 0x00 });
Thread.Sleep(300);
RobotManage.RFID.WriteEPC(Encoding.ASCII.GetBytes(epc));
Thread.Sleep(500);
if (RobotManage.RFID.ReadEPC(16, out byte[] data))
{
if (data[0] != 0xFF)
{
var ds = Encoding.ASCII.GetString(data).Trim();
if (ds == StoreMoveInfo.MoveParam.RFID)
{
StoreMoveInfo.log("RFID 写入成功:" + ds);
writeok = true;
break;
}
else
{
StoreMoveInfo.log("失败的 RFID:" + ds);
}
}
}
if (!writeok && RobotManage.RFID2 != null)
{
RobotManage.RFID2.WriteByte(550, new byte[] { 0x40, 0x00 });
Thread.Sleep(300);
RobotManage.RFID2.WriteEPC(Encoding.ASCII.GetBytes(epc));
Thread.Sleep(500);
if (RobotManage.RFID2.ReadEPC(16, out data))
{
if (data[0] != 0xFF)
{
var ds = Encoding.ASCII.GetString(data).Trim();
if (ds == StoreMoveInfo.MoveParam.RFID)
{
StoreMoveInfo.log("RFID2 写入成功:" + ds);
writeok = true;
break;
}
else
{
StoreMoveInfo.log("失败的 RFID2:" + ds);
}
}
}
}
if (!writeok)
{
var of = i * 3000 * (i % 2 == 0 ? 1 : -1);
var zp = Z_Axis.GetAclPosition() + of;
var yp = Y_Axis.GetAclPosition() + of;
var zt = Z_Axis.AbsMoveASYNC(zp, Config.Z_Axis_P1_speed);
var yt = Y_Axis.AbsMoveASYNC(yp, Config.Y_Axis_P1_speed);
Task.WaitAll(new Task[] { zt, yt }, 10000);
}
//Thread.Sleep(100);
}
if (!writeok)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn08);
StoreMoveInfo.MoveParam.ReelOnFixture = true;
StoreMoveInfo.MoveParam.IsNg = true;
StoreMoveInfo.MoveParam.NgMsg = crc.GetString("Res0139", "RFID 写入失败");
StoreMoveInfo.log($"RFID 写入失败 NG");
ServerCM.cancelPutInTask("", StoreMoveInfo.MoveParam.WareCode);
Z_Axis.AbsMove(StoreMoveInfo, Config.Z_Axis_P1, Config.Z_Axis_P1_speed);
StoreMoveInfo.Msg(crc.GetString("Res0186.7faa6f6b", "RFID 写入失败"), MsgLevel.info, 5);
ServerCM.RfidMsg = crc.GetString("Res0186.7faa6f6b", "RFID 写入失败");
if (Setting_Init.Device_step_by_step_mode)
RobotManage.UserPause();
return;
}
else
{
StoreMoveInfo.Msg(crc.GetString("Res0187.6b2d7028", "RFID 写入成功"), MsgLevel.info, 5);
ServerCM.RfidMsg = crc.GetString("Res0187.6b2d7028", "RFID 写入成功");
}
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn09);
from = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
to = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
StoreMoveInfo.MoveParam.ReelOnFixture = true;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
StoreMoveInfo.log($"开始转运到入库位置");
if (Setting_Init.Device_step_by_step_mode)
RobotManage.UserPause();
break;
case MoveStep.StoreIn06:
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn07);
Z_Axis.AbsMove(StoreMoveInfo, Config.Z_Axis_P1, Config.Z_Axis_P1_speed);
break;
case MoveStep.StoreIn07:
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn08);
X_Axis.AbsMove(StoreMoveInfo, Config.X_Axis_P1, Config.X_Axis_P1_speed);
Y_Axis.AbsMove(StoreMoveInfo, Config.Y_Axis_P1, Config.Y_Axis_P1_speed);
break;
case MoveStep.StoreIn08:
if (boxTransport.IsComplateOrFree)
{
//var outposid = "";
//var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
//olist = RobotManage.PositionNumList.ToList().Where(p => { return p.StartsWith("L") && !olist.Contains(p); }).ToList();
//olist.Remove(LabelP);
//if (olist.Count == 0)
//{
// StoreMoveInfo.NextMoveStep(MoveStep.Wait);
// StoreMoveInfo.log($"没有检测到有空余库位");
// return;
//}
//else
//{
// outposid = olist[olist.Count-1];
// StoreMoveInfo.log($"检测到空库位:{outposid}, 其他空库位:{string.Join(",", olist)}");
//}
//nglist.Add(outposid);
ServerCM.cancelPutInTask("", StoreMoveInfo.MoveParam.WareCode);
nglist.Add(Setting_Init.Runtime_FromPosid);
StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_FromPosid;
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn09);
from = CSVPositionReader<ACStorePosition>.GetPositon(LabelP);
to = CSVPositionReader<ACStorePosition>.GetPositon(Setting_Init.Runtime_FromPosid);
//StoreMoveInfo.MoveParam.PosID = outposid;
StoreMoveInfo.MoveParam.dateTime = DateTime.Now;
NGInfoList.Add(StoreMoveInfo.MoveParam.clone());
Setting_Init.Runtime_NGINFOLIST = JsonConvert.SerializeObject(NGInfoList);
//StoreMoveInfo.MoveParam.ReelOnFixture = false;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
StoreMoveInfo.log($"开始转运");
}
break;
case MoveStep.StoreIn09:
if (boxTransport.IsComplateOrFree)
{
Setting_Init.Runtime_Step = Runtime_StepE.None;
if (!StoreMoveInfo.MoveParam.IsNg)
{
if (!ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreEnd))
{ }
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn10);
StoreMoveInfo.log($"入库完成,开始检查库位");
CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
}
break;
case MoveStep.StoreIn10:
var posid = StoreMoveInfo.MoveParam.PosID;//SA1
List<string> ol = new List<string>();
TestStorePointPort tspp = CameraPointTest.GetTestStorePointPort(posid);
ol = CameraPointTest.GetThingStoreName(tspp);
StoreMoveInfo.log($"检测到有料库位,{tspp}: {string.Join(",", ol)}");
if (ol.Contains(posid))
{
StoreMoveInfo.log("入库成功");
}
else
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn10);
Msg.add(string.Format("No material detected at storage location {0} – please check.", posid), MsgLevel.alarm);
StoreMoveInfo.log("入库失败,请检查库位:" + posid);
RobotManage.UserPause();
return;
}
if (OutStoreJobList.Count == 0)
StoreMoveInfo.NewMove(MoveStep.StoreIn01);
else
StoreMoveInfo.NewMove(MoveStep.Wait);
ServerCM.RfidMsg = "";
break;
case MoveStep.StoreOut10:
if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.Out_Drawer_Lock).Equals(IO_VALUE.HIGH))
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut10_1);
}
else if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.LOW) && IOValue(IO_Type.Out_Drawer_Lock).Equals(IO_VALUE.HIGH))
{
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.LOW);
}
else if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0137", "出库任务正在执行,请关好抽屉"), MsgLevel.alarm);
}
else
{
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
}
break;
case MoveStep.StoreOut10_1:
inposid = StoreMoveInfo.MoveParam.PosID;
Setting_Init.Runtime_Posid = inposid;
Setting_Init.Runtime_WareCode = StoreMoveInfo.MoveParam.WareCode;
{
var outposid = "";
if (!ServerCM.selfAuditException)
{
var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.出口);
StoreMoveInfo.log($"检测到出库口有料库位:{string.Join(",", olist)}");
olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("U") && !olist.Contains(p); }).ToList();
olist.Reverse();
if (olist.Count == 0)
{
OutStoreJobList.ClearLastPosid();
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
StoreMoveInfo.log($"没有检测到出库未有空位");
return;
}
else
{
outposid = olist[0];
StoreMoveInfo.log($"检测到出库位有料:{outposid}, 其他有料出库位:{string.Join(",", olist)}");
}
StoreMoveInfo.MoveParam.IsNg = false;
}
else
{
var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
StoreMoveInfo.log($"检测到入库口有料库位:{string.Join(",", olist)}");
olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("L") && !p.StartsWith("La") && !olist.Contains(p); }).ToList();
StoreMoveInfo.log($"检测到入库口无料库位:{string.Join(",", olist)}");
if (olist.Count == 0)
{
OutStoreJobList.ClearLastPosid();
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
StoreMoveInfo.log($"没有检测到NG出库未有空位");
return;
}
else
{
outposid = olist[0];
StoreMoveInfo.log($"检测到NG出库可用:{outposid}, 其他NG可用出库位:{string.Join(",", olist)}");
}
StoreMoveInfo.MoveParam.IsNg = true;
StoreMoveInfo.MoveParam.dateTime = DateTime.Now;
var n = StoreMoveInfo.MoveParam.clone();
n.PosID = outposid;
NGInfoList.Add(n);
Setting_Init.Runtime_NGINFOLIST = JsonConvert.SerializeObject(NGInfoList);
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
from = CSVPositionReader<ACStorePosition>.GetPositon(inposid);
if (StoreMoveInfo.MoveParam.IsNg)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut12);
to = CSVPositionReader<ACStorePosition>.GetPositon(outposid);//NG出库直接去入口库位
}
else
{
to = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
}
StoreMoveInfo.MoveParam.OutPosID = outposid;
//StoreMoveInfo.MoveParam.ReelOnFixture = false;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.OutStore, true);
StoreMoveInfo.log($"开始转运出库");
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreExecute);
}
break;
case MoveStep.StoreOut11:
if (boxTransport.IsComplateOrFree)
{
//ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreBoxEnd);
bool issame = false;
string ds = "";
if (!Setting_Init.Device_Disable_RFID_Check)
{
for (int i = 0; i < 15; i++)
{
if (RobotManage.RFID.ReadEPC(16, out byte[] data))
{
if (data[0] != 0xFF)
{
ds = Encoding.ASCII.GetString(data).Trim();
var mds = ds;
if (mds.StartsWith("S"))
mds = mds.Substring(1);
if (StoreMoveInfo.MoveParam.WareCode.IndexOf(mds) > -1)
{
StoreMoveInfo.MoveParam.RFID = ds;
StoreMoveInfo.log("读取到 RFID:" + ds + " , " + RobotManage.RFID.HexBuff(data));
issame = true;
break;
}
}
}
if (!issame && RobotManage.RFID2 != null)
{
if (RobotManage.RFID2.ReadEPC(16, out data))
{
if (data[0] != 0xFF)
{
var mds = ds;
if (mds.StartsWith("S"))
mds = mds.Substring(1);
if (StoreMoveInfo.MoveParam.WareCode.IndexOf(mds) > -1)
if (StoreMoveInfo.MoveParam.WareCode.IndexOf(ds) > -1)
{
StoreMoveInfo.MoveParam.RFID = ds;
StoreMoveInfo.log("读取到 RFID2:" + ds + " , " + RobotManage.RFID2.HexBuff(data));
issame = true;
break;
}
}
}
}
Thread.Sleep(200);
}
}
else
{
issame = true;
}
if (!issame)
{
StoreMoveInfo.log("读取到的RFID与物料信息不符 读取到 RFID:" + ds);
StoreMoveInfo.MoveParam.OutPosID = StoreMoveInfo.MoveParam.PosID;
Msg.add("rfid.nomatch", crc.GetString("Res0140", "读取到的RFID与物料信息不符:") + ds, MsgLevel.alarm);
//RobotManage.UserPause(crc.GetString("Res0141","读取到的RFID与物料信息不符"));
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut12);
from = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
to = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.OutPosID);
StoreMoveInfo.log($"开始转运出库");
StoreMoveInfo.MoveParam.ReelOnFixture = true;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.OutStore, true);
if (Setting_Init.Device_step_by_step_mode)
RobotManage.UserPause();
}
break;
case MoveStep.StoreOut12:
if (boxTransport.IsComplateOrFree)
{
Setting_Init.Runtime_Step = Runtime_StepE.None;
if (StoreMoveInfo.MoveParam.OutPosID != StoreMoveInfo.MoveParam.PosID)
{
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreBoxEnd);
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreEnd);
StoreMoveInfo.log("出库完成");
}
else
{
ServerCM.cancelAndDisable(StoreMoveInfo.MoveParam.PosID);
StoreMoveInfo.log("出库NG,自动禁用库位:" + StoreMoveInfo.MoveParam.PosID);
}
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
OutStoreJobList.ClearLastPosid();
if (!StoreMoveInfo.MoveParam.IsNg)
{
var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.出口);
StoreMoveInfo.log($"检测到出库口有料库位:{string.Join(",", olist)}");
olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("U") && !olist.Contains(p); }).ToList();
if (olist.Count == 0)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
StoreMoveInfo.log($"出库库位已用完");
}
}
else
{
var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
StoreMoveInfo.log($"检测到NG出库口有料库位:{string.Join(",", olist)}");
olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("L") && !p.StartsWith("Lab") && !olist.Contains(p); }).ToList();
StoreMoveInfo.log($"检测到NG出库口无料库位:{string.Join(",", olist)}");
//if (olist.Count == 0)
{
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
StoreMoveInfo.log($"NG出库库位已完成");
return;
}
}
if (OutStoreJobList.Count == 0)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
StoreMoveInfo.log($"没有出库任务了");
}
}
break;
case MoveStep.StoreOut13:
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut14);
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.LOW);
StoreMoveInfo.log($"出库抽屉解锁");
break;
case MoveStep.StoreOut14:
if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.LOW))
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut15);
StoreMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
else
{
Msg.add(crc.GetString("Res0115", "出库已完成请取走锡膏"), MsgLevel.warning);
}
break;
case MoveStep.StoreOut15:
if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.HIGH))
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut16);
StoreMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
else
{
Msg.add(crc.GetString("Res0116", "等待出料抽屉关闭"), MsgLevel.warning);
}
break;
case MoveStep.StoreOut16:
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut17);
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
break;
case MoveStep.StoreOut17:
if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.HIGH))
{
StoreMoveInfo.log("抽屉已经上锁 newDrawer:" + newDrawer);
if (!newDrawer)
StoreMoveInfo.NewMove(MoveStep.StoreIn01);
else
StoreMoveInfo.NewMove(MoveStep.Wait);
}
else
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut15);
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.LOW);
}
break;
default:
StoreMoveInfo.log($"未找到对应步骤:{StoreMoveInfo.MoveStep}");
break;
}
}
string StoreState()
{
string state = crc.GetString("Res0107", "空闲中");
if (StoreMoveInfo.MoveStep >= MoveStep.StoreOut10)
{
state = crc.GetString("Res0113", "出库中") + "," + crc.GetString("Res0071", "库位号") + StoreMoveInfo.MoveParam.PosID;
}
else if (StoreMoveInfo.MoveStep >= MoveStep.StoreIn01)
{
state = crc.GetString("Res0114", "入库中") + "," + crc.GetString("Res0071", "库位号") + StoreMoveInfo.MoveParam.PosID;
if (StoreMoveInfo.MoveStep >= MoveStep.StoreIn09)
{
state += "RFID:" + StoreMoveInfo.MoveParam.RFID;
}
}
return state;
}
}
}