BoxEquip_PosDebug.cs
30.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
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public partial class BoxEquip
{
public bool isInitPosDebugInfo = false;
public PosDebugInfo posDebugInfo = null;
public void InitPosDebugInfo()
{
PosDebugResultManager.Init(PositionNumList);
isInitPosDebugInfo = PosDebugResultManager.isInit;
posDebugInfo = new PosDebugInfo(this.CID, this.Config);
}
public void StartPosDebug(InOutParam param)
{
if (isInSuddenDown || isNoAirpressure_Check ||
(!runStatus.Equals(RunStatus.Runing))
|| (!MoveInfo.MoveType.Equals(MoveType.None)))
{
LogUtil.error(Name + " 启动库位调试出错,忙碌或报警中 ,storeStatus=" + runStatus + ",MoveType=" + MoveInfo.MoveType + ",isInSuddenDown=" + isInSuddenDown + ",isNoAirpressure_Check=" + isNoAirpressure_Check);
return;
}
LogInfo(" 启动库位调试【" + param.PosInfo.ToStr() + "】 ");
param.MoveP = new LineMoveP(Config, param.PosInfo.PosId);
MoveInfo.NewMove(MoveType.Working, param);
SetBoxStatus(DeviceStatus.Debugging, RunStatus.Busy);
MoveInfo.NextMoveStep(StepEnum.SP_00_1_StartPosDebug);
PullAxis_Inout_To_P1();
}
//public void Test()
//{
// Random random = new Random();
// Task.Factory.StartNew(new Action(delegate
// {
// while (!posDebugInfo.IsLastDrawer())
// {
// while (!posDebugInfo.IsLastGrid())
// {
// PosDebugResultManager.SetGridResult(posDebugInfo.CurGrid, 1);
// posDebugInfo.NextGrid();
// System.Threading.Thread.Sleep(500);
// }
// PosDebugResultManager.SetGridResult(posDebugInfo.CurGrid, 1);
// PosDebugResultManager.SetDrawerResult(posDebugInfo.CurDrawer, 1);
// PosDebugResultManager.SetDrawerResultWithGrid(posDebugInfo.CurDrawer);
// posDebugInfo.NextDrawer();
// System.Threading.Thread.Sleep(500);
// }
// while (!posDebugInfo.IsLastGrid())
// {
// PosDebugResultManager.SetGridResult(posDebugInfo.CurGrid, 1);//random.Next(0, 2)
// posDebugInfo.NextGrid();
// System.Threading.Thread.Sleep(500);
// }
// PosDebugResultManager.SetGridResult(posDebugInfo.CurGrid, 1);
// PosDebugResultManager.SetDrawerResultWithGrid(posDebugInfo.CurDrawer);
// posDebugInfo.NextDrawer();
// }));
// PosDebugResultManager.SaveResult();
//}
/// <summary>
/// 更新移动信息
/// </summary>
private void UpdateMoveInfo(string posId)
{
InOutPosInfo inOutPosInfo = new InOutPosInfo("PosDebug", posId);
MoveInfo.MoveParam.PosInfo = inOutPosInfo;
MoveInfo.MoveParam.MoveP = new LineMoveP(Config, inOutPosInfo.PosId);
}
/// <summary>
/// 设置抽屉的结果代码
/// </summary>
/// <param name="code"></param>
private void SetDrawerResult(int code)
{
PosDebugResultManager.SetDrawerResult(posDebugInfo.CurDrawer, code);
}
public void PosDebugProcess()
{
if (MoveInfo.IsInWait)
{
CheckWait(MoveInfo);
logColumnSig();
}
if (MoveInfo.IsInWait)
{
return;
}
if (posDebugInfo.IsPause)
return;
switch (MoveInfo.MoveStep)
{
case StepEnum.SP_00_1_StartPosDebug:
PullAxisToP1("库位调试");
break;
case StepEnum.SP_00_2_PullAxisReady:
SetBoxStatus(DeviceStatus.Debugging, RunStatus.Busy);
MoveInfo.NextMoveStep(StepEnum.SP_00_3_CheckMoveAxisSafe);
if (!IsMoveAxisInSafePos())
{
MoveAxisToP1(true);
LogInfo($"库位调试 行走机构不在安全位置,先到安全位置={Config.MoveAxis_SafePos}。当前位置{MoveAxis.GetAclPosition()}");
}
break;
case StepEnum.SP_00_3_CheckMoveAxisSafe:
MoveInfo.NextMoveStep(StepEnum.SP_01_ToBufferArea);
LogInfo($"库位调试 {MoveInfo.SLog}:到暂存区入料口," +
$"行走机构到待机点P1,料斗升降轴到P1点,移栽升降轴到上暂存区取料低点P3/P9,移栽压紧轴到压紧前点P2,移栽旋转轴到取放料水平点P2,移栽X轴到P1[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
MoveAxisToP1(true);
PullAxis_UpdownToP1(true);
UpdownAxisTo_P3_P9(true);
ComAxis_To_P2(true);
MiddleAxis_To_P2(true);
XAxis_To_P1(true);
break;
case StepEnum.SP_01_ToBufferArea:
//if (!InDoorCheck(MoveInfo.MoveParam))
//{
// SetWarnMsg($"库位调试 {MoveInfo.SLog}:入口料盘无信息[barcode={MoveInfo.MoveParam.PosInfo.barcode},PosSide={MoveInfo.MoveParam.PosInfo.GetPosSide()}],结束调试");
// SetBoxStatus(DeviceStatus.Debugging, RunStatus.Runing);
// MoveInfo.EndMove();
//}
//else
{
MoveInfo.NextMoveStep(StepEnum.SP_02_VerifyBufferState);
LogInfo($"库位调试 {MoveInfo.SLog}:入料口料盘信息确认[barcode={MoveInfo.MoveParam.PosInfo.barcode}][posId={MoveInfo.MoveParam.PosInfo.PosId}][{MoveInfo.MoveParam.PosInfo.GetPosSide()}面],开始取料");
}
break;
case StepEnum.SP_02_VerifyBufferState:
//if (!CheckInputMiddleAxisInBuff())
{
MoveInfo.NextMoveStep(StepEnum.SP_03_XAxisToBuff);
LogInfo($"库位调试 {MoveInfo.SLog}:移栽X轴到暂存区取放点P2,行走机构到取放点P2[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
XAxis_To_P2(true);
MoveAxisToP2(true);
}
//else if (MoveInfo.IsTimeOut())
//{
// SetWarnMsg($"等待上料机构旋转轴离开{MoveInfo.MoveParam.PosInfo.GetPosSide()}面暂存区超时");
//}
break;
case StepEnum.SP_03_XAxisToBuff:
MoveInfo.NextMoveStep(StepEnum.SP_04_GetReel);
LogInfo($"库位调试 {MoveInfo.SLog}:取料盘,移栽升降轴到上暂存区取料高点P2/P8,移栽压紧轴到压紧点P3[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
UpdownAxisTo_P2_P8(true);
ComAxis_To_P3(true);
break;
case StepEnum.SP_04_GetReel:
MoveInfo.NextMoveStep(StepEnum.SP_05_XAxisBackToP1);
LogInfo($"库位调试 {MoveInfo.SLog}:移栽X轴到待机点P1[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
XAxis_To_P1(true);
break;
case StepEnum.SP_05_XAxisBackToP1:
MoveInfo.NextMoveStep(StepEnum.SP_06_ClearBuffInfo);
LogInfo($"库位调试 {MoveInfo.SLog}:清空暂存区料盘信息[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
//清空暂存区料盘信息
ClearInDoorBuffer();
break;
case StepEnum.SP_06_ClearBuffInfo:
MoveInfo.NextMoveStep(StepEnum.SP_07_MiddleToP3);
LogInfo($"库位调试 {MoveInfo.SLog}:[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
break;
case StepEnum.SP_07_MiddleToP3:
MoveInfo.NextMoveStep(StepEnum.SP_08_ToPosition);
LogInfo($"库位调试 {MoveInfo.SLog}:运行到库位,移栽升降轴到料屉上方过渡点P6/P12,行走机构到存储库位取放点位P3," +
$"料斗拉取升降轴到料屉提取低点P4,料斗拉取进出轴到拍照点,移栽旋转轴到料屉库位垂直取放料点P3,移栽X轴到料斗库位取放料点P3[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
XAxis_To_P3(true);
PullAxis_Inout_To_Cam(true);
MiddleAxis_To_P3(true);
MoveAxisToP3(true);
PullAxis_UpdownToLowP4(true);
UpdownAxisTo_P6_P12(true);
break;
case StepEnum.SP_08_ToPosition:
if (CamCheckReelPosition())
{
MoveInfo.NextMoveStep(StepEnum.SP_09_ToDrawer);
LogInfo($"库位调试 {MoveInfo.SLog}:到抽屉提取点,料斗拉取进出轴到料屉提取点P2/P4[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_Inout_To_P2_P4(true);
CamDetectError = false;
IgnoreCamDect = false;
}
else
{
MoveInfo.NextMoveStep(StepEnum.SP_25_ToNextGrid);
PosDebugResultManager.SetDrawerResult(posDebugInfo.CurDrawer, 0);
LogInfo($"库位调试 {MoveInfo.SLog}:视觉检查失败,抽屉[{posDebugInfo.CurDrawer}]NG [{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
}
break;
case StepEnum.SP_09_ToDrawer:
MoveInfo.NextMoveStep(StepEnum.SP_10_LiftDrawer);
LogInfo($"库位调试 {MoveInfo.SLog}:提升抽屉,料斗拉取升降轴到料屉提取高点P3 [{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_UpdownToHighP3(true);
break;
case StepEnum.SP_10_LiftDrawer:
MoveInfo.NextMoveStep(StepEnum.SP_11_PullDrawer);
LogInfo($"库位调试 {MoveInfo.SLog}:拉抽屉到库位点,料斗拉取进出轴到料屉库位点P3/P5[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_Inout_To_P3_P5(true);
break;
case StepEnum.SP_11_PullDrawer:
MoveInfo.NextMoveStep(StepEnum.SP_12_DropDrawerToPos);
LogInfo($"库位调试 {MoveInfo.SLog}:将抽屉降到库位提取点,料斗拉取升降轴到P2料屉提取水平点P2,到位后检测{trayRows[GetPosRow()]}=1 [{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_UpdownToMiddleP2(true);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(trayRows[GetPosRow()], IO_VALUE.HIGH));
break;
case StepEnum.SP_12_DropDrawerToPos:
MoveInfo.NextMoveStep(StepEnum.SP_13_PutReel);
LogInfo($"库位调试 {MoveInfo.SLog}:进入库位中,移栽升降轴到料屉取放点P7/P13[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
UpdownAxisToP7_P13(true);
SaveSpecifiedImage(true);
break;
case StepEnum.SP_13_PutReel:
MoveInfo.NextMoveStep(StepEnum.SP_14_ReleaseCompress);
LogInfo($"库位调试 {MoveInfo.SLog}:放下料盘,压紧轴开始缓慢释放,移栽压紧轴到压紧前点P2[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
ComAxis_To_P2(true);
break;
case StepEnum.SP_14_ReleaseCompress:
MoveInfo.NextMoveStep(StepEnum.SP_15_UpDownBack);
LogInfo($"库位调试 {MoveInfo.SLog}:叉子从库位返回[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
UpdownAxisTo_P6_P12(true);
break;
case StepEnum.SP_15_UpDownBack:
MoveInfo.NextMoveStep(StepEnum.SP_16_GetReel);
LogInfo($"库位调试 {MoveInfo.SLog}:进入库位中,移栽升降轴到料斗取放点P7/P13[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
UpdownAxisToP7_P13(true);
break;
case StepEnum.SP_16_GetReel:
MoveInfo.NextMoveStep(StepEnum.SP_17_StartCompress);
LogInfo($"库位调试 {MoveInfo.SLog}:压紧轴开始缓慢夹取,移栽压紧轴到压紧点P3[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
ComAxis_To_P3(true);
break;
case StepEnum.SP_17_StartCompress:
MoveInfo.NextMoveStep(StepEnum.SP_18_UpDownBack);
LogInfo($"库位调试 {MoveInfo.SLog}:叉子从库位返回,移栽升降轴到料斗上方过度点P6/P12 [{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
UpdownAxisTo_P6_P12(true);
break;
case StepEnum.SP_18_UpDownBack:
if (posDebugInfo.IsLastGrid())
{
MoveInfo.NextMoveStep(StepEnum.SP_19_CheckDrawerFinish);
int drawerRescode = PosDebugResultManager.SetDrawerResultWithGrid(posDebugInfo.CurDrawer);
LogInfo($"库位调试 {MoveInfo.SLog}:{posDebugInfo.CurGrid}是抽屉的最后一个库位,统计抽屉结果:{drawerRescode}[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
}
else
{
MoveInfo.NextMoveStep(StepEnum.SP_25_ToNextGrid);
PosDebugResultManager.SetGridResult(posDebugInfo.CurGrid, 1);
LogInfo($"库位调试 {MoveInfo.SLog}:{posDebugInfo.CurGrid}库位调试OK,切换到下一个库位[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
posDebugInfo.NextGrid();
UpdateMoveInfo(posDebugInfo.CurGrid);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
break;
case StepEnum.SP_19_CheckDrawerFinish:
MoveInfo.NextMoveStep(StepEnum.SP_20_LiftDrawer);
LogInfo($"库位调试 {MoveInfo.SLog}:提升抽屉,料斗拉取升降轴到料斗提取高点P3[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_UpdownToHighP3(true);
break;
case StepEnum.SP_20_LiftDrawer:
MoveInfo.NextMoveStep(StepEnum.SP_21_PushDrawer);
LogInfo($"库位调试 {MoveInfo.SLog}:将抽屉推入,料斗拉取进出轴到料斗提取点P2/P4[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_Inout_To_P2_P4(true);
break;
case StepEnum.SP_21_PushDrawer:
MoveInfo.NextMoveStep(StepEnum.SP_22_PutDrawerMiddle);
LogInfo($"库位调试 {MoveInfo.SLog}:抽屉降到水平点[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
break;
case StepEnum.SP_22_PutDrawerMiddle:
MoveInfo.NextMoveStep(StepEnum.SP_23_PutDrawerDown);
LogInfo($"库位调试 {MoveInfo.SLog}:抽屉降到低点,料斗拉取升降轴到料斗提取低点P4[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_UpdownToLowP4(true);
break;
case StepEnum.SP_23_PutDrawerDown:
MoveInfo.NextMoveStep(StepEnum.SP_24_InoutBack);
if (CheckASide())
{
LogInfo($"库位调试 {MoveInfo.SLog}:进出轴返回拍照点,同时检测{trayAColumns[GetPosColumn()]}=1[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
if (!GetShieldState(sheidAColmns[GetPosColumn()]))
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(trayAColumns[GetPosColumn()], IO_VALUE.HIGH));
}
else
{
LogInfo($"库位调试 {MoveInfo.SLog}:进出轴返回拍照点,同时检测{trayBColumns[GetPosColumn()]} = 1[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
if (!GetShieldState(sheidBColmns[GetPosColumn()]))
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(trayBColumns[GetPosColumn()], IO_VALUE.HIGH));
}
PullAxis_Inout_To_Cam(true);
break;
case StepEnum.SP_24_InoutBack:
if (posDebugInfo.IsLastDrawer())
{
MoveInfo.NextMoveStep(StepEnum.SP_26_ToBufferArea);
LogInfo($"库位调试 {MoveInfo.SLog}:{posDebugInfo.CurDrawer}是最后一个抽屉,将料盘送回暂存区。旋转轴到水平点P2,行走机构到待机点P1,抽屉升降轴到待机点P1、移栽升降轴到下暂存区高点P4/P10[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
MiddleAxis_To_P2(true);
MoveAxisToP1(true);
PullAxis_UpdownToP1(true);
UpdownAxisTo_P4_P10(true);
}
else
{
MoveInfo.NextMoveStep(StepEnum.SP_25_ToNextDrawer);
LogInfo($"库位调试 {MoveInfo.SLog}:{posDebugInfo.CurDrawer}调试结束,切换到下一个抽屉[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
posDebugInfo.NextDrawer();
UpdateMoveInfo(posDebugInfo.CurGrid);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
break;
case StepEnum.SP_25_ToNextDrawer:
MoveInfo.NextMoveStep(StepEnum.SP_07_MiddleToP3);
LogInfo($"库位调试 {MoveInfo.SLog}:抽屉{posDebugInfo.CurDrawer}调试开始[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
break;
case StepEnum.SP_25_ToNextGrid:
MoveInfo.NextMoveStep(StepEnum.SP_12_DropDrawerToPos);
LogInfo($"库位调试 {MoveInfo.SLog}:到下一料格位置,移栽X轴到料斗库位取放料点P3、料斗拉取进出轴到料斗库位点P3/P5[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
XAxis_To_P3(true);
PullAxis_Inout_To_P3_P5(true);
break;
case StepEnum.SP_26_ToBufferArea:
//if (!CheckInputMiddleAxisInBuff())
{
MoveInfo.NextMoveStep(StepEnum.SP_27_XAxisToBuffer);
LogInfo($"库位调试 {MoveInfo.SLog}:到下暂存区碗里,移栽X轴到进出料暂存区取放点P2,行走机构到进出料机构取放点P2[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
XAxis_To_P2(true);
MoveAxisToP2(true);
}
//else if (MoveInfo.IsTimeOut())
//{
// SetWarnMsg($"等待上料机构旋转轴离开{MoveInfo.MoveParam.PosInfo.GetPosSide()}面暂存区超时");
//}
break;
case StepEnum.SP_27_XAxisToBuffer:
MoveInfo.NextMoveStep(StepEnum.SP_28_PutReel);
LogInfo($"库位调试 {MoveInfo.SLog}:放料盘,移栽升降轴到下暂存区放料低点P5/P11,移栽压紧轴到压紧前点P2[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
UpdownAxisTo_P5_P11(true);
ComAxis_To_P2(true);
break;
case StepEnum.SP_28_PutReel:
MoveInfo.NextMoveStep(StepEnum.SP_29_XAxisBack);
LogInfo($"库位调试 {MoveInfo.SLog}:移栽X轴回待机点,库位调试结束[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
XAxis_To_P1(true);
break;
case StepEnum.SP_29_XAxisBack:
SetBoxStatus(DeviceStatus.Debugging, RunStatus.Runing);
MoveInfo.EndMove();
break;
}
}
}
public class PosDebugInfo
{
public PosDebugInfo(string cid, BoxEquip_Config config)
{
CID = cid;
this.config = config;
}
BoxEquip_Config config;
/// <summary>
/// 当前抽屉
/// </summary>
public string CurDrawer { get { return $"{CID}{PosSide}{CurDrawerRow.ToString("00")}{CurDrawerCol.ToString("00")}"; } }
/// <summary>
/// 当前料格
/// </summary>
public string CurGrid { get { return $"{CurDrawer}{CurRowInDrawer.ToString("00")}{CurColInDrawer.ToString("00")}"; } }
public string CID { get; private set; }
public string PosSide { get; set; } = "AA";
public int CurDrawerRow { get; set; }
public int CurDrawerCol { get; set; }
public int CurRowInDrawer { get; set; }
public int CurColInDrawer { get; set; }
public int PreDrawerRow { get; set; }
public int PreDrawerCol { get; set; }
public int PreRowInDrawer { get; set; }
public int PreColInDrawer { get; set; }
public int EndDrawerRow { get; set; }
public int EndDrawerCol { get; set; }
public int EndRowInDrawer { get; set; }
public int EndColInDrawer { get; set; }
public void SetDrawerParam(int startrow, int startcol, int endrow, int endcol)
{
CurDrawerRow = startrow;
PreDrawerRow = startrow;
CurDrawerCol = startcol;
PreDrawerCol = startcol;
EndDrawerRow = endrow;
EndDrawerCol = endcol;
}
public void SetGridParam(int startrow, int startcol, int endrow, int endcol)
{
CurRowInDrawer = startrow;
PreRowInDrawer = startrow;
CurColInDrawer = startcol;
PreColInDrawer = startcol;
EndRowInDrawer = endrow;
EndColInDrawer = endcol;
}
public void ResetGridParam()
{
SetGridParam(1, 1, 4, 1);
}
/// <summary>
/// 停止调试
/// </summary>
public bool IsBreak { get; set; } = false;
public bool IsPause { get; set; } = false;
/// <summary>
/// 是否是最后一个抽屉
/// </summary>
/// <returns></returns>
public bool IsLastDrawer()
{
if (IsBreak)
return true;
if (CurDrawerRow >= EndDrawerRow && CurDrawerCol == EndDrawerCol)
return true;
return false;
}
/// <summary>
/// 是否是抽屉内的最后一个料格
/// </summary>
/// <returns></returns>
public bool IsLastGrid()
{
if (IsBreak)
return true;
if (CurColInDrawer == EndColInDrawer && CurRowInDrawer >= EndRowInDrawer)
return true;
return false;
}
/// <summary>
/// 下一个料格
/// </summary>
public void NextGrid()
{
PosDebugResultManager.SaveResult();
if ((CurColInDrawer == PreColInDrawer && CurRowInDrawer == PreRowInDrawer) || //第一个料格结束
(CurRowInDrawer == PreRowInDrawer && CurColInDrawer > PreColInDrawer))//同一层下一个,正向走
{
if (CurRowInDrawer < EndRowInDrawer)//轴未到目标层
{
if (CurColInDrawer < config.Cols_In_Drawer)
{
PreColInDrawer = CurColInDrawer;
if (CurColInDrawer == 2)
CurColInDrawer = 17;
else
CurColInDrawer++;
}
else
{
PreRowInDrawer = CurRowInDrawer;
PreColInDrawer = CurColInDrawer;
if (CurRowInDrawer == 1)
CurRowInDrawer = 3;
else
CurRowInDrawer++;
}
}
else//轴在目标层
{
if (CurColInDrawer < EndColInDrawer)
{
PreColInDrawer = CurColInDrawer;
if (CurColInDrawer == 2)
CurColInDrawer = 17;
else
CurColInDrawer++;
}
}
}
else if (CurColInDrawer == PreColInDrawer && CurRowInDrawer > PreRowInDrawer)//不同层,同一列
{
PreRowInDrawer = CurRowInDrawer;
if (CurColInDrawer == config.Cols_In_Drawer)
{
PreColInDrawer = CurColInDrawer;
if (CurColInDrawer == 17)
CurColInDrawer = 2;
else
CurColInDrawer--;
}
else if (CurColInDrawer == 1)
{
PreColInDrawer = CurColInDrawer;
CurColInDrawer++;
}
}
else if (CurRowInDrawer == PreRowInDrawer && CurColInDrawer < PreColInDrawer)//同一层,上一个。反向走
{
if (CurRowInDrawer < EndRowInDrawer)//轴未到目标层
{
if (CurColInDrawer > 1)
{
PreColInDrawer = CurColInDrawer;
if (CurColInDrawer == 17)
CurColInDrawer = 2;
else
CurColInDrawer--;
}
else
{
PreRowInDrawer = CurRowInDrawer;
PreColInDrawer = CurColInDrawer;
if (CurRowInDrawer == 1)
CurRowInDrawer = 3;
else
CurRowInDrawer++;
}
}
else//轴在目标层
{
if (CurColInDrawer > EndColInDrawer)
{
PreColInDrawer = CurColInDrawer;
if (CurColInDrawer == 17)
CurColInDrawer = 2;
else
CurColInDrawer--;
}
}
}
Common.LogUtil.info($"上一料格:{PreRowInDrawer},{PreColInDrawer}; 当前料格:{CurRowInDrawer},{CurColInDrawer}");
}
/// <summary>
/// 下一个抽屉
/// </summary>
public void NextDrawer()
{
PosDebugResultManager.SaveResult();
if ((CurDrawerCol == PreDrawerCol && CurDrawerRow == PreDrawerRow) || //第一个抽屉结束
(CurDrawerRow == PreDrawerRow && CurDrawerCol > PreDrawerCol))//同一层下一个,正向走
{
if (CurDrawerRow < EndDrawerRow)//轴未到目标层
{
if (CurDrawerCol < config.Drawer_Columns)
{
PreDrawerCol = CurDrawerCol;
CurDrawerCol++;
}
else
{
PreDrawerRow = CurDrawerRow;
PreDrawerCol = CurDrawerCol;
CurDrawerRow++;
}
}
else//轴在目标层
{
if (CurDrawerCol < EndDrawerCol)
{
PreDrawerCol = CurDrawerCol;
CurDrawerCol++;
}
}
}
else if (CurDrawerCol == PreDrawerCol && CurDrawerRow > PreDrawerRow)//不同层,同一列
{
PreDrawerRow = CurDrawerRow;
if (CurDrawerCol == config.Drawer_Columns)
{
PreDrawerCol = CurDrawerCol;
CurDrawerCol--;
}
else if (CurDrawerCol == 1)
{
PreDrawerCol = CurDrawerCol;
CurDrawerCol++;
}
}
else if (CurDrawerRow == PreDrawerRow && CurDrawerCol < PreDrawerCol)//同一层,上一个。反向走
{
if (CurDrawerRow < EndDrawerRow)//轴未到目标层
{
if (CurDrawerCol > 1)
{
PreDrawerCol = CurDrawerCol;
CurDrawerCol--;
}
else
{
PreDrawerRow = CurDrawerRow;
PreDrawerCol = CurDrawerCol;
CurDrawerRow++;
}
}
else//轴在目标层
{
if (CurDrawerCol > EndDrawerCol)
{
PreDrawerCol = CurDrawerCol;
CurDrawerCol--;
}
}
}
ResetGridParam();
Common.LogUtil.info($"上一抽屉:{PreDrawerRow},{PreDrawerCol}; 当前抽屉:{CurDrawerRow},{CurDrawerCol}");
}
}
}