Agv.cs
10 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
using XingYe_ACS.Business;
using PropertyChanged;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace XingYe_ACS.BaseStruct
{
[ImplementPropertyChanged]
public class Agv : IComparable
{
/// <summary>
/// 电量排序
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public int CompareTo(object obj)
{
Agv agv = obj as Agv;
if (agv == null) throw new NotImplementedException();
return currentCharge.CompareTo(agv.currentCharge);
}
/// <summary>
/// 小车编号
/// </summary>
public string strAgvNo { get; set; }
/// <summary>
/// 小车当前所在区域
/// </summary>
public string agvAreaType { get; set; }
/// <summary>
/// 小车当前码值
/// </summary>
public string strBarcode { get; set; }
/// <summary>
/// 小车状态
/// </summary>
public EnumMsg.State agvState { get; set; }
/// <summary>
/// 小车顶升状态
/// </summary>
public EnumMsg.HeightState heightState { get; set; }
/// <summary>
/// 小车车头方向
/// </summary>
public EnumMsg.OriType agvOri { get; set; }
/// <summary>
/// 小车转盘方向
/// </summary>
public EnumMsg.OriType dialOri { get; set; }
/// <summary>
/// 小车当前的电量
/// </summary>
public float currentCharge { get; set; }
/// <summary>
/// 小车充电时间的时间
/// </summary>
public DateTime chargeTime { get; set; }
/// <summary>
/// 小车充电时间的时间
/// </summary>
public DateTime taskTime { get; set; }
/// <summary>
/// 小车匹配的充电桩
/// </summary>
public string strChooseStation { get; set; }
/// <summary>
/// 小车当前是否可用
/// </summary>
public bool isEnable { get; set; }
/// <summary>
/// 小车当前是否在线
/// </summary>
public bool isOnline { get; set; }
/// <summary>
/// 计算小车多久未发送心跳
/// </summary>
public void HeartStop()
{
float Sec = 0;
TimeSpan tsHeart = new TimeSpan(agvHeart.Ticks);
TimeSpan tsNow = new TimeSpan(DateTime.Now.Ticks);
TimeSpan tsDurat = tsNow.Subtract(tsHeart).Duration();
float S = tsDurat.Seconds;
Sec = tsDurat.Hours * 3600 + tsDurat.Minutes * 60 + S;
if (Sec > 30)//大于10S,判定离线
{
isOnline = false;
if (App.offAgvNo.Contains(strAgvNo))
{
App.offAgvNo.Remove(strAgvNo);
}
if (isEnable)
{
agvBground = EnumMsg.AgvBground.Gray;//小车未报心跳
if (agvState != EnumMsg.State.离线)
{
string errState = "AGV离线";
App.ExFile.MessageBusinessErr("BusinessAgvState", strAgvNo + "= =" + errState + "= =" + agvState);
agvState = EnumMsg.State.离线;
Agv agv = App.AgvList.Find(a => a.strAgvNo == strAgvNo);
UpdateManage.UpdateAgvMsg(agv);
UpdateManage.InsertAgvState(agv, 15);
}
}
else
{
return;
}
Config_ClientControl clientControl = App.ClientWork.Find(a => a.strAgvNo == strAgvNo);
if (clientControl == null) return;
if (clientControl.isDoing)
{
clientControl.isDoing = false;
App.ExFile.MessageError("ClientIp", "==" + clientControl.strAgvNo + "==" + "线程没正确释放此小车IP控制");
}
}
else
{
if (!Enum.IsDefined(typeof(EnumMsg.State), (int)agvState) || agvState == EnumMsg.State.离线)
{
string errState = "AGV上报自身状态";
App.ExFile.MessageBusinessErr("BusinessAgvState", strAgvNo + "= =" + errState + "= =" + agvState);
}
isOnline = true;
}
}
/// <summary>
/// 小车是否载货
/// </summary>
public bool isCarry { get; set; }
/// <summary>
/// 输送线标识
/// </summary>
public int flag;
/// <summary>
/// 小车发送最新心跳的时间
/// </summary>
public DateTime agvHeart { get; set; }
/// <summary>
/// 小车当前的执行的任务
/// </summary>
public FTask agvTask { get; set; }
/// <summary>
/// 小车当前的界面显示的背景色
/// </summary>
public EnumMsg.AgvBground agvBground { get; set; }
/// <summary>
/// 小车停止原因
/// </summary>
public string strStopReason { get; set; }
/// <summary>
/// 小车异常信息
/// </summary>
public string strAgvError { get; set; }
/// <summary>
/// agv里程
/// </summary>
public int agvMilage { get; set; }
/// <summary>
/// AGV群组
/// </summary>
public string agvGroup { get; set; }
/// <summary>
/// AGV所在地图
/// </summary>
public string agvMap { get; set; }
/// <summary>
/// AGV开始充电电量
/// </summary>
public float startCharges { get; set; }
/// <summary>
/// 增删改
/// </summary>
public string type { get; set; }
/// <summary>
/// 等待时间
/// </summary>
public string waitTime { get; set; }
public int intRunDistance { get; set; }
/// <summary>
/// 下个路径点
/// </summary>
public string nextPoint { get; set; }
/// <summary>
/// 上一路径点
/// </summary>
public string beforePoint { get; set; }
/// <summary>
/// 两点之间的距离
/// </summary>
public int pointLength { get; set; }
/// <summary>
/// agvIP地址
/// </summary>
public string agvIP { get; set; }
/// <summary>
/// agv异常编码
/// </summary>
public int agvErrorCode { get; set; }
/// <summary>
/// 记录充电日志时间
/// </summary>
public DateTime logTime { get; set; }
/// <summary>
/// 车速[mm/min]
/// </summary>
public float rSpeed { get; set; }
/// <summary>
/// 电压
/// </summary>
public float rBatVoltage { get; set; }
/// <summary>
/// 电流
/// </summary>
public float rBatCurrent { get; set; }
/// <summary>
/// 电池健康状态
/// </summary>
public short iBatPowerSupplyHealth { get; set; }
}
/// <summary>
/// 关机AGV
/// </summary>
public class offAgv
{
/// <summary>
/// 关机类型1:整体关机;2:指定AGV关机
/// </summary>
public int offType { get; set; }
/// <summary>
/// 关机AGV编号 整体关机不做判断
/// </summary>
public string agvNo { get; set; }
}
/// <summary>
/// 单步控制AGV
/// </summary>
public class LinkAgv
{
#region 单步控制agv
/// <summary>
/// 控制AGV编号
/// </summary>
public string agvNo { get; set; }
/// <summary>
/// 控制AGV动作
/// </summary>
public int action { get; set; }
/// <summary>
/// 连接状态 true开启连接,false关闭连接
/// </summary>
public bool link { get; set; }
#endregion
}
public class s7AGV
{
/// <summary>
/// 状态
/// </summary>
public short iStatus { get; set; }
/// <summary>
/// 错误
/// </summary>
public short iAlarm { get; set; }
/// <summary>
/// 错误信息
/// </summary>
public short iAlarmMsg { get; set; }
/// <summary>
/// 当前坐标
/// </summary>
public short iCurrentPose { get; set; }
/// <summary>
/// 前一坐标
/// </summary>
public short iBeforePose { get; set; }
/// <summary>
/// 后一坐标
/// </summary>
public short iAfterPose { get; set; }
/// <summary>
/// 状态[0:空闲1:有任务2:充电]
/// </summary>
public short iTaskStatus { get; set; }
/// <summary>
/// 车速[mm/min]
/// </summary>
public float rSpeed { get; set; }
/// <summary>
/// 电压
/// </summary>
public float rBatVoltage { get; set; }
/// <summary>
/// 电流
/// </summary>
public float rBatCurrent { get; set; }
/// <summary>
/// 电池电量
/// </summary>
public short iBatteryCapacity { get; set; }
/// <summary>
/// 供能状态[0:功能状态未知1:充电中2:前往充电点3:没在充电4:电池满电量]
/// </summary>
public short iBatPowerSupplyStatus { get; set; }
/// <summary>
/// 电池健康状态
/// </summary>
public short iBatPowerSupplyHealth { get; set; }
/// <summary>
/// 当前小车托盘状态[0:无托盘1:下料托盘2:上料托盘]
/// </summary>
public short iActProductState { get; set; }
}
}