VdaSegmentedPathCache.cs
4.58 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 Rcs.Domain.Enums;
namespace Rcs.Application.Services.PathFind.Models;
/// <summary>
/// VDA5050分段路径缓存
/// @author zzy
/// 2026-02-05 更新:支持两层切割结构
/// 2026-02-06 更新:支持网络动作执行状态跟踪
/// </summary>
public class VdaSegmentedPathCache
{
public Guid TaskId { get; set; }
public string TaskCode { get; set; } = string.Empty;
public Guid RobotId { get; set; }
public Guid MapId { get; set; }
public string MapCode { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; }
/// <summary>
/// 当前路口段索引(第一层)
/// </summary>
public int CurrentJunctionIndex { get; set; }
/// <summary>
/// 当前资源段索引(第二层)
/// </summary>
public int CurrentResourceIndex { get; set; }
/// <summary>
/// 路口切割后的段落列表
/// </summary>
public List<VdaJunctionSegmentCache> JunctionSegments { get; set; } = new();
/// <summary>
/// 当前活跃的网络动作上下文ID(用于跟踪正在执行的网络动作)
/// @author zzy
/// </summary>
public string? ActiveNetActionContextId { get; set; }
/// <summary>
/// 网络动作执行状态
/// @author zzy
/// </summary>
public NetActionExecutionStatus? NetActionStatus { get; set; }
/// <summary>
/// 是否正在等待网络动作完成
/// @author zzy
/// </summary>
public bool IsWaitingForNetAction =>
NetActionStatus == NetActionExecutionStatus.Executing ||
NetActionStatus == NetActionExecutionStatus.WaitingAsyncResponse;
}
/// <summary>
/// 路口切割段缓存(第一层)
/// @author zzy
/// </summary>
public class VdaJunctionSegmentCache
{
/// <summary>
/// 资源/模板切割后的子段列表
/// </summary>
public List<VdaSegmentCacheItem> ResourceSegments { get; set; } = new();
}
/// <summary>
/// VDA5050分段缓存项(第二层)
/// @author zzy
/// 2026-02-06 更新:添加网络动作相关字段
/// </summary>
public class VdaSegmentCacheItem
{
public bool IsSent { get; set; } = false;
public List<PathSegmentWithCode> Segments { get; set; } = new();
/// <summary>
/// 终点网络动作上下文ID列表(用于关联网络动作执行状态)
/// @author zzy
/// </summary>
public List<string> EndNodeNetActionContextIds { get; set; } = new();
/// <summary>
/// 起点网络动作上下文ID列表(用于关联网络动作执行状态)
/// @author zzy
/// </summary>
public List<string> StartNodeNetActionContextIds { get; set; } = new();
/// <summary>
/// 是否已执行终点网络动作
/// @author zzy
/// </summary>
public bool IsEndNodeNetActionExecuted { get; set; } = false;
/// <summary>
/// 是否已执行起点网络动作
/// @author zzy
/// </summary>
public bool IsStartNodeNetActionExecuted { get; set; } = false;
/// <summary>
/// 获取该段的终点网络动作ID列表(仅返回动作申请类型的网络动作)
/// @author zzy
/// 2026-02-06 更新:从字典Keys获取,过滤只返回ActionType为Apply的网络动作
/// </summary>
public List<Guid> GetEndNodeNetActionIds()
{
if (Segments.Count == 0)
{
return new List<Guid>();
}
var lastSegment = Segments.Last();
if (lastSegment.EndNodeNetActionTypes == null || lastSegment.EndNodeNetActionTypes.Count == 0)
{
return new List<Guid>();
}
// 从字典Keys中获取ActionType为Apply的网络动作ID
return lastSegment.EndNodeNetActionTypes
.Where(kv => kv.Value == ActionType.Apply)
.Select(kv => kv.Key)
.ToList();
}
/// <summary>
/// 获取该段的起点网络动作ID列表(仅返回动作申请类型的网络动作)
/// @author zzy
/// 2026-02-06 更新:从字典Keys获取,过滤只返回ActionType为Apply的网络动作
/// </summary>
public List<Guid> GetStartNodeNetActionIds()
{
if (Segments.Count == 0)
{
return new List<Guid>();
}
var firstSegment = Segments.First();
if (firstSegment.StartNodeNetActionTypes == null || firstSegment.StartNodeNetActionTypes.Count == 0)
{
return new List<Guid>();
}
// 从字典Keys中获取ActionType为Apply的网络动作ID
return firstSegment.StartNodeNetActionTypes
.Where(kv => kv.Value == ActionType.Apply)
.Select(kv => kv.Key)
.ToList();
}
}