EmptyShelfBackJob.cs
5.7 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
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 EmptyShelfBackJob : Job
{
/// <summary>
/// 料架回收任务
/// </summary>
public EmptyShelfBackJob(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))
{
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))
{
Node node = NodeManager.GetNodeByName(JobParam.TargetNode.Name);
if (node.StateEquals(NodeStatus.MayEnter))
{
{
JobRunStep.ToNextStep(RunStep.RECY_BACK_WAIT_SHELF_IN_RECY_ST);
runInfo = "收到入料架请求的响应 " + JobParam.TargetNode + "入料架,小车链条运行";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.Leave);
}
}
else if (JobRunStep.IsTimeOut(15000, out TimeSpan timeOutValue))
{
tryTimes++;
if (tryTimes < 3)
return this;
tryTimes = 0;
JobRunStep.ToNextStep(RunStep.RECY_BACK_WAIT_REACH_RECY_ST);
runInfo = JobParam.TargetNode + "无响应,再次发送请求";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.Standby);
}
}
else if (JobRunStep.IsStep(RunStep.RECY_BACK_WAIT_SHELF_IN_RECY_ST))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.END);
runInfo = $"料架{(JobParam.Shelf == null ? "" : JobParam.Shelf.RFID)}进入{JobParam.TargetNode}完成";
JobRunStep.Msg = runInfo;
}
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.END))
{
JobRunStep.EndJob();
return null;
}
return this;
}
}
}