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.

50 lines
1.3 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 MsgHeadApciEncoder
{
/// <summary>
/// 创建基础的APCI字节列表
/// </summary>
/// <param name="baseApci">APCI实例化值</param>
/// <returns>APCI字节列表</returns>
public static List<byte> BuildBaseAPCI(APCI baseApci)
{
List<byte> lstResult = null;
if (baseApci != null)
{
lstResult = new List<byte>();
//启动字符
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;
}
}
}