RecycleJob.cs
5.0 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
using System;
using Model;
namespace BLL
{
public class RecycleJob : IJob
{
private AgvInfo _info;
private MissionJob move;
private string mission;
private DateTime getTime;
private string key;
//private bool fullNext;
private JobStep<RecycleStep> recycleStep;
public RecycleJob()
{
IsEnd = false;
recycleStep = new JobStep<RecycleStep>(RecycleStep.None);
Common.log.Debug("加载RecycleJob");
}
public bool IsEnd { get; private set; }
public string Msg
{
get
{
return recycleStep.Msg;
}
}
public IJob Execute(AgvInfo info)
{
_info = info;
if (recycleStep.Equals(RecycleStep.None))
{
_info.Place = "进入电梯";
_info.LogJson.SetMissionStart("回收空架任务", "电梯");
_info.LogJson.SetMissionStep("开始执行任务", RecycleStep.None.ToString());
MoveElevator();
}
else if (recycleStep.Equals(RecycleStep.EnterInto))
{
move.Execute(_info);
if (move.IsEnd)
{
ManageWork.ElevatorEmptyShelf();
getTime = DateTime.Now;
recycleStep.NextStep(RecycleStep.Leave);
recycleStep.Msg = string.Format("{0} 发送离开信号", _info.Name);
_info.LogJson.SetMissionStep("发送离开信号", RecycleStep.Leave.ToString());
}
}
else if (recycleStep.Equals(RecycleStep.Leave))
{
TimeSpan ts = DateTime.Now - getTime;
if (ts.Seconds >= 3)
{
ManageWork.ElevatorEnd();
ManageWork.FirstFloorMinus();
recycleStep.Msg = string.Format("{0} 回收空货架任务,当前一楼货架数量{1}个", _info.Name, Common.FirstFloorCurr);
FindLine();
}
}
else if (recycleStep.Equals(RecycleStep.MoveLine))
{
move.Execute(_info);
if (move.IsEnd)
{
ManageWork.LineSendTo(key);
recycleStep.NextStep(RecycleStep.End);
if (ManageWork.PauseFull)
{
_info.LogJson.SetMissionStep("回收空货架任务完成,继续满货架任务", RecycleStep.End.ToString());
recycleStep.Msg = string.Format("{0} 回收空货架任务完成,继续满货架任务", _info.Name);
}
else
{
_info.LogJson.SetMissionStep("回收空货架任务完成", RecycleStep.End.ToString());
recycleStep.Msg = string.Format("{0} 回收空货架任务完成,回待机位", _info.Name);
}
}
}
else if (recycleStep.Equals(RecycleStep.End))
{
IsEnd = true;
if (ManageWork.PauseFull)
{
return new FullShelfJob();
}
else
{
IJob job = ManageWork.GetJob();
if (job == null)
return new StandbyJob();
else
return job;
}
}
return this;
}
private void MoveElevator()
{
mission = Common.MISSION_ENTER_ELEVATOR_EMPTY;
_info.ExistShelf = 1;
move = new MissionJob(mission);
move.Execute(_info);
recycleStep.NextStep(RecycleStep.EnterInto);
recycleStep.Msg = string.Format("{0} 回收空货架任务,进入电梯,[{1}]", _info.Name, mission);
_info.LogJson.SetMissionStep("进入电梯", RecycleStep.EnterInto.ToString());
}
private void FindLine()
{
bool rtn = ManageWork.FindLineWithoutShelf(out string key, out string name);
if (rtn)
{
_info.Place = name;
this.key = key;
mission = Common.MISSION_CARRY_EMPTY + key;
_info.ExistShelf = 0;
move = new MissionJob(mission);
move.Execute(_info);
recycleStep.Msg = string.Format("{0} 回收空货架任务,去{1},[{2}]", _info.Name, name, mission);
recycleStep.NextStep(RecycleStep.MoveLine);
}
else
{
recycleStep.Msg = string.Format("{0} 没有找到回收空货架任务", _info.Name);
recycleStep.NextStep(RecycleStep.End);
}
}
private enum RecycleStep
{
None,
End,
EnterInto,
Leave,
FindLine,
MoveLine
}
}
}