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.
46 lines
1.2 KiB
46 lines
1.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using BatCharging.Model;
|
|
|
|
namespace BatCharging.Service
|
|
{
|
|
/// <summary>
|
|
/// 基础APCI解包类
|
|
/// </summary>
|
|
public class MsgHeadApciDecoder
|
|
{
|
|
/// <summary>
|
|
/// 解包基础的APCI字节数组
|
|
/// </summary>
|
|
/// <param name="msgRecv">接收到字节数组</param>
|
|
/// <returns>APCI消息</returns>
|
|
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;
|
|
}
|
|
}
|
|
}
|