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.
45 lines
1.4 KiB
45 lines
1.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using BatCharging.Model;
|
|
|
|
namespace BatCharging.Service
|
|
{
|
|
/// <summary>
|
|
/// 创建基础的ASDU字节列表
|
|
/// </summary>
|
|
public class MsgHeadAsduEncoder
|
|
{
|
|
/// <summary>
|
|
/// 创建基础的ASDU字节列表
|
|
/// </summary>
|
|
/// <param name="baseAsdu">ASDU实例化值</param>
|
|
/// <returns>ASDU字节列表</returns>
|
|
public static List<byte> BuildBaseASDU(ASDU baseAsdu)
|
|
{
|
|
List<byte> lstResult = null;
|
|
if (baseAsdu != null)
|
|
{
|
|
lstResult = new List<byte>();
|
|
//帧类型号
|
|
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;
|
|
|
|
}
|
|
}
|
|
}
|