StatusDataPkg.cs
3.0 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
using Mushiny.Model.Pkg;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mushiny.Model
{
/// <summary>
/// 状态数据包:周期性状态数据包 (每隔10s发一次)
/// </summary>
internal class StatusDataPkg:PkgData
{
public StatusDataPkg() : base()
{
}
public Battery Battery { get; set; }
public Temp Temp { get; set; }
public byte[] BootTime { get; set; }
public byte[] LeftMotorFaultFlag { get; set;}
public byte[] RightMotorFaultFlag { get;set;}
public byte[] UpdownMotorFaultFlag { get; set;}
public byte[] InoutMotorFaultFlag { get; set;}
public byte[] MiddleMotorFaultFlag { get; set;}
public byte[] FaultFlag { get; set;}
public byte[] BatteryCurrent { get; set; }
public byte[] Reserved { get; set;}
public override bool Parse(byte[] bytes)
{
bool result = false;
try
{
if (base.Parse(bytes))
{
if (bytes.Length < 48)
{
return false;
}
Battery = new Battery();
Battery.Voltage = Common.ConvertToUshort(Common.GetSubBytes(bytes, 12, 2));
Battery.SOC = Common.GetSubBytes(bytes, 14, 1)[0];
Battery.SOH = Common.GetSubBytes(bytes, 15, 1)[0];
Battery.FaultFlag = Common.GetSubBytes(bytes, 16, 1)[0];
Battery.Tempture = Common.GetSubBytes(bytes, 17, 1)[0];
Temp = new Temp();
Temp.ChassisTemp = Common.GetSubBytes(bytes,18, 1)[0];
Temp.LeftmotorTemp= Common.GetSubBytes(bytes, 19, 1)[0];
Temp.RightmotorTemp= Common.GetSubBytes(bytes,20, 1)[0];
Temp.UpdownMotorTemp= Common.GetSubBytes(bytes,21, 1)[0];
Temp.InoutMotorTemp= Common.GetSubBytes(bytes,22, 1)[0];
Temp.MiddleMotorTemp= Common.GetSubBytes(bytes,23, 1)[0];
BootTime = Common.GetSubBytes(bytes, 24, 4);
LeftMotorFaultFlag = Common.GetSubBytes(bytes, 28, 2);
RightMotorFaultFlag = Common.GetSubBytes(bytes, 30, 2);
UpdownMotorFaultFlag= Common.GetSubBytes(bytes,32, 2);
InoutMotorFaultFlag = Common.GetSubBytes(bytes, 34, 2);
MiddleMotorFaultFlag=Common.GetSubBytes(bytes,36,2);
FaultFlag = Common.GetSubBytes(bytes, 38, 4);
BatteryCurrent = Common.GetSubBytes(bytes, 42, 2);
Reserved = Common.GetSubBytes(bytes,44,2);
result = true;
}
else
{
result = false;
}
}
catch (Exception ex)
{
throw ex;
}
return result;
}
}
}