FixToInStoreJob.cs
9.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.ModelBinding;
using System.Windows.Forms;
using Common;
using DeviceLibrary.bean;
using DeviceLibrary.manager;
namespace DeviceLibrary
{
/// <summary>
/// 治具入库任务
/// </summary>
public class FixToInStoreJob : Job
{
/// <summary>
/// 料架回收任务
/// </summary>
public FixToInStoreJob(JobParam jobParam) : base(jobParam)
{
JobName = "治具入库任务";
}
private int tryTimes = 0;
/// <summary>
/// 料架回收任务
/// </summary>
/// <param name="agv"></param>
public override Job Run(Agv_Info agv)
{
if (JobRunStep.IsStep(RunStep.NONE))
{
if (JobParam.SrcNode.Area.Equals(Area.Air_C))//C车间风淋门
{
JobRunStep.ToNextStep(RunStep.WAIT_OUT_AIR_DOOR);
runInfo = string.Format("从{0}去风淋门", JobParam.SrcNode);
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.DoorAirOut);
}
else if (JobParam.SrcNode.Area.Equals(Area.C))//C车间
{
JobRunStep.ToNextStep(RunStep.WAIT_IN_ROOM_D);
runInfo = string.Format("从{0}过门", JobParam.SrcNode);
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.DoorCToD);
}
else
{
JobRunStep.ToNextStep(RunStep.RECY_BACK_WAIT_REACH_RECY_ST);
runInfo = string.Format("从{0}去{1}", JobParam.SrcNode, JobParam.TargetNode);
JobRunStep.Msg = runInfo;
AllocateTask(agv, JobParam.TargetNode.Name);
}
}
else if (JobRunStep.IsStep(RunStep.WAIT_OUT_AIR_DOOR))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.WAIT_IN_ROOM_D);
runInfo = string.Format("出风淋门,准备过门");
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.DoorCToD);
}
}
else if (JobRunStep.IsStep(RunStep.WAIT_IN_ROOM_D))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.RECY_BACK_WAIT_REACH_RECY_ST);
runInfo = string.Format("进门,送往{0}", JobParam.TargetNode);
JobRunStep.Msg = runInfo;
AllocateTask(agv, JobParam.TargetNode.Name);
}
}
else if (JobRunStep.IsStep(RunStep.RECY_BACK_WAIT_REACH_STANDBY))
{
}
else if (JobRunStep.IsStep(RunStep.RECY_BACK_WAIT_REACH_RECY_ST))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
WarehouseSigManager.TargetWithFix.CurPlace = JobParam.TargetNode.Name;
JobRunStep.ToNextStep(RunStep.RECY_BACK_WAIT_RECY_ST_RESPONSE);
runInfo = "AGV到达 " + JobParam.TargetNode + ",并发送治具入库请求";
JobRunStep.Msg = runInfo;
OpManager.ServerToClient.ReadyEnter(JobParam.TargetNode.Name, JobParam.Shelf == null ? "" : JobParam.Shelf.RFID);
}
}
else if (JobRunStep.IsStep(RunStep.RECY_BACK_WAIT_RECY_ST_RESPONSE))
{
if (WarehouseSigManager.MayEnter)
{
{
JobRunStep.ToNextStep(RunStep.RECY_BACK_WAIT_SHELF_IN_RECY_ST);
runInfo = "收到治具入库请求的响应 " + JobParam.TargetNode + "入治具,小车链条运行";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.Leave);
WarehouseSigManager.MayEnter = false;
}
}
else if (JobRunStep.IsTimeOut(15000, out TimeSpan timeOutValue))
{
tryTimes++;
if (tryTimes < 3)
return this;
tryTimes = 0;
runInfo = JobParam.TargetNode + "无响应";
JobRunStep.Msg = runInfo;
}
}
else if (JobRunStep.IsStep(RunStep.RECY_BACK_WAIT_SHELF_IN_RECY_ST))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.RECY_BACK_CHECK_OUT_STORE);
runInfo = $"治具{(JobParam.Shelf == null ? "" : JobParam.Shelf.RFID)}进入{JobParam.TargetNode}完成";
JobRunStep.Msg = runInfo;
}
else if (WarehouseSigManager.StopEnter)
{
JobRunStep.ToNextStep(RunStep.RECY_BACK_CHECK_OUT_STORE);
runInfo = $"治具{(JobParam.Shelf == null ? "" : JobParam.Shelf.RFID)}进入{JobParam.TargetNode}完成";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.Init);
WarehouseSigManager.StopEnter = false;
}
else if (JobRunStep.IsTimeOut(60000, out TimeSpan timeOutValue1))
{
runInfo = "治具在[" + JobParam.TargetNode + "]离开小车超时";
agv.HasError = true;
agv.SetErrorMsg("治具在[" + JobParam.TargetNode + "]进入小车超时", timeOutValue1.TotalMinutes.ToString("f2"));
}
}
else if (JobRunStep.IsStep(RunStep.RECY_BACK_CHECK_OUT_STORE))
{
if (WarehouseSigManager.OutStore.Has)
{
//调宽
JobRunStep.ToNextStep(RunStep.ADJUST_WIDTH);
runInfo = JobParam.TargetNode + " 有出库任务,开始调宽";
JobRunStep.Msg = runInfo;
AdjustWidth(agv, WarehouseSigManager.OutStore.Type);
}
else if (OpManager.Info.GetTransfer(out string target))
{
JobRunStep.ToNextStep(RunStep.END);
runInfo = JobParam.TargetNode + " 无出库任务,任务结束";
JobRunStep.Msg = runInfo;
}
}
else if(JobRunStep.IsStep(RunStep.ADJUST_WIDTH))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.RECY_BACK_WAIT_RESPONSE);
runInfo = $"调宽完成";
JobRunStep.Msg = runInfo;
}
}
else if (JobRunStep.IsStep(RunStep.RECY_BACK_WAIT_RESPONSE))
{
if(WarehouseSigManager.MayLeave)
{
JobRunStep.ToNextStep(RunStep.RECY_BACK_WAIT_FIX_IN_AGV);
runInfo = "收到出料的响应 " + JobParam.TargetNode + "出治具,小车链条运行";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.Enter);
}
}
else if(JobRunStep.IsStep(RunStep.RECY_BACK_WAIT_FIX_IN_AGV))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
agv.HasError = false;
JobRunStep.ToNextStep(RunStep.RECY_BACK_WAIT_LEAVE_SIG);
runInfo ="治具进入AGV完成";
JobRunStep.Msg = runInfo;
}
else if (JobRunStep.IsTimeOut(60000, out TimeSpan timeOutValue))
{
//链条停止
runInfo = "治具在[" + JobParam.TargetNode.Name + "]进入小车超时";
//msg +=runInfo;
//GoFullShelfStationStep.Msg = msg;
agv.HasError = true;
agv.SetErrorMsg("治具在[" + JobParam.TargetNode.Name + "]进入小车超时", timeOutValue.TotalMinutes.ToString("f2"));
}
}
else if (JobRunStep.IsStep(RunStep.RECY_BACK_WAIT_LEAVE_SIG))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
if (OpManager.Info.GetTransfer(out string target))
{
if(!target.Equals(SettingString.Cancel))
{
agv.HasError = false;
runInfo = $"收到离开信号,开始运送出库治具到"+ target;
JobRunStep.Msg = runInfo;
JobRunStep.EndJob();
return new SendFixToLineJob(new JobParam(JobParam.TargetNode, NodeManager.GetNodeByName(target)),true);
}
else
{
agv.HasError = true;
agv.SetErrorMsg("有出库任务,但返回目的地为Cancel",(DateTime.Now-StartJobTime).TotalMinutes.ToString("f2"));
}
}
}
}
else if (JobRunStep.IsStep(RunStep.END))
{
JobRunStep.EndJob();
return null;
}
return this;
}
}
}