SendFullShelfToLineJob.cs
12.6 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
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;
}
/// <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; }
private string runInfo = "";
/// <summary>
/// 运行信息
/// </summary>
public override string RunInfo
{
get { return runInfo; }
}
private JobStep<SEND_FULL_SHELF_STEP> SendFullShelfStep = 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;
//if (!CurTaskID.Equals(-1) && Common.mir.Get_Task_State(CurTaskID, out string st))
// CurTaskState = st;
if (SendFullShelfStep.IsStep(SEND_FULL_SHELF_STEP.NONE))
{
if (FullShelfPlace.StartsWith(SettingString.C4_Name_Prefix))
{
SendFullShelfStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_DOOR);
runInfo = "满料架前往4C门,从双层线A6送往[" + FullShelfPlace + "][RFID=" + RFID + "]";
msg += runInfo;
SendFullShelfStep.Msg = msg;
Common.DoorMission(agv, SettingString.DoorDToC);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
SendFullShelfStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
runInfo = "满料架从双层线A6送往[" + FullShelfPlace + "][RFID=" + RFID + "]";
msg += runInfo;
SendFullShelfStep.Msg = msg;
Common.MoveToNode(agv, FullShelfPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
else if (SendFullShelfStep.IsStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_DOOR))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
if (Common.CheckTaskFinished(agv, SettingString.DoorDToC, CurTaskState))
{
if (Common.Check4CTarget(agv, FullShelfPlace))//被占用
{
SendFullShelfStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_REACH_TEMP_PLACE);
runInfo = "目的地" + FullShelfPlace + "有小车占用,先到临时待机位";
msg += runInfo;
SendFullShelfStep.Msg = msg;
Common.MoveTo4CStandy(agv);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
else
{
SendFullShelfStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
runInfo = "满料架从双层线A6送往[" + FullShelfPlace + "][RFID=" + RFID + "]";
msg += runInfo;
SendFullShelfStep.Msg = msg;
Common.MoveToNode(agv, FullShelfPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
else if (SendFullShelfStep.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))
{
if (!Common.Check4CTarget(agv, FullShelfPlace))//未占用
{
SendFullShelfStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
runInfo = "满料架从临时待机位送往[" + FullShelfPlace + "][RFID=" + RFID + "]";
msg += runInfo;
SendFullShelfStep.Msg = msg;
Common.DeleteStandyInfo(agv);
Common.MoveToNode(agv, FullShelfPlace);
UpdateJobTaskInfo(agv.CurTaskName, agv.CurTaskID);
}
}
}
else if (SendFullShelfStep.IsStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
if (Common.CheckTaskFinished(agv, FullShelfPlace, CurTaskState))
{
//if (FullShelfPlace.Equals(SettingString.C4FeederIn))
//{
// runInfo = "AGV到达 " + FullShelfPlace + "完成";
// msg += runInfo;
// SendFullShelfStep.Msg = msg;
// return new EnterLeaveShelfJob(FullShelfPlace, eEnterLeaveType.Leave);
//}
if (IsIgnoreBigShelf)
{
SendFullShelfStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_LINE_RESPONSE);
runInfo = "AGV到达 " + FullShelfPlace + ",并发送入料架请求[ReadyEnter]";
msg += runInfo;
SendFullShelfStep.Msg = msg;
Common.server.ReadyEnter(FullShelfPlace);
}
else
{
if (RFID.StartsWith("C") && !agv.Place.Equals(SettingString.D4FeederIn) && !agv.Place.Equals(SettingString.C4FeederIn))
{
SendFullShelfStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_BIG_SHELF_UNLOCK);
runInfo = "AGV到达 " + FullShelfPlace + ",并等待大料架[" + RFID + "]解绑";
msg += runInfo;
SendFullShelfStep.Msg = msg;
}
else
{
SendFullShelfStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_LINE_RESPONSE);
runInfo = "AGV到达 " + FullShelfPlace + ",并发送入料架请求[ReadyEnter]";
msg += runInfo;
SendFullShelfStep.Msg = msg;
Common.server.ReadyEnter(FullShelfPlace);
}
}
}
}
else if (SendFullShelfStep.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]))
{
runInfo = "大料架在" + FullShelfPlace + "解绑完成 [" + RFID + "] [" + agv.BoxDestInfo + "]";
agv.BoxDestInfo = "";
msg += runInfo;
SendFullShelfStep.Msg = msg;
return new EmptyShelfBackJob(FullShelfPlace, eShelfType.BigShelf);
}
}
else if (SendFullShelfStep.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))
{
if (!agv.CurTaskName.Equals("Leave"))
{
SendFullShelfStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT__SHELF_IN_LINE);
runInfo = "收到产线入料架请求[ReadyEnter]的响应 " + FullShelfPlace + "入料架,小车链条运行";
msg += runInfo;
SendFullShelfStep.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])
{
runInfo = "手动操作:满料架进入" + FullShelfPlace + "完成 [RFID=" + RFID + "] [" + agv.BoxDestInfo + "]";
msg += runInfo;
SendFullShelfStep.Msg = msg;
agv.RFID = "";
agv.BoxDestInfo = "";
AGVManager.UpdateStatus(RFID, FullShelfPlace);
return new EmptyAGVBackJob(FullShelfPlace);
}
else if (SendFullShelfStep.IsTimeOut(15000, out double timeOutValue))
{
SendFullShelfStep.ToNextStep(SEND_FULL_SHELF_STEP.WAIT_AGV_REACH_LINE);
runInfo = "AGV到达 " + FullShelfPlace + ",15秒后重新向产线发送入料架请求[ReadyEnter]";
msg += runInfo;
SendFullShelfStep.Msg = msg;
}
}
else if (SendFullShelfStep.IsStep(SEND_FULL_SHELF_STEP.WAIT__SHELF_IN_LINE))
{
CurTaskState = Common.GetTakJobState(CurTaskID);
if (Common.CheckEnterOrLeaveFinished(agv, "Leave", CurTaskState))
{
runInfo = "满料架进入" + FullShelfPlace + "完成 [RFID=" + RFID + "] [" + agv.BoxDestInfo + "]";
msg += runInfo;
SendFullShelfStep.Msg = msg;
agv.RFID = "";
agv.BoxDestInfo = "";
AGVManager.UpdateStatus(RFID, FullShelfPlace);
return new EmptyAGVBackJob(FullShelfPlace);
}
else if (SendFullShelfStep.IsTimeOut(60000, out double timeOutValue))
{
//链条停止
runInfo = "满料架在[" + FullShelfPlace + "]离开小车超时[" + timeOutValue.ToString("f1") + "秒],请检查料架离开小车的情况";
//msg += runInfo;
//SendFullShelfStep.Msg = msg;
}
}
//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>
/// 等待小车到达目的地
/// </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
}
}