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.

73 lines
2.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using BatCharging.Model;
namespace BatCharging.Service.Encoder.New
{
internal class MsgChargRespEcoder
{
public MsgChargRespEcoder()
{
}
internal byte[] GetRecordChargRespEcoderMsg(byte[] destAddr, byte reserve1, byte reserve2)
{
byte[] result = null;
APCI headAPCI = new APCI();
headAPCI.StartChar = CmnChargerConst.APCI_START_CHAR;
headAPCI.PackLen = 0; //临时赋值为零,具体数值看下面的计算结果
headAPCI.CtlArea = 0; //控制域
headAPCI.DestAddr = destAddr;//目的地址
headAPCI.SrcAddr = 0;//源地址本系统中源地址统一为00000000即为0
ASDU headASDU = new ASDU();
headASDU.FrameTypeNo = 70; //帧类型号
headASDU.MsgBodyCount = 1; //信息体个数
headASDU.TransReason = 3; //传送原因
headASDU.PublicAddr = 0; //公共地址
headASDU.MsgBodyAddr = new byte[] { 0, 0, 0 }; //信息体地址
RecordChargRespData recordChargRespData = new RecordChargRespData();
recordChargRespData.Reserve1 = reserve1;
recordChargRespData.Reserve2 = reserve2;
headASDU.MsgBodyContents = GetMsgContents(recordChargRespData); //信息体
headAPCI.PackLen = Convert.ToUInt16(24 + headASDU.MsgBodyContents.Length); //报文长度
List<byte> lstResult = MsgHeadApciEncoder.BuildBaseAPCI(headAPCI);
lstResult.AddRange(MsgHeadAsduEncoder.BuildBaseASDU(headASDU).ToArray());
result = lstResult.ToArray();
return result;
}
private byte[] GetMsgContents(RecordChargRespData recordChargRespData)
{
byte[] results = null;
if (recordChargRespData != null)
{
List<byte> lstContent = new List<byte>();
lstContent.Add(recordChargRespData.Reserve1);
lstContent.Add(recordChargRespData.Reserve2);
results = lstContent.ToArray();
}
return results;
}
class RecordChargRespData
{
//保留1
public byte Reserve1 { get; set; }
//保留2
public byte Reserve2 { get; set; }
}
}
}