GoFullShelfStationJob.cs
10.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
using AGVControl;
using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGVControl
{
/// <summary>
/// 检查AGV是否有负载,去A6入料口并装车
/// </summary>
public class GoFullShelfStationJob : Job
{
/// <summary>
/// 去A6入料口任务并检查AGV是否有负载
/// </summary>
/// <param name="agvCurPlace">接到任务时,AGV的位置(空表示待机位)</param>
/// <param name="palce"></param>
public GoFullShelfStationJob(string agvCurPlace = "", string palce = "A6")
{
FullShelfStationPlace = palce;
agvPlace = agvCurPlace;
}
/// <summary>
/// 出满料位置点
/// </summary>
public string FullShelfStationPlace { get; set; }
/// <summary>
/// 运行信息
/// </summary>
public string RunInfo { get; set; }
/// <summary>
/// 接到任务时,AGV的位置
/// </summary>
public string agvPlace { get; set; }
public override bool IsEnd { get { return GoFullShelfStationStep.IsStep(GO_FULL_SHELF_STATION_STEP.END); } }
/// <summary>
/// AGV上是否有负载
/// </summary>
public bool IsLoadOnAGV { get; private set; } = false;
public AGVManager.BoxDestInfo FullShelfDestInfo = null;
private JobStep<GO_FULL_SHELF_STATION_STEP> GoFullShelfStationStep = new JobStep<GO_FULL_SHELF_STATION_STEP>(GO_FULL_SHELF_STATION_STEP.NONE);
public override Job Execute(Agv_Info agv)
{
string msg = "";
bool rtn = false;
if (GoFullShelfStationStep.IsStep(GO_FULL_SHELF_STATION_STEP.NONE))
{
GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_CHECK_RESULT);
msg = agv.Name + " 检查AGV负载情况";
GoFullShelfStationStep.Msg = msg;
Common.CheckLoad(agv);
}
else if (GoFullShelfStationStep.IsStep(GO_FULL_SHELF_STATION_STEP.WAIT_CHECK_RESULT))
{
if (GoFullShelfStationStep.IsTimeOut(15000, out double timeOutValue))
{
Common.mir.Get_IO_Status(agv, out bool[] input, out bool[] output);
if (!input.Equals(null) && input[3])
{
GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.END);
msg = agv.Name + " 车上有料架,无法去入料口出料";
GoFullShelfStationStep.Msg = msg;
agv.IsExistShelf = true;
IsLoadOnAGV = true;
}
else if (!input.Equals(null) && !input[3])
{
if (agvPlace.Equals(""))//待机位接到任务
{
GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_AGV_REACH_A6);
msg = agv.Name + " 无负载,准备运动到入料口";
GoFullShelfStationStep.Msg = msg;
Common.MoveToNode(agv, FullShelfStationPlace);
}
else if (agvPlace.StartsWith("G"))//4C车间
{
GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_AGV_REACH_DOOR);
msg = agv.Name + " 在4C车间,向4D门运行,再到双层线入料口";
GoFullShelfStationStep.Msg = msg;
Common.DoorMission(agv, SettingString.MoveDoorCToD);
}
}
}
}
else if (GoFullShelfStationStep.IsStep(GO_FULL_SHELF_STATION_STEP.WAIT_AGV_REACH_DOOR))
{
if (agv.Place.Equals(SettingString.D4_DOOR_Name) && agv.PlaceState.Equals(ePlaceState.MoveFinish))
{
GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_AGV_REACH_A6);
msg = agv.Name + " 到达4D门,准备运动到双层线入料口";
GoFullShelfStationStep.Msg = msg;
Common.MoveToNode(agv, FullShelfStationPlace);
}
}
else if (GoFullShelfStationStep.IsStep(GO_FULL_SHELF_STATION_STEP.WAIT_AGV_REACH_A6))
{
if (agv.Place.Equals(FullShelfStationPlace) && agv.PlaceState.Equals(ePlaceState.MoveFinish))
{
ClientNode node = Common.nodeInfo.Find(s => s.Name.Equals(SettingString.A6)
&& (s.StateEquals(eNodeStatus.NeedEnterLeave) || s.StateEquals(eNodeStatus.NeedEnterLeave)) && !s.RFID.Equals("00"));
if (node.Name.Equals(SettingString.A6))
{
if (AGVManager.FindFullShelfTarget(node.RFID, out FullShelfDestInfo))
{
GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_DOUBLE_LINE_RESPONSE);
msg = "AGV到达 " + FullShelfStationPlace + ",并发送出料架请求[ReadyLeave]";
GoFullShelfStationStep.Msg = msg;
Common.server.ReadyLeave(FullShelfStationPlace);
}
else
{
if (!FullShelfDestInfo.Equals(null))
{
msg = "AGV到达 " + FullShelfStationPlace + ",查询满料架目的地:" + FullShelfDestInfo.ShowInfo();
GoFullShelfStationStep.Msg = msg;
}
else
{
//[{"msg":"0料车已解绑或未发新料"}]
GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_REACH_STANDBY);
msg = "从产线" + agvPlace + "回到待机位";
GoFullShelfStationStep.Msg = msg;
Common.MoveToNode(agv, SettingString.MoveStandby);
}
}
}
}
}
else if (GoFullShelfStationStep.IsStep(GO_FULL_SHELF_STATION_STEP.WAIT_REACH_STANDBY))
{
if (agv.Place.StartsWith(SettingString.Standby_Name_Prefix) && agv.PlaceState.Equals(ePlaceState.MoveFinish))
{
GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.END);
msg = "到达待机位";
GoFullShelfStationStep.Msg = msg;
}
}
else if (GoFullShelfStationStep.IsStep(GO_FULL_SHELF_STATION_STEP.WAIT_DOUBLE_LINE_RESPONSE))
{
int id = Common.FindNode(FullShelfStationPlace);
ClientNode node = Common.nodeInfo[id];
if (node.StateEquals(eNodeStatus.MayLeave))
{
GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT__FULL_SHELF_IN_AGV);
msg = "收到双层线出料架请求[ReadyLeave]的响应 " + FullShelfStationPlace + "出料架,小车链条运行";
GoFullShelfStationStep.Msg = msg;
rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Enter"]);
agv.TaskSend = rtn ? "Enter" : "";
}
else if (GoFullShelfStationStep.IsTimeOut(15000, out double timeOutValue))
{
GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.WAIT_AGV_REACH_A6);
msg = "AGV到达 " + FullShelfStationPlace + ",15秒后重新向双层线发送出料架请求[ReadyLeave]";
GoFullShelfStationStep.Msg = msg;
}
}
else if (GoFullShelfStationStep.IsStep(GO_FULL_SHELF_STATION_STEP.WAIT__FULL_SHELF_IN_AGV))
{
if (agv.Place.Equals(FullShelfStationPlace) && agv.PlaceState.Equals(ePlaceState.EnterFinish))
{
//GoFullShelfStationStep.ToNextStep(GO_FULL_SHELF_STATION_STEP.END);
msg = FullShelfStationPlace + "满料架进入小车完成";
GoFullShelfStationStep.Msg = msg;
if (FullShelfDestInfo.location.StartsWith("G"))
{
return new SendFullShelfToLineJob(FullShelfDestInfo, true);
}
else
return new SendFullShelfToLineJob(FullShelfDestInfo);
}
else if (GoFullShelfStationStep.IsTimeOut(60000, out double timeOutValue))
{
//链条停止
msg = "满料架在[" + FullShelfStationPlace + "]进入小车超时[" + timeOutValue.ToString("f1") + "秒],请检查料架进入小车的情况";
GoFullShelfStationStep.Msg = msg;
}
}
RunInfo = GoFullShelfStationStep.Msg;
return this;
}
}
/// <summary>
/// 出满料步骤
/// </summary>
public enum GO_FULL_SHELF_STATION_STEP
{
/// <summary>
/// 负载检查
/// </summary>
NONE,
/// <summary>
/// 负载检查结果
/// </summary>
WAIT_CHECK_RESULT,
/// <summary>
/// 等待AGV到达门
/// </summary>
WAIT_AGV_REACH_DOOR,
/// <summary>
/// 等待到达A6
/// </summary>
WAIT_AGV_REACH_A6,
/// <summary>
/// 等待双层线回应
/// </summary>
WAIT_DOUBLE_LINE_RESPONSE,
/// <summary>
/// 等待料架进入小车
/// </summary>
WAIT__FULL_SHELF_IN_AGV,
/// <summary>
/// 等待AGV到达待机位
/// </summary>
WAIT_REACH_STANDBY,
/// <summary>
/// 送上双层线
/// </summary>
END
}
}