RecycleJob.cs
3.9 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
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 IJob Execute(AgvInfo info)
{
_info = info;
if (recycleStep.Equals(RecycleStep.None))
{
_info.Place = "进入电梯";
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);
}
}
else if (recycleStep.Equals(RecycleStep.Leave))
{
TimeSpan ts = DateTime.Now - getTime;
if (ts.Seconds >= 3)
{
ManageWork.ElevatorEnd();
Common.FirstFloorCurr--;
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)
recycleStep.Msg = string.Format("{0} 回收空货架任务完成,继续满货架任务", _info.Name);
else
recycleStep.Msg = string.Format("{0} 回收空货架任务完成,回待机位", _info.Name);
}
}
else if (recycleStep.Equals(RecycleStep.End))
{
IsEnd = true;
if (ManageWork.PauseFull)
return new FullShelfJob();
else
return new StandbyJob();
}
return this;
}
private void MoveElevator()
{
mission = Common.MISSION_ENTER_ELEVATOR_EMPTY;
move = new MissionJob(mission);
move.Execute(_info);
recycleStep.NextStep(RecycleStep.EnterInto);
recycleStep.Msg = string.Format("{0} 回收空货架任务,进入电梯,[{1}]", _info.Name, mission);
}
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;
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
}
}
}