using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using BatCharging.Model; namespace BatCharging.Service { /// /// 创建基础的ASDU字节列表 /// public class MsgHeadAsduEncoder { /// /// 创建基础的ASDU字节列表 /// /// ASDU实例化值 /// ASDU字节列表 public static List BuildBaseASDU(ASDU baseAsdu) { List lstResult = null; if (baseAsdu != null) { lstResult = new List(); //帧类型号 lstResult.Add(baseAsdu.FrameTypeNo); //信息体个数 lstResult.Add(baseAsdu.MsgBodyCount); //传送原因 lstResult.AddRange(BitConverter.GetBytes(baseAsdu.TransReason)); //公共地址 byte[] packPublicAddr = BitConverter.GetBytes(baseAsdu.PublicAddr); lstResult.AddRange(packPublicAddr); //信息地址 lstResult.AddRange(baseAsdu.MsgBodyAddr); //信息体 lstResult.AddRange(baseAsdu.MsgBodyContents); } return lstResult; } } }