CTURealtimeInfo.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
136
137
138
139
140
141
142
143
144
145
146
147
148
using Mushiny;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CtuDeviceLib
{
/// <summary>
/// 运行中的CTU实时信息
/// </summary>
public class CTURealtimeInfo
{
public CTURealtimeInfo(CTU ctu)
{
Ctu = ctu;
}
/// <summary>
/// 当前Ctu
/// </summary>
public CTU Ctu { get; set; }
/// <summary>
/// 当前移动状态
/// </summary>
public CtuMoveState MoveState {
get;
set;
}
/// <summary>
/// 目标信息
/// </summary>
public PosInfo DstPosInfo { get; set; }
/// <summary>
/// 路线中的Ctu名称
/// </summary>
public List<string> CtusInPath { get; private set; } = new List<string>();
/// <summary>
/// 设置障碍点信息-得出路上ctu
/// </summary>
/// <param name="pointCodes"></param>
public void SetBlockedPoints(List<PointCode> pointCodes)
{
if (pointCodes == null || pointCodes.Count == 0)
{
CtusInPath.Clear();
return;
}
CtusInPath.Clear();
var ctus = MushinyManager.GetCTUBean().GetCTUs();
foreach (var ctu in ctus)
{
if (ctu.Name.Equals(Ctu.Name))
{
continue;
}
var find = pointCodes.Find(s => s.Id == ctu.CurLandMark);
if (find != null)
{
if (!CtusInPath.Contains(ctu.Name))
{
CtusInPath.Add(ctu.Name);
}
}
}
}
/// <summary>
/// 当前所在的路线
/// </summary>
public PathWay CurPathWay
{
get
{
if (Ctu == null) return null;
if (Ctu.CurLandMark == 0) return null;
return MushinyManager.GetCTUBean()?.GetPathWay(Ctu.CurLandMark);
}
}
public PathWay NextPathWay { get;private set; }
public void SetNextPathWay(List<PointCode> pointCodes)
{
if (pointCodes == null)
{
NextPathWay=null;
return;
}
if (pointCodes.Count == 0)
{
NextPathWay = null;
return;
}
if (pointCodes.Count == 1)
{
NextPathWay = MushinyManager.GetCTUBean()?.GetPathWay(pointCodes[0].Id);
}
else
{
NextPathWay = MushinyManager.GetCTUBean()?.GetPathWay(pointCodes[0].Id, pointCodes[1].Id);
}
}
/// <summary>
/// 优先级
/// </summary>
public int Priority
{
get
{
int idx = CTUManager.CTUs.IndexOf(Ctu);
var execTasks = TaskManager.GetAllTasks()?.FindAll(s => Ctu.Name.Equals(s.CtuName));
int taskCnt = execTasks?.Count ?? 0;
var ppType = MushinyManager.GetCTUBean()?.GetPointCode(Ctu.CurLandMark);
int inLane = 0;
if (ppType != null)
{
if (ppType.Type == LandmarkType.Shelves)
{
inLane = 2;
}
if (ppType.Type == LandmarkType.Docking_0 || ppType.Type == LandmarkType.Docking_90
|| ppType.Type == LandmarkType.Docking_180 || ppType.Type == LandmarkType.Docking_270)
{
inLane = 1;
}
}
return idx + taskCnt + inLane;
}
}
}
public enum CtuMoveState
{
空闲,
规划中,
规划失败,
避让中,
规划成功,
移动中,
等待路径释放,
重规划失败
}
}