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.

48 lines
1.1 KiB

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