SendFixToLineJob.cs
11.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
using Common;
using DeviceLibrary.bean;
using DeviceLibrary.manager;
using System;
namespace DeviceLibrary
{
/// <summary>
/// 将治具送往产线
/// </summary>
public class SendFixToLineJob : Job
{
/// <summary>
/// 送治具任务
/// </summary>
public SendFixToLineJob(JobParam jobParam, bool adjustWidth = true) : base(jobParam)
{
JobName = "送治具任务";
jobParam.OpType = OpType.Mannual;
this.adjustWidth = adjustWidth;
}
bool adjustWidth = false;
public override Job Run(Agv_Info agv)
{
if (JobRunStep.IsStep(RunStep.NONE))
{
if (adjustWidth)
{
OpManager.ClientToSMDServer.RemoveRfidBufInfo(JobParam.Shelf==null?"":JobParam.Shelf.RFID);
if (JobParam.TargetNode.Area.Equals(Area.C) || JobParam.TargetNode.Area.Equals(Area.Air_C))
{
JobRunStep.ToNextStep(RunStep.WAIT_IN_ROOM_C);
runInfo = string.Format("前往{0},先过门", JobParam.TargetNode);
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.DoorDToC);
}
else
{
JobRunStep.ToNextStep(RunStep.SF_WAIT_AGV_REACH_LINE);
runInfo = string.Format("前往{0}", JobParam.TargetNode);
JobRunStep.Msg = runInfo;
AllocateTask(agv, JobParam.TargetNode.Name);
}
}
else
{
JobRunStep.ToNextStep(RunStep.ADJUST_WIDTH);
runInfo = "准备去" + JobParam.TargetNode + ",先调宽";
JobRunStep.Msg = runInfo;
AdjustWidth(agv, JobParam.FixMissionInfo.Type);
}
}
else if (JobRunStep.IsStep(RunStep.ADJUST_WIDTH))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
OpManager.ClientToSMDServer.RemoveRfidBufInfo(JobParam.Shelf.RFID);
if (JobParam.TargetNode.Area.Equals(Area.C) || JobParam.TargetNode.Area.Equals(Area.Air_C))
{
JobRunStep.ToNextStep(RunStep.WAIT_IN_ROOM_C);
runInfo = string.Format("前往{0}", JobParam.TargetNode);
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.DoorDToC);
}
else
{
JobRunStep.ToNextStep(RunStep.SF_WAIT_AGV_REACH_LINE);
runInfo = string.Format("前往{0}", JobParam.TargetNode);
JobRunStep.Msg = runInfo;
AllocateTask(agv, JobParam.TargetNode.Name);
}
}
}
else if (JobRunStep.IsStep(RunStep.WAIT_IN_ROOM_C))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
if (AGVManager.CheckRoomCTarget(agv, JobParam.TargetNode.Name))//被占用
{
JobRunStep.ToNextStep(RunStep.SF_WAIT_REACH_TEMP_PLACE);
runInfo = "目的地" + JobParam.TargetNode + "有小车占用,先到临时待机位";
JobRunStep.Msg = runInfo;
AGVManager.MoveToRoomCStandy(agv);
}
else
{
if (JobParam.TargetNode.Area.Equals(Area.Air_C))
{
JobRunStep.ToNextStep(RunStep.WAIT_IN_AIR_DOOR);
runInfo = "过风淋门,去" + JobParam.TargetNode;
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.DoorAirIn);
}
else
{
JobRunStep.ToNextStep(RunStep.SF_WAIT_AGV_REACH_LINE);
runInfo = "送往" + JobParam.TargetNode;
JobRunStep.Msg = runInfo;
AllocateTask(agv, JobParam.TargetNode.Name);
}
}
}
}
else if (JobRunStep.IsStep(RunStep.WAIT_IN_AIR_DOOR))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.SF_WAIT_AGV_REACH_LINE);
runInfo = "送往" + JobParam.TargetNode;
JobRunStep.Msg = runInfo;
AllocateTask(agv, JobParam.TargetNode.Name);
}
}
else if (JobRunStep.IsStep(RunStep.SF_WAIT_REACH_TEMP_PLACE))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
if (!AGVManager.CheckRoomCTarget(agv, JobParam.TargetNode.Name))//未占用
{
if (JobParam.TargetNode.Area.Equals(Area.Air_C))
{
JobRunStep.ToNextStep(RunStep.WAIT_IN_AIR_DOOR);
runInfo = "到临时待机位,先过风淋门,去" + JobParam.TargetNode;
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.DoorAirIn);
}
else
{
JobRunStep.ToNextStep(RunStep.SF_WAIT_AGV_REACH_LINE);
runInfo = "从临时待机位送往" + JobParam.TargetNode;
JobRunStep.Msg = runInfo;
AllocateTask(agv, JobParam.TargetNode.Name);
}
}
}
}
else if (JobRunStep.IsStep(RunStep.SF_WAIT_AGV_REACH_LINE))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
//设置音效类型
SetPlcWithToOutstore(agv);
AllocateTask(agv,SettingString.PlaySound);
if (JobParam.OpType.Equals(OpType.ComToLine))
{
JobRunStep.ToNextStep(RunStep.SF_WAIT_LINE_RESPONSE);
runInfo = "到达" + JobParam.TargetNode + ",并发送入料架请求";
JobRunStep.Msg = runInfo;
OpManager.ServerToClient.ReadyEnter(JobParam.TargetNode.Name, JobParam.Shelf == null ? "" : JobParam.Shelf.RFID);
}
else
{
JobRunStep.ToNextStep(RunStep.SF_WAIT_Manual_Operation);
runInfo = "到达" + JobParam.TargetNode + ",并等待人员操作";
JobRunStep.Msg = runInfo;
}
}
}
else if (JobRunStep.IsStep(RunStep.SF_WAIT_Manual_Operation))
{
if (JobParam.OpType.Equals(OpType.Mannual))
{
if (agv.GetInput(2, 0).Equals(true))
{
runInfo = "人员在" + JobParam.TargetNode + "操作完成";
JobRunStep.Msg = runInfo;
JobRunStep.EndJob();
//关闭音效
CloseSound(agv);
AllocateTask(agv, SettingString.StopSound);
return new EmptyAGVBackJob(new JobParam(JobParam.TargetNode, null, JobParam.Shelf==null?null:JobParam.Shelf.ToCopy()));
}
}
else if (JobParam.OpType.Equals(OpType.RequestAPI))
{
if (OpManager.Info.GetUnlock(JobParam.Shelf.RFID))
{
runInfo = "人员在" + JobParam.TargetNode + "操作完成";
JobRunStep.Msg = runInfo;
JobRunStep.EndJob();
//关闭音效
CloseSound(agv);
AllocateTask(agv, SettingString.StopSound);
return new FixToInStoreJob(new JobParam(JobParam.TargetNode, null, JobParam.Shelf==null?null:JobParam.Shelf.ToCopy()));
}
}
else if (JobParam.OpType.Equals(OpType.MaulAndAPI))
{
if (agv.GetInput(2,0) || OpManager.Info.GetUnlock(JobParam.Shelf.RFID))
{
runInfo = "人员在" + JobParam.TargetNode + "操作完成";
JobRunStep.Msg = runInfo;
JobRunStep.EndJob();
//关闭音效
CloseSound(agv);
AllocateTask(agv, SettingString.StopSound);
return new FixToInStoreJob(new JobParam(JobParam.TargetNode, null, JobParam.Shelf.ToCopy()));
}
}
}
else if (JobRunStep.IsStep(RunStep.SF_WAIT_LINE_RESPONSE))
{
Node node = NodeManager.GetNodeByName(JobParam.TargetNode.Name);
System.Threading.Thread.Sleep(50);
if (node.StateEquals(NodeStatus.MayEnter))
{
JobRunStep.ToNextStep(RunStep.SF_WAIT__SHELF_IN_LINE);
runInfo = "收到入料架请求的响应" + JobParam.TargetNode + "入料架";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.Leave);
}
else if (JobRunStep.IsTimeOut(15, out TimeSpan timeOutValue))
{
JobRunStep.ToNextStep(RunStep.SF_WAIT_AGV_REACH_LINE);
runInfo = "到达" + JobParam.TargetNode + ",15秒后重新向线体发送入料架请求";
JobRunStep.Msg = runInfo;
agv.HasError = true;
agv.SetErrorMsg("到达 " + JobParam.TargetNode + ",向线体发送入料架请求异常", timeOutValue.TotalMinutes.ToString("f2"));
}
}
else if (JobRunStep.IsStep(RunStep.SF_WAIT__SHELF_IN_LINE))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
agv.HasError = false;
runInfo = "料架进入" + JobParam.TargetNode + "完成";
JobRunStep.Msg = runInfo;
OpManager.Info.UpdateShelfStatus(JobParam.Shelf == null ? "" : JobParam.Shelf.RFID, JobParam.TargetNode.Name);
JobRunStep.EndJob();
return new EmptyAGVBackJob(new JobParam(JobParam.TargetNode.ToCopy()));
}
else if (JobRunStep.IsTimeOut(120, out TimeSpan timeOutValue))
{
//链条停止
runInfo = "料架在" + JobParam.TargetNode + "离开小车超时";
//msg += string.Format("[{0}] {1}", jobStep.CurStep(),runInfo);
//SendFullShelfStep.Msg = msg;
agv.HasError = true;
agv.SetErrorMsg("满料架在" + JobParam.TargetNode + "离开小车超时", timeOutValue.TotalMinutes.ToString("f2"));
}
}
else if (JobRunStep.IsStep(RunStep.END))
{
return null;
}
return this;
}
}
}