JobParam.cs
4.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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
using System;
using System.Collections.Generic;
using System.Text;
namespace DeviceLib.Model.AGV
{
/// <summary>
/// Job运行参数
/// </summary>
public class JobParam
{
/// <summary>
/// 订单编号
/// </summary>
public string OrderId { get; set; } = "";
public string RobotIp { get; set; }
/// <summary>
/// Job的运行类型
/// </summary>
public JobGoal JobGoal { get; set; }
/// <summary>
/// 满料箱编号
/// </summary>
public string FullBoxId { get; set; } = "";
/// <summary>
/// 回调Job
/// </summary>
public JobCallBack CallbackJob;
/// <summary>
/// 取料动作
/// </summary>
public JobAction GetAction = new JobAction();
/// <summary>
/// 送料动作
/// </summary>
public JobAction SendAction = new JobAction();
/// <summary>
/// 返还动作
/// </summary>
public JobAction ReturnAction = new JobAction();
public void SetAction(string action="000000")
{
char[] actions = action.ToCharArray();
GetAction.SetAction(int.Parse(action[0].ToString()), int.Parse(action[1].ToString()));
SendAction.SetAction(int.Parse(action[2].ToString()), int.Parse(action[3].ToString()));
ReturnAction.SetAction(int.Parse(action[4].ToString()), int.Parse(action[5].ToString()));
}
/// <summary>
/// 当前动作
/// </summary>
public JobAction CurAction
{
get
{
if (JobGoal == JobGoal.Send)
{
return SendAction;
}
else if (JobGoal == JobGoal.Get)
{
return GetAction;
}
else if (JobGoal == JobGoal.Return)
{
return ReturnAction;
}
else
return new JobAction();
}
}
/// <summary>
///线体点位
/// </summary>
public ClientNode LineNode { get; set; }
/// <summary>
/// 所有起始点
/// </summary>
public List<NodeJobState> SrcNodes { get; set; }
/// <summary>
/// 上一目标点
/// </summary>
public NodeJobState PreDstNode { get; set; }
public MissionState MissionState { get; set; } = new MissionState();
/// <summary>
/// 料架返还点
/// 默认为null,不使用
///
/// </summary>
public NodeJobState ReturnDstNode { get; set; } = null;
/// <summary>
/// 当前目标地点
/// </summary>
public NodeJobState CurDstNode
{
get
{
if (JobGoal == JobGoal.Send)
{
return TargetNodes.Find(s => s.Finished.Equals(false));
}
else if (JobGoal == JobGoal.Get)
{
return SrcNodes.Find(s => s.Finished.Equals(false));
}
else if (JobGoal == JobGoal.Return)
{
return ReturnDstNode;
}
else
return TargetNodes[0];
}
}
/// <summary>
/// 是否有下一目的地
/// </summary>
/// <returns></returns>
public bool HasNextDst()
{
if (JobGoal == JobGoal.Send)
{
return TargetNodes.Find(s => s.Finished.Equals(false)) != null;
}
else if (JobGoal == JobGoal.Get)
{
return SrcNodes.Find(s => s.Finished.Equals(false)) != null;
}
else if (JobGoal == JobGoal.Return)
{
return false;
}
return false;
}
/// <summary>
/// 所有任务点
/// </summary>
public List<NodeJobState> TargetNodes { get; set; }
/// <summary>
/// 料车信息
/// </summary>
public Shelf Shelf { get; set; }
public JobParam(List<NodeJobState> sourceNodes, List<NodeJobState> targetNodes, string orderId = null, Shelf shelf = null)
{
SrcNodes = sourceNodes;
TargetNodes = targetNodes;
Shelf = shelf;
this.OrderId = orderId;
}
public void SetCurNodeFinished()
{
PreDstNode = CurDstNode;
CurDstNode.Finished = true;
}
}
public class JobCallBack
{
public Type Type { get; set; }
public Job Job { get; set; }
public RunStep RunStep { get; set; }
public JobCallBack(Type type, RunStep step)
{
this.Type = type;
this.RunStep = step;
}
}
}