MainMachine _AutoInOutTest.cs
16.1 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
using CodeLibrary;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
partial class MainMachine
{
public bool StartAutoInOutTest(string posname, out string errmsg)
{
errmsg = "";
if (!boxTransport.IsComplateOrFree)
{
errmsg = crc.GetString("Res0002", "料仓忙碌中,无法启动");
return false;
}
//if (!IsAIOTestReelIsReady)
//{
// errmsg = crc.GetString("Res0003", "入库料盘没有准备好,无法启动");
// return false;
//}
poslist = RobotManage.PositionNumList.Select(a => { return CSVPositionReader<ACStorePosition>.allPositionMap[a]; }).ToList();//CSVPositionReader<ACStorePosition>.getPositionList();
poslist.RemoveAll(x => { return x.PositionNum.StartsWith("fix#"); });
CurrentPosIndex = poslist.FindIndex(x => x.PositionNum == posname);
AutoInOutTest = true;
StopAutoInOut = false;
//AIOTMoveInfo.NewMove(MoveStep.Wait);
return true;
}
public void StopAutoInOutTest()
{
StopAutoInOut = true;
}
List<ACStorePosition> poslist;
int CurrentPosIndex = 0;
/// <summary>
/// 自动出入库状态
/// </summary>
public bool AutoInOutTest { get; set; } = false;
bool StopAutoInOut = false;
void AutoInOutTestProcess()
{
if (CheckWait(AIOTMoveInfo))
return;
//常规上料扫码流程
switch (AIOTMoveInfo.MoveStep)
{
case MoveStep.Wait:
//if (IsAIOTestReelIsReady)
//{
// AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn01);
// AIOTMoveInfo.log($"入库料盘已准备好");
//}
AIOTMoveInfo.NextMoveStep(MoveStep.AIOTest_01_CloseFlip);
CloseFlipDoor(AIOTMoveInfo);
AIOTMoveInfo.log($"关闭翻板门");
break;
case MoveStep.AIOTest_01_CloseFlip:
AIOTMoveInfo.NextMoveStep(MoveStep.AIOTest_02_Pause1);
AIOTMoveInfo.log($"库位测试,放第一盘料");
RobotManage.UserPause();
break;
case MoveStep.AIOTest_02_Pause1:
AIOTMoveInfo.NextMoveStep(MoveStep.AIOTest_03_FirstReady);
var ac = poslist[CurrentPosIndex];
var reel = new ReelParam("auto", ac.BagWidth, ac.BagHigh);
if (!boxTransport.Start(new BoxStorePosition(Config, StoreSide.NGDoor, reel), new BoxStorePosition(Config, ac, reel), StoreMoveType.InStore))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
StopAutoInOut = true;
return;
}
AIOTMoveInfo.log($"开始转运料盘第一盘");
break;
case MoveStep.AIOTest_03_FirstReady:
if (boxTransport.IsTakedReel)
{
AIOTMoveInfo.NextMoveStep(MoveStep.AIOTest_04_FirstPuted);
ReelTaked();
AIOTMoveInfo.log($"第一盘料盘已取走");
}
else
{
Msg.add(crc.GetString(L.wait_reel_transfer, "单料口等待料盘离开."), MsgLevel.info);
}
break;
case MoveStep.AIOTest_04_FirstPuted:
if (boxTransport.IsComplateOrFree)
{
AIOTMoveInfo.NextMoveStep(MoveStep.AIOTest_05_Pause2);
AIOTMoveInfo.log($"第一盘料盘已到达目的地");
if (CurrentPosIndex - 1 < 0 || StopAutoInOut)
{
AIOTMoveInfo.log($"已达到最后一个库位:{CurrentPosIndex},或手动停止{StopAutoInOut},自动出入库停止,将料盘送至出口");
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut10);
CloseFlipDoor(AIOTMoveInfo);
return;
}
CloseFlipDoor(AIOTMoveInfo);
}
break;
case MoveStep.AIOTest_05_Pause2:
AIOTMoveInfo.NextMoveStep(MoveStep.AIOTest_06_SecondReady);
RobotManage.UserPause();
AIOTMoveInfo.log($"库位测试,放第二盘料");
break;
case MoveStep.AIOTest_06_SecondReady:
AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn05);
AIOTMoveInfo.log($"开始转运料盘第二盘");
ac = poslist[CurrentPosIndex - 1];
reel = new ReelParam("auto", ac.BagWidth, ac.BagHigh);
if (!boxTransport.Start(new BoxStorePosition(Config, StoreSide.NGDoor, reel), new BoxStorePosition(Config, ac, reel), StoreMoveType.InStore))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
StopAutoInOut = true;
return;
}
break;
case MoveStep.StoreIn01:
//AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn02);
//var ac = poslist[CurrentPosIndex];
//var reel = new ReelParam("auto", ac.BagWidth, ac.BagHigh);
//if (!boxTransport.Start(new BoxStorePosition(Config, StoreSide.NGDoor, reel), new BoxStorePosition(Config, ac, reel), StoreMoveType.InStore))
//{
// AIOTMoveInfo.log($"料仓周转启动失败");
// AutoInOutTest = false;
// StopAutoInOut = true;
// return;
//}
//AIOTMoveInfo.log($"开始转运料盘第一盘");
break;
case MoveStep.StoreIn02:
//if (boxTransport.IsTakedReel)
//{
// AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn03);
// ReelTaked();
// AIOTMoveInfo.log($"第一盘料盘已取走");
//}
//else
//{
// Msg.add(crc.GetString(L.wait_reel_transfer, "单料口等待料盘离开."), MsgLevel.info);
//}
break;
case MoveStep.StoreIn03:
//if (Setting_Init.Device_AIOTest_DirectGetReel)
//{
// AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn04);
// CloseFlipDoor(AIOTMoveInfo);
// AIOTMoveInfo.log($"合拢翻转板,准备料盘");
//}
//else if (IsAIOTestReelIsReady)
//{
// AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn04);
// AIOTMoveInfo.log($"入库料盘已准备好");
//}
break;
case MoveStep.StoreIn04:
//if (boxTransport.IsComplateOrFree)
//{
// AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn05);
// AIOTMoveInfo.log($"第一盘料盘已到达目的地");
// if (CurrentPosIndex - 1 < 0 || StopAutoInOut)
// {
// AIOTMoveInfo.log($"已达到最后一个库位:{CurrentPosIndex},或手动停止{StopAutoInOut},自动出入库停止,将料盘送至出口");
// AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut10);
// CloseFlipDoor(AIOTMoveInfo);
// return;
// }
// if (Setting_Init.Device_AIOTest_DirectGetReel)
// {
// RobotManage.UserPause("暂停放入第二盘", true);
// }
// AIOTMoveInfo.log($"开始转运料盘第二盘");
// ac = poslist[CurrentPosIndex - 1];
// reel = new ReelParam("auto", ac.BagWidth, ac.BagHigh);
// if (!boxTransport.Start(new BoxStorePosition(Config, StoreSide.NGDoor, reel), new BoxStorePosition(Config, ac, reel), StoreMoveType.InStore))
// {
// AIOTMoveInfo.log($"料仓周转启动失败");
// AutoInOutTest = false;
// StopAutoInOut = true;
// return;
// }
//}
break;
case MoveStep.StoreIn05:
if (boxTransport.IsTakedReel)
{
AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn06);
ReelTaked();
AIOTMoveInfo.log($"第二盘料盘已取走");
}
else
{
Msg.add(crc.GetString(L.wait_reel_transfer, "单料口等待料盘离开."), MsgLevel.info);
}
break;
case MoveStep.StoreIn06:
if (boxTransport.IsComplateOrFree)
{
AIOTMoveInfo.log($"第二盘料盘已到达目的地");
if (CurrentPosIndex - 1 < 0 || StopAutoInOut)
{
AIOTMoveInfo.log($"已达到最后一个库位:{CurrentPosIndex},或手动停止{StopAutoInOut},自动出入库停止,将料盘送至出口");
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut10);
CloseFlipDoor(AIOTMoveInfo);
return;
}
//ac = poslist[CurrentPosIndex - 1];
//reel = new ReelParam("auto", ac.BagWidth, ac.BagHigh);
//if (!boxTransport.Start(new BoxStorePosition(Config, StoreSide.String, reel), new BoxStorePosition(Config, ac, reel), StoreMoveType.InStore))
//{
// AIOTMoveInfo.log($"料仓周转启动失败");
// AutoInOutTest = false;
// StopAutoInOut = true;
// return;
//}
AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn07);
}
break;
case MoveStep.StoreIn07:
if (boxTransport.IsComplateOrFree)
{
AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn08);
var ac1 = poslist[CurrentPosIndex];
if (CurrentPosIndex - 2 < 0 || StopAutoInOut)
{
AIOTMoveInfo.log($"A已达到最后一个库位:{CurrentPosIndex},或手动停止{StopAutoInOut},自动出入库停止,将料盘送至出口");
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut10);
CurrentPosIndex++;
CloseFlipDoor(AIOTMoveInfo);
return;
}
var ac2 = poslist[CurrentPosIndex - 2];
reel = new ReelParam("auto", ac2.BagWidth, ac2.BagHigh);
if (!boxTransport.Start(new BoxStorePosition(Config, ac1, reel), new BoxStorePosition(Config, ac2, reel), StoreMoveType.InStore))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
StopAutoInOut = true;
return;
}
AIOTMoveInfo.log($"开始交替");
}
break;
case MoveStep.StoreIn08:
if (boxTransport.IsComplateOrFree)
{
AIOTMoveInfo.log($"料盘已到达目的地");
if (CurrentPosIndex - 1 < 0 || StopAutoInOut)
{
AIOTMoveInfo.log($"B已达到最后一个库位:{CurrentPosIndex},或手动停止{StopAutoInOut},自动出入库停止,将料盘送至出口");
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut10);
CloseFlipDoor(AIOTMoveInfo);
return;
}
CurrentPosIndex--;
AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn07);
}
break;
case MoveStep.StoreOut10:
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut11);
CurrentPosIndex--;
ac = poslist[CurrentPosIndex];
reel = new ReelParam("auto", ac.BagWidth, ac.BagHigh);
if (!boxTransport.Start(new BoxStorePosition(Config, ac, reel), new BoxStorePosition(Config, StoreSide.NGDoor, reel), StoreMoveType.OutStore))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
StopAutoInOut = true;
return;
}
AIOTMoveInfo.log($"开始转运料盘");
break;
case MoveStep.StoreOut11:
if (boxTransport.IsComplateOrFree)
{
NGPuted("");
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut12);
AIOTMoveInfo.log($"料盘已到达目的地");
//AutoInOutTest = false;
}
break;
case MoveStep.StoreOut12:
if (ClampMoveInfo.MoveStep == MoveStep.Wait)
{
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut13);
AIOTMoveInfo.log($"NG口已空闲");
CloseFlipDoor(AIOTMoveInfo);
}
else
{
AIOTMoveInfo.log($"等待NG口空闲");
}
break;
case MoveStep.StoreOut13:
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut14);
ac = poslist[CurrentPosIndex - 1];
reel = new ReelParam("auto", ac.BagWidth, ac.BagHigh);
if (!boxTransport.Start(new BoxStorePosition(Config, ac, reel), new BoxStorePosition(Config, StoreSide.NGDoor, reel), StoreMoveType.OutStore))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
StopAutoInOut = true;
return;
}
AIOTMoveInfo.log($"开始转运料盘");
break;
case MoveStep.StoreOut14:
if (boxTransport.IsComplateOrFree)
{
NGPuted("");
AIOTMoveInfo.log($"料盘已到达目的地");
AIOTMoveInfo.EndMove();
AutoInOutTest = false;
}
break;
default:
AIOTMoveInfo.log($"未找到对应步骤:{AIOTMoveInfo.MoveStep}");
break;
}
}
}
}