You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

6 months ago
using HybirdFrameworkDriver.Common;
using Service.Charger.Common;
6 months ago
namespace Service.Charger.Msg
6 months ago
{
public abstract class APCI : IToBytes
{
/// <summary>
/// 报文长度
/// </summary>
public UInt16 PackLen { get; set; }
/// <summary>
/// 控制域
/// </summary>
public UInt32 CtlArea { get; set; }
/// <summary>
/// 目标地址
/// </summary>
public byte[] DestAddr { get; set; }
/// <summary>
/// 源地址
/// </summary>
public UInt32 SrcAddr { get; set; }
public byte[] ToBytes()
{
byte[] bodyBytes = GetBytes();
List<byte> list = new List<byte>();
list.AddRange(ChargerConst.ApciStartChar);
list.AddRange(BitConverter.GetBytes(bodyBytes.Length + 12));
list.AddRange(BitConverter.GetBytes(CtlArea));
list.AddRange(DestAddr);
list.AddRange(BitConverter.GetBytes(SrcAddr));
list.AddRange(bodyBytes);
return list.ToArray();
}
public abstract byte[] GetBytes();
}
}