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 MsgHeadApciDecoder { /// /// 解包基础的APCI字节数组 /// /// 接收到字节数组 /// APCI消息 public static APCI GetBaseAPCIMsg(byte[] msgRecv) { APCI msgResult = null; if (msgRecv != null) { int num = msgRecv.Length; if (num > 15) { msgResult = new APCI { StartChar = msgRecv[0], PackLen = ByteUtils.ToUInt16(msgRecv, 1), CtlArea = ByteUtils.ToUInt32(msgRecv, 3), DestAddr = msgRecv.Skip(7).Take(4).ToArray(), SrcAddr = ByteUtils.ToUInt32(msgRecv, 11) }; } } else { return null; } return msgResult; } } }