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.

2073 lines
73 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;
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 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 = GetRCMD1DataInfo(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[] 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));
lstContent.Add(CMD1.value5);
lstContent.AddRange(BitConverter.GetBytes(CMD1.value6));
if (CMD1.value3 == 1)
{
lstContent.AddRange(CMD1.value7);
}
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 = 3;
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(BitConverter.GetBytes(CMD.value5));
if (CMD.value3 == 1)
{
lstContent.AddRange(CMD.value6);
}
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 = 5;
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(BitConverter.GetBytes(CMD.value6));
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 = 7;
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.ToByteByHexStr32(CMD.value13, 32));
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 = 9;
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 = 101;
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 = 103;
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 = 105;
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 = 107;
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 = 109;
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 = 111;
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 = 113;
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, uint func)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
if (func == 202)
{
model.CMD = 201;
}
else if (func == 222)
{
model.CMD = 221;
}
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.ToByteByHexStr32(CMD.value04, 32));
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 = 203;
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.ToByteByHexStr32(CMD.value11, 32));
lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.value12, 17));
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 = 205;
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 = 207;
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.ToByteByHexStr32(CMD.value03, 32));
lstContent.AddRange(BitConverter.GetBytes(CMD.value04));
lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.value05, 17));
lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.value06, 32));
lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.value07, 32));
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 = 209;
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.ToByteByHexStr32(CMD.value03, 32));
lstContent.AddRange(BitConverter.GetBytes(CMD.value04));
lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.value05, 17));
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD221(out APDUModel APDUModel, CMD221 CMD)
{
byte[] result = null;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 221;
model.checksumDomain = 0x01;
model.dataDomain = GetRCMD221DataInfo(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[] GetRCMD221DataInfo(CMD221 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;
}
#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 = 301;
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 = 303;
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 = 401;
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 = 1001;
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 = 1003;
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 = 1005;
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 = 1007;
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 = 1009;
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 = 1011;
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 = 1021;
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 = 1101;
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;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1103;
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.Add(CMD.startHour1);
lstContent.Add(CMD.startMinute1);
lstContent.Add(CMD.endHour1);
lstContent.Add(CMD.endMinute1);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate1));
lstContent.Add(CMD.startHour2);
lstContent.Add(CMD.startMinute2);
lstContent.Add(CMD.endHour2);
lstContent.Add(CMD.endMinute2);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate2));
lstContent.Add(CMD.startHour3);
lstContent.Add(CMD.startMinute3);
lstContent.Add(CMD.endHour3);
lstContent.Add(CMD.endMinute3);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate3));
lstContent.Add(CMD.startHour4);
lstContent.Add(CMD.startMinute4);
lstContent.Add(CMD.endHour4);
lstContent.Add(CMD.endMinute4);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate4));
lstContent.Add(CMD.startHour5);
lstContent.Add(CMD.startMinute5);
lstContent.Add(CMD.endHour5);
lstContent.Add(CMD.endMinute5);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate5));
lstContent.Add(CMD.startHour6);
lstContent.Add(CMD.startMinute6);
lstContent.Add(CMD.endHour6);
lstContent.Add(CMD.endMinute6);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate6));
lstContent.Add(CMD.startHour7);
lstContent.Add(CMD.startMinute7);
lstContent.Add(CMD.endHour7);
lstContent.Add(CMD.endMinute7);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate7));
lstContent.Add(CMD.startHour8);
lstContent.Add(CMD.startMinute8);
lstContent.Add(CMD.endHour8);
lstContent.Add(CMD.endMinute8);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate8));
lstContent.Add(CMD.startHour9);
lstContent.Add(CMD.startMinute9);
lstContent.Add(CMD.endHour9);
lstContent.Add(CMD.endMinute9);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate9));
lstContent.Add(CMD.startHour10);
lstContent.Add(CMD.startMinute10);
lstContent.Add(CMD.endHour10);
lstContent.Add(CMD.endMinute10);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate10));
lstContent.Add(CMD.startHour11);
lstContent.Add(CMD.startMinute11);
lstContent.Add(CMD.endHour11);
lstContent.Add(CMD.endMinute11);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate11));
lstContent.Add(CMD.startHour12);
lstContent.Add(CMD.startMinute12);
lstContent.Add(CMD.endHour12);
lstContent.Add(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 = 1105;
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.Add(CMD.startHour1);
lstContent.Add(CMD.startMinute1);
lstContent.Add(CMD.endHour1);
lstContent.Add(CMD.endMinute1);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate1));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate1));
lstContent.Add(CMD.startHour2);
lstContent.Add(CMD.startMinute2);
lstContent.Add(CMD.endHour2);
lstContent.Add(CMD.endMinute2);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate2));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate2));
lstContent.Add(CMD.startHour3);
lstContent.Add(CMD.startMinute3);
lstContent.Add(CMD.endHour3);
lstContent.Add(CMD.endMinute3);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate3));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate3));
lstContent.Add(CMD.startHour4);
lstContent.Add(CMD.startMinute4);
lstContent.Add(CMD.endHour4);
lstContent.Add(CMD.endMinute4);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate4));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate4));
lstContent.Add(CMD.startHour5);
lstContent.Add(CMD.startMinute5);
lstContent.Add(CMD.endHour5);
lstContent.Add(CMD.endMinute5);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate5));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate5));
lstContent.Add(CMD.startHour6);
lstContent.Add(CMD.startMinute6);
lstContent.Add(CMD.endHour6);
lstContent.Add(CMD.endMinute6);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate6));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate6));
lstContent.Add(CMD.startHour7);
lstContent.Add(CMD.startMinute7);
lstContent.Add(CMD.endHour7);
lstContent.Add(CMD.endMinute7);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate7));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate7));
lstContent.Add(CMD.startHour8);
lstContent.Add(CMD.startMinute8);
lstContent.Add(CMD.endHour8);
lstContent.Add(CMD.endMinute8);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate8));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate8));
lstContent.Add(CMD.startHour9);
lstContent.Add(CMD.startMinute9);
lstContent.Add(CMD.endHour9);
lstContent.Add(CMD.endMinute9);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate9));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate9));
lstContent.Add(CMD.startHour10);
lstContent.Add(CMD.startMinute10);
lstContent.Add(CMD.endHour10);
lstContent.Add(CMD.endMinute10);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate10));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate10));
lstContent.Add(CMD.startHour11);
lstContent.Add(CMD.startMinute11);
lstContent.Add(CMD.endHour11);
lstContent.Add(CMD.endMinute11);
lstContent.AddRange(BitConverter.GetBytes(CMD.rate11));
lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate11));
lstContent.Add(CMD.startHour12);
lstContent.Add(CMD.startMinute12);
lstContent.Add(CMD.endHour12);
lstContent.Add(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 = 1107;
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 = 1301;
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>
/// 针对CMD1301 充电卡号 不足30byte补\0
/// </summary>
/// <param name="byteArray"></param>
/// <returns></returns>
public byte[] AddByteArray(byte[] byteArray, int len)
{
byte[] result = new byte[len];
if (byteArray != null)
{
if (byteArray.Length <= len)
{
Array.Copy(byteArray, result, byteArray.Length);
}
}
return result;
}
/// <summary>
/// 获取鉴权消息体字节数组
/// 白名单1-充电卡号 32byte\2-VIN码 17byte
/// </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(AddByteArray(Encoding.ASCII.GetBytes(CMD.chargingStationCode), 32));
lstContent.Add(CMD.whitelistType);
lstContent.Add(CMD.operation);
lstContent.AddRange(BitConverter.GetBytes(CMD.whitelistVersionNum));
//操作为查询 即=4后面字段不需要
if (CMD.operation != 4)
{
lstContent.AddRange(BitConverter.GetBytes(CMD.DistributeWhitelistNum));
if (CMD.whitelistType == 1)
{
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum01), 32));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum02), 32));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum03), 32));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum04), 32));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum05), 32));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum06), 32));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum07), 32));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum08), 32));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum09), 32));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum10), 32));
}
else
{
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum01), 17));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum02), 17));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum03), 17));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum04), 17));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum05), 17));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum06), 17));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum07), 17));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum08), 17));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum09), 17));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum10), 17));
}
}
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 = 1401;
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((ushort)(Convert.ToSingle(CMD.UpgradeSoftwareFileVersionNum) * 100)));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpServerIPaddress), 32));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpUserName), 16));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpPassWord), 16));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpDownloadPath), 64));
lstContent.Add(CMD.executeWay);
lstContent.Add(CMD.nowUpgradeDeviceType);
results = lstContent.ToArray();
}
return results;
}
public byte[] SendRCMD1406(out APDUModel APDUModel, CMD1406 CMD)
{
byte[] result;
APDUModel model = new APDUModel();
model.OriginDomain1 = 0xAA;
model.OriginDomain2 = 0xF5;
model.infoDomain = 0x02;
model.SerialNumberDomain = 0xff;
model.CMD = 1406;
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(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpServerIPaddress),32));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpUserName),16));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpPassWord),16));
lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ftpSavePath),32));
lstContent.Add(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 = 1502;
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 = 1504;
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 = 1506;
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
}
}