ActionDataRtnPkg.cs
1.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mushiny.Model
{
/// <summary>
/// 命令码回复数据包:当RCS发送命令码过来,并执行完相应的命令码后发一次
/// AGV->RCS
/// </summary>
internal class ActionDataRtnPkg : PkgData
{
public ActionDataRtnPkg() : base()
{
}
/// <summary>
/// 命令码
/// 数据位置:起始编号12,长度1
/// </summary>
public byte ActionCode { get; set; }
/// <summary>
/// 属性值
/// int8
/// 数据位置:起始编号13,长度1
/// </summary>
public byte PropVal { get; set; }
/// <summary>
/// 动作参数
/// 数据位置:起始编号14
/// </summary>
public List<byte> ActionParams { get; set; }
public override bool Parse(byte[] bytes)
{
bool result = false;
try
{
if (base.Parse(bytes))
{
if (bytes.Length < 17)
{
return false;
}
ActionCode = Common.GetSubBytes(bytes, 12, 1)[0];
PropVal = Common.GetSubBytes(bytes, 13, 1)[0];
ActionParams = new List<byte>();
for (int i = 14; i <= bytes.Length - 1 - 2; i++)
{
ActionParams.Add(bytes[i]);
}
result = true;
}
else
{
result = false;
}
}
catch (Exception ex)
{
throw ex;
}
return result;
}
}
}