LoginDataPkg.cs
7.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
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
using Mushiny.Model.Pkg;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
namespace Mushiny.Model
{
/// <summary>
/// AGV->RCS
/// 登录数据包:上电后主动发送,或者受到重新登陆命令包(也即激活包)后继续发送
/// </summary>
internal class LoginDataPkg : PkgData
{
public LoginDataPkg() : base()
{
}
/// <summary>
/// 车型
/// 0x10: 单深位
//0x20: 双深位
//0x30: 双深位带可调宽度 300~400mm
//0x31: 双深位带可调宽度 450~700mm
/// </summary>
public byte RobotType { get; set; }
/// <summary>
/// 功能选项
/// bit0: RFID射频卡使能
/// bit1: 货叉避障使能
/// </summary>
public byte FuncOption { get; set; }
/// <summary>
/// 保留
/// </summary>
public byte[] Reserved { get; set; } = new byte[2];
/// <summary>
/// 设备类型
/// 0x01:堆高车
//0x02:重载车
//0x03:潜伏车
//0x04:分拣车
//0x05:料箱机器人
/// </summary>
public byte DeviceType { get; set; }
/// <summary>
/// 硬件版本
/// 十进制20表示V2.0
/// </summary>
public byte[] HardwareVer { get; set; }
/// <summary>
/// 出厂日期
/// 0x20190101表示2019年1月1日
/// </summary>
public byte[] MFD { get; set; }
/// <summary>
/// 软件版本号
/// </summary>
public byte[] SoftVer { get; set; }
/// <summary>
/// 发布日期
/// 0x20190101表示2019年1月1日
/// </summary>
public byte[] ReleaseDate { get; set; }
/// <summary>
/// 累计工作时间
/// 单位秒
/// </summary>
public uint LastWorkTime { get; set; }
/// <summary>
/// 累计行走距离
/// 单位 米
/// </summary>
public uint LastRunDis { get; set; }
/// <summary>
/// 电池信息
/// </summary>
public Battery Battery { get; set; }
/// <summary>
/// 位置信息
/// </summary>
public Location Location { get; set; }
/// <summary>
/// 当前状态
/// </summary>
public byte CurState { get; set; }
/// <summary>
/// 故障标志位
/// </summary>
public uint FaultFlag { get; set; }
/// <summary>
/// 入侵检测次数
/// </summary>
public byte IntrusionDetectNum { get; set; }
/// <summary>
/// 等待料仓信息同步标志
/// =1表示需要等待
/// </summary>
public byte WaitStoreSyncFlag { get; set; }
/// <summary>
/// 料仓层数
/// </summary>
public byte SroreRows { get; set; }
/// <summary>
/// 模块
/// 模块ID定义
/// 0x01: 第二主控(上主控)
//0x02: 摄像头模组1
//0x03: 摄像头模组2
//0x04: IMU惯导模块1
//0x05: 预留
//0x06: 行走左轮电机
//0x07: 行走右轮电机
//0x08: 升降电机
//0x09: 旋转电机
//0x0A: 伸缩电机
/// </summary>
public List<MushineModule> Modules { get; set; }
/// <summary>
/// 解析
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
public override bool Parse(byte[] bytes)
{
bool result = false;
try
{
if(base.Parse(bytes))
{
if(bytes.Length<66)
{
return false;
}
RobotType = Common.GetSubBytes(bytes, 12, 1)[0];
FuncOption = Common.GetSubBytes(bytes, 13, 1)[0];
DeviceType = Common.GetSubBytes(bytes, 16, 1)[0];
HardwareVer = Common.GetSubBytes(bytes, 17, 2);
MFD = Common.GetSubBytes(bytes, 19, 4);
SoftVer = Common.GetSubBytes(bytes, 23, 4);
ReleaseDate = Common.GetSubBytes(bytes, 27, 4);
LastWorkTime = Common.ConvertToUInt(Common.GetSubBytes(bytes, 31, 4));
LastRunDis = Common.ConvertToUInt(Common.GetSubBytes(bytes, 35, 4));
Battery = new Battery();
Battery.Type = Common.GetSubBytes(bytes, 39, 1)[0];
Battery.MaxChargeCurrent = Common.ConvertToUshort(Common.GetSubBytes(bytes, 40, 2));
Battery.Voltage = Common.ConvertToUshort(Common.GetSubBytes(bytes, 42, 2));
Battery.SOC = Common.GetSubBytes(bytes, 44, 1)[0];
Battery.SOH = Common.GetSubBytes(bytes, 45, 1)[0];
Location = new Location();
Location.AddrCode = Common.ConvertToUInt(Common.GetSubBytes(bytes,46,4));
Location.AddrShiftX = Common.ConvertToUshort(Common.GetSubBytes(bytes, 50, 2));
Location.AddrShiftY= Common.ConvertToUshort(Common.GetSubBytes(bytes, 52, 2));
Location.AddrShiftTheta = Common.ConvertToFloat(Common.GetSubBytes(bytes, 54, 4));
CurState = Common.GetSubBytes(bytes, 58, 1)[0];
FaultFlag = Common.ConvertToUInt(Common.GetSubBytes(bytes, 59, 4));
IntrusionDetectNum = Common.GetSubBytes(bytes, 63, 1)[0];
WaitStoreSyncFlag = Common.GetSubBytes(bytes, 64, 1)[0];
SroreRows = Common.GetSubBytes(bytes,65, 1)[0];
result = true;
}
else
{
result = false;
}
}
catch (Exception ex)
{
throw ex;
}
return result;
}
}
public class Location
{
/// <summary>
/// 地址码ID
/// </summary>
public uint AddrCode { get; set; }
/// <summary>
/// 地址码偏移X
/// </summary>
public ushort AddrShiftX { get; set; }
/// <summary>
/// 地址码偏移Y
/// </summary>
public ushort AddrShiftY { get; set; }
/// <summary>
/// 地址码偏移θ
/// </summary>
public float AddrShiftTheta { get; set; }
}
/// <summary>
/// 牧星模块
/// </summary>
public class MushineModule
{
/// <summary>
/// 模块ID
/// </summary>
public byte ModuleID { get; set; }
/// <summary>
/// 硬件版本
/// </summary>
public ushort HardwareVer { get; set; }
/// <summary>
/// 软件版本
/// </summary>
public ushort SoftwareVer { get; set; }
}
}