SendFullShelfToLineJob.cs
17.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
using AGVControl;
using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
/// <summary>
/// 从A6向产线运行任务(出满料)
/// </summary>
public class SendFullShelfToLineJob : Job
{
/// <summary>
/// 从A6向产线运行任务(出满料)
/// </summary>
/// <param name="palce">产线名</param>
/// <param name="rfid">料架RFID</param>
/// <param name="isIgNoreBigShelf">是否忽略大料架</param>
public SendFullShelfToLineJob(AGVManager.BoxDestInfo boxDestInfo, bool isIgNoreBigShelf = false)
{
FullShelfPlace = boxDestInfo.location;
RFID = boxDestInfo.id;
BoxDestInfo = boxDestInfo;
IsIgnoreBigShelf = isIgNoreBigShelf;
JobName = "送满料任务";
}
/// <summary>
/// 满料架目标位置点
/// </summary>
public string FullShelfPlace { get; set; }
public string RFID { get; set; }
public AGVManager.BoxDestInfo BoxDestInfo { get; private set; }
/// <summary>
/// 是否忽略大料架移库解绑
/// </summary>
public bool IsIgnoreBigShelf { get; private set; }
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return runInfo; }
}
private JobStep<SEND_FULL_SHELF_STEP> curJobStep = new JobStep<SEND_FULL_SHELF_STEP>(SEND_FULL_SHELF_STEP.NONE);
public override Job Execute(Agv_Info agv)
{
string msg = agv.Name + " ";
bool rtn = false;
agv.RFID = RFID;
agv.Msg = runInfo;
//runInfo = "送满料任务:";
//if (!CurTaskID.Equals(-1) && Common.mir.Get_Task_State(CurTaskID, out string st))
// CurTaskState = st;
if (curJobStep.IsStep(SEND_FULL_SHELF_STEP.NONE))
{
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
AGVManager.AgvRemoveRfid(RFID);
if (FullShelfPlace.StartsWith(SettingString.C4_Name_Prefix))
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_DOOR);
runInfo = "前往4C门,从双层线A6送往[" + FullShelfPlace + "][RFID=" + RFID + "]";
msg += runInfo;
curJobStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorDToC);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
runInfo = "从双层线A6送往[" + FullShelfPlace + "][RFID=" + RFID + "]";
msg += runInfo;
curJobStep.Msg = msg;
Common.SetNodeOccupied(FullShelfPlace, agv.Name);
Common.MoveToNode(agv, FullShelfPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_DOOR))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
if (Common.CheckTaskFinished(agv, SettingString.DoorDToC, CurTaskState))
{
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
if (Common.Check4CTarget(agv, FullShelfPlace))//被占用
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_REACH_TEMP_PLACE);
runInfo = "目的地" + FullShelfPlace + "有小车占用,先到临时待机位";
msg += runInfo;
curJobStep.Msg = msg;
Common.MoveTo4CStandy(agv);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
if (Common.CheckIsInAirDoor(FullShelfPlace))
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_AIR_DOOR);
runInfo = "到达4C门,过风淋门[" + FullShelfPlace + "][RFID=" + RFID + "]";
msg += runInfo;
curJobStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorAirIn);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
runInfo = "从双层线A6送往[" + FullShelfPlace + "][RFID=" + RFID + "]";
msg += runInfo;
curJobStep.Msg = msg;
Common.SetNodeOccupied(FullShelfPlace, agv.Name);
Common.MoveToNode(agv, FullShelfPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
}
else if (curJobStep.IsStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_AIR_DOOR))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
if (Common.CheckTaskFinished(agv, SettingString.DoorAirIn, CurTaskState))
{
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
runInfo = "送往[" + FullShelfPlace + "][RFID=" + RFID + "]";
msg += runInfo;
curJobStep.Msg = msg;
Common.SetNodeOccupied(FullShelfPlace, agv.Name);
Common.MoveToNode(agv, FullShelfPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (curJobStep.IsStep(SEND_FULL_SHELF_STEP.WAIT_REACH_TEMP_PLACE))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
if (Common.CheckTaskFinished(agv, SettingString.C4_STANDBY1, CurTaskState) || Common.CheckTaskFinished(agv, SettingString.C4_STANDBY2, CurTaskState))
{
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
if (!Common.Check4CTarget(agv, FullShelfPlace))//未占用
{
if (Common.CheckIsInAirDoor(FullShelfPlace))
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_AIR_DOOR);
runInfo = "到临时待机位,去产线先过风淋门[" + FullShelfPlace + "][RFID=" + RFID + "]";
msg += runInfo;
curJobStep.Msg = msg;
Common.DeleteStandyInfo(agv);
Common.DoorMission(agv, SettingString.DoorAirIn);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
runInfo = "从临时待机位送往[" + FullShelfPlace + "][RFID=" + RFID + "]";
msg += runInfo;
curJobStep.Msg = msg;
Common.DeleteStandyInfo(agv);
Common.SetNodeOccupied(FullShelfPlace, agv.Name);
Common.MoveToNode(agv, FullShelfPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
}
else if (curJobStep.IsStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
if (Common.CheckTaskFinished(agv, FullShelfPlace, CurTaskState))
{
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
//if (FullShelfPlace.Equals(SettingString.C4FeederIn))
//{
// runInfo = "AGV到达 " + FullShelfPlace + "完成";
// msg += runInfo;
// SendFullShelfStep.Msg = msg;
// return new EnterLeaveShelfJob(FullShelfPlace, eEnterLeaveType.Leave);
//}
if (IsIgnoreBigShelf)
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_LINE_RESPONSE);
runInfo = "AGV到达 " + FullShelfPlace + ",并发送入料架请求[ReadyEnter]";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.ReadyEnter(FullShelfPlace);
}
else
{
if (agv.Place.Equals("S0"))
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_BIG_SHELF_UNLOCK);
runInfo = "AGV到达 " + FullShelfPlace + ",并等待3D工单料架[" + RFID + "]库位转移";
msg += runInfo;
curJobStep.Msg = msg;
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Play"]);
}
else if (RFID.StartsWith("C") && !agv.Place.Equals(SettingString.D4FeederIn) && !agv.Place.Equals(SettingString.C4FeederIn))
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_BIG_SHELF_UNLOCK);
runInfo = "AGV到达 " + FullShelfPlace + ",并等待大料架[" + RFID + "]库位转移";
msg += runInfo;
curJobStep.Msg = msg;
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Play"]);
}
else
{
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_LINE_RESPONSE);
runInfo = "AGV到达 " + FullShelfPlace + ",并发送入料架请求[ReadyEnter]";
msg += runInfo;
curJobStep.Msg = msg;
Common.server.ReadyEnter(FullShelfPlace);
}
}
}
}
else if (curJobStep.IsStep(SEND_FULL_SHELF_STEP.WAIT_BIG_SHELF_UNLOCK))
{
Common.mir.Get_IO_Status(agv, out bool[] input, out bool[] output);
System.Threading.Thread.Sleep(50);
if (AGVManager.GetRackBy(RFID, out string lineName) || (input != null && input[0]))
{
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Stop"]);
runInfo = "大料架在" + FullShelfPlace + "库位转移完成 [" + RFID + "] [" + agv.BoxDestInfo + "]";
agv.BoxDestInfo = "";
msg += runInfo;
curJobStep.Msg = msg;
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
if (RFID.StartsWith("D"))
return new EmptyShelfBackJob(FullShelfPlace, eShelfType.SmallShelf);
else
return new EmptyShelfBackJob(FullShelfPlace, eShelfType.BigShelf);
}
}
else if (curJobStep.IsStep(SEND_FULL_SHELF_STEP.WAIT_LINE_RESPONSE))
{
int id = Common.FindNode(FullShelfPlace);
ClientNode node = Common.nodeInfo[id];
Common.mir.Get_IO_Status(agv, out bool[] input, out bool[] output);
System.Threading.Thread.Sleep(50);
if (node.StateEquals(eNodeStatus.MayEnter))
{
agv.HasError = false;
if (!agv.CurTaskName.Equals("Leave"))
{
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT__SHELF_IN_LINE);
runInfo = "收到产线入料架请求[ReadyEnter]的响应 " + FullShelfPlace + "入料架,小车链条运行";
msg += runInfo;
curJobStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Leave"]);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (input != null && !input[3] && input[0])
{
agv.HasError = false;
runInfo = "手动操作:满料架进入" + FullShelfPlace + "完成 [RFID=" + RFID + "] [" + agv.BoxDestInfo + "]";
msg += runInfo;
curJobStep.Msg = msg;
agv.RFID = "";
agv.BoxDestInfo = "";
AGVManager.UpdateStatus(RFID, FullShelfPlace);
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
return new EmptyAGVBackJob(FullShelfPlace);
}
else if (curJobStep.IsTimeOut(15000, out TimeSpan timeOutValue))
{
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
curJobStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
runInfo = "AGV到达 " + FullShelfPlace + ",15秒后重新向产线发送入料架请求[ReadyEnter]";
msg += runInfo;
curJobStep.Msg = msg;
agv.HasError = true;
agv.SetErrorMsg("AGV到达 " + FullShelfPlace + ",向产线发送入料架请求[ReadyEnter]异常", timeOutValue.TotalMinutes.ToString("f2"));
}
}
else if (curJobStep.IsStep(SEND_FULL_SHELF_STEP.WAIT__SHELF_IN_LINE))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
if (Common.CheckEnterOrLeaveFinished(agv, "Leave", CurTaskState))
{
agv.HasError = false;
runInfo = "满料进入" + FullShelfPlace + "完成 [RFID=" + RFID + "] [" + agv.BoxDestInfo + "]";
msg += runInfo;
curJobStep.Msg = msg;
agv.RFID = "";
agv.BoxDestInfo = "";
AGVManager.UpdateStatus(RFID, FullShelfPlace);
curJobStep.RecordRunLog(agv, JobName, runInfo, FullShelfPlace);
return new EmptyAGVBackJob(FullShelfPlace);
}
else if (curJobStep.IsTimeOut(60000, out TimeSpan timeOutValue))
{
//链条停止
runInfo = "满料在[" + FullShelfPlace + "]离开小车超时,请检查料架离开小车的情况";
agv.HasError = true;
agv.SetErrorMsg("满料在[" + FullShelfPlace + "]离开小车超时", timeOutValue.TotalMinutes.ToString("f2"));
}
}
//else if (SendFullShelfStep.IsStep(SEND_FULL_SHELF_STEP.END))
//{
//}
return this;
}
}
/// <summary>
/// AGV送满料架到产线
/// </summary>
public enum SEND_FULL_SHELF_STEP
{
/// <summary>
/// 料架已进入小车,去目的地
/// </summary>
NONE,
/// <summary>
/// 等待AGV到达门
/// </summary>
WAIT_AGV_REACH_DOOR,
/// <summary>
/// 等待agv到达4C临时待机位
/// </summary>
WAIT_REACH_TEMP_PLACE,
/// <summary>
/// 等待到达4C风淋门
/// </summary>
WAIT_AGV_REACH_AIR_DOOR,
/// <summary>
/// 等待小车到达目的地
/// </summary>
WAIT_AGV_REACH_LINE,
/// <summary>
/// 等待大料架解绑
/// </summary>
WAIT_BIG_SHELF_UNLOCK,
/// <summary>
/// 等待AGV载大料架返回双层线
/// </summary>
WAIT_BIG_SHELF_BACK_DOUBLE_LINE,
/// <summary>
/// 等待AGV到达停车位
/// </summary>
WAIT_BIG_SHELF_BACK_STANDYBY,
/// <summary>
/// 等待产线回应
/// </summary>
WAIT_LINE_RESPONSE,
/// <summary>
/// 等待料架进入产线
/// </summary>
WAIT__SHELF_IN_LINE,
/// <summary>
/// 进入产线完成
/// </summary>
END
}
}