using HybirdFrameworkDriver.Common;
using Service.Charger.Common;
namespace Service.Charger.Msg
{
public abstract class APCI : IToBytes
{
///
/// 报文长度
///
public UInt16 PackLen { get; set; }
///
/// 控制域
///
public UInt32 CtlArea { get; set; }
///
/// 目标地址
///
public byte[] DestAddr { get; set; }
///
/// 源地址
///
public UInt32 SrcAddr { get; set; }
public byte[] ToBytes()
{
byte[] bodyBytes = GetBytes();
List list = new List();
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();
}
}