StandbyJob.cs
2.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
using System;
using Model;
namespace BLL
{
public class StandbyJob : IJob
{
private AgvInfo _info;
private MissionJob move;
private string mission;
private JobStep<StandbyStep> standbyStep;
public StandbyJob()
{
IsEnd = false;
standbyStep = new JobStep<StandbyStep>(StandbyStep.None);
Common.log.Debug("加载StandbyJob");
}
public bool IsEnd { get; private set; }
public IJob Execute(AgvInfo info)
{
_info = info;
if (standbyStep.Equals(StandbyStep.None))
{
_info.Place = "去待机位";
SendStandby();
}
else if (standbyStep.Equals(StandbyStep.MoveStandby))
{
move.Execute(_info);
if (move.IsEnd)
{
_info.Place = "待机位";
standbyStep.NextStep(StandbyStep.End);
standbyStep.Msg = _info.Name + " 到达待机位";
}
}
else if (standbyStep.Equals(StandbyStep.End))
{
IsEnd = true;
if (_info.Battery <= Common.BatteryMin)
{
if (Common.AutoCharge)
{
_info.Place = "";
standbyStep.Msg = string.Format("{0} 电量小于{1}%,执行充电任务", _info.Name, Common.BatteryMin);
return new ChargeJob();
}
}
else
{
IJob job = ManageWork.GetJob();
if (job == null)
{
if (_info.Battery <= Common.BatteryIdle)
{
if (Common.AutoCharge)
{
_info.Place = "";
standbyStep.Msg = string.Format("{0} 空闲并且电量小于{1}%,执行充电任务", _info.Name, Common.BatteryIdle);
return new ChargeJob();
}
}
}
else
{
_info.Place = "";
return job;
}
}
}
return this;
}
private void SendStandby()
{
mission = Common.MISSION_STANDBY;
move = new MissionJob(mission);
move.Execute(_info);
standbyStep.NextStep(StandbyStep.MoveStandby);
standbyStep.Msg = string.Format("{0} 去待机位,[{1}]", _info.Name, mission);
}
private enum StandbyStep
{
None,
End,
MoveStandby
}
}
}