MainMachine_StoreDemo.cs
20.5 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
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.Text.RegularExpressions;
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)
{
JobInfo jobInfo = new JobInfo(warecode, posId);
OutStoreJobList.Enqueue(jobInfo);
LogUtil.info($"添加出库任务队列: {posId},当前任务数量: {OutStoreJobList.Count}");
}
public bool IsInStoreReady { get => true; }
public void DemoIn()
{
if (StoreMoveInfo.MoveStep == MoveStep.Wait)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn01);
IOMove(IO_Type.Entry_Drawer_Lock, IO_VALUE.HIGH);
StoreMoveInfo.log($"开始入库任务");
}
}
bool demomode = true;
public void DemoOut()
{
if (StoreMoveInfo.MoveStep == MoveStep.Wait)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut10);
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
StoreMoveInfo.log($"开始出任务");
}
}
void StoreDemoProcess()
{
if (CheckWait(StoreMoveInfo))
return;
//常规上料扫码流程
switch (StoreMoveInfo.MoveStep)
{
case MoveStep.Wait:
StoreMoveInfo.MoveParam.ReelOnFixture = false;
if (demomode && false)
return;
if (IOValue(IO_Type.Taking_Clamp).Equals(IO_VALUE.LOW)) {
if (Setting_Init.Runtime_Step == Runtime_StepE.LabelProcess) {
StoreMoveInfo.log("检测到上次正在贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid);
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling01);
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
}else
if (Setting_Init.Runtime_Step == Runtime_StepE.LabelPasteFinish)
{
StoreMoveInfo.log("检测到上次已完成贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid);
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
}
else
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);
//LabelingMoveInfo.NextMoveStep(MoveStep.Labeling01);
//StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
Msg.add("重置前物料正在贴标,无法继续,请手动处理", MsgLevel.warning, ErrInfo.LabelInPaste);
RobotManage.UserPause("重置前物料正在贴标,无法继续,请手动处理");
}else
if (IOValue(IO_Type.Entry_Drawer_Lock).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.Entry_Drawer).Equals(IO_VALUE.HIGH))
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn01);
StoreMoveInfo.log($"检测到入库抽屉已锁定");
}
Setting_Init.Runtime_Step = Runtime_StepE.None;
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.WareCode = "";
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.ReelOnFixture = true;
}
else if (Setting_Init.Runtime_Step == Runtime_StepE.Out)
{
StoreMoveInfo.log("检测到上次正在出库:" + Setting_Init.Runtime_Posid);
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
{
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.Wait);
StoreMoveInfo.log($"没有检测到出库未有空位");
return;
}
else
{
StoreMoveInfo.MoveParam.PosID = olist[0];
StoreMoveInfo.log($"检测到出库位有料:{StoreMoveInfo.MoveParam.PosID}, 其他有料出库位:{string.Join(",", olist)}");
}
}
}
break;
case MoveStep.StoreIn01:
string inposid;
var slist = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
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;
StoreMoveInfo.MoveParam.WareCode = "";
//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.StoreIn02:
if (boxTransport.IsComplateOrFree)
{
if (LabelingMoveInfo.MoveStep == MoveStep.Wait)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling01);
StoreMoveInfo.log($"等待贴标完成");
}
else
{
StoreMoveInfo.log($"等待贴标机构空闲");
}
}
break;
case MoveStep.StoreIn03:
if (LabelingMoveInfo.MoveStep == MoveStep.Wait)
{
if (demomode)
{
string outposid = "";
var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.下层右侧);
olist = RobotManage.PositionNumList.ToList().Where(p => { return Regex.IsMatch(p, "^S[H-N]([7-9]|\\d{2})$") && !olist.Contains(p); }).ToList();
if (olist.Count == 0)
{
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
StoreMoveInfo.log($"没有检测到有空余库位");
return;
}
else
{
outposid = olist[0];
StoreMoveInfo.log($"检测到库位有料:{outposid}, 其他有料库位:{string.Join(",", olist)}");
}
LabelingMoveInfo.MoveParam.PosID = outposid;
}
if (string.IsNullOrEmpty(LabelingMoveInfo.MoveParam.PosID))
{
Msg.add("等待服务器返回库位", MsgLevel.info);
StoreMoveInfo.log($"等待服务器返回库位");
return;
}
StoreMoveInfo.MoveParam = LabelingMoveInfo.MoveParam.clone();
if (StoreMoveInfo.MoveParam.IsNg)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn04);
StoreMoveInfo.log($"收到完成贴标");
}
else
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn04);
StoreMoveInfo.log($"收到完成贴标");
}
}
else
{
StoreMoveInfo.log($"等待贴标完成");
}
break;
case MoveStep.StoreIn04:
if (boxTransport.IsComplateOrFree)
{
var outposid= StoreMoveInfo.MoveParam.PosID;
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn09);
from = CSVPositionReader<ACStorePosition>.GetPositon(LabelP);
to = CSVPositionReader<ACStorePosition>.GetPositon(outposid);
StoreMoveInfo.MoveParam.PosID = outposid;
StoreMoveInfo.MoveParam.WareCode = "";
//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.StoreIn05:
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();
if (olist.Count == 0)
{
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
StoreMoveInfo.log($"没有检测到有空余库位");
return;
}
else
{
outposid = olist[0];
StoreMoveInfo.log($"检测到空库位:{outposid}, 其他空库位:{string.Join(",", olist)}");
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn09);
from = CSVPositionReader<ACStorePosition>.GetPositon(LabelP);
to = CSVPositionReader<ACStorePosition>.GetPositon(outposid);
StoreMoveInfo.MoveParam.PosID = outposid;
StoreMoveInfo.MoveParam.WareCode = "";
//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)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn01);
StoreMoveInfo.log($"入库完成");
}
break;
case MoveStep.StoreOut10:
slist = CameraPointTest.GetThingStoreName(TestStorePointPort.下层右侧);
if (slist.Count == 0)
{
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
StoreMoveInfo.log($"没有检测到库内有料");
return;
}
else
{
inposid = slist[0];
StoreMoveInfo.log($"检测到库位有料:{inposid}, 其他有料库位:{string.Join(",", slist)}");
}
{
var outposid="";
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.Wait);
StoreMoveInfo.log($"没有检测到出库未有空位");
return;
}
else
{
outposid = olist[0];
StoreMoveInfo.log($"检测到出库位有料:{outposid}, 其他有料出库位:{string.Join(",", olist)}");
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
from = CSVPositionReader<ACStorePosition>.GetPositon(inposid);
to = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
StoreMoveInfo.MoveParam.PosID = outposid;
StoreMoveInfo.MoveParam.WareCode = "";
//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.StoreOut11:
if (boxTransport.IsComplateOrFree)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut12);
from = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
to = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
StoreMoveInfo.MoveParam.WareCode = "";
StoreMoveInfo.MoveParam.ReelOnFixture = true;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
StoreMoveInfo.log($"开始转运出库");
}
break;
case MoveStep.StoreOut12:
if (boxTransport.IsComplateOrFree)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut10);
slist = CameraPointTest.GetThingStoreName(TestStorePointPort.下层右侧);
if (slist.Count == 0)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
StoreMoveInfo.log($"没有检测到库内有料");
return;
}
}
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.EndMove();
}
else
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn05);
}
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;
}
return state;
}
}
}