AC_BOX_Bean_AutoInOutTest.cs
20.0 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
using Asa;
using CodeLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
partial class AC_BOX_Bean
{
public PosDebugInfo PosDebugInfo;
protected override void InOuTestProcess()
{
LineMoveP moveP = MoveInfo.MoveParam.MoveP;
if (MoveInfo.IsInWait)
{
CheckWait();
}
if (MoveInfo.IsInWait)
{
return;
}
#region 放入料盘
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_01_StartGetTray))
{
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_02_InOutToP1);
InOutStoreLog("库位测试,料架取料,叉子后退到待机点P1, 重置盘信息");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_02_InOutToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_03_MoveToShelf);
InOutStoreLog("库位测试,料架取料,升降轴到P101低点[" + moveP.UpDown_LP101 + "],旋转轴到P101点[" + moveP.Middle_P101 + "],压紧轴到压紧前点p3[" + Config.CompAxis_Max_P3 + "]");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_LP101, Config.UpDownAxis_P102_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P101, Config.MiddleAxis_P101_Speed);
ACAxisMove(Config.Comp_Axis, Config.CompAxis_Max_P3, Config.CompAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_03_MoveToShelf))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_04_InoutToP101);
InOutStoreLog("库位测试,料架取料,叉子前进到P101点[" + moveP.InOut_P101 + "]");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P101, Config.InOutAxis_P101_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_04_InoutToP101))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_05_UpdownToP102);
InOutStoreLog("库位测试,料架取料,升降轴上升到P102点[" + moveP.UpDown_HP102 + "]");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_HP102, Config.UpDownAxis_P101_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_05_UpdownToP102))
{
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_06_ComDownMove);
InOutStoreLog("库位测试,料架取料,压紧轴走到压紧点P2: " + MoveInfo.MoveParam.MoveP.ComPress_P2);
ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P2, Config.CompAxis_P2_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_06_StartCompress))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_06_ComDownMove);
int currPosition = ACServerManager.GetActualtPosition(Config.Comp_Axis);
ComTargetPosition = currPosition;
int targetP = currPosition + Config.CompAxis_Down_Position;
LastHeight = Config.GetComP2PlateH(targetP);
MoveInfo.MoveParam.MoveP.ComPress_P2 = targetP;
MoveInfo.MoveParam.MoveP.ComPress_P3 = targetP + Config.CompAxis_P3_P2_Value;
InOutStoreLog("库位测试,料架取料,检测到Compress_Check,盘高【" + LastHeight + "】,向下压紧 [" + Config.CompAxis_Down_Position + "] 目标 [" + targetP +
"]记录ComP2[" + targetP + "]ComP3[" + MoveInfo.MoveParam.MoveP.ComPress_P3 + "]");
ACAxisMove(Config.Comp_Axis, targetP, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_06_ComDownMove))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_07_InoutBack);
InOutStoreLog("库位测试,料架取料,叉子后退到扫码点");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_07_InoutBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_09_MoveToBag);
InOutStoreLog("库位测试,到库位点,旋转轴至P2( 库位点)轴2(上下) 至P3(库位入库前点)");
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P3, Config.UpDownAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_09_MoveToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_10_DeviceToBag);
InOutStoreLog("库位测试,叉子进入库位中,进出轴到库位P3");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P3, Config.InOutAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_10_DeviceToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_11_PutWareToBag);
InOutStoreLog("库位测试,放下物品,升降轴到库位缓冲点P4,压紧轴到P3");
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P4, Config.UpDownAxis_P4_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_11_PutWareToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_12_DeviceBackFromBag);
InOutStoreLog("库位测试,叉子从库位中返回,进出轴到P1");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_12_DeviceBackFromBag))
{
if (PosDebugInfo.IsReady())
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_14_StartInOutTest);
PosDebugInfo.MoveToNext();
InOutStoreLog($"库位测试,变换位置:{PosDebugInfo.FrmPoId}-->{PosDebugInfo.ToPosId}");
MoveInfo.MoveParam.PosID = PosDebugInfo.FrmPoId;
if (!StoreManager.LoadInoutParam(MoveInfo.MoveParam, true, this))
{
InOutStoreLog("库位测试,加载库位位置失败");
MoveInfo.EndMove();
}
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_01_StartGetTray);
PosDebugInfo.AddTestReel(out string posId);
MoveInfo.MoveParam.PosID = posId;
if (!StoreManager.LoadInoutParam(MoveInfo.MoveParam, true, this))
{
InOutStoreLog("库位测试,加载库位位置失败");
MoveInfo.EndMove();
}
MoveInfo.MoveParam.UpdateShelfPosId(ShelfPosList[1]);
}
}
#endregion
#region 跑库位
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_14_StartInOutTest))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_15_ToPosition);
InOutStoreLog("库位测试,到库位点,旋转轴至P2( 库位点)轴2(上下) 至P3(库位入库前点)");
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P3, Config.UpDownAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_15_ToPosition))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_16_ToPos);
InOutStoreLog("叉子进入库位中, 进出轴至P3[" + moveP.InOut_P3 + "] ");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P3, Config.InOutAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_16_ToPos))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_17_GetReel);
InOutStoreLog("拿起物品,升降轴至P6[" + moveP.UpDown_P6 + "],压紧轴到压紧点P2 :" + moveP.ComPress_P2);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P2, Config.CompAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P6, Config.UpDownAxis_P6_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_17_GetReel))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_18_InoutBack);
InOutStoreLog("进出轴至待机点P1[" + moveP.InOut_P1 + "] ");
InOutBackToP1(moveP.InOut_P1);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_18_InoutBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_20_SetInstoreParam);
MoveInfo.MoveParam.PosID = PosDebugInfo.ToPosId;
if (!StoreManager.LoadInoutParam(MoveInfo.MoveParam, true, this))
{
InOutStoreLog("库位测试,加载库位位置失败");
MoveInfo.EndMove();
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_20_SetInstoreParam))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_21_MoveToBag);
InOutStoreLog("到库位点,旋转轴至P2( 库位点)轴2(上下) 至P3(库位入库前点)");
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P3, Config.UpDownAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_21_MoveToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_22_DeviceToBag);
InOutStoreLog("叉子进入库位中,进出轴到库位P3");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P3, Config.InOutAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_22_DeviceToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_23_PutWareToBag);
InOutStoreLog("放下物品,升降轴到库位缓冲点P4,压紧轴到P3");
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P4, Config.UpDownAxis_P4_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_23_PutWareToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_24_DeviceBackFromBag);
InOutStoreLog("叉子从库位中返回,进出轴到P1");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_24_DeviceBackFromBag))
{
if (PosDebugInfo.HasNext())
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_14_StartInOutTest);
PosDebugInfo.MoveToNext();
InOutStoreLog($"库位测试,变换位置:{PosDebugInfo.FrmPoId}-->{PosDebugInfo.ToPosId}");
MoveInfo.MoveParam.PosID = PosDebugInfo.FrmPoId;
if (!StoreManager.LoadInoutParam(MoveInfo.MoveParam, true, this))
{
InOutStoreLog("库位测试,加载库位位置失败");
MoveInfo.EndMove();
}
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_25_StartPutTray);
InOutStoreLog("库位测试,无剩余库位,将料盘送出");
PosDebugInfo.RemoveTestReel(out string posId);
MoveInfo.MoveParam.PosID = posId;
MoveInfo.MoveParam.UpdateShelfPosId(ShelfPosList[0]);
if (!StoreManager.LoadInoutParam(MoveInfo.MoveParam, true, this))
{
InOutStoreLog("库位测试,加载库位位置失败");
MoveInfo.EndMove();
}
}
}
#endregion
#region 把料盘送回料架逻辑
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_25_StartPutTray))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_26_ToPosition);
InOutStoreLog("库位测试,到库位点,旋转轴至P2( 库位点)轴2(上下) 至P3(库位入库前点)");
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P3, Config.UpDownAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_26_ToPosition))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_27_ToPos);
InOutStoreLog("叉子进入库位中, 进出轴至P3[" + moveP.InOut_P3 + "] ");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P3, Config.InOutAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_27_ToPos))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_28_GetReel);
InOutStoreLog("拿起物品,升降轴至P6[" + moveP.UpDown_P6 + "],压紧轴到压紧点P2 :" + moveP.ComPress_P2);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P2, Config.CompAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P6, Config.UpDownAxis_P6_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_28_GetReel))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_29_InoutBack);
InOutStoreLog("进出轴至待机点P1[" + moveP.InOut_P1 + "] ");
InOutBackToP1(moveP.InOut_P1);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BT_29_InoutBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_30_ToShelfPosition);
}
else if (MoveInfo.MoveStep == StoreMoveStep.BT_30_ToShelfPosition)
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_31_ToShelf);
InOutStoreLog("库位测试,送出料盘,叉子进出料口,进出轴至P101");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P101, Config.InOutAxis_P101_Speed);
}
else if (MoveInfo.MoveStep == StoreMoveStep.BT_31_ToShelf)
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_32_PutReel);
InOutStoreLog("库位测试,送出料盘,放下物品,压紧轴到P1,升降轴至P101,清空 taskData=null ");
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P1, Config.CompAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_LP101, Config.UpDownAxis_P101_Speed);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
else if (MoveInfo.MoveStep == StoreMoveStep.BT_32_PutReel)
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_33_InoutBack);
InOutStoreLog("库位测试,送出料盘,叉子从出料口返回, 进出轴到P1 ");
InOutBackToP1(moveP.InOut_P1);
}
else if (MoveInfo.MoveStep == StoreMoveStep.BT_33_InoutBack)
{
MoveInfo.NextMoveStep(StoreMoveStep.BT_25_StartPutTray);
if (PosDebugInfo.RemoveTestReel(out string posId))
{
MoveInfo.MoveParam.PosID = posId;
MoveInfo.MoveParam.UpdateShelfPosId(ShelfPosList[1]);
if (!StoreManager.LoadInoutParam(MoveInfo.MoveParam, true, this))
{
InOutStoreLog("库位测试,加载库位位置失败");
MoveInfo.EndMove();
}
InOutStoreLog("库位测试,送出料盘结束");
}
else
{
PosDebugInfo.StopAutoInOutTest();
MoveInfo.EndMove();
}
}
#endregion
}
}
/// <summary>
/// 位置调试信息
/// </summary>
public class PosDebugInfo
{
/// <summary>
/// 同尺寸所有位置
/// </summary>
public List<ACBoxPosition> BoxPositions;
public int CurPosIdx = 0;
public bool AutoInOutPosTest = false;
public bool StopAutoInOut = false;
public string FrmPoId = "";
public string ToPosId = "";
AC_BOX_Bean box = null;
Queue<int> curPosIdxs = new Queue<int>();
public PosDebugInfo(AC_BOX_Bean bean)
{
box = bean;
}
/// <summary>
/// 料盘是否已送入仓内
/// </summary>
/// <returns></returns>
public bool IsReady()
{
return curPosIdxs.Count == 2;
}
public void StopAutoInOutTest()
{
StopAutoInOut = true;
AutoInOutPosTest=false;
}
public void AddTestReel(out string posId)
{
posId = BoxPositions[CurPosIdx].PositionNum;
curPosIdxs.Enqueue(CurPosIdx);
CurPosIdx++;
}
public bool RemoveTestReel(out string posId)
{
posId = "";
if (curPosIdxs.Count > 0)
{
int idx = curPosIdxs.Dequeue();
posId = BoxPositions[idx].PositionNum;
return true;
}
return false;
}
public void MoveToNext()
{
int fromIdx = curPosIdxs.Dequeue();
FrmPoId = BoxPositions[fromIdx].PositionNum;
curPosIdxs.Enqueue(CurPosIdx);
ToPosId = BoxPositions[CurPosIdx].PositionNum;
CurPosIdx++;
}
public bool StartAutoInOutTest(string posId, out string errmsg)
{
errmsg = "";
if (!box.MoveInfo.MoveType.Equals(StoreMoveType.None))
{
errmsg = "料仓忙碌中,无法启动";
return false;
}
if (box.IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW))
{
errmsg = "未检测到料架,无法启动";
return false;
}
if (!StoreManager.LoadSameSizePos(posId, out BoxPositions))
{
errmsg = "未找到调试库位,或调试库位小于3个";
return false;
}
AutoInOutPosTest = true;
StopAutoInOut = false;
CurPosIdx = 0;
AddTestReel(out posId);
InOutParam param = new InOutParam();
param.PosID = posId;
param.UpdateShelfPosId(box.ShelfPosList[0]);
if (!StoreManager.LoadInoutParam(param, true, box))
{
errmsg = "加载位置信息失败";
return false;
}
box.MoveInfo.NewMove(StoreMoveType.CheckPos, param);
box.MoveInfo.NextMoveStep(StoreMoveStep.BT_01_StartGetTray);
LogUtil.info($"调试的所有位置[{BoxPositions.Count}]:");
BoxPositions.ForEach(pos => { LogUtil.info($"{pos.PositionNum},{pos.BagWidth}*{pos.BagHigh}"); });
return true;
}
public bool HasNext()
{
if (StopAutoInOut || CurPosIdx > BoxPositions.Count - 2)
{
return false;
}
return true;
}
}
}