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.

1987 lines
71 KiB

using BatCharging.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BatCharging.Service
{
public class ChargerSendCMD
{
#region 协议格式
public byte[] SendRCMD1(out APDUModel APDUModel, CMD1 t)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1DataInfo(t); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1DataInfo(CMD1 CMD1)
{
byte[] results = null;
if (CMD1 != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD1.value1));
lstContent.AddRange(BitConverter.GetBytes(CMD1.value2));
lstContent.Add(CMD1.value3);
lstContent.AddRange(BitConverter.GetBytes(CMD1.value4));
if (CMD1.value3 == 1)
{
lstContent.Add(CMD1.value5);
lstContent.AddRange(BitConverter.GetBytes(CMD1.value6));
lstContent.AddRange(CMD1.value7);
}
else
{
}
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD3(out APDUModel APDUModel, CMD3 CMD3)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD3DataInfo(CMD3); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD3DataInfo(CMD3 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value1));
lstContent.AddRange(BitConverter.GetBytes(CMD.value2));
lstContent.Add(CMD.value3);
lstContent.AddRange(BitConverter.GetBytes(CMD.value4));
lstContent.AddRange(CMD.value6);
if (CMD.value3 == 1)
{
lstContent.AddRange(BitConverter.GetBytes(CMD.value5));
lstContent.AddRange(CMD.value6);
}
else
{
}
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD5(out APDUModel APDUModel, CMD5 cMD5)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD5DataInfo(cMD5); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD5DataInfo(CMD5 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value1));
lstContent.AddRange(BitConverter.GetBytes(CMD.value2));
lstContent.Add(CMD.value3);
lstContent.AddRange(BitConverter.GetBytes(CMD.value4));
lstContent.Add(CMD.value5);
lstContent.AddRange(CMD.value7);
if (CMD.value3 == 1)
{
lstContent.AddRange(BitConverter.GetBytes(CMD.value4));
lstContent.AddRange(CMD.value7);
}
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD7(out APDUModel APDUModel, CMD7 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD7DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD7DataInfo(CMD7 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
lstContent.AddRange(BitConverter.GetBytes(CMD.value03));
lstContent.AddRange(BitConverter.GetBytes(CMD.value04));
lstContent.AddRange(BitConverter.GetBytes(CMD.value05));
lstContent.AddRange(BitConverter.GetBytes(CMD.value07));
lstContent.AddRange(BitConverter.GetBytes(CMD.value08));
lstContent.AddRange(BitConverter.GetBytes(CMD.value09));
lstContent.AddRange(BitConverter.GetBytes(CMD.value10));
lstContent.AddRange(BitConverter.GetBytes(CMD.value11));
lstContent.AddRange(BitConverter.GetBytes(CMD.value12));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.value13));
lstContent.AddRange(BitConverter.GetBytes(CMD.value14));
lstContent.AddRange(BitConverter.GetBytes(CMD.value15));
lstContent.AddRange(BitConverter.GetBytes(CMD.value16));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD9(out APDUModel APDUModel,CMD9 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD9DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD9DataInfo(CMD9 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
lstContent.AddRange(BitConverter.GetBytes(CMD.value03));
lstContent.AddRange(BitConverter.GetBytes(CMD.value04));
lstContent.AddRange(BitConverter.GetBytes(CMD.value05));
lstContent.AddRange(BitConverter.GetBytes(CMD.value06));
lstContent.AddRange(CMD.value07);
results = lstContent.ToArray();
}
return results;
}
#endregion
#region 充电桩主动上传数据
public byte[] SendRCMD101(out APDUModel APDUModel, CMD101 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD101DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD101DataInfo(CMD101 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
lstContent.AddRange(BitConverter.GetBytes(CMD.value03));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD103(out APDUModel APDUModel, CMD103 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD103DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD103DataInfo(CMD103 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
lstContent.AddRange(BitConverter.GetBytes(CMD.value03));
lstContent.AddRange(BitConverter.GetBytes(CMD.value04));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD105(out APDUModel APDUModel, CMD105 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD105DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD105DataInfo(CMD105 CMD105)
{
byte[] results = null;
if (CMD105 != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD105.value1));
lstContent.AddRange(BitConverter.GetBytes(CMD105.value2));
lstContent.AddRange(BitConverter.GetBytes(CMD105.value3));
lstContent.Add(CMD105.value4);
lstContent.Add(CMD105.value5);
if (CMD105.value5 == 1)
{
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD105.value6));
lstContent.AddRange(BitConverter.GetBytes(CMD105.value7));
}
lstContent.Add(CMD105.value8);
lstContent.AddRange(BitConverter.GetBytes(CMD105.value9));
lstContent.Add(CMD105.value10);
if (CMD105.value5 == 1)
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD105.value11));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD107(out APDUModel APDUModel, CMD107 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD107DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD107DataInfo(CMD107 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
//lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
//lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
//lstContent.AddRange(BitConverter.GetBytes(CMD.value03));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD109(out APDUModel APDUModel, CMD109 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD109DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD109DataInfo(CMD109 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD111(out APDUModel APDUModel, CMD111 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD111DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD111DataInfo(CMD111 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
lstContent.AddRange(BitConverter.GetBytes(CMD.value03));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD113(out APDUModel APDUModel, CMD113 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD113DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD113DataInfo(CMD113 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
lstContent.AddRange(BitConverter.GetBytes(CMD.value03));
lstContent.AddRange(BitConverter.GetBytes(CMD.value04));
results = lstContent.ToArray();
}
return results;
}
#endregion
#region 充电信息数据
public byte[] SendRCMD201(out APDUModel APDUModel, CMD201 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD201DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD201DataInfo(CMD201 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
lstContent.AddRange(BitConverter.GetBytes(CMD.value03));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.value04));
lstContent.AddRange(BitConverter.GetBytes(CMD.value05));
lstContent.AddRange(BitConverter.GetBytes(CMD.value06));
lstContent.AddRange(BitConverter.GetBytes(CMD.value07));
lstContent.AddRange(BitConverter.GetBytes(CMD.value08));
lstContent.AddRange(BitConverter.GetBytes(CMD.value09));
lstContent.AddRange(BitConverter.GetBytes(CMD.value10));
lstContent.AddRange(BitConverter.GetBytes(CMD.value11));
lstContent.AddRange(BitConverter.GetBytes(CMD.value12));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD203(out APDUModel APDUModel, CMD203 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD203DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD203DataInfo(CMD203 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
lstContent.AddRange(BitConverter.GetBytes(CMD.value03));
lstContent.AddRange(BitConverter.GetBytes(CMD.value04));
lstContent.AddRange(BitConverter.GetBytes(CMD.value05));
lstContent.AddRange(BitConverter.GetBytes(CMD.value06));
lstContent.AddRange(BitConverter.GetBytes(CMD.value07));
lstContent.AddRange(BitConverter.GetBytes(CMD.value08));
lstContent.AddRange(BitConverter.GetBytes(CMD.value09));
lstContent.AddRange(BitConverter.GetBytes(CMD.value10));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.value11));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.value12));
lstContent.AddRange(BitConverter.GetBytes(CMD.value13));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD205(out APDUModel APDUModel, CMD205 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD205DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD205DataInfo(CMD205 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
lstContent.AddRange(BitConverter.GetBytes(CMD.value03));
lstContent.AddRange(BitConverter.GetBytes(CMD.value04));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD207(out APDUModel APDUModel, CMD207 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD207DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD207DataInfo(CMD207 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.value03));
lstContent.AddRange(BitConverter.GetBytes(CMD.value04));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.value05));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.value06));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.value07));
lstContent.AddRange(BitConverter.GetBytes(CMD.value08));
lstContent.AddRange(BitConverter.GetBytes(CMD.value09));
lstContent.AddRange(BitConverter.GetBytes(CMD.value10));
lstContent.AddRange(BitConverter.GetBytes(CMD.value11));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD209(out APDUModel APDUModel, CMD209 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD209DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD209DataInfo(CMD209 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.value03));
lstContent.AddRange(BitConverter.GetBytes(CMD.value04));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.value05));
results = lstContent.ToArray();
}
return results;
}
#endregion
#region 直流充电桩 BMS 信息数据(预留)
public byte[] SendRCMD301(out APDUModel APDUModel, CMD301 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD301DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD301DataInfo(CMD301 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD303(out APDUModel APDUModel, CMD303 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD303DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD303DataInfo(CMD303 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2));
results = lstContent.ToArray();
}
return results;
}
#endregion
#region 历史记录
public byte[] SendRCMD401(out APDUModel APDUModel, CMD401 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD401DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD401DataInfo(CMD401 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2));
lstContent.AddRange(BitConverter.GetBytes(CMD.startingIndexOfQueryRecord));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.chargingSerialNumber));
results = lstContent.ToArray();
}
return results;
}
#endregion
#region 升级命令
public byte[] SendRCMD1001(out APDUModel APDUModel, CMD1001 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1001DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1001DataInfo(CMD1001 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.eraseOrQueryInstructions));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1003(out APDUModel APDUModel, CMD1003 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1003DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1003DataInfo(CMD1003 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.fileName));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1005(out APDUModel APDUModel, CMD1005 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1005DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1005DataInfo(CMD1005 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.fileLength));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1007(out APDUModel APDUModel, CMD1007 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1007DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1007DataInfo(CMD1007 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.upgradeFileData));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1009(out APDUModel APDUModel, CMD1009 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1009DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1009DataInfo(CMD1009 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.Value01));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1011(out APDUModel APDUModel, CMD1011 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1011DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1011DataInfo(CMD1011 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1021(out APDUModel APDUModel, CMD1021 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1021DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1021DataInfo(CMD1021 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.responseResults));
lstContent.AddRange(Encoding.UTF8.GetBytes(CMD.responseDescription));
results = lstContent.ToArray();
}
return results;
}
#endregion
#region 与计费策略相关的指令
public byte[] SendRCMD1101(out APDUModel APDUModel )
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
CMD1101 CMD = new CMD1101();
model.dataDomain = GetRCMD1101DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1101DataInfo(CMD1101 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1103(out APDUModel APDUModel, CMD1103 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1103DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1103DataInfo(CMD1103 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour1));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute1));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour1));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute1));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate1));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour2));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute2));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour2));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute2));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate2));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour3));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute3));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour3));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute3));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate3));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour4));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute4));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour4));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute4));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate4));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour5));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute5));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour5));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute5));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate5));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour6));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute6));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour6));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute6));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate6));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour7));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute7));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour7));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute7));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate7));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour8));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute8));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour8));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute8));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate8));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour9));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute9));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour9));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute9));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate9));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour10));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute10));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour10));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute10));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate10));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour11));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute11));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour11));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute11));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate11));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour12));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute12));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour12));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute12));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate12));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1105(out APDUModel APDUModel, CMD1105 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1105DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1105DataInfo(CMD1105 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour1));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute1));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour1));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute1));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate1));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate1));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour2));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute2));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour2));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute2));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate2));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate2));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour3));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute3));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour3));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute3));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate3));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate3));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour4));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute4));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour4));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute4));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate4));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate4));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour5));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute5));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour5));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute5));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate5));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate5));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour6));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute6));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour6));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute6));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate6));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate6));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour7));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute7));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour7));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute7));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate7));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate7));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour8));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute8));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour8));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute8));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate8));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate8));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour9));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute9));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour9));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute9));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate9));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate9));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour10));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute10));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour10));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute10));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate10));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate10));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour11));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute11));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour11));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute11));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate11));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate11));
lstContent.AddRange(BitConverter.GetBytes(CMD.startHour12));
lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute12));
lstContent.AddRange(BitConverter.GetBytes(CMD.endHour12));
lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute12));
lstContent.AddRange(BitConverter.GetBytes(CMD.rate12));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate12));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1107(out APDUModel APDUModel)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
CMD1107 CMD = new CMD1107();
model.dataDomain = GetRCMD1107DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1107DataInfo(CMD1107 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
results = lstContent.ToArray();
}
return results;
}
#endregion
#region 白名单报文
public byte[] SendRCMD1301(out APDUModel APDUModel, CMD1301 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1301DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1301DataInfo(CMD1301 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.chargingStationCode));
lstContent.AddRange(BitConverter.GetBytes(CMD.whitelistType));
lstContent.AddRange(BitConverter.GetBytes(CMD.operation));
lstContent.AddRange(BitConverter.GetBytes(CMD.whitelistVersionNum));
lstContent.AddRange(BitConverter.GetBytes(CMD.DistributeWhitelistNum));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum01));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum02));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum03));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum04));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum05));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum06));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum07));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum08));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum09));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum10));
results = lstContent.ToArray();
}
return results;
}
#endregion
#region FTP 远程升级和 FTP 方式日志上传
public byte[] SendRCMD1401(out APDUModel APDUModel, CMD1401 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1401DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1401DataInfo(CMD1401 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2));
lstContent.AddRange(BitConverter.GetBytes(CMD.UpgradeSoftwareFileVersionNum));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpServerIPaddress));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpUserName));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpPassWord));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpDownloadPath));
lstContent.Add(CMD.executeWay);
lstContent.Add(CMD.nowUpgradeDeviceType);
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1406(out APDUModel APDUModel, CMD1406 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD1406DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1406DataInfo(CMD1406 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2));
lstContent.Add(CMD.getLogType);
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpServerIPaddress));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpUserName));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpPassWord));
lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpSavePath));
lstContent.AddRange(BitConverter.GetBytes(CMD.executeWay));
results = lstContent.ToArray();
}
return results;
}
#endregion
#region 协议方式日志上传
public byte[] SendRCMD1502(out APDUModel APDUModel, CMD1502 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
//CMD1502 CMD = new CMD1502();
//CMD.reserved1 = 0;
//CMD.reserved2 = 0;
//CMD.responseCode = 0;
model.dataDomain = GetRCMD1502DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1502DataInfo(CMD1502 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2));
lstContent.AddRange(BitConverter.GetBytes(CMD.responseCode));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1504(out APDUModel APDUModel, CMD1504 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
//CMD1504 CMD = new CMD1504();
//CMD.reserved1 = 0;
//CMD.reserved2 = 0;
//CMD.logo = 0;
//CMD.successReservedMessageNum = 0;
model.dataDomain = GetRCMD1504DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1504DataInfo(CMD1504 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2));
lstContent.AddRange(BitConverter.GetBytes(CMD.logo));
lstContent.AddRange(BitConverter.GetBytes(CMD.successReservedMessageNum));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1506(out APDUModel APDUModel, CMD1506 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1;
model.checksumDomain = 0x01;
//CMD1504 CMD = new CMD1504();
//CMD.reserved1 = 0;
//CMD.reserved2 = 0;
//CMD.logo = 0;
//CMD.successReservedMessageNum = 0;
model.dataDomain = GetRCMD1506DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List<byte> lstResult = new List<byte>();
lstResult.AddRange(PublicProgram.APCI(model).ToArray());
result = lstResult.ToArray();
APDUModel = model;
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private byte[] GetRCMD1506DataInfo(CMD1506 CMD)
{
byte[] results = null;
if (CMD != null)
{
List<byte> lstContent = new List<byte>();
lstContent.AddRange(BitConverter.GetBytes(CMD.value01));
lstContent.AddRange(BitConverter.GetBytes(CMD.value02));
results = lstContent.ToArray();
}
return results;
}
#endregion
}
}