LineOneToManyJob.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
using Common;
using DeviceLibrary.manager;
namespace DeviceLibrary.bean.job
{
/// <summary>
/// 一线体到多线体
/// </summary>
public class LineOneToManyJob : Job
{
/// <summary>
///线体到多线体任务
/// </summary>
public LineOneToManyJob(JobParam jobParam) : base(jobParam)
{
}
public LineOneToManyJob() : base()
{
}
lift.LiftStatus liftStatus;
public override Job Run(AgvInfo agv)
{
if (JobRunStep.IsStep(RunStep.NONE))
{
JobRunStep.ToNextStep(RunStep.SD_Line_OneToMany_01_ToPickUpPosition);
runInfo = $"任务开始,去{JobParam.SrcNode.AliceName}的取料点";
//任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.接料, out string msg);
AllocateTask(agv, $"{JobParam.SrcNode.Name}_{SettingString.PutShelfOn}");
JobRunStep.Msg = runInfo;
}
else if (JobRunStep.IsStep(RunStep.SD_Line_OneToMany_01_ToPickUpPosition))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.SD_Line_OneToMany_02_PutShelfOn);
runInfo = $"到达{JobParam.SrcNode.AliceName}的取料点,准备拾取料车";
JobRunStep.Msg = runInfo;
AllocateTask(agv, $"{SettingString.PutShelfOn}");
//上报运输状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"到达{ JobParam.SrcNode.Name }"));
}
}
else if (JobRunStep.IsStep(RunStep.SD_Line_OneToMany_02_PutShelfOn))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.SD_Line_OneToMany_03_ToLine);
//上报运输状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"取车"));
runInfo = $"在{JobParam.SrcNode.AliceName}拾取料车完成,去{JobParam.CurTargetNode.AliceName}的放料点";
//任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.送料, out string msg);
AllocateTask(agv, $"{JobParam.CurTargetNode.Name}_{SettingString.TakeShelfOff}");
JobRunStep.Msg = runInfo;
}
}
else if (JobRunStep.IsStep(RunStep.SD_Line_OneToMany_03_ToLine))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
//确认按钮生效
JobParam.CurTargetNode.ExtendEquip.AllowConfirm();
JobRunStep.ToNextStep(RunStep.SD_Line_OneToMany_04_UpdateLocation);
runInfo = $"到达{JobParam.CurTargetNode.AliceName}的放料点,上报运输状态";
JobRunStep.Msg = runInfo;
//上报运输状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"到达{ JobParam.CurTargetNode.Name }"));
}
}
else if (JobRunStep.IsStep(RunStep.SD_Line_OneToMany_04_UpdateLocation))
{
if(NeedConfirm())
{
JobRunStep.ToNextStep(RunStep.SD_Line_OneToMany_05_WaitConfirm);
runInfo = $"等待{JobParam.CurTargetNode.AliceName}的人员确认";
JobRunStep.Msg = runInfo;
}
else
{
JobRunStep.ToNextStep(RunStep.SD_Line_OneToMany_06_CheckNextLine);
runInfo = $"{JobParam.CurTargetNode.AliceName}无需人员确认";
JobRunStep.Msg = runInfo;
//manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
//service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.agvButton,
//$"卸货{ JobParam.CurTargetNode.Name }"));
}
}
else if (JobRunStep.IsStep(RunStep.SD_Line_OneToMany_05_WaitConfirm))
{
if (OpManager.WaitConfirm.Line(JobParam.CurTargetNode))
{
JobRunStep.ToNextStep(RunStep.SD_Line_OneToMany_06_CheckNextLine);
runInfo = $"{JobParam.CurTargetNode.AliceName}的人员确认完成,检查是否有下一线体";
JobRunStep.Msg = runInfo;
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.agvButton,
$"卸货{ JobParam.CurTargetNode.Name }"));
//关闭按钮确认
JobParam.CurTargetNode.ExtendEquip.Reset();
}
else if (JobRunStep.IsTimeOut(WaitTimeOut, out double timeoutval))
{
//报警,$"等待{JobParam.CurTargetNode.AliceName}的人员确认超时{timeoutval}分"
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.error, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.agvButton,
$"等待{ JobParam.CurTargetNode.Name }确认超时{timeoutval}分"));
}
}
else if (JobRunStep.IsStep(RunStep.SD_Line_OneToMany_06_CheckNextLine))
{
if (JobParam.TargetNodes != null && JobParam.TargetNodes.Count > 0)
{
JobRunStep.ToNextStep(RunStep.SD_Line_OneToMany_03_ToLine);
JobParam.CurTargetNode = JobParam.TargetNodes[0];
JobParam.TargetNodes.RemoveAt(0);
System.Threading.Thread.Sleep(1000);
runInfo = $"去下一线体{JobParam.CurTargetNode.AliceName}的放料点";
JobRunStep.Msg = runInfo;
AllocateTask(agv, $"{JobParam.CurTargetNode.Name}_{SettingString.TakeShelfOff}");
}
else
{
if (JobParam.GetMissionInfo() != null && JobParam.GetMissionInfo().needBack)
{
JobRunStep.ToNextStep(RunStep.SD_Line_OneToMany_07_BackToPickUpPosition);
runInfo = $"{JobParam.CurTargetNode.AliceName}是最后一个线体,分发结束,需要返回{JobParam.SrcNode.Name}的放料点";
//任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.返回起始地, out string msg);
AllocateTask(agv, $"{JobParam.SrcNode.Name}_{SettingString.TakeShelfOff}");
JobRunStep.Msg = runInfo;
}
else if (JobParam.GetMissionInfo() != null && !JobParam.GetMissionInfo().needBack)
{
JobRunStep.ToNextStep(RunStep.SD_Line_OnToMany_08_TakeShelfOff);
runInfo = $"{JobParam.CurTargetNode.AliceName}是最后一个线体,分发结束,无需返回,直接卸下";
JobRunStep.Msg = runInfo;
AllocateTask(agv, $"{SettingString.TakeShelfOff}");
}
else
{
LogUtil.error(JobParam.GetMissionInfo().ToString());
}
}
}
else if (JobRunStep.IsStep(RunStep.SD_Line_OneToMany_07_BackToPickUpPosition))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.SD_Line_OnToMany_08_TakeShelfOff);
//上报运输状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"到达{ JobParam.SrcNode.Name }"));
runInfo = $"到达{JobParam.SrcNode.AliceName}的放料点,准备卸下料车";
JobRunStep.Msg = runInfo;
AllocateTask(agv, SettingString.TakeShelfOff);
}
}
else if (JobRunStep.IsStep(RunStep.SD_Line_OnToMany_08_TakeShelfOff))
{
if (agv.TaskRunState.CheckTaskFinished(agv.Name))
{
JobRunStep.ToNextStep(RunStep.END);
if (JobParam.GetMissionInfo() != null && JobParam.GetMissionInfo().needBack)
{
//上报运输状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"还车"));
}
else if (JobParam.GetMissionInfo() != null && !JobParam.GetMissionInfo().needBack)
{
//上报运输状态
manager.UploadManager.UploadTransportStatus(new service.model.TransportStatus(agv.CurJob.JobParam.GetMissionInfo().missionId,
service.model.TransportStatus.TypeStr.status, agv.Name, agv.Place.Name, service.model.TransportStatus.ModeStr.auto,
$"卸车"));
}
runInfo = $"料车在{JobParam.SrcNode.AliceName}放下完成,任务结束";
//任务状态变更
MissionManager.SetMissionState(JobParam.GetMissionInfo().missionId, service.model.MissionState.完成, out string msg);
JobRunStep.Msg = runInfo;
}
}
else if (JobRunStep.IsStep(RunStep.END))
{
JobRunStep.EndJob();
return null;
}
agv.SetJobContext(new bean.agv.JobContext()
{
MissionId = JobParam.GetMissionInfo().missionId,
AgvTask = agv.TaskRunState.Task,
JobFullName = this.ToString(),
JobStep = JobRunStep.PreStep(),
Name = agv.Name,
JobParam = JobParam
});
return this;
}
}
}