AutoChargeTask.cs
2.5 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
using CtuDeviceLib;
using Mushiny;
using OnlineStore.Common;
namespace DeviceLibrary.CtuService
{
/// <summary>
/// 自动充电任务
/// </summary>
public class AutoChargeTask : CtuTaskBase
{
public AutoChargeTask(CTU ctu) : base(ctu)
{
Name = "自动充电";
}
CtuTaskBase GetChargeTask()
{
var chargeStation = PosInfos.GetAllPosInfos().Find(posInfo =>
{
if (posInfo.Name.StartsWith("ChargeStation"))
{
var thisStationUsedCtu = CTUManager.GetEnabledCTUs().Find(otherCtu => otherCtu.CtuTask != null && otherCtu.CtuTask is ChargeTask && otherCtu.CtuTask.DstName.Equals(posInfo.Name));
if (thisStationUsedCtu == null)
{
return true;
}
}
return false;
});
if (chargeStation != null)
{
return new ChargeTask(ctu, chargeStation.Name);
}
else
{
MoveInfo.Info($"CTU [{ctu.Name}] 到达强制充电值,但未找到可用充电位");
}
return null;
}
public override void Excute()
{
if (ctu.AllBasketIsEmpty())
{
var chargeTask = GetChargeTask();
if (chargeTask != null)
{
ctu.CtuTask = chargeTask;
return;
}
}
switch (MoveInfo.MoveStep)
{
case RunStep.Wait:
MoveInfo.Info($"自动充电任务取出背篓料箱任务处理中");
CtuTaskBase putBoxTask = null;
putBoxTask = OutTaskHelper.GetPutBoxTask(ctu);
if (putBoxTask == null)
{
putBoxTask = OutTaskHelper.GetPutBoxToLineTask(ctu);
if (putBoxTask != null)
{
ctu.CtuTask = putBoxTask;
return;
}
}
if (putBoxTask != null)
{
ctu.CtuTask = putBoxTask;
return;
}
break;
case RunStep.CtuTask_ProcessFinished:
break;
}
}
}
}