RealtimePkg.cs
3.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mushiny.Model
{
/// <summary>
/// 实时数据包:
/// (登录完成后,从未检测到二维码到检测到二维码的时刻发一次, 正常情况下如果停在二维码上则每隔0.5秒发一次)
/// </summary>
internal class RealtimePkg:PkgData
{
public RealtimePkg() : base()
{
}
/// <summary>
/// 位置
/// </summary>
public Location Location { get; set; }
public byte CurState { get; set; }
/// <summary>
/// 直行方向坐标
/// 单位:mm
/// </summary>
public float StraightDirectionCoordinates { get; set; }
/// <summary>
/// 当前角度
/// 单位:°
/// </summary>
public float CurAngle { get; set; }
/// <summary>
/// 惯导角度
/// 单位:°
/// </summary>
public float InertialNavigationAngle { get;set; }
/// <summary>
/// 编码器角度
/// 单位:°
/// </summary>
public float EncoderAngle { get; set; }
/// <summary>
/// 当前高度
/// </summary>
public short CurHeight { get; set; }
/// <summary>
/// 传感器状态标志
/// </summary>
public byte[] SensorStatusFlags { get; set; }
public override bool Parse(byte[] bytes)
{
bool result = false;
try
{
if (base.Parse(bytes))
{
if (bytes.Length < 49)
{
return false;
}
Location = new Location();
Location.AddrCode = Common.ConvertToUInt(Common.GetSubBytes(bytes, 12, 4));
Location.AddrShiftX = Common.ConvertToUshort(Common.GetSubBytes(bytes, 16, 2));
Location.AddrShiftY = Common.ConvertToUshort(Common.GetSubBytes(bytes, 18, 2));
Location.AddrShiftTheta = Common.ConvertToFloat(Common.GetSubBytes(bytes, 20, 4));
CurState = Common.GetSubBytes(bytes, 24, 1)[0];
StraightDirectionCoordinates = Common.ConvertToFloat(Common.GetSubBytes(bytes, 25, 4));
CurAngle = Common.ConvertToFloat(Common.GetSubBytes(bytes, 29, 4));
InertialNavigationAngle= Common.ConvertToFloat(Common.GetSubBytes(bytes, 33, 4));
EncoderAngle= Common.ConvertToFloat(Common.GetSubBytes(bytes, 37, 4));
CurHeight = Common.ConvertToShort(Common.GetSubBytes(bytes, 41, 2));
SensorStatusFlags = Common.GetSubBytes(bytes, 43, 4);
result = true;
}
else
{
result = false;
}
}
catch (Exception ex)
{
throw ex;
}
return result;
}
}
}