using HybirdFrameworkDriver.Common; using Service.Fire.Common; namespace Service.Fire.Msg; public abstract class APCI : IToBytes { /// /// 目标地址 /// public byte DestAddress { get; set; } /// /// 数据长度 /// public byte Length { get; set; } public byte CrcHight { get; set; } public byte CrcLow { get; set; } public byte[] ToBytes() { var bodyBytes = GetBytes(); var list = new List(); list.AddRange(FireConst.StartChar); list.Add(DestAddress); list.Add((byte)bodyBytes.Length); list.AddRange(bodyBytes); CRC16 CRC16 = new(); //进行CRC校验 list.AddRange(BitConverter.GetBytes(CRC16.ComputeChecksum(list.ToArray()))); return list.ToArray(); } public abstract byte[] GetBytes(); }