using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using BatCharging.Model; namespace BatCharging.Service { /// /// 基础APCI封装 /// public class MsgHeadApciEncoder { /// /// 创建基础的APCI字节列表 /// /// APCI实例化值 /// APCI字节列表 public static List BuildBaseAPCI(APCI baseApci) { List lstResult = null; if (baseApci != null) { lstResult = new List(); //启动字符 lstResult.Add(baseApci.StartChar); //报文长度 byte[] packLens=BitConverter.GetBytes(baseApci.PackLen); lstResult.AddRange(packLens); //控制域 byte[] packAreas = BitConverter.GetBytes(baseApci.CtlArea); lstResult.AddRange(packAreas); //目标地址 lstResult.AddRange(baseApci.DestAddr); //源地址 byte[] packSrcs = BitConverter.GetBytes(baseApci.SrcAddr); lstResult.AddRange(packSrcs); } return lstResult; } } }