StandbyJob.cs
3.3 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
using System;
using Model;
namespace BLL
{
public class StandbyJob : IJob
{
private AgvInfo _info;
private MissionJob move;
private string mission;
private JobStep<StandbyStep> standbyStep;
private DateTime _getTime;
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))
{
if (_info.IsWorkshop4D)
SendStandby();
else
PassDoor4D();
}
else if (standbyStep.Equals(StandbyStep.PassDoor))
{
move.Execute(_info);
if (move.IsEnd)
SendStandby();
}
else if (standbyStep.Equals(StandbyStep.MoveStandby))
{
move.Execute(_info);
if (move.IsEnd)
{
standbyStep.NextStep(StandbyStep.End);
standbyStep.Msg = _info.Name + " 到达待机位";
_getTime = DateTime.Now;
}
}
else if (standbyStep.Equals(StandbyStep.End))
{
if (_info.Battery <= _info.BatteryMin)
{
standbyStep.Msg = _info.Name + " 电量小于" + _info.BatteryMin + ",执行充电任务";
return new ChargeJob();
}
else
{
TimeSpan span = DateTime.Now - _getTime;
if (span.TotalMinutes >= 2)
{
standbyStep.Msg = _info.Name + " 在待机位停留超过2分钟,执行充电任务";
return new ChargeJob();
}
else
{
//IJob job = SteelManage.GetSteelJob(info);
//if (job != null) return job;
}
}
}
return this;
}
/// <summary>
/// 发送待机位任务
/// </summary>
private void SendStandby()
{
mission = Common.MISSION_STANDBY + _info.Name;
_info.Place = "待机位";
move = new MissionJob(mission);
move.Execute(_info);
standbyStep.NextStep(StandbyStep.MoveStandby);
standbyStep.Msg = string.Format("{0} 去待机位,[{1}]", _info.Name, mission);
}
/// <summary>
/// 过车间门去4D
/// </summary>
private void PassDoor4D()
{
mission = Common.MISSION_PASS_DOOR_4D;
_info.Place = "Goto4D";
move = new MissionJob(mission);
move.Execute(_info);
standbyStep.NextStep(StandbyStep.PassDoor);
standbyStep.Msg = string.Format("{0} 去4D车间,[{1}]", _info.Name, mission);
}
private enum StandbyStep
{
None,
End,
PassDoor,
MoveStandby
}
}
}