ActionDataPkg.cs
1.5 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mushiny.Model
{
/// <summary>
/// 动作命令包
/// RCS->AGV
/// 需要机器人执行单独的动作命令的时候发送一次
/// 执行完成后机器人须发送一次命令码完成回复包
/// </summary>
public class ActionDataPkg : PkgData
{
public ActionDataPkg() : base()
{
FrameHead = 0xbb;
CmdWord = 0x02;
}
/// <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 byte[] ToBytes()
{
List<byte> bytes = new List<byte>(base.ToBytes())
{
ActionCode,
PropVal,
};
if (ActionParams != null && ActionParams.Count > 0)
bytes.AddRange(ActionParams);
calSendCrc(bytes);
bytes.Add(CRC16Low);
bytes.Add(CRC16Upper);
return bytes.ToArray();
}
}
}