Base_Agv.cs
20.8 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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
using RCS.Model.Comm;
using RCS.Model.Entity.PrimaryKey;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.InteropServices.JavaScript;
using System.Text.Json.Serialization;
using static RCS.Model.Comm.EnumMsg;
namespace RCS.Model.Entity
{
[Table("t_base_agv")]
public class Base_Agv : IdEntity, IComparable
{
#region 基础实体类
#region AGV上报信息
/// <summary>
/// AGV上报的地标二维码
/// </summary>
[NotMapped]
[Description("小车扫描二维码")]
public string AGVBarcode
{
get => agvBarcode;
set
{
agvBarcode = value; NotifyPropertyChanged();
}
}
/// <summary>
/// AGV上报的推断二维码
/// </summary>
[NotMapped]
[Description("小车推测地标")]
public ushort RCSBarcode
{
get => rcsBarcode;
set
{
rcsBarcode = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 小车当前的电量
/// </summary>
[Description("小车电量")]
public byte Voltage
{
get => voltage;
set
{
voltage = value; NotifyPropertyChanged();
}
}
/// <summary>
/// 小车状态
/// </summary>
[NotMapped]
[Description("小车状态")]
public EnumMsg.AGVState AgvState
{
get
{
return agvState;
}
set
{
agvState = value; NotifyPropertyChanged();
}
}
/// <summary>
/// 小车车头方向
/// </summary>
[NotMapped]
[Description("车头方向")]
public EnumMsg.Direction AgvDirection
{
get
{
if (AgvNo == "A003")
{
switch (agvDirection)
{
case Direction.X正方向:
return Direction.X负方向;
case Direction.Y正方向:
return Direction.Y负方向;
case Direction.X负方向:
return Direction.X正方向;
case Direction.Y负方向:
return Direction.Y正方向;
default:
return Direction.无方向;
};
}
else {
switch (agvDirection)
{
case Direction.X正方向:
return Direction.Y负方向;
case Direction.Y正方向:
return Direction.X正方向;
case Direction.X负方向:
return Direction.Y正方向;
case Direction.Y负方向:
return Direction.X正方向;
default:
return Direction.无方向;
};
}
}
set
{
agvDirection = value;
NotifyPropertyChanged();
NotifyPropertyChanged("AgvDirectionByMap");
}
}
/// <summary>
/// 基于地图的车头方向
/// </summary>
[NotMapped]
[Description("基于地图的车头方向")]
public EnumMsg.Direction AgvDirectionByMap
{
get
{
return agvDirection;
}
}
/// <summary>
/// 小车转盘方向
/// </summary>
[NotMapped]
[Description("转盘方向")]
public EnumMsg.Direction DialDirection
{
get
{
var temp = 0;
//保持与车头方向相同
if (Math.Abs(dialAngle - 0) <= 3)
{
temp = (int)agvDirection;
}
else if (Math.Abs(dialAngle - 90) <= 3)
{
temp = agvDirection - 1 == 0 ? 4 : (int)agvDirection - 1;
}
else if (Math.Abs(dialAngle - 180) <= 3)
{
temp = ((int)agvDirection + 2) % 4;
}
else if (Math.Abs(dialAngle - 0) <= 3)
{
dialDirection = agvDirection - 1;
}
dialDirection = (EnumMsg.Direction)temp;
return dialDirection;
}
set
{
dialDirection = value; NotifyPropertyChanged();
}
}
/// <summary>
/// 小车转盘角度
/// </summary>
[NotMapped]
[Description("转盘角度")]
public short DialAngle
{
get => dialAngle;
set
{
dialAngle = value; NotifyPropertyChanged();
}
}
/// <summary>
/// 小车顶升状态
/// </summary>
[Description("顶升方向")]
public EnumMsg.HeightState HeightState
{
get => heightState;
set
{
heightState = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 错误代码
/// </summary>
//[NotMapped]
//public BitArray ErrorList
//{
// get => errorList;
// set
// {
// errorList = value;
// NotifyPropertyChanged();
// }
//}
[NotMapped]
[Description("错误代码")]
public AGVErrorCode ErrorList
{
get => errorList;
set
{
errorList = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 行驶距离
/// </summary>
[NotMapped]
[Description("行驶距离")]
public int RunDistance
{
get => runDistance;
set
{
runDistance = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 动作的状态
/// </summary>
[NotMapped]
[Description("动作状态")]
public EnumMsg.ActState ActState
{
get => actState;
set
{
actState = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// X坐标
/// </summary>
[NotMapped]
[Description("X坐标")]
public int XLength
{
get => xLength;
set
{
xLength = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// Y坐标
/// </summary>
[NotMapped]
[Description("Y坐标")]
public int YLength
{
get => yLength;
set
{
yLength = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 位置可信度
/// </summary>
[NotMapped]
[Description("置信度")]
public byte Reliability
{
get => reliability;
set
{
reliability = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 车头角度
/// </summary>
[NotMapped]
[Description("车头角度")]
public short Angle
{
get => angle;
set
{
angle = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 顶升高度
/// </summary>
[NotMapped]
[Description("顶升高度")]
public ushort AgvHeight
{
get => agvHeight;
set
{
agvHeight = value;
NotifyPropertyChanged();
}
}
///// <summary>
///// AGV货物状态,用于工装为滚筒AGV
///// </summary>
//[NotMapped]
//[Description("货物状态")]
//public EnumMsg.InStock InStock
//{
// get => inStock;
// set
// {
// inStock = value;
// NotifyPropertyChanged();
// }
//}
/// <summary>
/// AGV滚筒状态,用于工装为滚筒AGV
/// </summary>
[NotMapped]
[Description("滚筒状态")]
public EnumMsg.RollerState RollerState
{
get => rollerState;
set
{
rollerState = value;
NotifyPropertyChanged();
}
}
#endregion
#region 数据库操作数据
/// <summary>
/// 小车编号
/// </summary>
[Description("Agv编号")]
[JsonPropertyOrder(1)]
public string AgvNo
{
get => agvNo;
set
{
agvNo = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 小车类型
/// </summary>
public EnumMsg.AgvType AgvType
{
get => agvType;
set
{
agvType = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 导航方式
/// </summary>
[NotMapped]
public AGVNavigationMode AGVNavigationMode { get; set; }
/// <summary>
/// AGV群组
/// </summary>
public string Group
{
get => group;
set
{
group = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// RCS上一个地标
/// </summary>
[Description("RCS上一个地标")]
[JsonPropertyOrder(2)]
public string FrontBarcode { get; set; }
/// <summary>
/// RCS地标
/// </summary>
[Description("RCS地标")]
[JsonPropertyOrder(3)]
public string Barcode
{
get => barcode;
set
{
barcode = value; NotifyPropertyChanged();
}
}
/// <summary>
/// AGV车头长度
/// </summary>
public int HeadLength
{
get => headLength;
set
{
headLength = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// AGV车尾长度
/// </summary>
public int TailLength
{
get => tailLength;
set
{
tailLength = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// AGV车宽
/// </summary>
public int Width
{
get => width;
set
{
width = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// AGV开始充电电量
/// </summary>
public int StartVoltage
{
get => startVoltage;
set
{
startVoltage = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 小车匹配的充电桩
/// </summary>
[NotMapped]
public Base_Station? LockStation
{
get => lockStation;
set
{
lockStation = value;
chooseStation = lockStation?.Name;
NotifyPropertyChanged();
}
}
public string? ChooseStation
{
get => chooseStation;
set
{
chooseStation = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 车配置的充电站台
/// </summary>
public string ChargeStation
{
get => chargeStation;
set
{
chargeStation = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 小车当前是否可用
/// </summary>
public bool IsEnable
{
get => isEnable;
set
{
isEnable = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 小车是否载货
/// </summary>
public bool IsCarry
{
get => isOnline;
set
{
isOnline = value;
NotifyPropertyChanged();
}
}
private DateTime heart;
/// <summary>
/// 小车发送最新心跳的时间
/// </summary>
public DateTime Heart
{
get { return heart; }
set
{
heart = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// agv当前任务里程
/// </summary>
public int Milage
{
get => milage;
set
{
milage = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 小车异常信息
/// </summary>
public string Error
{
get => error;
set
{
error = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 小车异常时间
/// </summary>
public DateTime? ErrorTime
{
get => errorTime;
set
{
errorTime = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// AGV所在地图
/// </summary>
[Description("AGV所在地图")]
public string CurrMap
{
get => currMap;
set
{
currMap = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// agvIP地址
/// </summary>
public string IP
{
get => ip;
set
{
ip = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 设备序列号
/// </summary>
public string SN { get; set; }
[NotMapped]
public ActionType LastActionType { get; set; }
#endregion 数据库操作数据
#region 缓存数据
/// <summary>
/// 小车动作
/// </summary>
[NotMapped]
[Description("小车动作")]
[JsonPropertyOrder(4)]
public EnumMsg.ActionType Action
{
get => action;
set
{
action = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 传感器状态
/// </summary>
[NotMapped]
public SensorStatus SensorStatus
{
get => sensorStatus;
set { sensorStatus = value; NotifyPropertyChanged(); }
}
/// <summary>
/// 小车空闲时间
/// </summary>
[NotMapped]
public DateTime FreeTime
{
get => freeTime;
set
{
freeTime = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 小车充电时间
/// </summary>
[NotMapped]
public DateTime ChargeTime
{
get => chargeTime;
set
{
chargeTime = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 小车当前是否在线
/// </summary>
[NotMapped]
public bool IsOnline
{
get => isOnline;
set
{
isOnline = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// 小车当前的执行的任务
/// </summary>
[NotMapped]
public Base_Task? AgvTask { get; set; }
/// <summary>
/// 小车停止原因
/// </summary>
[NotMapped]
public string StopReason
{
get => stopReason;
set
{
stopReason = value;
NotifyPropertyChanged();
}
}
/// <summary>
/// AGV路径点
/// </summary>
[NotMapped]
public List<Base_PathPoint> PathPointList { get; set; } = new List<Base_PathPoint>();
/// <summary>
/// 获取充电桩名称
/// </summary>
[NotMapped]
public string ChargeName
{
get; set;
}
/// <summary>
/// WEB操作类型(增删改)
/// </summary>
[NotMapped]
public string Type { get; set; }
/// <summary>
/// 速度(毫米)
/// </summary>
[NotMapped]
public byte Speed { get; set; }
/// <summary>
/// 雷达状态
/// </summary>
[NotMapped]
public byte RadarStatus { get; set; }
/// <summary>
/// 雷达区域
/// </summary>
[NotMapped]
public byte RadarArea { get; set; }
/// <summary>
/// 载重
/// </summary>
[NotMapped]
public float LoadWeight { get; set; }
[NotMapped]
public uint SubTaskNo { get; set; }
#region 变量
private string barcode;
private string agvBarcode;
private byte voltage;
private EnumMsg.AGVState agvState;
private EnumMsg.Direction agvDirection;
private EnumMsg.Direction dialDirection;
private short dialAngle;
private EnumMsg.HeightState heightState;
private EnumMsg.ActState actState;
private byte reliability;
private short angle;
private ushort agvHeight;
private EnumMsg.InStock inStock;
private Base_Station? lockStation;
private string? chooseStation;
private bool isEnable;
private string error;
private string stopReason = "";
private int xLength;
private int yLength;
private ushort rcsBarcode;
private string agvNo;
private bool isOnline;
private string ip;
private DateTime freeTime;
private DateTime? errorTime;
private string currMap;
private DateTime chargeTime;
private int startVoltage;
private int tailLength;
private int headLength;
private string group;
private EnumMsg.RollerState rollerState;
//private BitArray errorList;
private AGVErrorCode errorList;
private int runDistance;
private EnumMsg.AgvType agvType;
private int milage;
private EnumMsg.ActionType action;
private int width;
private string chargeStation;
private SensorStatus sensorStatus;
#endregion
#endregion 缓存数据
/// <summary>
/// rcs发送给agv的信息
/// </summary>
[NotMapped]
public RCSToAGV RCSToAGV { get; set; }
#endregion 基础实体类
/// <summary>
/// 电量排序
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public int CompareTo(object? obj)
{
var agv = obj as Base_Agv;
if (agv == null)
{
throw new NotImplementedException();
}
//return AgvVoltage.CompareTo(agv.AgvVoltage);
return AgvNo.CompareTo(agv.AgvNo);
}
/// <summary>
/// 计算两个角度的差值
/// </summary>
/// <param name="ori1">方向1</param>
/// <param name="ori2"></param>
/// <param name="accuracy">精度</param>
/// <returns></returns>
public static int GetDirectionDifference(int ori1, int ori2)
{
var res = ori1 + ori2;
if (res < 0)
res = 4 - res % 4;
else
res = res % 4 == 0 ? 4 : res % 4;
return res;
}
}
}