TakeOldJob.cs
4.1 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
using System;
using Model;
namespace BLL
{
public class TakeOldJob : IJob
{
private AgvInfo _info;
private MoveJob move;
private string mission;
//private DateTime _getTime;
private JobStep<TakeOldStep> takeOldStep;
public TakeOldJob()
{
takeOldStep = new JobStep<TakeOldStep>(TakeOldStep.None);
Common.log.Debug("加载TakeOldJob");
SteelManage.OldSteelWorkDel();
}
public bool IsEnd { get; private set; }
public string Msg
{
get
{
return takeOldStep.Msg;
}
}
public IJob Execute(AgvInfo info)
{
_info = info;
if (takeOldStep.Equals(TakeOldStep.None))
{
_info.From = "";
info.OldSteel = 0;
takeOldStep.Msg = info.Name + " 查找回收钢板任务";
takeOldStep.NextStep(TakeOldStep.FindLine);
}
else if (takeOldStep.Equals(TakeOldStep.FindLine))
{
if (info.OldSteel == 5)
{
takeOldStep.Msg = info.Name + " 回收钢板已满";
takeOldStep.NextStep(TakeOldStep.GoWashPoint);
}
else
{
FindLine(info);
}
}
else if (takeOldStep.Equals(TakeOldStep.MoveLine))
{
move.Execute(_info);
if (move.IsEnd)
{
info.OldSteel++;
SteelManage.OldSteelWorkDel(info.Place);
takeOldStep.NextStep(TakeOldStep.FindLine);
takeOldStep.Msg = _info.Name + " 到达" + _info.Place;
}
}
else if (takeOldStep.Equals(TakeOldStep.GoWashPoint))
{
if (info.OldSteel == 0)
{
takeOldStep.NextStep(TakeOldStep.End);
takeOldStep.Msg = _info.Name + " 回收钢板数量为0,结束任务";
}
else
{
mission = Common.MISSION_MOVE_WASH + _info.Workshop;
_info.Place = mission;
move = new MoveJob(mission);
move.Execute(_info);
takeOldStep.NextStep(TakeOldStep.WaitWashPoint);
takeOldStep.Msg = _info.Name + " 发送回收钢板任务 " + mission;
}
}
else if (takeOldStep.Equals(TakeOldStep.WaitWashPoint))
{
move.Execute(_info);
if (move.IsEnd)
{
takeOldStep.NextStep(TakeOldStep.End);
takeOldStep.Msg = _info.Name + " 到达" + _info.Workshop + "清洗点";
}
}
else if (takeOldStep.Equals(TakeOldStep.End))
{
info.OldSteel = 0;
IJob job = SteelManage.GetSteelJob(info);
if (job == null)
return new StandbyJob();
else
return job;
}
return this;
}
private void FindLine(AgvInfo info)
{
bool rtn = SteelManage.FindOldSteelWork(info, out string place);
if (rtn)
{
info.Place = place;
mission = Common.MISSION_MOVE_STEEL + place;
move = new MoveJob(mission);
move.Execute(_info);
takeOldStep.NextStep(TakeOldStep.MoveLine);
takeOldStep.Msg = _info.Name + " 发送回收钢板任务 " + mission;
}
else
{
takeOldStep.NextStep(TakeOldStep.GoWashPoint);
takeOldStep.Msg = info.Name + " 没有后续旧钢板任务";
}
}
private enum TakeOldStep
{
None,
FindLine,
MoveLine,
GoWashPoint,
WaitWashPoint,
End
}
}
}