GoWarehouseForOutStoreJob.cs
8.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
using Common;
using DeviceLibrary.bean;
using DeviceLibrary.manager;
using System;
namespace DeviceLibrary
{
/// <summary>
/// 去立库接出库的治具
/// </summary>
public class GoWarehouseForOutStoreJob : Job
{
/// <summary>
/// 去云仓接满料
/// </summary>
public GoWarehouseForOutStoreJob(JobParam jobParam) : base(jobParam)
{
JobName = "出库任务";
}
bool IsLoadOnAGV = false;
public override Job Run(Agv_Info agv)
{
if (JobRunStep.IsStep(RunStep.NONE))
{
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))
{
JobRunStep.ToNextStep(RunStep.WAIT_CHECK_RESULT);
runInfo = "检查AGV负载情况";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.CheckShelf);
}
}
else if (JobRunStep.IsStep(RunStep.WAIT_CHECK_RESULT))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
if (agv.IsExistShelf)
{
JobRunStep.ToNextStep(RunStep.END);
runInfo = "车上有负载,无法运行出库任务";
JobRunStep.Msg = runInfo;
IsLoadOnAGV = true;
}
else if (!agv.IsExistShelf)
{
if (JobParam.SrcNode.Area.Equals(Area.D))
{
JobRunStep.ToNextStep(RunStep.WAIT_AGV_REACH_A6);
runInfo = $"车上无负载,准备去{JobParam.TargetNode.Name}接料";
JobRunStep.Msg = runInfo;
AllocateTask(agv, JobParam.TargetNode.Name);
}
else if (JobParam.SrcNode.Area.Equals(Area.Air_C))
{
JobRunStep.ToNextStep(RunStep.WAIT_AGV_REACH_AIR_DOOR);
runInfo = "去接料,先过风淋门";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.DoorAirOut);
}
else if (JobParam.SrcNode.Area.Equals(Area.C))//4C车间
{
JobRunStep.ToNextStep(RunStep.WAIT_AGV_REACH_DOOR);
runInfo = "先过门,再接料";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.DoorCToD);
}
else
{
JobRunStep.ToNextStep(RunStep.WAIT_AGV_REACH_A6);
runInfo = $"车上无负载,准备去{JobParam.TargetNode.Name}接料";
JobRunStep.Msg = runInfo;
AllocateTask(agv, JobParam.TargetNode.Name);
}
}
}
}
else if (JobRunStep.IsStep(RunStep.WAIT_AGV_REACH_AIR_DOOR))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.WAIT_AGV_REACH_DOOR);
runInfo = $"去{JobParam.TargetNode.Name},先过门";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.DoorCToD);
}
}
else if (JobRunStep.IsStep(RunStep.WAIT_AGV_REACH_DOOR))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.WAIT_AGV_REACH_A6);
runInfo = $"去{JobParam.TargetNode.Name}接料";
JobRunStep.Msg = runInfo;
AllocateTask(agv, JobParam.TargetNode.Name);
}
}
else if (JobRunStep.IsStep(RunStep.WAIT_AGV_REACH_A6))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
WarehouseSigManager.TargetWithFix.CurPlace = JobParam.TargetNode.Name;
JobRunStep.ToNextStep(RunStep.WAIT_DOUBLE_LINE_RESPONSE);
runInfo = "到达 " + JobParam.TargetNode.Name + ",并发送出库请求";
JobRunStep.Msg = runInfo;
OpManager.ServerToClient.ReadyLeave(JobParam.TargetNode.Name, JobParam.Shelf == null ? "" : JobParam.Shelf.RFID);
}
}
else if (JobRunStep.IsStep(RunStep.WAIT_DOUBLE_LINE_RESPONSE))
{
if (WarehouseSigManager.MayLeave)
{
agv.HasError = false;
JobRunStep.ToNextStep(RunStep.WAIT__FULL_SHELF_IN_AGV);
runInfo = "收到出库请求的响应," + JobParam.TargetNode.Name + "出治具";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.Enter);
WarehouseSigManager.MayLeave = false;
}
else if (OpManager.Info.GetTransfer(out string target))
{
if (target.Equals(SettingString.Cancel))
{
agv.HasError = false;
runInfo = $"收到离开信号,出库任务取消";
JobRunStep.Msg = runInfo;
JobRunStep.EndJob();
return null;
}
}
else if (JobRunStep.IsTimeOut(15, out TimeSpan timeOutValue))
{
//JobRunStep.ToNextStep(RunStep.WAIT_AGV_REACH_A6);
agv.HasError = true;
agv.SetErrorMsg($"{JobParam.TargetNode.Name}回复出料请求超时", timeOutValue.TotalMinutes.ToString("f2"));
}
}
else if (JobRunStep.IsStep(RunStep.WAIT__FULL_SHELF_IN_AGV))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
agv.HasError = false;
JobRunStep.ToNextStep(RunStep.WAIT_LEAVE_SIG);
runInfo = JobParam.TargetNode.Name + "治具进入小车完成";
JobRunStep.Msg = runInfo;
//JobRunStep.EndJob();
// return new SendFixToLineJob(new JobParam(JobParam.TargetNode.ToCopy()),true);
}
else if (JobRunStep.IsTimeOut(120, 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.WAIT_LEAVE_SIG))
{
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;
}
}
}