diff --git a/.vs/hybirdMyFrame/DesignTimeBuild/.dtbcache.v2 b/.vs/hybirdMyFrame/DesignTimeBuild/.dtbcache.v2 index 248bbf7..775c3cd 100644 Binary files a/.vs/hybirdMyFrame/DesignTimeBuild/.dtbcache.v2 and b/.vs/hybirdMyFrame/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/hybirdMyFrame/v17/.futdcache.v2 b/.vs/hybirdMyFrame/v17/.futdcache.v2 index 212b1f1..e4481a7 100644 Binary files a/.vs/hybirdMyFrame/v17/.futdcache.v2 and b/.vs/hybirdMyFrame/v17/.futdcache.v2 differ diff --git a/.vs/hybirdMyFrame/v17/.suo b/.vs/hybirdMyFrame/v17/.suo index fcc86d1..c5e13fd 100644 Binary files a/.vs/hybirdMyFrame/v17/.suo and b/.vs/hybirdMyFrame/v17/.suo differ diff --git a/BatCharging.Manager/BatCharging.Manager.csproj b/BatCharging.Manager/BatCharging.Manager.csproj new file mode 100644 index 0000000..1a50bd5 --- /dev/null +++ b/BatCharging.Manager/BatCharging.Manager.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/BatCharging.Manager/ChargerEqmManager.cs b/BatCharging.Manager/ChargerEqmManager.cs new file mode 100644 index 0000000..c1eecdd --- /dev/null +++ b/BatCharging.Manager/ChargerEqmManager.cs @@ -0,0 +1,85 @@ +using BatCharging.Service; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BatCharging.Manager +{ + public class ChargerEqmManager + { + #region 定义锁 + + private object lockObj = new object(); //线程同步锁 + + #endregion 定义锁 + + #region 字段属性 + + /// + /// 是否可以发送充电机数据到云平台 + /// + private bool _can_send_chrg_data = true; + + /// + /// 是否可以发送充电机数据到云平台 + /// + public bool F_CanSendChrgData + { + get { return _can_send_chrg_data; } + set + { + lock (lockObj) + { + _can_send_chrg_data = value; + } + } + } + + /// + /// 是否启动智能充电方法 + /// + private bool _can_smart_chrg = true; + + /// + /// 是否启动智能充电方法 + /// + public bool F_CanSmartChrg + { + get { return _can_smart_chrg; } + set + { + lock (lockObj) + { + _can_smart_chrg = value; + } + } + } + + /// + /// 发送充电机数据到云平台的周期(单位:秒) + /// + private int _send_chrg_data_period = 30; + + /// + /// 发送充电机数据到云平台的周期(单位:秒) + /// + public int F_SendChrgDataPeriod + { + get { return _send_chrg_data_period; } + set + { + lock (lockObj) + { + _send_chrg_data_period = value; + } + } + } + + #endregion 字段属性 + + + } +} diff --git a/BatCharging.Manager/CmnChargingsEqmInfo.cs b/BatCharging.Manager/CmnChargingsEqmInfo.cs new file mode 100644 index 0000000..e6bbb36 --- /dev/null +++ b/BatCharging.Manager/CmnChargingsEqmInfo.cs @@ -0,0 +1,118 @@ +using BatCharging.Service; +using DotNetty.Transport.Channels; +using System; + +namespace BatCharging.Manager +{ + public class CmnChargingsEqmInfo + { + #region + private static object lockObj = new object(); //߳ͬ + #endregion + + #region ֶ + /// + /// վ + /// + internal static string _station_no = ""; + /// + /// վ + /// + public static string F_StationNo + { + get + { + return _station_no; + } + set + { + lock (lockObj) + { + _station_no = value; + } + } + } + + /// + /// λгʵʱ + /// + internal static float[] _bin_powers = new float[7] { 0, 0, 0, 0, 0, 0, 0 }; + /// + /// λгʵʱ + /// + public static float[] F_BinPowers + { + get + { + return _bin_powers; + } + set + { + lock (lockObj) + { + _bin_powers = value; + } + } + } + #endregion ֶ + + #region ֶ + public static string _OUTCHR01IPADDR = "172.0.30.30"; + public static string _OUTCHR02IPADDR = "172.0.30.31"; + public static string _OUTCHR03IPADDR = "172.0.30.32"; + public static string _OUTCHR04IPADDR = "172.0.30.33"; + + public static int _OUTCHR01PORT = 4567; + public static int _OUTCHR02PORT = 4567; + public static int _OUTCHR03PORT = 4567; + public static int _OUTCHR04PORT = 4567; + + public static IChannelId _ID; + public static string _CHR0IPADDR = "0.0.0.0"; + public static int _CHR0PORT = 4567; + public static string _EQMCODE = ""; + + + public volatile static ChargerMgrTool _CHR01 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR02 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR03 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR04 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR05 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR06 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR07 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + + public volatile static ChargerMgrTool _CHR08 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR09 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR10 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR11 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR12 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR13 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR14 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + + public volatile static ChargerMgrTool _CHR15 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR16 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR17 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR18 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR19 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR20 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR21 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + + public volatile static ChargerMgrTool _CHR22 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR23 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR24 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + + #endregion ֶ + + #region ״ֵ̬ + + public static byte _CHR01WORKVAL = 0; + public static byte _CHR02WORKVAL = 0; + public static byte _CHR03WORKVAL = 0; + public static byte _CHR04WORKVAL = 0; + public static byte _CHR05WORKVAL = 0; + public static byte _CHR06WORKVAL = 0; + public static byte _CHR07WORKVAL = 0; + public static byte[] _CHRSWORKVAL = new byte[] { 0, 0, 0, 0, 0, 0, 0 }; + #endregion ״ֵ̬ + } +} diff --git a/BatCharging.Model/BatCharging.Model.csproj b/BatCharging.Model/BatCharging.Model.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/BatCharging.Model/BatCharging.Model.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/HybirdFrameworkEntity/MsgModel/APDUModel.cs b/BatCharging.Model/MsgModel/APDUModel.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/APDUModel.cs rename to BatCharging.Model/MsgModel/APDUModel.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD10.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD10.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD10.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD10.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1002.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1002.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1002.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1002.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1004.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1004.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1004.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1004.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1006.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1006.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1006.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1006.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1008.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1008.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1008.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1008.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1010.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1010.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1010.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1010.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1012.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1012.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1012.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1012.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD102.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD102.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD102.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD102.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1022.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1022.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1022.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1022.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD104.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD104.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD104.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD104.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD106.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD106.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD106.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD106.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD108.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD108.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD108.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD108.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD110.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD110.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD110.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD110.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1102.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1102.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1102.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1102.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1104.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1104.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1104.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1104.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1106.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1106.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1106.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1106.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1108.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1108.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1108.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1108.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD112.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD112.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD112.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD112.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD114.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD114.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD114.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD114.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1302.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1302.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1302.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1302.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1402.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1402.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1402.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1402.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1403.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1403.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1403.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1403.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1407.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1407.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1407.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1407.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1501.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1501.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1501.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1501.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1503.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1503.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1503.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1503.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1505.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1505.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1505.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1505.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1506.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD1506.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD1506.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD1506.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD2.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD2.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD2.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD2.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD202.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD202.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD202.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD202.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD204.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD204.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD204.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD204.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD206.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD206.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD206.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD206.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD208.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD208.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD208.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD208.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD210.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD210.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD210.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD210.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD221.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD221.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD221.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD221.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD222.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD222.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD222.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD222.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD302.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD302.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD302.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD302.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD304.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD304.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD304.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD304.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD4.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD4.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD4.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD4.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD402.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD402.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD402.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD402.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD6.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD6.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD6.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD6.cs diff --git a/HybirdFrameworkEntity/MsgModel/RecpCMD/CMD8.cs b/BatCharging.Model/MsgModel/RecpCMD/CMD8.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/RecpCMD/CMD8.cs rename to BatCharging.Model/MsgModel/RecpCMD/CMD8.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1001.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1001.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1001.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1001.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1003.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1003.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1003.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1003.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1005.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1005.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1005.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1005.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1007.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1007.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1007.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1007.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1009.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1009.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1009.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1009.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD101.cs b/BatCharging.Model/MsgModel/SendCMD/CMD101.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD101.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD101.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1011.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1011.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1011.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1011.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1021.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1021.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1021.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1021.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD103.cs b/BatCharging.Model/MsgModel/SendCMD/CMD103.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD103.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD103.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD105.cs b/BatCharging.Model/MsgModel/SendCMD/CMD105.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD105.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD105.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD107.cs b/BatCharging.Model/MsgModel/SendCMD/CMD107.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD107.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD107.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD109.cs b/BatCharging.Model/MsgModel/SendCMD/CMD109.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD109.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD109.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1101.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1101.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1101.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1101.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1103.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1103.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1103.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1103.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1105.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1105.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1105.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1105.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1107.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1107.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1107.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1107.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD111.cs b/BatCharging.Model/MsgModel/SendCMD/CMD111.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD111.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD111.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD113.cs b/BatCharging.Model/MsgModel/SendCMD/CMD113.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD113.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD113.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1301.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1301.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1301.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1301.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1401.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1401.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1401.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1401.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1406.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1406.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1406.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1406.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1502.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1502.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1502.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1502.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD1504.cs b/BatCharging.Model/MsgModel/SendCMD/CMD1504.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD1504.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD1504.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD201.cs b/BatCharging.Model/MsgModel/SendCMD/CMD201.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD201.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD201.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD203.cs b/BatCharging.Model/MsgModel/SendCMD/CMD203.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD203.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD203.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD205.cs b/BatCharging.Model/MsgModel/SendCMD/CMD205.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD205.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD205.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD207.cs b/BatCharging.Model/MsgModel/SendCMD/CMD207.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD207.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD207.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD209.cs b/BatCharging.Model/MsgModel/SendCMD/CMD209.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD209.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD209.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD3.cs b/BatCharging.Model/MsgModel/SendCMD/CMD3.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD3.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD3.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD301.cs b/BatCharging.Model/MsgModel/SendCMD/CMD301.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD301.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD301.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD303.cs b/BatCharging.Model/MsgModel/SendCMD/CMD303.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD303.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD303.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD401.cs b/BatCharging.Model/MsgModel/SendCMD/CMD401.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD401.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD401.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD5.cs b/BatCharging.Model/MsgModel/SendCMD/CMD5.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD5.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD5.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD7.cs b/BatCharging.Model/MsgModel/SendCMD/CMD7.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD7.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD7.cs diff --git a/HybirdFrameworkEntity/MsgModel/SendCMD/CMD9.cs b/BatCharging.Model/MsgModel/SendCMD/CMD9.cs similarity index 100% rename from HybirdFrameworkEntity/MsgModel/SendCMD/CMD9.cs rename to BatCharging.Model/MsgModel/SendCMD/CMD9.cs diff --git a/BatCharging.Service/BatCharging.Service.csproj b/BatCharging.Service/BatCharging.Service.csproj new file mode 100644 index 0000000..c89146a --- /dev/null +++ b/BatCharging.Service/BatCharging.Service.csproj @@ -0,0 +1,18 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + diff --git a/HybirdFrameworkEntity/MsgModel/ByteUtils.cs b/BatCharging.Service/ByteUtils.cs similarity index 99% rename from HybirdFrameworkEntity/MsgModel/ByteUtils.cs rename to BatCharging.Service/ByteUtils.cs index 05aced8..9884f0d 100644 --- a/HybirdFrameworkEntity/MsgModel/ByteUtils.cs +++ b/BatCharging.Service/ByteUtils.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace HybirdFrameworkEntity +namespace BatCharging.Service { public class ByteUtils { diff --git a/BatCharging.Service/ChargerMgrTool.cs b/BatCharging.Service/ChargerMgrTool.cs new file mode 100644 index 0000000..253d2e4 --- /dev/null +++ b/BatCharging.Service/ChargerMgrTool.cs @@ -0,0 +1,5225 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Reflection; +using System.Threading.Tasks; +using System.Threading; +using HybirdFrameworkEntity; +using System.Text; +using Newtonsoft.Json; +using System.Linq; +using DotNetty.Transport.Channels; + +namespace BatCharging.Service +{ + /// + /// 1ų + /// + public class ChargerMgrTool + { + #region + + private object lockObj = new object(); //߳ͬ + + #endregion + + #region ֶ + + #region Ϣ + private IChannelId _id; + public IChannelId ID + { + get { return _id; } + set + { + lock (lockObj) + { + _id = value; + } + } + } + + IChannel channel; + + /// + /// IPַ + /// + private string _ip_addr; + + /// + /// IPַ + /// + public string F_IPAddr + { + get { return _ip_addr; } + set + { + lock (lockObj) + { + _ip_addr = value; + } + } + } + + /// + /// ˿ں + /// + private int _ip_port = 4567; + + /// + /// ˿ں + /// + public int F_Port + { + get { return _ip_port; } + set + { + lock (lockObj) + { + _ip_port = value; + } + } + } + + /// + /// ӱ־ + /// + private bool connecting_flage = false; + + /// + /// ӱ־ + /// + public bool ConnectingFlage + { + get { return connecting_flage; } + set + { + lock (lockObj) + { + connecting_flage = value; + } + } + } + + + /// + /// ͨѶǷ + /// + private bool _net_connected = false; + + /// + /// ͨѶǷ + /// + public bool F_NetConnected + { + get { return _net_connected; } + set + { + lock (lockObj) + { + _net_connected = value; + } + } + } + + + /// + /// ͨѶʹ + /// + private bool _net_connect_enabled = true; + + /// + /// ͨѶʹ + /// + public bool F_NetConnectEnabled + { + get { return _net_connect_enabled; } + set + { + lock (lockObj) + { + _net_connect_enabled = value; + } + } + } + + /// + /// ͨѶж϶߳ʱʱ䣨λ룩 + /// + private int _net_check_time_out = 30; + + /// + /// ͨѶǷ + /// + public int F_NetCheckTimeOut + { + get { return _net_check_time_out; } + set + { + lock (lockObj) + { + _net_check_time_out = value; + } + } + } + + /// + /// ǷѾʼ + /// + private bool _is_charged = false; + + /// + /// ǷѾʼ + /// + public bool F_IsCharged + { + get { return _is_charged; } + set + { + lock (lockObj) + { + _is_charged = value; + } + } + } + + /// + /// Ƿֹͣ + /// + private bool _is_stoped = false; + + /// + /// Ƿֹͣ + /// + public bool F_IsStoped + { + get { return _is_stoped; } + set + { + lock (lockObj) + { + _is_stoped = value; + } + } + } + + /// + /// ״̬0:Чֵ1:Ȩɹ2:Ȩʧܣ3ʼɹ4ʼʧܣ5ڳ磻6ֹͣɹ7ֹͣʧܣ + /// + private UInt16 _charging_status = 0; + + /// + /// ״̬0:Чֵ1:Ȩɹ2:Ȩʧܣ3ʼɹ4ʼʧܣ5ڳ磻6ֹͣɹ7ֹͣʧܣ + /// + public UInt16 F_ChargingStatus + { + get { return _charging_status; } + set + { + lock (lockObj) + { + _charging_status = value; + } + } + } + + /// + /// 翪ʼʱ䣨Ĭ2000-1-1 + /// + private DateTime _charging_start_time = Convert.ToDateTime("2000-1-1"); + + /// + /// 翪ʼʱ䣨Ĭ2000-1-1 + /// + public DateTime F_ChargingStartTime + { + get { return _charging_start_time; } + set + { + lock (lockObj) + { + _charging_start_time = value; + } + } + } + + /// + /// ֹͣʱ䣨Ĭ2000-1-1 + /// + private DateTime _charging_stop_time = Convert.ToDateTime("2000-1-1"); + + /// + /// ֹͣʱ䣨Ĭ2000-1-1 + /// + public DateTime F_ChargingStopTime + { + get { return _charging_stop_time; } + set + { + lock (lockObj) + { + _charging_stop_time = value; + } + } + } + + /// + /// ǷѾȨ + /// + private bool _is_authed = false; + + /// + /// վǷѾȨ + /// + public bool F_IsAuthed + { + get { return _is_authed; } + set + { + lock (lockObj) + { + _is_authed = value; + } + } + } + + /// + /// óֹͣԭ.0ͣ 1׮쳣,ǿͣ + /// + private byte _stop_reason = 0; + + /// + /// óֹͣԭ.0ͣ 1׮쳣,ǿͣ + /// + public byte F_StopReason + { + get { return _stop_reason; } + set + { + lock (lockObj) + { + _stop_reason = value; + } + } + } + + /// + /// ѭԶָֹͣյظֹͣɺΪFalse + /// + private bool _is_can_send_stop_cmd = true; + + /// + /// óֹͣԭ.0ͣ 1׮쳣,ǿͣ + /// + public bool F_IsCanSendStopCmd + { + get { return _is_can_send_stop_cmd; } + set + { + lock (lockObj) + { + _is_can_send_stop_cmd = value; + } + } + } + + /// + /// ¼ǷѾ͸ƽ̨ + /// + internal bool _record_to_cloud_sended = false; + + /// + /// ¼ǷѾ͸ƽ̨ + /// + public bool F_RecordToCloudSended + { + get { return _record_to_cloud_sended; } + set + { + lock (lockObj) + { + _record_to_cloud_sended = value; + } + } + } + + /// + /// + /// + private string _eqmcode; + + /// + /// + /// + public string F_EqmCode + { + get { return _eqmcode; } + set + { + lock (lockObj) + { + _eqmcode = value; + } + } + } + + /// + /// ״̬-ңݰеõ0:12ɣ3/ŵͣ + /// + private byte _workstate; + + /// + /// ״̬-ңݰеõ0:12ɣ3/ŵͣ + /// + public byte F_WorkState + { + get { return _workstate; } + set + { + lock (lockObj) + { + _workstate = value; + } + } + } + + /// + /// + /// + private bool _is_fault; + + /// + /// -true:ϣfalse: + /// + public bool F_IsFault + { + get { return _is_fault; } + set + { + lock (lockObj) + { + _is_fault = value; + } + } + } + + /// + /// + /// + private bool _is_alarm; + + /// + /// -true:false: + /// + public bool F_IsAlarm + { + get { return _is_alarm; } + set + { + lock (lockObj) + { + _is_alarm = value; + } + } + } + + /// + /// + /// + private int _fault_number = 0; + + /// + /// + /// + public int F_FaultNumber + { + get { return _fault_number; } + set + { + lock (lockObj) + { + _fault_number = value; + } + } + } + + /// + /// ϱб + /// + private List _fault_alaram_no_list = new List(); + + /// + /// ϱб + /// + public List F_FaultAlarmNoList + { + get { return _fault_alaram_no_list; } + set + { + lock (lockObj) + { + _fault_alaram_no_list = value; + } + } + } + + /// + ///SOC + /// + private byte _soc = 0; + + /// + /// SOC + /// + public byte F_SOC + { + get { return _soc; } + set + { + lock (lockObj) + { + _soc = value; + } + } + } + + /// + ///ʵʱ繦 + /// + private float _power = 0; + + /// + /// ʵʱ繦 + /// + public float F_Power + { + get { return _power; } + set + { + lock (lockObj) + { + _power = value; + } + } + } + + + /// + /// ʱ + /// + private DateTime _recving_data_time = DateTime.Now; + + /// + /// ʱ + /// + public DateTime F_RecvingDataTime + { + get { return _recving_data_time; } + set + { + lock (lockObj) + { + _recving_data_time = value; + } + } + } + + /// + ///ʷ״̬¼ֵ + /// + private bool _charger_status_record_value; + + /// + /// ʷ״̬¼ֵ false֮ǰΪڳ״̬ true:֮ǰΪڳ״̬ + /// + public bool ChargerStatusRecordValue + { + get { return _charger_status_record_value; } + set + { + lock (lockObj) + { + _charger_status_record_value = value; + } + } + } + + + /// + ///ͷ״̬ʷ¼ֵ 0δ֪ 1֮ǰΪ״̬ 2:֮ǰΪδ״̬ + /// + private int electr_connector_connect_status_record = 0; + + /// + /// ͷ״̬ʷ¼ֵ 0δ֪ 1֮ǰΪ״̬ 2:֮ǰΪδ״̬ + /// + public int electrConnectorConnectStatusRecord + { + get { return electr_connector_connect_status_record; } + set + { + lock (lockObj) + { + electr_connector_connect_status_record = value; + } + } + } + + //private int alarmProcessCounter = 0; + /// + /// + /// + private ushort HeartBeatProcessCounter = 0; + + + + + + #endregion Ϣ + + + #region Ϣ + + + + #endregion Ϣ + + #endregion ֶ + + #region ṹ + + public ChargerMgrTool() + { + } + + + /// + /// ṹ + /// + /// IPַ + /// ˿ں + public ChargerMgrTool(string ipAddr, int port) + { + _ip_addr = ipAddr; + _ip_port = port; + } + + /// + /// + /// + /// IPַ + /// ˿ں + /// Ŀĵַֽ + public ChargerMgrTool(IChannelId id, string ipAddr, int port, string eqmcode) + { + _id = id; + _ip_addr = ipAddr; + _ip_port = port; + _eqmcode = eqmcode; + } + + #endregion ṹ + + #region ¼ + + + #endregion ¼ + + #region ¼ + + #endregion ¼ + + #region ͨѶ߳ + /// + /// ̺߳Ͷ߳ + /// + public void ChargerNetHeartBeatThread() + { + Thread chrgConnectedThread = new Thread(ChargerHeartBeatFunc); + chrgConnectedThread.IsBackground = true; + chrgConnectedThread.Start(); + } + + + public void ChargerHeartBeatFunc() + { + _net_connected = true; + while (_net_connect_enabled && _net_connected) + { + Thread.Sleep(2000); + if (!connecting_flage) + { + DateTime recvTime = DateTime.Now; + int seconds = Convert.ToInt32(recvTime.Subtract(F_RecvingDataTime).TotalSeconds); + if (seconds >= _net_check_time_out) + { + + } + } + + if (_net_connected) + { + ushort heartbeatNum = 0; + byte[] bytes = Send101(heartbeatNum); + //if (Server != null) + //{ + // Server.Send(bytes); + //} + } + } + } + + #endregion ͨѶ߳ + + #region ݽ + + + public void decode(string IP, string port, byte[] data) + { + switch (IP) + { + case "1": + + break; + case "2": + break; + case "3": + break; + case "4": + break; + case "5": + break; + } + int func = (ushort)(data[6] + (data[6 + 1] << 8)); + F_RecvingDataTime = DateTime.Now; + switch (func) + { + #region Эʽ + + case 2: + { + CMD2 CMD2 = ConCMD2(data); + string result = "(CMD=2)׮/ѯӦ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=2)׮/ѯӦ" + JsonConvert.SerializeObject(CMD2); + ////Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 4: + { + CMD4 CMD4 = ConCMD4(data); + string result = "(CMD=4)׮ַ/ѯӦ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=4)׮ַ/ѯӦ" + JsonConvert.SerializeObject(CMD4); + ////Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 6: + { + CMD6 CMD6 = ConCMD6(data); + string result = "(CMD=6)׮Ժ̨Ӧ- ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=6)׮Ժ̨Ӧ" + JsonConvert.SerializeObject(CMD6); + ////Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 8: + { + CMD8 CMD8 = ConCMD8(data); + string result = "(CMD=8) ׮Ժ̨·ij׮Ӧ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=8) ׮Ժ̨·ij׮Ӧ" + JsonConvert.SerializeObject(CMD8); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 10: + { + CMD10 CMD10 = ConCMD10(data); + string result = "(CMD=10)׮ϴ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ϴ(Ԥ)" + JsonConvert.SerializeObject(CMD10); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + #endregion + + #region ׮ϴ + + case 102: + { + CMD102 CMD102 = ConCMD102(data); + string result = "(CMD=10)׮ϴϢ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ϴϢ" + JsonConvert.SerializeObject(CMD102); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 104: + { + CMD104 CMD104 = ConCMD104(data); + string result = "(CMD=10)׮״̬Ϣϱ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮״̬Ϣϱ" + JsonConvert.SerializeObject(CMD104); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 106: + { + CMD106 CMD106 = ConCMD106(data); + string result = "(CMD=10)׮ǩϢϱ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ǩϢϱ" + JsonConvert.SerializeObject(CMD106); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 108: + { + CMD108 CMD108 = ConCMD108(data); + string result = "(CMD=10)׮澯Ϣϱ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮澯Ϣϱ(Ԥ)" + JsonConvert.SerializeObject(CMD108); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 110: + { + CMD110 CMD110 = ConCMD110(data); + string result = "(CMD=10)׮ϱ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ϱ(Ԥ)" + JsonConvert.SerializeObject(CMD110); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 112: + { + CMD112 CMD112 = ConCMD112(data); + string result = "(CMD=10)׮ģϢϱ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ģϢϱ" + JsonConvert.SerializeObject(CMD112); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 114: + { + CMD114 CMD114 = ConCMD114(data); + string result = "(CMD=10)׮ӦѯһγʱϢ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ӦѯһγʱϢ" + JsonConvert.SerializeObject(CMD114); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region Ϣ + + case 202: + case 222: + { + CMD202 CMD202 = ConCMD202((UInt16)func, data); + string result = "׮ϱ¼Ϣ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "ϱ¼Ϣ" + JsonConvert.SerializeObject(CMD202); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 204: + { + CMD204 CMD204 = ConCMD204(data); + string result = "׮ϴû˻ѯ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϴû˻ѯĶ" + JsonConvert.SerializeObject(CMD204); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 206: + { + CMD206 CMD206 = ConCMD206(data); + string result = "׮ϴû֤ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϴû֤Ķ" + JsonConvert.SerializeObject(CMD206); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 208: + { + CMD208 CMD208 = ConCMD208(data); + string result = "׮ϱ弴䡱 - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϱ弴䡱" + JsonConvert.SerializeObject(CMD208); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 210: + { + CMD210 CMD210 = ConCMD210(data); + string result = "׮ϱ弴䡱 - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϱ弴䡱" + JsonConvert.SerializeObject(CMD210); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region ֱ׮ BMS Ϣ(Ԥ) + case 302: + { + CMD302 CMD302 = ConCMD302(data); + string result = "׮ϱBMSϢ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϱBMSϢ" + JsonConvert.SerializeObject(CMD302); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 304: + { + CMD304 CMD304 = ConCMD304(data); + string result = "׮ϱBMSϢ(Ԥ-ʱ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϱBMSϢ(Ԥ-ʱ)" + JsonConvert.SerializeObject(CMD304); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region ʷ¼ + case 402: + case 422: + { + CMD402 CMD402 = ConCMD402((UInt16)func, data); + string result = "׮ϱʷij¼ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϱʷij¼" + JsonConvert.SerializeObject(CMD402); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + #endregion + + #region + case 1002: + { + CMD1002 CMD1002 = ConCMD1002(data); + string result = "׮ظ·ָ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ظ·ָ" + JsonConvert.SerializeObject(CMD1002); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1004: + { + CMD1004 CMD1004 = ConCMD1004(data); + string result = "׮Ӧ·ļָ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ļָ" + JsonConvert.SerializeObject(CMD1004); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1006: + { + CMD1006 CMD1006 = ConCMD1006(data); + string result = "׮Ӧ·ļСָ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ļСָ" + JsonConvert.SerializeObject(CMD1006); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1008: + { + CMD1008 CMD1008 = ConCMD1008(data); + string result = "׮Ӧ·ļָ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ļָ" + JsonConvert.SerializeObject(CMD1008); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1010: + { + CMD1010 CMD1010 = ConCMD1010(data); + string result = "׮Ӧ·ļݽָ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ļݽָ" + JsonConvert.SerializeObject(CMD1010); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1012: + { + CMD1012 CMD1012 = ConCMD1012(data); + string result = "׮Ӧ·ָ- ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ָ" + JsonConvert.SerializeObject(CMD1012); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1022: + { + CMD1022 CMD1022 = ConCMD1022(data); + string result = "׮ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮" + JsonConvert.SerializeObject(CMD1022); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region ƷѲصָ + case 1102: + { + CMD1102 CMD1102 = ConCMD1102(data); + string result = "׮Ӧ̨ѯ24ʱѼƼ۲Ϣ- ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ̨ѯ24ʱѼƼ۲Ϣ" + JsonConvert.SerializeObject(CMD1102); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1104: + { + CMD1104 CMD1104 = ConCMD1104(data); + string result = "׮Ӧ̨24ʱѼƼ۲Ϣ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ̨24ʱѼƼ۲Ϣ" + JsonConvert.SerializeObject(CMD1104); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1106: + { + CMD1106 CMD1106 = ConCMD1106(data); + string result = "׮Ӧ̨÷ʱμƼ۲Ϣ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ̨÷ʱμƼ۲Ϣ" + JsonConvert.SerializeObject(CMD1106); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1108: + { + CMD1108 CMD1108 = ConCMD1108(data); + string result = "׮ظʱѼƼ۲Ϣ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ظʱѼƼ۲Ϣ" + JsonConvert.SerializeObject(CMD1108); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region + case 1302: + { + CMD1302 CMD1302 = ConCMD1302(data); + string result = "׮Ӧ־ݰ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ־ݰ" + JsonConvert.SerializeObject(CMD1302); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region FTPԶFTPʽ־ϴ + case 1402: + { + CMD1402 CMD1402 = ConCMD1402(data); + string result = "׮Ӧ·FTPԶ- ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·FTPԶ" + JsonConvert.SerializeObject(CMD1402); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1403: + { + CMD1403 CMD1403 = ConCMD1403(data); + string result = "׮ӦFTPؽ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ӦFTPؽȶ" + JsonConvert.SerializeObject(CMD1403); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1407: + { + CMD1407 CMD1407 = ConCMD1407(data); + string result = "׮Ӧ·ȡ׮־ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ȡ׮־" + JsonConvert.SerializeObject(CMD1407); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region Э鷽ʽ־ϴ + case 1501: + { + CMD1501 CMD1501 = ConCMD1501(data); + string result = "(CMD=1501ϴļ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=1501ϴļ" + JsonConvert.SerializeObject(CMD1501); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1503: + { + CMD1503 CMD1503 = ConCMD1503(data); + string result = "(CMD=10)׮ϴ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ϴ(Ԥ)" + JsonConvert.SerializeObject(CMD1503); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 1505://ɣҪر + { + CMD1505 CMD1505 = ConCMD1505(data); + string result = "(CMD=10)׮ϴ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ϴ(Ԥ)" + JsonConvert.SerializeObject(CMD1505); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + } + } + + + #endregion ݽ + + #region ݷ + + #region ׮/ѯ + /// + /// (CMD=1)̨·׮ι + /// + /// + /// + /// + /// + /// + public byte[] Send1(byte type, uint startAddress, byte num, byte[] setData) + { + APDUModel APDUModel; + + CMD1 CMD1 = new CMD1(); + CMD1.Type = type; + CMD1.SetAddress = startAddress; + CMD1.SelectNum = num; + CMD1.SetByteNum = (ushort)(num * 4); + CMD1.SetData = setData; + + byte[] bytes = new ChargerSendCMD().SendRCMD1(out APDUModel, CMD1); + + if (APDUModel != null) + { + string result = "1̨·׮ι-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// (CMD=3) + /// + /// + /// + /// + public byte[] Send3(byte type, uint startAddress, byte[] setData) + { + APDUModel APDUModel; + + + CMD3 CMD3 = new CMD3(); + CMD3.Reserved1 = 0; + CMD3.Reserved2 = 0; + CMD3.Type = type; + CMD3.SAddress = startAddress; + CMD3.SBytes = cmd3StartAddress[startAddress]; + CMD3.SData = setData; + + byte[] bytes = new ChargerSendCMD().SendRCMD3(out APDUModel, CMD3); + + if (APDUModel != null) + { + string result = "3̨·׮ַͲ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + + /// + /// ̨·׮ + /// + /// + /// ǹ + /// ʼַ + /// + /// + public byte[] Send5(byte chargeMuzzle, uint startAddress, byte num, byte[] setData) + { + + APDUModel APDUModel; + + CMD5 CMD = new CMD5(); + CMD.RechargeableMuzzle = chargeMuzzle; + CMD.CommandAddress = startAddress; + CMD.CommandNum = num; + CMD.CommandLength = (ushort)(num * 4); + CMD.CommandData = setData; + + + byte[] bytes = new ChargerSendCMD().SendRCMD5(out APDUModel, CMD); + + if (APDUModel != null) + { + string result = "5̨·׮-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + + + /// + /// ̨·׮ + /// + /// + /// + public byte[] Send7(CMD7 CMD) + { + APDUModel APDUModel; + + byte[] bytes = new ChargerSendCMD().SendRCMD7(out APDUModel, CMD); + if (APDUModel != null) + { + + string result = "7̨·׮-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + + + + public byte[] Send9(byte chargeMuzzle, uint executeResult, uint address, byte[] setData) + { + APDUModel APDUModel; + + CMD9 CMD = new CMD9(); + + CMD.ChargGunNum = chargeMuzzle; + CMD.FWResult = executeResult; + CMD.CommandAddress = address; + CMD.DataLength = 4; + CMD.Datas = new byte[4]; + + byte[] bytes = new ChargerSendCMD().SendRCMD9(out APDUModel, CMD); + + if (APDUModel != null) + { + string result = "9̨Ӧ׮ϴ(Ԥ)-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + + #endregion + + #region ׮ϴ + /// + /// ӦϢ + /// + /// + /// Ӧ + public byte[] Send101(ushort heartbeatNum) + { + APDUModel APDUModel; + + CMD101 CMD = new CMD101(); + + CMD.HearResponse = heartbeatNum; + + byte[] bytes = new ChargerSendCMD().SendRCMD101(out APDUModel, CMD); + if (APDUModel != null) + { + + string result = "101ӦϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// Ӧ׮״̬Ϣ + /// + /// + /// ں + /// Ƿϱһ104 0- 1- + public byte[] Send103(byte chargeNum, bool reportMessage) + { + APDUModel APDUModel; + + + CMD103 CMD = new CMD103(); + CMD.ChargNum = chargeNum; + CMD.Reported = reportMessage; + + + byte[] bytes = new ChargerSendCMD().SendRCMD103(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "103Ӧ׮״̬Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// Ӧ׮ǩ + /// + /// + /// + public byte[] Send105(CMD105 CMD) + { + APDUModel APDUModel; + + byte[] bytes = new ChargerSendCMD().SendRCMD105(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "105Ӧ׮ǩ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// Ӧ׮澯Ϣ + /// + /// + public byte[] Send107() + { + APDUModel APDUModel; + + CMD107 CMD = new CMD107(); + + byte[] bytes = new ChargerSendCMD().SendRCMD107(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "107Ӧ׮澯Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// Ӧ׮澯Ϣ + /// + /// + public byte[] Send109() + { + APDUModel APDUModel; + + + + CMD109 CMD = new CMD109(); + + + byte[] bytes = new ChargerSendCMD().SendRCMD109(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "109Ӧ׮-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + public byte[] Send111(byte messageType) + { + APDUModel APDUModel; + + + CMD111 CMD = new CMD111(); + + CMD.MessageType = messageType; + + + byte[] bytes = new ChargerSendCMD().SendRCMD111(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "111Ӧ׮ϱģϢԤ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// ѯһγʱϢ + /// + /// + /// ں + /// ־ + public byte[] Send113(byte chargeNum, byte sign) + { + APDUModel APDUModel; + + CMD113 CMD = new CMD113(); + + CMD.ChargNum = chargeNum; + CMD.Sign = sign; + + + byte[] bytes = new ChargerSendCMD().SendRCMD113(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "113ѯһγʱϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + #endregion + + #region Ϣ + + /// + /// (CMD=5) + /// + /// + /// + /// + public byte[] Send201(CMD201 CMD, uint func) + { + + byte[] bytes = new ChargerSendCMD().SendRCMD201(out APDUModel APDUModel, CMD, func); + string result = "201Ӧ׮ϱϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + + public byte[] Send203(CMD203 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD203(out APDUModel APDUModel, CMD); + string result = "203Ӧ˻ѯϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + + public byte[] Send205(uint value03, uint value04) + { + CMD205 CMD = new CMD205(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + CMD.ResponseCode = value03; + if (CMD.ResponseCode == 0) + { + CMD.Balance = value04; + } + else + { + CMD.Balance = 0; + } + + byte[] bytes = new ChargerSendCMD().SendRCMD205(out APDUModel APDUModel, CMD); + string result = "205Ӧ֤ģԤ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + + public byte[] Send207(CMD208 CMD208, string value06, string value07, byte value08, byte value09, uint value10, ulong value11) + { + CMD207 CMD = new CMD207(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + CMD.ASCIINum = CMD208.ASCIINum; + CMD.ChargGunNum = CMD208.ChargGunNum; + CMD.VINNum = CMD208.VINNum; + CMD.VINBindAccount = value06; + CMD.ChargSerialNum = value07; + CMD.VerifyResult = value08; + CMD.VerifyCause = value09; + CMD.RechBalance = value10; + CMD.StopCode = value11; + byte[] bytes = new ChargerSendCMD().SendRCMD207(out APDUModel APDUModel, CMD); + string result = "207ƽ̨ظ弴䡱-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + + public byte[] Send209(CMD210 CMD210, string value05) + { + CMD209 CMD = new CMD209(); + CMD.Reserved1 = CMD210.Reserved1; + CMD.Reserved2 = CMD210.Reserved2; + CMD.ASCIINum = CMD210.ASCIINum; + CMD.ChargGunNum = CMD210.ChargGunNum; + CMD.VINNum = value05; + byte[] bytes = new ChargerSendCMD().SendRCMD209(out APDUModel APDUModel, CMD); + string result = "209ƽ̨ظ弴䡱-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send221(CMD221 CMD221, uint value05) + { + CMD221 CMD = new CMD221(); + CMD.Reserved1 = CMD221.Reserved1; + CMD.Reserved2 = CMD221.Reserved2; + CMD.ChargNum = CMD221.ChargNum; + CMD.ChargID = CMD221.ChargID; + CMD.IndexNum = value05; + byte[] bytes = new ChargerSendCMD().SendRCMD221(out APDUModel APDUModel, CMD); + string result = "վӦŵϱģ״̬-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + #endregion + + #region ֱ׮ BMS Ϣ(Ԥ) + + public byte[] Send301() + { + CMD301 CMD = new CMD301(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + byte[] bytes = new ChargerSendCMD().SendRCMD301(out APDUModel APDUModel, CMD); + string result = "301Ӧ׮ϱBMSϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + public byte[] Send303() + { + CMD303 CMD = new CMD303(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + byte[] bytes = new ChargerSendCMD().SendRCMD303(out APDUModel APDUModel, CMD); + string result = "303Ӧ׮ϱBMSϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + #region ʷ¼ + + public byte[] Send401(string chargingSerialNum, uint startIndex) + { + CMD401 CMD = new CMD401(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + CMD.SelectIndex = startIndex; + CMD.ChargSerialNum = chargingSerialNum; + byte[] bytes = new ChargerSendCMD().SendRCMD401(out APDUModel APDUModel, CMD); + string result = "401/421ѯ׮ʷ¼-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + #region + + public byte[] Send1001(uint instruct) + { + CMD1001 CMD = new CMD1001(); + CMD.CInstruction = instruct; + byte[] bytes = new ChargerSendCMD().SendRCMD1001(out APDUModel APDUModel, CMD); + string result = "1001·ָ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1003(string fileName) + { + CMD1003 CMD = new CMD1003(); + CMD.Filename = fileName; + byte[] bytes = new ChargerSendCMD().SendRCMD1003(out APDUModel APDUModel, CMD); + string result = "1003·ļָ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1005(uint fileLength) + { + CMD1005 CMD = new CMD1005(); + CMD.FileLength = fileLength; + byte[] bytes = new ChargerSendCMD().SendRCMD1005(out APDUModel APDUModel, CMD); + string result = "1005·ļС-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1007(string updata) + { + CMD1007 CMD = new CMD1007(); + CMD.UpFileData = updata; + byte[] bytes = new ChargerSendCMD().SendRCMD1007(out APDUModel APDUModel, CMD); + string result = "1007·ļ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1009(uint Reserved1) + { + CMD1009 CMD = new CMD1009(); + CMD.Reserved1 = Reserved1; + byte[] bytes = new ChargerSendCMD().SendRCMD1009(out APDUModel APDUModel, CMD); + string result = "1009·ļݽָ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1011(uint Reserved1) + { + CMD1011 CMD = new CMD1011(); + CMD.Reserved1 = 0; + byte[] bytes = new ChargerSendCMD().SendRCMD1011(out APDUModel APDUModel, CMD); + string result = "1011·ָ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1021(uint results, string description) + { + CMD1021 CMD = new CMD1021(); + CMD.ResponseResult = results; + CMD.ResponsExplain = description; + byte[] bytes = new ChargerSendCMD().SendRCMD1021(out APDUModel APDUModel, CMD); + string result = "1021ظ׮-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + #region ƷѲصָ + + + public byte[] Send1101() + { + byte[] bytes = new ChargerSendCMD().SendRCMD1101(out APDUModel APDUModel); + string result = "1101̨ѯ24ʱѼƼ۲Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1103(CMD1103 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD1103(out APDUModel APDUModel, CMD); + string result = "1103̨24ʱεѼƼ۲Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1105(CMD1105 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD1105(out APDUModel APDUModel, CMD); + string result = "1105̨÷ʱμƼ۲Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1107() + { + byte[] bytes = new ChargerSendCMD().SendRCMD1107(out APDUModel APDUModel); + string result = "1107̨ѯʱѼƼ۲Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + #region + + + public byte[] Send1301(CMD1301 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD1301(out APDUModel APDUModel, CMD); + string result = "1301·־ݰ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + #endregion + + #region FTP Զ FTP ʽ־ϴ + + public byte[] Send1401(CMD1401 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD1401(out APDUModel APDUModel, CMD); + string result = "1401·FTPԶ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1406(CMD1406 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD1406(out APDUModel APDUModel, CMD); + string result = "1406·ȡ׮־Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + #region Э鷽ʽ־ϴ + + public byte[] Send1502(uint responseCode) + { + CMD1502 CMD = new CMD1502(); + + CMD.AnswerCode = responseCode; + byte[] bytes = new ChargerSendCMD().SendRCMD1502(out APDUModel APDUModel, CMD); + string result = "cmd1502 ϴ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1504(uint logo, uint successReservedMessageNum) + { + CMD1504 CMD = new CMD1504(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + CMD.Sign = logo; + CMD.ReceiveMessageNum = successReservedMessageNum; + byte[] bytes = new ChargerSendCMD().SendRCMD1504(out APDUModel APDUModel, CMD); + string result = "1504Ӧϴ־-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1506() + { + CMD1506 CMD = new CMD1506(); + CMD.Reserved1 = 0; + CMD.Reserved1 = 0; + byte[] bytes = new ChargerSendCMD().SendRCMD1506(out APDUModel APDUModel, CMD); + string result = "1506ǰļ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + /// + /// + /// + Dictionary cmd3StartAddress = new Dictionary() + { + {1, 32}, + {2, 8}, + {3, 8}, + {4, 8}, + {5, 6}, + {6, 16}, + {7, 256}, + {8, 16}, + {9, 16}, + {10, 256}, + {11, 128}, + {12, 12}, + {13, 64}, + {14, 8}, + {15, 256}, + {16, 256}, + {17, 256}, + {18, 256}, + {19, 256}, + { 20, 256}, + }; + + #endregion + + #region ݽ + + public CMD2 ConCMD2(byte[] data) + { + CMD2 CMD2 = null; + if (data != null && data.Length > 0) + { + CMD2 = new CMD2(); + CMD2.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD2.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD2.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD2.Type = data[44]; + CMD2.SAddress = ByteUtils.DToUInt32(data, 45); + CMD2.SNum = data[50]; + CMD2.SResult = data[51]; + CMD2.SData = Encoding.ASCII.GetString(data, 52, (data.Length - 52)); + + } + return CMD2; + } + public CMD4 ConCMD4(byte[] data) + { + CMD4 CMD4 = null; + if (data != null && data.Length > 0) + { + CMD4 = new CMD4(); + CMD4.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD4.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD4.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD4.Type = data[44]; + CMD4.SAddress = ByteUtils.DToUInt32(data, 45); + CMD4.SResult = data[49]; + CMD4.SData = Encoding.ASCII.GetString(data, 50, (data.Length - 51)); + + } + return CMD4; + } + public CMD6 ConCMD6(byte[] data) + { + CMD6 CMD6 = null; + if (data != null && data.Length > 0) + { + CMD6 = new CMD6(); + CMD6.value01 = ByteUtils.DToUInt16(data, 8); + CMD6.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD6.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD6.ChargMuzzle = data[44]; + CMD6.CommandMark = ByteUtils.DToUInt32(data, 45); + CMD6.CommandNum = data[49]; + CMD6.CommandResult = data[50]; + } + return CMD6; + } + public CMD8 ConCMD8(byte[] data) + { + CMD8 CMD8 = null; + if (data != null && data.Length > 0) + { + CMD8 = new CMD8(); + CMD8.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD8.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD8.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD8.ChargMuzzle = data[44]; + CMD8.CommandResult = ByteUtils.DToUInt16(data, 45); + CMD8.ChargSerialNum = Encoding.ASCII.GetString(data, 49, 32); + } + return CMD8; + } + public CMD10 ConCMD10(byte[] data) + { + CMD10 CMD10 = null; + if (data != null && data.Length > 0) + { + CMD10 = new CMD10(); + CMD10.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD10.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD10.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); ; + CMD10.ChargGunNum = data[44]; + CMD10.RequestStaIP = ByteUtils.DToUInt32(data, 45); + CMD10.Parameter = (float)((ByteUtils.DToUInt32(data, 49)) * 0.01); + } + return CMD10; + } + public CMD102 ConCMD102(byte[] data) + { + CMD102 CMD102 = null; + if (data != null && data.Length > 0) + { + CMD102 = new CMD102(); + CMD102.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD102.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD102.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); ; + CMD102.HeartNum = ByteUtils.DToUInt16(data, 44); + CMD102.GunStatus[0] = data[46]; + CMD102.GunStatus[1] = data[47]; + CMD102.GunStatus[2] = data[48]; + CMD102.GunStatus[3] = data[49]; + CMD102.GunStatus[4] = data[50]; + CMD102.GunStatus[5] = data[51]; + CMD102.GunStatus[6] = data[52]; + CMD102.GunStatus[7] = data[53]; + CMD102.GunStatus[8] = data[54]; + CMD102.GunStatus[9] = data[55]; + CMD102.GunStatus[10] = data[56]; + CMD102.GunStatus[11] = data[57]; + CMD102.GunStatus[12] = data[58]; + CMD102.GunStatus[13] = data[59]; + CMD102.GunStatus[14] = data[60]; + CMD102.GunStatus[15] = data[61]; + } + return CMD102; + } + public CMD104 ConCMD104(byte[] data) + { + CMD104 CMD104 = null; + if (data != null && data.Length > 0) + { + CMD104 = new CMD104(); + + CMD104.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD104.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD104.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD104.ChargGunNum = data[44]; + CMD104.ChargNum = data[45]; + CMD104.ChargGunType = data[46]; + CMD104.WorkState = data[47]; + CMD104.SOCNOW = data[48]; + CMD104.MaxAlarmCode = Encoding.ASCII.GetString(data, 49, 4); + CMD104.ConnecteState = data[53]; + CMD104.TotalCost = (float)(ByteUtils.DToUInt32(data, 54) * 0.01); + CMD104.Reserved3 = ByteUtils.DToUInt32(data, 58); + CMD104.Reserved4 = ByteUtils.DToUInt32(data, 62); + if (data[46] == 1) + { + CMD104.DcChargVoltage = ByteUtils.DToUInt16(data, 66); + CMD104.DcChargCurrent = ByteUtils.DToUInt16(data, 68); + CMD104.BMSDemVoltage = ByteUtils.DToUInt16(data, 70); + CMD104.BMSDemCurrent = ByteUtils.DToUInt16(data, 72); + } + else + { + CMD104.DcChargVoltage = 0; + CMD104.DcChargCurrent = 0; + CMD104.BMSDemVoltage = 0; + CMD104.BMSDemCurrent = 0; + } + + + + CMD104.BMSchargMode = data[74]; + CMD104.AcChargVoltageA = ByteUtils.DToUInt16(data, 75); + CMD104.AcChargVoltageB = ByteUtils.DToUInt16(data, 77); + CMD104.AcChargVoltageC = ByteUtils.DToUInt16(data, 79); + CMD104.AcChargCurrentA = ByteUtils.DToUInt16(data, 81); + CMD104.AcChargCurrentB = ByteUtils.DToUInt16(data, 83); + CMD104.AcChargCurrentC = ByteUtils.DToUInt16(data, 85); + CMD104.RemainTime = ByteUtils.DToUInt16(data, 87); + CMD104.ChargTime = ByteUtils.DToUInt32(data, 89); + CMD104.TotalChargkwh = ByteUtils.DToUInt32(data, 93); + CMD104.StartAmmeterValue = (float)(ByteUtils.DToUInt32(data, 97) * 0.01); + CMD104.AmmeterValue = (float)(ByteUtils.DToUInt32(data, 101) * 0.01); + CMD104.ChargStartMode = data[105]; + CMD104.ChargStrategy = data[106]; + CMD104.ChargStrategyPara = ByteUtils.DToUInt32(data, 107); + CMD104.AppointmentSign = data[111]; + CMD104.ChargID = Encoding.ASCII.GetString(data, 112, 32); + CMD104.OutTime = data[144]; + CMD104.StartTime = Encoding.ASCII.GetString(data, 145, 8); + CMD104.InitialBalance = ByteUtils.DToUInt32(data, 153); + CMD104.Reserved5 = ByteUtils.DToUInt32(data, 157); + CMD104.ChargPower = (float)(ByteUtils.DToUInt32(data, 161) * 0.1); + CMD104.Reserved6 = ByteUtils.DToUInt32(data, 165); + CMD104.Reserved7 = ByteUtils.DToUInt32(data, 169); + CMD104.Reserved8 = ByteUtils.DToUInt32(data, 173); + CMD104.OutletTemp = data[177]; + CMD104.Temperature = data[178]; + CMD104.ChargGunTemp = data[179]; + CMD104.VINNum = Encoding.ASCII.GetString(data, 180, 18); + CMD104.DoorState = data[198]; + CMD104.ChargSerialNum = Encoding.ASCII.GetString(data, 199, 32); + CMD104.TotalElectricity = ByteUtils.DToUInt32(data, 231); + CMD104.ServiceCharge = ByteUtils.DToUInt32(data, 235); + CMD104.HomingState = data[239]; + CMD104.GroundLockedState = data[240]; + CMD104.KilojoulesElec = data[241]; + CMD104.DcACElectricity = ((float)(ByteUtils.DToUInt32(data, 242) * 0.001)).ToString("F1"); + CMD104.ChargMode = data[246]; + CMD104.ChargeOrDisSign = data[247]; + } + return CMD104; + } + public CMD106 ConCMD106(byte[] data) + { + CMD106 CMD106 = null; + if (data != null && data.Length > 0) + { + CMD106 = new CMD106(); + CMD106.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD106.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD106.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD106.Sign = data[44]; + CMD106.ChargVersion = ByteUtils.DToUInt32(data, 45); + CMD106.ChargProType = ByteUtils.DToUInt16(data, 49); + CMD106.StartNum = ByteUtils.DToUInt32(data, 51); + CMD106.DataUploadMode = data[55]; + CMD106.SignInterval = ByteUtils.DToUInt16(data, 56); + CMD106.RunVariable = data[58]; + CMD106.ChargGunNum = data[59]; + CMD106.HeartReportCycle = data[60]; + CMD106.TimeoutNum = data[61]; + CMD106.RecordNum = ByteUtils.DToUInt32(data, 62); + CMD106.SystemTime = Encoding.ASCII.GetString(data, 66, 8); + CMD106.Reserved3 = Encoding.ASCII.GetString(data, 74, 8); + CMD106.Reserved4 = Encoding.ASCII.GetString(data, 82, 8); + CMD106.Reserved5 = Encoding.ASCII.GetString(data, 90, 8); + CMD106.RandomNum = ByteUtils.DToUInt32(data, 98); + CMD106.ProtocolVersion = ByteUtils.DToUInt16(data, 102); + CMD106.WhiteVersionNum = ByteUtils.DToUInt16(data, 104); + CMD106.DeviceType = data[108]; + CMD106.AssetCoding = Encoding.ASCII.GetString(data, 109, 32); + } + return CMD106; + } + public CMD108 ConCMD108(byte[] data) + { + CMD108 CMD108 = null; + if (data != null && data.Length > 0) + { + CMD108 = new CMD108(); + CMD108.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD108.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD108.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD108.AlarmBitInfo = Encoding.ASCII.GetString(data, 44, 32); + } + return CMD108; + } + public CMD110 ConCMD110(byte[] data) + { + CMD110 CMD110 = null; + if (data != null && data.Length > 0) + { + CMD110 = new CMD110(); + CMD110.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD110.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD110.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD110.ChargGunNum = data[44]; + CMD110.ChargeFail = ByteUtils.DToUInt32(data, 45); + CMD110.SendMessage = ByteUtils.DToUInt16(data, 49); + CMD110.Reserved3 = ByteUtils.DToUInt16(data, 51); + CMD110.Reserved4 = ByteUtils.DToUInt32(data, 53); + byte version1 = data[58]; + byte version2 = data[59]; + byte version3 = data[60]; + CMD110.BRMBMSVersionNum = "v" + version1.ToString() + version2.ToString() + version3.ToString(); + CMD110.BRMBatteryType = data[61]; + CMD110.BRMRatedCapacity = ByteUtils.DToUInt32(data, 62); + CMD110.BRMRatedVoltage = ByteUtils.DToUInt32(data, 66); + CMD110.BRMBatteryManu = ByteUtils.DToUInt32(data, 70); + CMD110.BRMBatteryPackID = ByteUtils.DToUInt32(data, 74); + CMD110.BRMDateYear = ByteUtils.DToUInt16(data, 78); + CMD110.BRMDateMonth = data[80]; + CMD110.BRMDateDay = data[81]; + CMD110.BRMChargeCount = ByteUtils.DToUInt32(data, 82); + CMD110.BRMTitleMark = data[86]; + CMD110.Reserved5 = data[87]; + CMD110.BRMVINID = Encoding.ASCII.GetString(data, 88, 17); + + byte VersionSerialNum = data[105]; + byte day = data[106]; + byte month = data[107]; + ushort year = ByteUtils.DToUInt16(data, 108); + + + CMD110.BRMBMSSoftVerNum = VersionSerialNum.ToString() + year.ToString() + "" + month.ToString() + "" + day.ToString() + ""; + CMD110.MaxChargVoltage = (float)(ByteUtils.DToUInt32(data, 113) * 0.1); + CMD110.MaxChargCurrent = (float)(ByteUtils.DToUInt32(data, 117) * 0.1); + CMD110.TotalEnergy = (float)(ByteUtils.DToUInt32(data, 121) * 0.1); + CMD110.MaxTotalVoltage = (float)(ByteUtils.DToUInt32(data, 125) * 0.1); + CMD110.MaxTemp = data[129]; + CMD110.ChargeState = (float)(ByteUtils.DToUInt16(data, 130) * 0.1); + CMD110.CellVoltage = (float)(ByteUtils.DToUInt32(data, 132) * 0.1); + CMD110.ChargSerialNum = Encoding.ASCII.GetString(data, 136, 32); + } + return CMD110; + } + public CMD112 ConCMD112(byte[] data) + { + CMD112 CMD112 = null; + if (data != null && data.Length > 0) + { + CMD112 = new CMD112(); + CMD112.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD112.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD112.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD112.ReportMode = data[44]; + CMD112.ModuleNum = data[45]; + CMD112.ModuleType = data[46]; + CMD112.ACModuleversion1 = ByteUtils.DToUInt16(data, 47); + CMD112.DCModuleversion1 = ByteUtils.DToUInt16(data, 49); + CMD112.ModuleState1 = data[51]; + CMD112.ModuleOutVoltage1 = ByteUtils.DToUInt16(data, 52); + CMD112.ModuleOutCurrent1 = ByteUtils.DToUInt16(data, 54); + CMD112.ModuleAlarm1 = ByteUtils.DToUInt32(data, 56); + CMD112.ACModuleversion2 = ByteUtils.DToUInt16(data, 60); + CMD112.DCModuleversion2 = ByteUtils.DToUInt16(data, 62); + CMD112.ModuleState2 = data[64]; + CMD112.ModuleOutVoltage2 = ByteUtils.DToUInt16(data, 65); + CMD112.ModuleOutCurrent2 = ByteUtils.DToUInt16(data, 67); + CMD112.ModuleAlarm2 = ByteUtils.DToUInt32(data, 69); + } + return CMD112; + } + public CMD114 ConCMD114(byte[] data) + { + CMD114 CMD114 = null; + if (data != null && data.Length > 0) + { + CMD114 = new CMD114(); + CMD114.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD114.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD114.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD114.ChargGunNum = data[44]; + CMD114.WorkState = data[45]; + CMD114.StartChargTime = Encoding.ASCII.GetString(data, 46, 8); + /* + 7 54 + 8 56 + 9 58 + 10 60 + 11 62 + 12 64 + 13 66 + 14 68 + 15 70 + 16 72 + 17 74 + 18 76 + 19 78 + 20 80 + 21 82 + 22 84 + 23 86 + 24 88 + 25 90 + 26 92 + 27 94 + 28 96 + 29 98 + 30 100 + 31 102 + 32 104 + 33 106 + 34 108 + 35 110 + 36 112 + 37 114 + 38 116 + 39 118 + 40 120 + 41 122 + 42 124 + 43 126 + 44 128 + 45 130 + 46 132 + 47 134 + 48 136 + 49 138 + 50 140 + 51 142 + 52 144 + 53 146 + 54 148 + + */ + CMD114.Charge01 = ByteUtils.DToUInt16(data, 54); + CMD114.Charge02 = ByteUtils.DToUInt16(data, 56); + CMD114.Charge03 = ByteUtils.DToUInt16(data, 58); + CMD114.Charge04 = ByteUtils.DToUInt16(data, 60); + CMD114.Charge05 = ByteUtils.DToUInt16(data, 62); + CMD114.Charge06 = ByteUtils.DToUInt16(data, 64); + CMD114.Charge07 = ByteUtils.DToUInt16(data, 66); + CMD114.Charge08 = ByteUtils.DToUInt16(data, 68); + CMD114.Charge09 = ByteUtils.DToUInt16(data, 70); + CMD114.Charge10 = ByteUtils.DToUInt16(data, 72); + CMD114.Charge11 = ByteUtils.DToUInt16(data, 74); + CMD114.Charge12 = ByteUtils.DToUInt16(data, 76); + CMD114.Charge13 = ByteUtils.DToUInt16(data, 78); + CMD114.Charge14 = ByteUtils.DToUInt16(data, 80); + CMD114.Charge15 = ByteUtils.DToUInt16(data, 82); + CMD114.Charge16 = ByteUtils.DToUInt16(data, 84); + CMD114.Charge17 = ByteUtils.DToUInt16(data, 86); + CMD114.Charge18 = ByteUtils.DToUInt16(data, 88); + CMD114.Charge19 = ByteUtils.DToUInt16(data, 90); + CMD114.Charge20 = ByteUtils.DToUInt16(data, 92); + CMD114.Charge21 = ByteUtils.DToUInt16(data, 94); + CMD114.Charge22 = ByteUtils.DToUInt16(data, 96); + CMD114.Charge23 = ByteUtils.DToUInt16(data, 98); + CMD114.Charge24 = ByteUtils.DToUInt16(data, 100); + CMD114.Charge25 = ByteUtils.DToUInt16(data, 102); + CMD114.Charge26 = ByteUtils.DToUInt16(data, 104); + CMD114.Charge27 = ByteUtils.DToUInt16(data, 106); + CMD114.Charge29 = ByteUtils.DToUInt16(data, 108); + CMD114.Charge30 = ByteUtils.DToUInt16(data, 110); + CMD114.Charge31 = ByteUtils.DToUInt16(data, 112); + CMD114.Charge32 = ByteUtils.DToUInt16(data, 114); + CMD114.Charge33 = ByteUtils.DToUInt16(data, 116); + CMD114.Charge34 = ByteUtils.DToUInt16(data, 118); + CMD114.Charge35 = ByteUtils.DToUInt16(data, 120); + CMD114.Charge36 = ByteUtils.DToUInt16(data, 122); + CMD114.Charge37 = ByteUtils.DToUInt16(data, 124); + CMD114.Charge38 = ByteUtils.DToUInt16(data, 126); + CMD114.Charge39 = ByteUtils.DToUInt16(data, 128); + CMD114.Charge40 = ByteUtils.DToUInt16(data, 130); + CMD114.Charge41 = ByteUtils.DToUInt16(data, 132); + } + return CMD114; + } + public CMD202 ConCMD202(uint func, byte[] data) + { + CMD202 CMD202 = null; + if (data != null && data.Length > 0) + { + CMD202 = new CMD202(); + CMD202.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD202.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD202.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD202.PosType = data[44]; + CMD202.ChargGun = data[45]; + CMD202.ChargID = Encoding.ASCII.GetString(data, 46, 32); + CMD202.StartTime = Encoding.ASCII.GetString(data, 78, 8); + CMD202.EndTime = Encoding.ASCII.GetString(data, 86, 8); + CMD202.TimeSpan = ByteUtils.DToUInt32(data, 94); + CMD202.SOCStart = data[98]; + CMD202.SOCEnd = data[99]; + CMD202.EndReason = ByteUtils.DToUInt32(data, 100); + + if (func == 202) + { + CMD202.ChargCapacityNow = (ByteUtils.DToUInt32(data, 104) * 0.01).ToString("F2"); + CMD202.SAmmeterValue = (ByteUtils.DToUInt32(data, 108) * 0.01).ToString("F2"); + CMD202.EAmmeterValue = (ByteUtils.DToUInt32(data, 112) * 0.01).ToString("F2"); + + + CMD202.ChargCapacity01 = ByteUtils.DToUInt16(data, 167).ToString(); + CMD202.ChargCapacity02 = ByteUtils.DToUInt16(data, 169).ToString(); + CMD202.ChargCapacity03 = ByteUtils.DToUInt16(data, 171).ToString(); + CMD202.ChargCapacity04 = ByteUtils.DToUInt16(data, 173).ToString(); + CMD202.ChargCapacity05 = ByteUtils.DToUInt16(data, 175).ToString(); + CMD202.ChargCapacity06 = ByteUtils.DToUInt16(data, 177).ToString(); + CMD202.ChargCapacity07 = ByteUtils.DToUInt16(data, 179).ToString(); + CMD202.ChargCapacity08 = ByteUtils.DToUInt16(data, 181).ToString(); + CMD202.ChargCapacity09 = ByteUtils.DToUInt16(data, 183).ToString(); + CMD202.ChargCapacity10 = ByteUtils.DToUInt16(data, 185).ToString(); + CMD202.ChargCapacity11 = ByteUtils.DToUInt16(data, 187).ToString(); + CMD202.ChargCapacity12 = ByteUtils.DToUInt16(data, 189).ToString(); + CMD202.ChargCapacity13 = ByteUtils.DToUInt16(data, 191).ToString(); + CMD202.ChargCapacity14 = ByteUtils.DToUInt16(data, 193).ToString(); + CMD202.ChargCapacity15 = ByteUtils.DToUInt16(data, 195).ToString(); + CMD202.ChargCapacity16 = ByteUtils.DToUInt16(data, 197).ToString(); + CMD202.ChargCapacity17 = ByteUtils.DToUInt16(data, 199).ToString(); + CMD202.ChargCapacity18 = ByteUtils.DToUInt16(data, 201).ToString(); + CMD202.ChargCapacity19 = ByteUtils.DToUInt16(data, 203).ToString(); + CMD202.ChargCapacity20 = ByteUtils.DToUInt16(data, 205).ToString(); + CMD202.ChargCapacity21 = ByteUtils.DToUInt16(data, 207).ToString(); + CMD202.ChargCapacity22 = ByteUtils.DToUInt16(data, 209).ToString(); + CMD202.ChargCapacity23 = ByteUtils.DToUInt16(data, 211).ToString(); + CMD202.ChargCapacity24 = ByteUtils.DToUInt16(data, 213).ToString(); + CMD202.ChargCapacity25 = ByteUtils.DToUInt16(data, 215).ToString(); + CMD202.ChargCapacity26 = ByteUtils.DToUInt16(data, 217).ToString(); + CMD202.ChargCapacity27 = ByteUtils.DToUInt16(data, 219).ToString(); + CMD202.ChargCapacity28 = ByteUtils.DToUInt16(data, 221).ToString(); + CMD202.ChargCapacity29 = ByteUtils.DToUInt16(data, 223).ToString(); + CMD202.ChargCapacity30 = ByteUtils.DToUInt16(data, 225).ToString(); + CMD202.ChargCapacity31 = ByteUtils.DToUInt16(data, 227).ToString(); + CMD202.ChargCapacity32 = ByteUtils.DToUInt16(data, 229).ToString(); + CMD202.ChargCapacity33 = ByteUtils.DToUInt16(data, 231).ToString(); + CMD202.ChargCapacity34 = ByteUtils.DToUInt16(data, 233).ToString(); + CMD202.ChargCapacity35 = ByteUtils.DToUInt16(data, 235).ToString(); + CMD202.ChargCapacity36 = ByteUtils.DToUInt16(data, 237).ToString(); + CMD202.ChargCapacity37 = ByteUtils.DToUInt16(data, 239).ToString(); + CMD202.ChargCapacity38 = ByteUtils.DToUInt16(data, 241).ToString(); + CMD202.ChargCapacity39 = ByteUtils.DToUInt16(data, 243).ToString(); + CMD202.ChargCapacity40 = ByteUtils.DToUInt16(data, 245).ToString(); + CMD202.ChargCapacity41 = ByteUtils.DToUInt16(data, 247).ToString(); + CMD202.ChargCapacity42 = ByteUtils.DToUInt16(data, 249).ToString(); + CMD202.ChargCapacity43 = ByteUtils.DToUInt16(data, 251).ToString(); + CMD202.ChargCapacity44 = ByteUtils.DToUInt16(data, 253).ToString(); + CMD202.ChargCapacity45 = ByteUtils.DToUInt16(data, 255).ToString(); + CMD202.ChargCapacity46 = ByteUtils.DToUInt16(data, 257).ToString(); + CMD202.ChargCapacity47 = ByteUtils.DToUInt16(data, 259).ToString(); + CMD202.ChargCapacity48 = ByteUtils.DToUInt16(data, 261).ToString(); + + CMD202.StartMode = data[263]; + CMD202.ChargSerialNum = Encoding.ASCII.GetString(data, 264, 32); + CMD202.ChargServiceCost = ByteUtils.DToUInt32(data, 296); + CMD202.KilElectricity = data[300]; + CMD202.ParallelMark = data[301]; + CMD202.ChargeOrDisMark = data[302]; + CMD202.MeterEncData = Encoding.ASCII.GetString(data, 303, 34); + CMD202.MeterNum = Encoding.ASCII.GetString(data, 337, 6); + CMD202.MeterProVersion = ByteUtils.DToUInt16(data, 343); + CMD202.EncMode = data[345]; + } + else if (func == 222) + { + CMD202.ChargCapacityNow = (ByteUtils.DToUInt32(data, 104) * 0.001).ToString("F3"); + CMD202.SAmmeterValue = (ByteUtils.DToUInt32(data, 108) * 0.001).ToString("F3"); + CMD202.EAmmeterValue = (ByteUtils.DToUInt32(data, 112) * 0.001).ToString("F3"); + + + CMD202.ChargCapacity01 = (ByteUtils.DToUInt32(data, 167) * 0.001).ToString("F3"); + CMD202.ChargCapacity02 = (ByteUtils.DToUInt32(data, 171) * 0.001).ToString("F3"); + CMD202.ChargCapacity03 = (ByteUtils.DToUInt32(data, 175) * 0.001).ToString("F3"); + CMD202.ChargCapacity04 = (ByteUtils.DToUInt32(data, 179) * 0.001).ToString("F3"); + CMD202.ChargCapacity05 = (ByteUtils.DToUInt32(data, 183) * 0.001).ToString("F3"); + CMD202.ChargCapacity06 = (ByteUtils.DToUInt32(data, 187) * 0.001).ToString("F3"); + CMD202.ChargCapacity07 = (ByteUtils.DToUInt32(data, 191) * 0.001).ToString("F3"); + CMD202.ChargCapacity08 = (ByteUtils.DToUInt32(data, 195) * 0.001).ToString("F3"); + CMD202.ChargCapacity09 = (ByteUtils.DToUInt32(data, 199) * 0.001).ToString("F3"); + CMD202.ChargCapacity10 = (ByteUtils.DToUInt32(data, 203) * 0.001).ToString("F3"); + CMD202.ChargCapacity11 = (ByteUtils.DToUInt32(data, 207) * 0.001).ToString("F3"); + CMD202.ChargCapacity12 = (ByteUtils.DToUInt32(data, 211) * 0.001).ToString("F3"); + CMD202.ChargCapacity13 = (ByteUtils.DToUInt32(data, 215) * 0.001).ToString("F3"); + CMD202.ChargCapacity14 = (ByteUtils.DToUInt32(data, 219) * 0.001).ToString("F3"); + CMD202.ChargCapacity15 = (ByteUtils.DToUInt32(data, 223) * 0.001).ToString("F3"); + CMD202.ChargCapacity16 = (ByteUtils.DToUInt32(data, 227) * 0.001).ToString("F3"); + CMD202.ChargCapacity17 = (ByteUtils.DToUInt32(data, 231) * 0.001).ToString("F3"); + CMD202.ChargCapacity18 = (ByteUtils.DToUInt32(data, 235) * 0.001).ToString("F3"); + CMD202.ChargCapacity19 = (ByteUtils.DToUInt32(data, 239) * 0.001).ToString("F3"); + CMD202.ChargCapacity20 = (ByteUtils.DToUInt32(data, 243) * 0.001).ToString("F3"); + CMD202.ChargCapacity21 = (ByteUtils.DToUInt32(data, 247) * 0.001).ToString("F3"); + CMD202.ChargCapacity22 = (ByteUtils.DToUInt32(data, 251) * 0.001).ToString("F3"); + CMD202.ChargCapacity23 = (ByteUtils.DToUInt32(data, 255) * 0.001).ToString("F3"); + CMD202.ChargCapacity24 = (ByteUtils.DToUInt32(data, 259) * 0.001).ToString("F3"); + CMD202.ChargCapacity25 = (ByteUtils.DToUInt32(data, 263) * 0.001).ToString("F3"); + CMD202.ChargCapacity26 = (ByteUtils.DToUInt32(data, 267) * 0.001).ToString("F3"); + CMD202.ChargCapacity27 = (ByteUtils.DToUInt32(data, 271) * 0.001).ToString("F3"); + CMD202.ChargCapacity28 = (ByteUtils.DToUInt32(data, 275) * 0.001).ToString("F3"); + CMD202.ChargCapacity29 = (ByteUtils.DToUInt32(data, 279) * 0.001).ToString("F3"); + CMD202.ChargCapacity30 = (ByteUtils.DToUInt32(data, 283) * 0.001).ToString("F3"); + CMD202.ChargCapacity31 = (ByteUtils.DToUInt32(data, 287) * 0.001).ToString("F3"); + CMD202.ChargCapacity32 = (ByteUtils.DToUInt32(data, 291) * 0.001).ToString("F3"); + CMD202.ChargCapacity33 = (ByteUtils.DToUInt32(data, 295) * 0.001).ToString("F3"); + CMD202.ChargCapacity34 = (ByteUtils.DToUInt32(data, 299) * 0.001).ToString("F3"); + CMD202.ChargCapacity35 = (ByteUtils.DToUInt32(data, 303) * 0.001).ToString("F3"); + CMD202.ChargCapacity36 = (ByteUtils.DToUInt32(data, 307) * 0.001).ToString("F3"); + CMD202.ChargCapacity37 = (ByteUtils.DToUInt32(data, 311) * 0.001).ToString("F3"); + CMD202.ChargCapacity38 = (ByteUtils.DToUInt32(data, 315) * 0.001).ToString("F3"); + CMD202.ChargCapacity39 = (ByteUtils.DToUInt32(data, 319) * 0.001).ToString("F3"); + CMD202.ChargCapacity40 = (ByteUtils.DToUInt32(data, 323) * 0.001).ToString("F3"); + CMD202.ChargCapacity41 = (ByteUtils.DToUInt32(data, 327) * 0.001).ToString("F3"); + CMD202.ChargCapacity42 = (ByteUtils.DToUInt32(data, 331) * 0.001).ToString("F3"); + CMD202.ChargCapacity43 = (ByteUtils.DToUInt32(data, 335) * 0.001).ToString("F3"); + CMD202.ChargCapacity44 = (ByteUtils.DToUInt32(data, 339) * 0.001).ToString("F3"); + CMD202.ChargCapacity45 = (ByteUtils.DToUInt32(data, 343) * 0.001).ToString("F3"); + CMD202.ChargCapacity46 = (ByteUtils.DToUInt32(data, 347) * 0.001).ToString("F3"); + CMD202.ChargCapacity47 = (ByteUtils.DToUInt32(data, 351) * 0.001).ToString("F3"); + CMD202.ChargCapacity48 = (ByteUtils.DToUInt32(data, 355) * 0.001).ToString("F3"); + + CMD202.StartMode = data[359]; + CMD202.ChargSerialNum = Encoding.ASCII.GetString(data, 360, 32); + CMD202.ChargServiceCost = ByteUtils.DToUInt32(data, 392); + CMD202.KilElectricity = data[396]; + CMD202.ParallelMark = data[397]; + CMD202.ChargeOrDisMark = data[398]; + CMD202.MeterEncData = Encoding.ASCII.GetString(data, 399, 34); + CMD202.MeterNum = Encoding.ASCII.GetString(data, 433, 6); + CMD202.MeterProVersion = ByteUtils.DToUInt16(data, 439); + CMD202.EncMode = data[441]; + } + + CMD202.ChargeAmount = ByteUtils.DToUInt32(data, 116); + CMD202.IndexNum = BitConverter.ToInt32(data, 120); + CMD202.CardBalance = ByteUtils.DToUInt32(data, 124); + CMD202.ChargRecord = ByteUtils.DToUInt32(data, 128); + CMD202.SumChargRecord = ByteUtils.DToUInt32(data, 132); + CMD202.Reserved3 = data[136]; + CMD202.ChargStrategy = data[137]; + switch (data[137]) + { + case 1: + CMD202.ChargStrategyPara = ByteUtils.DToUInt32(data, 138).ToString(); + break; + case 2: + CMD202.ChargStrategyPara = (ByteUtils.DToUInt32(data, 138) * 0.01).ToString("F2"); + break; + case 3: + CMD202.ChargStrategyPara = (ByteUtils.DToUInt32(data, 138) * 0.01).ToString("F2"); + break; + } + + + + CMD202.CarVIN = Encoding.ASCII.GetString(data, 142, 17); + CMD202.CarID = Encoding.ASCII.GetString(data, 159, 8); + + + } + return CMD202; + } + public CMD204 ConCMD204(byte[] data) + { + CMD204 CMD204 = null; + if (data != null && data.Length > 0) + { + CMD204 = new CMD204(); + CMD204.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD204.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD204.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD204.ChargID = Encoding.ASCII.GetString(data, 44, 32); + CMD204.Balance = ByteUtils.DToUInt32(data, 76); + CMD204.BlacklistSign = data[80]; + CMD204.ChargCardPassword = Encoding.ASCII.GetString(data, 81, 32); + CMD204.RandomData = Encoding.ASCII.GetString(data, 113, 48); + CMD204.M1CardID = ByteUtils.DToUInt32(data, 161); + CMD204.Auth = data[165]; + CMD204.ChargGunNum = data[166]; + } + return CMD204; + } + public CMD206 ConCMD206(byte[] data) + { + CMD206 CMD206 = null; + if (data != null && data.Length > 0) + { + CMD206 = new CMD206(); + CMD206.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD206.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD206.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD206.ChargID = Encoding.ASCII.GetString(data, 44, 32); + CMD206.ChargPassword = Encoding.ASCII.GetString(data, 76, 32); + CMD206.RandomData = Encoding.ASCII.GetString(data, 108, 48); + } + return CMD206; + } + public CMD208 ConCMD208(byte[] data) + { + CMD208 CMD208 = null; + if (data != null && data.Length > 0) + { + CMD208 = new CMD208(); + CMD208.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD208.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD208.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD208.ChargGunNum = data[44]; + CMD208.VINNum = Encoding.ASCII.GetString(data, 45, 17); + CMD208.ChargStrategy = data[62]; + CMD208.ChargStrategyPara = ByteUtils.DToUInt32(data, 63); + } + return CMD208; + } + public CMD210 ConCMD210(byte[] data) + { + CMD210 CMD210 = null; + if (data != null && data.Length > 0) + { + CMD210 = new CMD210(); + CMD210.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD210.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD210.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD210.ChargGunNum = data[44]; + CMD210.StartResult = ByteUtils.DToUInt32(data, 45); + } + return CMD210; + } + public CMD222 ConCMD222(byte[] data) + { + CMD222 CMD222 = null; + if (data != null && data.Length > 0) + { + CMD222 = new CMD222(); + CMD222.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD222.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD222.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD222.PosType = data[44]; + CMD222.ChargGun = data[45]; + CMD222.ChargID = Encoding.ASCII.GetString(data, 46, 32); + CMD222.StartTime = Encoding.ASCII.GetString(data, 78, 8); + CMD222.EndTime = Encoding.ASCII.GetString(data, 86, 8); + CMD222.TimeSpan = ByteUtils.DToUInt32(data, 94); + CMD222.SOCStart = data[98]; + CMD222.SOCEnd = data[99]; + CMD222.EndReason = ByteUtils.DToUInt32(data, 100); + CMD222.ChargCapacityNow = ByteUtils.DToUInt32(data, 104); + CMD222.SAmmeterValue = ByteUtils.DToUInt32(data, 108); + CMD222.EAmmeterValue = ByteUtils.DToUInt32(data, 112); + CMD222.ChargeAmount = ByteUtils.DToUInt32(data, 116); + CMD222.IndexNum = ByteUtils.DToUInt32(data, 120); + CMD222.CardBalance = ByteUtils.DToUInt32(data, 124); + CMD222.ChargRecord = ByteUtils.DToUInt32(data, 128); + CMD222.SumChargRecord = ByteUtils.DToUInt32(data, 132); + CMD222.Reserved3 = data[136]; + CMD222.ChargStrategy = data[137]; + CMD222.ChargStrategyPara = ByteUtils.DToUInt32(data, 138); + CMD222.CarVIN = Encoding.ASCII.GetString(data, 142, 17); + CMD222.CarID = Encoding.ASCII.GetString(data, 159, 8); + CMD222.ChargCapacity01 = (int)ByteUtils.DToUInt32(data, 167); + CMD222.ChargCapacity02 = (int)ByteUtils.DToUInt32(data, 171); + CMD222.ChargCapacity03 = (int)ByteUtils.DToUInt32(data, 175); + CMD222.ChargCapacity04 = (int)ByteUtils.DToUInt32(data, 179); + CMD222.ChargCapacity05 = (int)ByteUtils.DToUInt32(data, 183); + CMD222.ChargCapacity06 = (int)ByteUtils.DToUInt32(data, 187); + CMD222.ChargCapacity07 = (int)ByteUtils.DToUInt32(data, 191); + CMD222.ChargCapacity08 = (int)ByteUtils.DToUInt32(data, 195); + CMD222.ChargCapacity09 = (int)ByteUtils.DToUInt32(data, 199); + CMD222.ChargCapacity10 = (int)ByteUtils.DToUInt32(data, 203); + CMD222.ChargCapacity11 = (int)ByteUtils.DToUInt32(data, 207); + CMD222.ChargCapacity12 = (int)ByteUtils.DToUInt32(data, 211); + CMD222.ChargCapacity13 = (int)ByteUtils.DToUInt32(data, 215); + CMD222.ChargCapacity14 = (int)ByteUtils.DToUInt32(data, 219); + CMD222.ChargCapacity15 = (int)ByteUtils.DToUInt32(data, 223); + CMD222.ChargCapacity16 = (int)ByteUtils.DToUInt32(data, 227); + CMD222.ChargCapacity17 = (int)ByteUtils.DToUInt32(data, 231); + CMD222.ChargCapacity18 = (int)ByteUtils.DToUInt32(data, 235); + CMD222.ChargCapacity19 = (int)ByteUtils.DToUInt32(data, 239); + CMD222.ChargCapacity20 = (int)ByteUtils.DToUInt32(data, 243); + CMD222.ChargCapacity21 = (int)ByteUtils.DToUInt32(data, 247); + CMD222.ChargCapacity22 = (int)ByteUtils.DToUInt32(data, 251); + CMD222.ChargCapacity23 = (int)ByteUtils.DToUInt32(data, 255); + CMD222.ChargCapacity24 = (int)ByteUtils.DToUInt32(data, 259); + CMD222.ChargCapacity25 = (int)ByteUtils.DToUInt32(data, 263); + CMD222.ChargCapacity26 = (int)ByteUtils.DToUInt32(data, 267); + CMD222.ChargCapacity27 = (int)ByteUtils.DToUInt32(data, 271); + CMD222.ChargCapacity28 = (int)ByteUtils.DToUInt32(data, 275); + CMD222.ChargCapacity29 = (int)ByteUtils.DToUInt32(data, 279); + CMD222.ChargCapacity30 = (int)ByteUtils.DToUInt32(data, 283); + CMD222.ChargCapacity31 = (int)ByteUtils.DToUInt32(data, 287); + CMD222.ChargCapacity32 = (int)ByteUtils.DToUInt32(data, 291); + CMD222.ChargCapacity33 = (int)ByteUtils.DToUInt32(data, 295); + CMD222.ChargCapacity34 = (int)ByteUtils.DToUInt32(data, 299); + CMD222.ChargCapacity35 = (int)ByteUtils.DToUInt32(data, 303); + CMD222.ChargCapacity36 = (int)ByteUtils.DToUInt32(data, 307); + CMD222.ChargCapacity37 = (int)ByteUtils.DToUInt32(data, 311); + CMD222.ChargCapacity38 = (int)ByteUtils.DToUInt32(data, 315); + CMD222.ChargCapacity39 = (int)ByteUtils.DToUInt32(data, 319); + CMD222.ChargCapacity40 = (int)ByteUtils.DToUInt32(data, 323); + CMD222.ChargCapacity41 = (int)ByteUtils.DToUInt32(data, 327); + CMD222.ChargCapacity42 = (int)ByteUtils.DToUInt32(data, 331); + CMD222.ChargCapacity43 = (int)ByteUtils.DToUInt32(data, 335); + CMD222.ChargCapacity44 = (int)ByteUtils.DToUInt32(data, 339); + CMD222.ChargCapacity45 = (int)ByteUtils.DToUInt32(data, 343); + CMD222.ChargCapacity46 = (int)ByteUtils.DToUInt32(data, 347); + CMD222.ChargCapacity47 = (int)ByteUtils.DToUInt32(data, 351); + CMD222.ChargCapacity48 = (int)ByteUtils.DToUInt32(data, 355); + CMD222.StartMode = data[359]; + CMD222.ChargSerialNum = Encoding.ASCII.GetString(data, 360, 32); + CMD222.ChargServiceCost = ByteUtils.DToUInt32(data, 392); + CMD222.KilElectricity = data[394]; + CMD222.ParallelMark = data[395]; + CMD222.ChargeOrDisMark = data[396]; + CMD222.MeterEncData = data[397]; + CMD222.MeterNum = Encoding.ASCII.GetString(data, 398, 6); + CMD222.MeterProVersion = ByteUtils.DToUInt16(data, 404); + CMD222.EncMode = data[408]; + } + return CMD222; + } + public CMD302 ConCMD302(byte[] data) + { + CMD302 CMD302 = null; + if (data != null && data.Length > 0) + { + CMD302 = new CMD302(); + CMD302.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD302.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD302.MessageOrderNum = ByteUtils.DToUInt16(data, 12); + CMD302.ChargGunNum = ByteUtils.DToUInt16(data, 14); + CMD302.ASCIINum = Encoding.ASCII.GetString(data, 16, 32); + CMD302.WorkState = data[48]; + CMD302.connectState = data[49]; + CMD302.BRMBMSVersionNum = data[50]; + CMD302.BRMBatteryType = data[51]; + CMD302.BRMRatedCapacity = ByteUtils.DToUInt32(data, 52); + CMD302.BRMRatedVoltage = ByteUtils.DToUInt32(data, 56); + CMD302.BRMBatteryManu = ByteUtils.DToUInt32(data, 60); + CMD302.BRMBatteryPackID = ByteUtils.DToUInt32(data, 64); + CMD302.BRMDateYear = ByteUtils.DToUInt16(data, 68); + CMD302.BRMDateMonth = data[70]; + CMD302.BRMDateDay = data[71]; + CMD302.BRMChargeCount = ByteUtils.DToUInt32(data, 72); + CMD302.BRMTitleMark = data[76]; + CMD302.Reserved3 = data[77]; + CMD302.BRMVINID = Encoding.ASCII.GetString(data, 78, 17); + CMD302.BRMBMSSoftVerNum = ByteUtils.DToUInt16(data, 95); + CMD302.MaxChargVoltage = ByteUtils.DToUInt32(data, 103); + CMD302.MaxChargCurrent = ByteUtils.DToUInt32(data, 107); + CMD302.TotalEnergy = ByteUtils.DToUInt32(data, 111); + CMD302.MaxTotalVoltage = ByteUtils.DToUInt32(data, 115); + CMD302.MaxTemp = data[119]; + CMD302.ChargeState = ByteUtils.DToUInt16(data, 120); + CMD302.CellVoltage = ByteUtils.DToUInt32(data, 122); + CMD302.ChargePrepared = data[126]; + CMD302.BCLVoltage = ByteUtils.DToUInt32(data, 127); + CMD302.BCLCurrent = ByteUtils.DToUInt32(data, 131); + CMD302.BCLChargMode = data[135]; + CMD302.BCSVoltageValue = ByteUtils.DToUInt32(data, 136); + CMD302.BCSCurrentValue = ByteUtils.DToUInt32(data, 140); + CMD302.BCSVoltageMAX = ByteUtils.DToUInt32(data, 144); + CMD302.BCSBatteryNumMAX = data[145]; + CMD302.BCSChargState = ByteUtils.DToUInt16(data, 146); + CMD302.ReChargeTime = ByteUtils.DToUInt32(data, 148); + CMD302.BSMNum = data[152]; + CMD302.BSMMaxTemp = data[153]; + CMD302.MaxTempPointNum = data[154]; + CMD302.MinBatteryTemp = data[155]; + CMD302.MinTempPointNum = data[156]; + CMD302.voltageHighLow = data[157]; + CMD302.ChargStateHighLow = data[158]; + CMD302.BmsOvercurrent = data[159]; + CMD302.TempHigh = data[160]; + CMD302.InsulatState = data[161]; + CMD302.ConnectState = data[162]; + CMD302.AllowCharge = data[163]; + CMD302.SOCTargetValue = data[164]; + CMD302.SumVoltageSetValue = data[165]; + CMD302.VoltageSetValue = data[166]; + CMD302.ChargeEnd = data[167]; + CMD302.InsulatFault = data[168]; + CMD302.OvertempFault = data[169]; + CMD302.Overtemp = data[170]; + CMD302.ConnectorFault = data[171]; + CMD302.ChargOvertempFault = data[172]; + CMD302.HVoltageFault = data[173]; + CMD302.VoltageSenseFault = data[174]; + CMD302.OtherFault = data[175]; + CMD302.Overcurrent = data[176]; + CMD302.VoltageAnomaly = data[177]; + CMD302.VoltageAnomaly = data[178]; + CMD302.EndChargState = data[179]; + CMD302.MinVoltage = data[180]; + CMD302.MaxVoltage = data[181]; + CMD302.MinChargTemp = data[182]; + CMD302.MaxChargTemp = data[183]; + CMD302.ReceiveTimeout1 = data[184]; + CMD302.ReceiveTimeout2 = data[185]; + CMD302.ReceiveTimeout3 = data[186]; + CMD302.ReceiveTimeout4 = data[187]; + CMD302.ReceiveTimeout5 = data[188]; + CMD302.ReceiveTimeout6 = data[189]; + CMD302.ReceiveTimeout7 = data[190]; + CMD302.Other = data[191]; + } + return CMD302; + } + public CMD304 ConCMD304(byte[] data) + { + CMD304 CMD304 = null; + if (data != null && data.Length > 0) + { + CMD304 = new CMD304(); + CMD304.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD304.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD304.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD304.WorkState = data[44]; + CMD304.connectState = data[45]; + CMD304.BRMMessage = Encoding.ASCII.GetString(data, 46, 64); + CMD304.VBIMessage = Encoding.ASCII.GetString(data, 110, 64); + CMD304.ChargParameter = Encoding.ASCII.GetString(data, 174, 16); + CMD304.ReadyState = ByteUtils.DToUInt16(data, 190); + CMD304.ChargDemand = ByteUtils.DToUInt16(data, 198); + CMD304.TotalState = Encoding.ASCII.GetString(data, 206, 16); + CMD304.StateInfo = ByteUtils.DToUInt32(data, 222); + CMD304.StopCharg = ByteUtils.DToUInt32(data, 226); + CMD304.StatisticData = ByteUtils.DToUInt32(data, 230); + CMD304.BEMMessage = ByteUtils.DToUInt32(data, 234); + } + return CMD304; + } + public CMD402 ConCMD402(uint func, byte[] data) + { + CMD402 CMD402 = null; + if (data != null && data.Length > 0) + { + CMD402 = new CMD402(); + CMD402.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD402.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD402.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD402.PosType = data[44]; + CMD402.ChargGun = data[45]; + CMD402.ChargCardID = Encoding.ASCII.GetString(data, 46, 32); + CMD402.ChargStartTime = Encoding.ASCII.GetString(data, 78, 8); + CMD402.ChargEndTime = Encoding.ASCII.GetString(data, 86, 8); + CMD402.ChargTimeLength = ByteUtils.DToUInt32(data, 94); + CMD402.SOCStart = data[98]; + CMD402.SOCEnd = data[99]; + CMD402.ChargEndReason = Encoding.ASCII.GetString(data, 100, 4); + if (func == 402) + { + CMD402.ChargCapacity = (ByteUtils.ToUInt32(data, 104) * 0.01).ToString("F2"); + + + CMD402.ChargCapacity01 = ((ByteUtils.DToUInt16(data, 167)) * 0.01).ToString("F2"); + CMD402.ChargCapacity02 = ((ByteUtils.DToUInt16(data, 169)) * 0.01).ToString("F2"); + CMD402.ChargCapacity03 = ((ByteUtils.DToUInt16(data, 171)) * 0.01).ToString("F2"); + CMD402.ChargCapacity04 = ((ByteUtils.DToUInt16(data, 173)) * 0.01).ToString("F2"); + CMD402.ChargCapacity05 = ((ByteUtils.DToUInt16(data, 175)) * 0.01).ToString("F2"); + CMD402.ChargCapacity06 = ((ByteUtils.DToUInt16(data, 177)) * 0.01).ToString("F2"); + CMD402.ChargCapacity07 = ((ByteUtils.DToUInt16(data, 179)) * 0.01).ToString("F2"); + CMD402.ChargCapacity08 = ((ByteUtils.DToUInt16(data, 181)) * 0.01).ToString("F2"); + CMD402.ChargCapacity09 = ((ByteUtils.DToUInt16(data, 183)) * 0.01).ToString("F2"); + CMD402.ChargCapacity10 = ((ByteUtils.DToUInt16(data, 185)) * 0.01).ToString("F2"); + CMD402.ChargCapacity11 = ((ByteUtils.DToUInt16(data, 187)) * 0.01).ToString("F2"); + CMD402.ChargCapacity12 = ((ByteUtils.DToUInt16(data, 189)) * 0.01).ToString("F2"); + CMD402.ChargCapacity13 = ((ByteUtils.DToUInt16(data, 191)) * 0.01).ToString("F2"); + CMD402.ChargCapacity14 = ((ByteUtils.DToUInt16(data, 193)) * 0.01).ToString("F2"); + CMD402.ChargCapacity15 = ((ByteUtils.DToUInt16(data, 195)) * 0.01).ToString("F2"); + CMD402.ChargCapacity16 = ((ByteUtils.DToUInt16(data, 197)) * 0.01).ToString("F2"); + CMD402.ChargCapacity17 = ((ByteUtils.DToUInt16(data, 199)) * 0.01).ToString("F2"); + CMD402.ChargCapacity18 = ((ByteUtils.DToUInt16(data, 201)) * 0.01).ToString("F2"); + CMD402.ChargCapacity19 = ((ByteUtils.DToUInt16(data, 203)) * 0.01).ToString("F2"); + CMD402.ChargCapacity20 = ((ByteUtils.DToUInt16(data, 205)) * 0.01).ToString("F2"); + CMD402.ChargCapacity21 = ((ByteUtils.DToUInt16(data, 207)) * 0.01).ToString("F2"); + CMD402.ChargCapacity22 = ((ByteUtils.DToUInt16(data, 209)) * 0.01).ToString("F2"); + CMD402.ChargCapacity23 = ((ByteUtils.DToUInt16(data, 211)) * 0.01).ToString("F2"); + CMD402.ChargCapacity24 = ((ByteUtils.DToUInt16(data, 213)) * 0.01).ToString("F2"); + CMD402.ChargCapacity25 = ((ByteUtils.DToUInt16(data, 215)) * 0.01).ToString("F2"); + CMD402.ChargCapacity26 = ((ByteUtils.DToUInt16(data, 217)) * 0.01).ToString("F2"); + CMD402.ChargCapacity27 = ((ByteUtils.DToUInt16(data, 219)) * 0.01).ToString("F2"); + CMD402.ChargCapacity28 = ((ByteUtils.DToUInt16(data, 221)) * 0.01).ToString("F2"); + CMD402.ChargCapacity29 = ((ByteUtils.DToUInt16(data, 223)) * 0.01).ToString("F2"); + CMD402.ChargCapacity30 = ((ByteUtils.DToUInt16(data, 225)) * 0.01).ToString("F2"); + CMD402.ChargCapacity31 = ((ByteUtils.DToUInt16(data, 227)) * 0.01).ToString("F2"); + CMD402.ChargCapacity32 = ((ByteUtils.DToUInt16(data, 229)) * 0.01).ToString("F2"); + CMD402.ChargCapacity33 = ((ByteUtils.DToUInt16(data, 231)) * 0.01).ToString("F2"); + CMD402.ChargCapacity34 = ((ByteUtils.DToUInt16(data, 233)) * 0.01).ToString("F2"); + CMD402.ChargCapacity35 = ((ByteUtils.DToUInt16(data, 235)) * 0.01).ToString("F2"); + CMD402.ChargCapacity36 = ((ByteUtils.DToUInt16(data, 237)) * 0.01).ToString("F2"); + CMD402.ChargCapacity37 = ((ByteUtils.DToUInt16(data, 239)) * 0.01).ToString("F2"); + CMD402.ChargCapacity38 = ((ByteUtils.DToUInt16(data, 241)) * 0.01).ToString("F2"); + CMD402.ChargCapacity39 = ((ByteUtils.DToUInt16(data, 243)) * 0.01).ToString("F2"); + CMD402.ChargCapacity40 = ((ByteUtils.DToUInt16(data, 245)) * 0.01).ToString("F2"); + CMD402.ChargCapacity41 = ((ByteUtils.DToUInt16(data, 247)) * 0.01).ToString("F2"); + CMD402.ChargCapacity42 = ((ByteUtils.DToUInt16(data, 249)) * 0.01).ToString("F2"); + CMD402.ChargCapacity43 = ((ByteUtils.DToUInt16(data, 251)) * 0.01).ToString("F2"); + CMD402.ChargCapacity44 = ((ByteUtils.DToUInt16(data, 253)) * 0.01).ToString("F2"); + CMD402.ChargCapacity45 = ((ByteUtils.DToUInt16(data, 255)) * 0.01).ToString("F2"); + CMD402.ChargCapacity46 = ((ByteUtils.DToUInt16(data, 257)) * 0.01).ToString("F2"); + CMD402.ChargCapacity47 = ((ByteUtils.DToUInt16(data, 259)) * 0.01).ToString("F2"); + CMD402.ChargCapacity48 = ((ByteUtils.DToUInt16(data, 261)) * 0.01).ToString("F2"); + + CMD402.StartMode = data[263]; + CMD402.SerialNum = Encoding.ASCII.GetString(data, 264, 32); + CMD402.ChargServiceCost = ByteUtils.DToUInt32(data, 296); + CMD402.KilElectricity = (data[300] * 0.001).ToString("F4"); + CMD402.ParallelMark = data[301]; + } + else if (func == 422) + { + CMD402.ChargCapacity = (ByteUtils.ToUInt32(data, 104) * 0.001).ToString("F3"); + + + CMD402.ChargCapacity01 = ((ByteUtils.DToUInt32(data, 167) * 0.001)).ToString("F3"); + CMD402.ChargCapacity02 = ((ByteUtils.DToUInt32(data, 171) * 0.001)).ToString("F3"); + CMD402.ChargCapacity03 = ((ByteUtils.DToUInt32(data, 175) * 0.001)).ToString("F3"); + CMD402.ChargCapacity04 = ((ByteUtils.DToUInt32(data, 179) * 0.001)).ToString("F3"); + CMD402.ChargCapacity05 = ((ByteUtils.DToUInt32(data, 183) * 0.001)).ToString("F3"); + CMD402.ChargCapacity06 = ((ByteUtils.DToUInt32(data, 187) * 0.001)).ToString("F3"); + CMD402.ChargCapacity07 = ((ByteUtils.DToUInt32(data, 191) * 0.001)).ToString("F3"); + CMD402.ChargCapacity08 = ((ByteUtils.DToUInt32(data, 195) * 0.001)).ToString("F3"); + CMD402.ChargCapacity09 = ((ByteUtils.DToUInt32(data, 199) * 0.001)).ToString("F3"); + CMD402.ChargCapacity10 = ((ByteUtils.DToUInt32(data, 203) * 0.001)).ToString("F3"); + CMD402.ChargCapacity11 = ((ByteUtils.DToUInt32(data, 207) * 0.001)).ToString("F3"); + CMD402.ChargCapacity12 = ((ByteUtils.DToUInt32(data, 211) * 0.001)).ToString("F3"); + CMD402.ChargCapacity13 = ((ByteUtils.DToUInt32(data, 215) * 0.001)).ToString("F3"); + CMD402.ChargCapacity14 = ((ByteUtils.DToUInt32(data, 219) * 0.001)).ToString("F3"); + CMD402.ChargCapacity15 = ((ByteUtils.DToUInt32(data, 223) * 0.001)).ToString("F3"); + CMD402.ChargCapacity16 = ((ByteUtils.DToUInt32(data, 227) * 0.001)).ToString("F3"); + CMD402.ChargCapacity17 = ((ByteUtils.DToUInt32(data, 231) * 0.001)).ToString("F3"); + CMD402.ChargCapacity18 = ((ByteUtils.DToUInt32(data, 235) * 0.001)).ToString("F3"); + CMD402.ChargCapacity19 = ((ByteUtils.DToUInt32(data, 239) * 0.001)).ToString("F3"); + CMD402.ChargCapacity20 = ((ByteUtils.DToUInt32(data, 243) * 0.001)).ToString("F3"); + CMD402.ChargCapacity21 = ((ByteUtils.DToUInt32(data, 247) * 0.001)).ToString("F3"); + CMD402.ChargCapacity22 = ((ByteUtils.DToUInt32(data, 251) * 0.001)).ToString("F3"); + CMD402.ChargCapacity23 = ((ByteUtils.DToUInt32(data, 255) * 0.001)).ToString("F3"); + CMD402.ChargCapacity24 = ((ByteUtils.DToUInt32(data, 259) * 0.001)).ToString("F3"); + CMD402.ChargCapacity25 = ((ByteUtils.DToUInt32(data, 263) * 0.001)).ToString("F3"); + CMD402.ChargCapacity26 = ((ByteUtils.DToUInt32(data, 267) * 0.001)).ToString("F3"); + CMD402.ChargCapacity27 = ((ByteUtils.DToUInt32(data, 271) * 0.001)).ToString("F3"); + CMD402.ChargCapacity28 = ((ByteUtils.DToUInt32(data, 275) * 0.001)).ToString("F3"); + CMD402.ChargCapacity29 = ((ByteUtils.DToUInt32(data, 279) * 0.001)).ToString("F3"); + CMD402.ChargCapacity30 = ((ByteUtils.DToUInt32(data, 283) * 0.001)).ToString("F3"); + CMD402.ChargCapacity31 = ((ByteUtils.DToUInt32(data, 287) * 0.001)).ToString("F3"); + CMD402.ChargCapacity32 = ((ByteUtils.DToUInt32(data, 291) * 0.001)).ToString("F3"); + CMD402.ChargCapacity33 = ((ByteUtils.DToUInt32(data, 295) * 0.001)).ToString("F3"); + CMD402.ChargCapacity34 = ((ByteUtils.DToUInt32(data, 299) * 0.001)).ToString("F3"); + CMD402.ChargCapacity35 = ((ByteUtils.DToUInt32(data, 303) * 0.001)).ToString("F3"); + CMD402.ChargCapacity36 = ((ByteUtils.DToUInt32(data, 307) * 0.001)).ToString("F3"); + CMD402.ChargCapacity37 = ((ByteUtils.DToUInt32(data, 311) * 0.001)).ToString("F3"); + CMD402.ChargCapacity38 = ((ByteUtils.DToUInt32(data, 315) * 0.001)).ToString("F3"); + CMD402.ChargCapacity39 = ((ByteUtils.DToUInt32(data, 319) * 0.001)).ToString("F3"); + CMD402.ChargCapacity40 = ((ByteUtils.DToUInt32(data, 323) * 0.001)).ToString("F3"); + CMD402.ChargCapacity41 = ((ByteUtils.DToUInt32(data, 327) * 0.001)).ToString("F3"); + CMD402.ChargCapacity42 = ((ByteUtils.DToUInt32(data, 331) * 0.001)).ToString("F3"); + CMD402.ChargCapacity43 = ((ByteUtils.DToUInt32(data, 335) * 0.001)).ToString("F3"); + CMD402.ChargCapacity44 = ((ByteUtils.DToUInt32(data, 339) * 0.001)).ToString("F3"); + CMD402.ChargCapacity45 = ((ByteUtils.DToUInt32(data, 343) * 0.001)).ToString("F3"); + CMD402.ChargCapacity46 = ((ByteUtils.DToUInt32(data, 347) * 0.001)).ToString("F3"); + CMD402.ChargCapacity47 = ((ByteUtils.DToUInt32(data, 351) * 0.001)).ToString("F3"); + CMD402.ChargCapacity48 = ((ByteUtils.DToUInt32(data, 355) * 0.001)).ToString("F3"); + CMD402.StartMode = data[359]; + CMD402.SerialNum = Encoding.ASCII.GetString(data, 360, 32); + CMD402.ChargServiceCost = ByteUtils.DToUInt32(data, 392); + CMD402.KilElectricity = (data[396] * 0.001).ToString("F4"); + CMD402.ParallelMark = data[397]; + } + + CMD402.SAmmeterValue = ByteUtils.DToUInt32(data, 108); + CMD402.EAmmeterValue = ByteUtils.DToUInt32(data, 112); + CMD402.ChargeAmount = ByteUtils.DToUInt32(data, 116); + CMD402.IndexNum = ByteUtils.DToUInt32(data, 120); + CMD402.InitialBalance = ByteUtils.DToUInt32(data, 124); + CMD402.ChargRecordIndex = ByteUtils.DToUInt32(data, 128); + CMD402.TotalChargeRecord = ByteUtils.DToUInt32(data, 132); + CMD402.Reserved3 = data[136]; + CMD402.ChargStrategy = data[137]; + switch (data[137]) + { + case 1: + CMD402.ChargStrategyPara = (ByteUtils.ToUInt32(data, 138)).ToString(); + break; + case 2: + CMD402.ChargStrategyPara = ((float)ByteUtils.ToUInt32(data, 138) * 0.01).ToString("F2"); + break; + case 3: + CMD402.ChargStrategyPara = ((float)ByteUtils.ToUInt32(data, 138) * 0.01).ToString("F3"); + break; + } + + + CMD402.VINCar = Encoding.ASCII.GetString(data, 142, 17); + CMD402.CarID = Encoding.ASCII.GetString(data, 159, 8); + + } + return CMD402; + } + public CMD1002 ConCMD1002(byte[] data) + { + CMD1002 CMD1002 = null; + if (data != null && data.Length > 0) + { + CMD1002 = new CMD1002(); + CMD1002.ErasurePercentage = data[8]; + } + return CMD1002; + } + public CMD1004 ConCMD1004(byte[] data) + { + CMD1004 CMD1004 = null; + if (data != null && data.Length > 0) + { + CMD1004 = new CMD1004(); + CMD1004.DataLength = data[8]; + } + return CMD1004; + } + public CMD1006 ConCMD1006(byte[] data) + { + CMD1006 CMD1006 = null; + if (data != null && data.Length > 0) + { + CMD1006 = new CMD1006(); + CMD1006.ResponseFlag = data[8]; + } + return CMD1006; + } + public CMD1008 ConCMD1008(byte[] data) + { + CMD1008 CMD1008 = null; + if (data != null && data.Length > 0) + { + CMD1008 = new CMD1008(); + CMD1008.ReceiveSN = data[8]; + CMD1008.WriteFlag = data[9]; + CMD1008.Reserved1 = (short)ByteUtils.DToUInt16(data, 10); + CMD1008.Reserved2 = (int)ByteUtils.DToUInt32(data, 12); + } + return CMD1008; + } + public CMD1010 ConCMD1010(byte[] data) + { + CMD1010 CMD1010 = null; + if (data != null && data.Length > 0) + { + CMD1010 = new CMD1010(); + CMD1010.Reserved1 = ByteUtils.DToUInt16(data, 8); + } + return CMD1010; + } + public CMD1012 ConCMD1012(byte[] data) + { + CMD1012 CMD1012 = null; + if (data != null && data.Length > 0) + { + CMD1012 = new CMD1012(); + CMD1012.Reserved1 = (int)ByteUtils.DToUInt32(data, 8); + } + return CMD1012; + } + public CMD1022 ConCMD1022(byte[] data) + { + CMD1022 CMD1022 = null; + if (data != null && data.Length > 0) + { + CMD1022 = new CMD1022(); + CMD1022.EquipmentCode = (int)ByteUtils.DToUInt32(data, 8); + CMD1022.ProjectCode = (int)ByteUtils.DToUInt32(data, 12); + CMD1022.SoftwareVersion = (int)ByteUtils.DToUInt32(data, 16); + CMD1022.ReceiveFileSizeMax = (int)ByteUtils.DToUInt32(data, 20); + CMD1022.DeviceDescripte = Encoding.ASCII.GetString(data, 24, 32); + CMD1022.CommandFlag = (int)ByteUtils.DToUInt32(data, 56); + CMD1022.Offset = (int)ByteUtils.DToUInt32(data, 60); + CMD1022.ContinuatSN = data[64]; + CMD1022.DataLength = (int)ByteUtils.DToUInt32(data, 65); + } + return CMD1022; + } + public CMD1102 ConCMD1102(byte[] data) + { + CMD1102 CMD1102 = null; + if (data != null && data.Length > 0) + { + CMD1102 = new CMD1102(); + CMD1102.StartHour1 = data[8]; + CMD1102.STartMin1 = data[9]; + CMD1102.EndHour1 = data[10]; + CMD1102.EndMin1 = data[11]; + CMD1102.Rate1 = ByteUtils.DToUInt32(data, 12); + + CMD1102.StartHour2 = data[16]; + CMD1102.STartMin2 = data[17]; + CMD1102.EndHour2 = data[18]; + CMD1102.EndMin2 = data[19]; + CMD1102.Rate2 = ByteUtils.DToUInt32(data, 20); + + CMD1102.StartHour3 = data[24]; + CMD1102.STartMin3 = data[25]; + CMD1102.EndHour3 = data[26]; + CMD1102.EndMin3 = data[27]; + CMD1102.Rate3 = ByteUtils.DToUInt32(data, 28); + + CMD1102.StartHour4 = data[32]; + CMD1102.STartMin4 = data[33]; + CMD1102.EndHour4 = data[34]; + CMD1102.EndMin4 = data[35]; + CMD1102.Rate4 = ByteUtils.DToUInt32(data, 36); + + CMD1102.StartHour5 = data[40]; + CMD1102.STartMin5 = data[41]; + CMD1102.EndHour5 = data[42]; + CMD1102.EndMin5 = data[43]; + CMD1102.Rate5 = ByteUtils.DToUInt32(data, 44); + + CMD1102.StartHour6 = data[48]; + CMD1102.STartMin6 = data[49]; + CMD1102.EndHour6 = data[50]; + CMD1102.EndMin6 = data[51]; + CMD1102.Rate6 = ByteUtils.DToUInt32(data, 52); + + CMD1102.StartHour7 = data[56]; + CMD1102.STartMin7 = data[57]; + CMD1102.EndHour7 = data[58]; + CMD1102.EndMin7 = data[59]; + CMD1102.Rate7 = ByteUtils.DToUInt32(data, 60); + + CMD1102.StartHour8 = data[64]; + CMD1102.STartMin8 = data[65]; + CMD1102.EndHour8 = data[66]; + CMD1102.EndMin8 = data[67]; + CMD1102.Rate8 = ByteUtils.DToUInt32(data, 68); + + CMD1102.StartHour9 = data[72]; + CMD1102.STartMin9 = data[73]; + CMD1102.EndHour9 = data[74]; + CMD1102.EndMin9 = data[75]; + CMD1102.Rate9 = ByteUtils.DToUInt32(data, 76); + + CMD1102.StartHour10 = data[80]; + CMD1102.STartMin10 = data[81]; + CMD1102.EndHour10 = data[82]; + CMD1102.EndMin10 = data[83]; + CMD1102.Rate10 = ByteUtils.DToUInt32(data, 84); + + CMD1102.StartHour11 = data[88]; + CMD1102.STartMin11 = data[89]; + CMD1102.EndHour11 = data[90]; + CMD1102.EndMin11 = data[91]; + CMD1102.Rate11 = ByteUtils.DToUInt32(data, 92); + + CMD1102.StartHour12 = data[96]; + CMD1102.STartMin12 = data[97]; + CMD1102.EndHour12 = data[98]; + CMD1102.EndMin12 = data[99]; + CMD1102.Rate12 = ByteUtils.DToUInt32(data, 100); + } + return CMD1102; + } + public CMD1104 ConCMD1104(byte[] data) + { + CMD1104 CMD1104 = null; + if (data != null && data.Length > 0) + { + CMD1104 = new CMD1104(); + CMD1104.ConfirmResult = data[8]; + } + return CMD1104; + } + public CMD1106 ConCMD1106(byte[] data) + { + CMD1106 CMD1106 = null; + if (data != null && data.Length > 0) + { + CMD1106 = new CMD1106(); + CMD1106.ConfirmResult = data[8]; + } + return CMD1106; + } + public CMD1108 ConCMD1108(byte[] data) + { + CMD1108 CMD1108 = null; + if (data != null && data.Length > 0) + { + CMD1108 = new CMD1108(); + CMD1108.StartHour1 = data[8]; + CMD1108.STartMin1 = data[9]; + CMD1108.EndHour1 = data[10]; + CMD1108.EndMin1 = data[11]; + CMD1108.Rate1 = ByteUtils.DToUInt32(data, 12); + + CMD1108.StartHour2 = data[16]; + CMD1108.STartMin2 = data[17]; + CMD1108.EndHour2 = data[18]; + CMD1108.EndMin2 = data[19]; + CMD1108.Rate2 = ByteUtils.DToUInt32(data, 20); + + CMD1108.StartHour3 = data[24]; + CMD1108.STartMin3 = data[25]; + CMD1108.EndHour3 = data[26]; + CMD1108.EndMin3 = data[27]; + CMD1108.Rate3 = ByteUtils.DToUInt32(data, 28); + + CMD1108.StartHour4 = data[32]; + CMD1108.STartMin4 = data[33]; + CMD1108.EndHour4 = data[34]; + CMD1108.EndMin4 = data[35]; + CMD1108.Rate4 = ByteUtils.DToUInt32(data, 36); + + CMD1108.StartHour5 = data[40]; + CMD1108.STartMin5 = data[41]; + CMD1108.EndHour5 = data[42]; + CMD1108.EndMin5 = data[43]; + CMD1108.Rate5 = ByteUtils.DToUInt32(data, 44); + + CMD1108.StartHour6 = data[48]; + CMD1108.STartMin6 = data[49]; + CMD1108.EndHour6 = data[50]; + CMD1108.EndMin6 = data[51]; + CMD1108.Rate6 = ByteUtils.DToUInt32(data, 52); + + CMD1108.StartHour7 = data[56]; + CMD1108.STartMin7 = data[57]; + CMD1108.EndHour7 = data[58]; + CMD1108.EndMin7 = data[59]; + CMD1108.Rate7 = ByteUtils.DToUInt32(data, 60); + + CMD1108.StartHour8 = data[64]; + CMD1108.STartMin8 = data[65]; + CMD1108.EndHour8 = data[66]; + CMD1108.EndMin8 = data[67]; + CMD1108.Rate8 = ByteUtils.DToUInt32(data, 68); + + CMD1108.StartHour9 = data[72]; + CMD1108.STartMin9 = data[73]; + CMD1108.EndHour9 = data[74]; + CMD1108.EndMin9 = data[75]; + CMD1108.Rate9 = ByteUtils.DToUInt32(data, 76); + + CMD1108.StartHour10 = data[80]; + CMD1108.STartMin10 = data[81]; + CMD1108.EndHour10 = data[82]; + CMD1108.EndMin10 = data[83]; + CMD1108.Rate10 = ByteUtils.DToUInt32(data, 84); + + CMD1108.StartHour11 = data[88]; + CMD1108.STartMin11 = data[89]; + CMD1108.EndHour11 = data[90]; + CMD1108.EndMin11 = data[91]; + CMD1108.Rate11 = ByteUtils.DToUInt32(data, 92); + + CMD1108.StartHour12 = data[96]; + CMD1108.STartMin12 = data[97]; + CMD1108.EndHour12 = data[98]; + CMD1108.EndMin12 = data[99]; + CMD1108.Rate12 = ByteUtils.DToUInt32(data, 100); + + } + return CMD1108; + } + public CMD1302 ConCMD1302(byte[] data) + { + CMD1302 CMD1302 = null; + if (data != null && data.Length > 0) + { + CMD1302 = new CMD1302(); + + CMD1302.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD1302.WhitelistType = data[44]; + CMD1302.Operate = data[45]; + CMD1302.ListVersioe = ByteUtils.DToUInt32(data, 46); + CMD1302.OperatResult = data[50]; + } + return CMD1302; + } + public CMD1402 ConCMD1402(byte[] data) + { + CMD1402 CMD1402 = null; + if (data != null && data.Length > 0) + { + CMD1402 = new CMD1402(); + + CMD1402.Result = data[12]; + } + return CMD1402; + } + public CMD1403 ConCMD1403(byte[] data) + { + CMD1403 CMD1403 = null; + if (data != null && data.Length > 0) + { + CMD1403 = new CMD1403(); + + CMD1403.ScheduleResult = data[12]; + } + return CMD1403; + } + public CMD1407 ConCMD1407(byte[] data) + { + CMD1407 CMD1407 = null; + if (data != null && data.Length > 0) + { + CMD1407 = new CMD1407(); + + CMD1407.Result = data[12]; + } + return CMD1407; + } + public CMD1501 ConCMD1501(byte[] data) + { + CMD1501 CMD1501 = null; + if (data != null && data.Length > 0) + { + CMD1501 = new CMD1501(); + + CMD1501.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD1501.UpFileName = Encoding.ASCII.GetString(data, 44, 128); + } + return CMD1501; + } + public CMD1503 ConCMD1503(byte[] data) + { + CMD1503 CMD1503 = null; + if (data != null && data.Length > 0) + { + CMD1503 = new CMD1503(); + + CMD1503.DataLength = ByteUtils.DToUInt32(data, 12); + CMD1503.MessageNum = ByteUtils.DToUInt32(data, 16); + CMD1503.LogData = Encoding.ASCII.GetString(data, 20, (data.Length - 21)); ; + } + return CMD1503; + } + public CMD1505 ConCMD1505(byte[] data) + { + CMD1505 CMD1505 = null; + if (data != null && data.Length > 0) + { + CMD1505 = new CMD1505(); + } + return CMD1505; + } + + + + + + #endregion ݷ + } + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1DataInfo(CMD1 CMD1) + { + byte[] results = null; + if (CMD1 != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD1.WorkingData_Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD1.WorkingData_Reserved2)); + lstContent.Add(CMD1.Type); + lstContent.AddRange(BitConverter.GetBytes(CMD1.SetAddress));//ʼַ + lstContent.Add(CMD1.SelectNum);//ѯ + lstContent.AddRange(BitConverter.GetBytes(CMD1.SetByteNum));//ֽ + if (CMD1.Type == 1) + { + lstContent.AddRange(CMD1.SetData); + } + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD3DataInfo(CMD3 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.Add(CMD.Type); + lstContent.AddRange(BitConverter.GetBytes(CMD.SAddress)); + lstContent.AddRange(BitConverter.GetBytes(CMD.SBytes)); + if (CMD.Type == 1) + { + lstContent.AddRange(CMD.SData); + } + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD5DataInfo(CMD5 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.Add(CMD.RechargeableMuzzle); + lstContent.AddRange(BitConverter.GetBytes(CMD.CommandAddress)); + lstContent.Add(CMD.CommandNum); + lstContent.AddRange(BitConverter.GetBytes(CMD.CommandLength)); + lstContent.AddRange(CMD.CommandData); + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD7DataInfo(CMD7 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved)); + lstContent.Add(CMD.ChargMuzzle); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargeType)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargeStopPassword)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargStrategy)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargStrategyPara)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ScheduleStartupTime)); + lstContent.Add(CMD.OutTime); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.CardNumber, 32)); + lstContent.Add(CMD.NetOutageSign); + lstContent.AddRange(BitConverter.GetBytes(CMD.MaxElectric)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.SerialNum, 32)); + lstContent.Add(CMD.BMSVoltage); + lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); + lstContent.Add(CMD.DisOrChargeMark); + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD9DataInfo(CMD9 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); + lstContent.AddRange(BitConverter.GetBytes(CMD.FWResult)); + lstContent.AddRange(BitConverter.GetBytes(CMD.CommandAddress)); + lstContent.AddRange(BitConverter.GetBytes(CMD.DataLength)); + lstContent.AddRange(CMD.Datas); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD101DataInfo(CMD101 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.HearResponse)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD103DataInfo(CMD103 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.Add(CMD.ChargNum); + lstContent.Add(Convert.ToByte(CMD.Reported)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD105DataInfo(CMD105 CMD105) + { + byte[] results = null; + if (CMD105 != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD105.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD105.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD105.NumResponse)); + lstContent.Add(CMD105.LoginVerify); + lstContent.Add(CMD105.EncryptionFlag); + if (CMD105.EncryptionFlag == 1) + { + lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD105.RSAComModule)); + lstContent.AddRange(BitConverter.GetBytes(CMD105.RSAComSecret)); + } + lstContent.Add(CMD105.StSign); + lstContent.AddRange(BitConverter.GetBytes(CMD105.BCDTime)); + lstContent.Add(CMD105.MessageUpload); + if (CMD105.EncryptionFlag == 1) + lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD105.AESSecretKey)); + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD107DataInfo(CMD107 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + //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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD109DataInfo(CMD109 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD111DataInfo(CMD111 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.MessageType)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD113DataInfo(CMD113 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.Add(CMD.ChargNum); + lstContent.Add(Convert.ToByte(CMD.Sign)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD201DataInfo(CMD201 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargNum)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ChargID, 32)); + lstContent.AddRange(BitConverter.GetBytes(CMD.IndexNum)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ValidMark)); + lstContent.AddRange(BitConverter.GetBytes(CMD.InitialCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.DiscountCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetElectricCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetServiceCost)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD203DataInfo(CMD203 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ResCode)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); + lstContent.AddRange(BitConverter.GetBytes(CMD.SumEleRate)); + lstContent.AddRange(BitConverter.GetBytes(CMD.EleRate)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargPassword)); + lstContent.AddRange(BitConverter.GetBytes(CMD.VINSign)); + lstContent.AddRange(BitConverter.GetBytes(CMD.CarIDVerify)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved3)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.SerialNum, 32)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VIN, 17)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD205DataInfo(CMD205 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ResponseCode)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD207DataInfo(CMD207 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ASCIINum, 32)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VINNum, 17)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VINBindAccount, 32)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ChargSerialNum, 32)); + lstContent.AddRange(BitConverter.GetBytes(CMD.VerifyResult)); + lstContent.AddRange(BitConverter.GetBytes(CMD.VerifyCause)); + lstContent.AddRange(BitConverter.GetBytes(CMD.RechBalance)); + lstContent.AddRange(BitConverter.GetBytes(CMD.StopCode)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD209DataInfo(CMD209 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ASCIINum, 32)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VINNum, 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD221DataInfo(CMD221 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargNum)); + lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ChargID)); + lstContent.AddRange(BitConverter.GetBytes(CMD.IndexNum)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ValidMark)); + lstContent.AddRange(BitConverter.GetBytes(CMD.InitialCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.DiscountCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetElectricCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetServiceCost)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD301DataInfo(CMD301 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD303DataInfo(CMD303 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD401DataInfo(CMD401 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.SelectIndex)); + lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ChargSerialNum)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1001DataInfo(CMD1001 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.CInstruction)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1003DataInfo(CMD1003 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(Encoding.ASCII.GetBytes(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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1005DataInfo(CMD1005 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1007DataInfo(CMD1007 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.UpFileData)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1009DataInfo(CMD1009 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1011DataInfo(CMD1011 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1021DataInfo(CMD1021 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.ResponseResult)); + lstContent.AddRange(Encoding.UTF8.GetBytes(CMD.ResponsExplain)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1101DataInfo(CMD1101 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1103DataInfo(CMD1103 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.Add(CMD.StartHour1); + lstContent.Add(CMD.STartMin1); + lstContent.Add(CMD.EndHour1); + lstContent.Add(CMD.EndMin1); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate1)); + + lstContent.Add(CMD.StartHour2); + lstContent.Add(CMD.STartMin2); + lstContent.Add(CMD.EndHour2); + lstContent.Add(CMD.EndMin2); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate2)); + + lstContent.Add(CMD.StartHour3); + lstContent.Add(CMD.STartMin3); + lstContent.Add(CMD.EndHour3); + lstContent.Add(CMD.EndMin3); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate3)); + + lstContent.Add(CMD.StartHour4); + lstContent.Add(CMD.STartMin4); + lstContent.Add(CMD.EndHour4); + lstContent.Add(CMD.EndMin4); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate4)); + + lstContent.Add(CMD.StartHour5); + lstContent.Add(CMD.STartMin5); + lstContent.Add(CMD.EndHour5); + lstContent.Add(CMD.EndMin5); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate5)); + + lstContent.Add(CMD.StartHour6); + lstContent.Add(CMD.STartMin6); + lstContent.Add(CMD.EndHour6); + lstContent.Add(CMD.EndMin6); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate6)); + + lstContent.Add(CMD.StartHour7); + lstContent.Add(CMD.STartMin7); + lstContent.Add(CMD.EndHour7); + lstContent.Add(CMD.EndMin7); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate7)); + + lstContent.Add(CMD.StartHour8); + lstContent.Add(CMD.STartMin8); + lstContent.Add(CMD.EndHour8); + lstContent.Add(CMD.EndMin8); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate8)); + + lstContent.Add(CMD.StartHour9); + lstContent.Add(CMD.STartMin9); + lstContent.Add(CMD.EndHour9); + lstContent.Add(CMD.EndMin9); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate9)); + + lstContent.Add(CMD.StartHour10); + lstContent.Add(CMD.STartMin10); + lstContent.Add(CMD.EndHour10); + lstContent.Add(CMD.EndMin10); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate10)); + + lstContent.Add(CMD.StartHour11); + lstContent.Add(CMD.STartMin11); + lstContent.Add(CMD.EndHour11); + lstContent.Add(CMD.EndMin11); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate11)); + + lstContent.Add(CMD.StartHour12); + lstContent.Add(CMD.STartMin12); + lstContent.Add(CMD.EndHour12); + lstContent.Add(CMD.EndMin12); + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1105DataInfo(CMD1105 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.Add(CMD.StartHour1); + lstContent.Add(CMD.STartMin1); + lstContent.Add(CMD.EndHour1); + lstContent.Add(CMD.EndMin1); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate1)); + + lstContent.Add(CMD.StartHour2); + lstContent.Add(CMD.STartMin2); + lstContent.Add(CMD.EndHour2); + lstContent.Add(CMD.EndMin2); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate2)); + + lstContent.Add(CMD.StartHour3); + lstContent.Add(CMD.STartMin3); + lstContent.Add(CMD.EndHour3); + lstContent.Add(CMD.EndMin3); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate3)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate3)); + + lstContent.Add(CMD.StartHour4); + lstContent.Add(CMD.STartMin4); + lstContent.Add(CMD.EndHour4); + lstContent.Add(CMD.EndMin4); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate4)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate4)); + + lstContent.Add(CMD.StartHour5); + lstContent.Add(CMD.STartMin5); + lstContent.Add(CMD.EndHour5); + lstContent.Add(CMD.EndMin5); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate5)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate5)); + + lstContent.Add(CMD.StartHour6); + lstContent.Add(CMD.STartMin6); + lstContent.Add(CMD.EndHour6); + lstContent.Add(CMD.EndMin6); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate6)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate6)); + + lstContent.Add(CMD.StartHour7); + lstContent.Add(CMD.STartMin7); + lstContent.Add(CMD.EndHour7); + lstContent.Add(CMD.EndMin7); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate7)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate7)); + + lstContent.Add(CMD.StartHour8); + lstContent.Add(CMD.STartMin8); + lstContent.Add(CMD.EndHour8); + lstContent.Add(CMD.EndMin8); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate8)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate8)); + + lstContent.Add(CMD.StartHour9); + lstContent.Add(CMD.STartMin9); + lstContent.Add(CMD.EndHour9); + lstContent.Add(CMD.EndMin9); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate9)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate9)); + + lstContent.Add(CMD.StartHour10); + lstContent.Add(CMD.STartMin10); + lstContent.Add(CMD.EndHour10); + lstContent.Add(CMD.EndMin10); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate10)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate10)); + + lstContent.Add(CMD.StartHour11); + lstContent.Add(CMD.STartMin11); + lstContent.Add(CMD.EndHour11); + lstContent.Add(CMD.EndMin11); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate11)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate11)); + + lstContent.Add(CMD.StartHour12); + lstContent.Add(CMD.STartMin12); + lstContent.Add(CMD.EndHour12); + lstContent.Add(CMD.EndMin12); + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1107DataInfo(CMD1107 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// CMD1301 翨 30byte\0 + /// + /// + /// + 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; + } + + + /// + /// ȡȨϢֽ + /// 1-翨 32byte\2-VIN 17byte + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1301DataInfo(CMD1301 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ASCIINum), 32)); + lstContent.Add(CMD.WhitelistType); + lstContent.Add(CMD.Operate); + lstContent.AddRange(BitConverter.GetBytes(CMD.WhitelistVersioNum)); + //Ϊѯ =4ֶβҪ + if (CMD.Operate != 4) + { + lstContent.AddRange(BitConverter.GetBytes(CMD.WhitelistNum)); + if (CMD.WhitelistType == 1) + { + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID01), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID02), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID03), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID04), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID05), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID06), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID07), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID08), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID09), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID10), 32)); + } + else + { + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID01), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID02), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID03), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID04), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID05), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID06), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID07), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID08), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID09), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID10), 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1401DataInfo(CMD1401 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes((ushort)(Convert.ToSingle(CMD.UpFileVersioNum) * 100))); + + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ServerIP), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.UserName), 16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.Password), 16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.DownloadPath), 64)); + + lstContent.Add(CMD.ExecutiveMode); + lstContent.Add(CMD.DeviceType); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1406DataInfo(CMD1406 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.Add(CMD.LogType); + + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ServerIP), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.UserName), 16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.Password), 16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.LogPath), 32)); + lstContent.Add(CMD.ExecutiveMode); + + 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; + + + model.dataDomain = GetRCMD1502DataInfo(CMD); // + model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1502DataInfo(CMD1502 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.AnswerCode)); + + 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; + + model.dataDomain = GetRCMD1504DataInfo(CMD); // + model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1504DataInfo(CMD1504 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Sign)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ReceiveMessageNum)); + + 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; + + + model.dataDomain = GetRCMD1506DataInfo(CMD); // + model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1506DataInfo(CMD1506 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + + results = lstContent.ToArray(); + } + return results; + } + #endregion + + List APCI(APDUModel baseApci) + { + List lstResult = null; + if (baseApci != null) + { + lstResult = new List(); + //ʼ + lstResult.Add(baseApci.OriginDomain1); + lstResult.Add(baseApci.OriginDomain2); + // + byte[] packLens = BitConverter.GetBytes(baseApci.LengthDomain); + lstResult.AddRange(packLens); + //Ϣ + lstResult.Add(baseApci.infoDomain); + //к + lstResult.Add(baseApci.SerialNumberDomain); + //Դַ + byte[] packSrcs = BitConverter.GetBytes(baseApci.CMD); + lstResult.AddRange(packSrcs); + // + lstResult.AddRange(baseApci.dataDomain); + + baseApci.checksumDomain = checksumDomain(lstResult.ToArray()); + //У + lstResult.Add(baseApci.checksumDomain); + } + return lstResult; + } + /// + /// ݰ-У + /// + /// + /// + public static byte checksumDomain(byte[] data) + { + int checksum = 0; + + for (int i = 6; i < data.Count(); i++)//ûУԲһ + { + checksum += data[i]; + } + + //foreach (byte b in data) + //{ + // checksum += b; + //} + // ȡУ͵ĵ8λ + return (byte)(checksum & 0xFF); + } + } +} diff --git a/HybirdFrameworkEntity/Class1.cs b/HybirdFrameworkEntity/Class1.cs deleted file mode 100644 index 71c4664..0000000 --- a/HybirdFrameworkEntity/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace HybirdFrameworkEntity -{ - public class Class1 - { - - } -} diff --git a/HybirdFrameworkEntity/MsgModel/Decode.cs b/HybirdFrameworkEntity/MsgModel/Decode.cs deleted file mode 100644 index 345d201..0000000 --- a/HybirdFrameworkEntity/MsgModel/Decode.cs +++ /dev/null @@ -1,1766 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace HybirdFrameworkEntity -{ - public class Decode - { - public void decode(string IP,string port,byte[] data) - { - switch (IP) - { - case "1": - - break; - case "2": - break; - case "3": - break; - case "4": - break; - case "5": - break; - } - int func = (ushort)(data[6] + (data[6 + 1] << 8)); - switch (func) - { - #region 协议格式 - - case 2: - { - CMD2 CMD2 = ConCMD2(data); - string result = "(CMD=2)充电桩参数整形设置/查询应答 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=2)充电桩参数整形设置/查询应答对象:" + JsonConvert.SerializeObject(CMD2); - ////Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 4: - { - CMD4 CMD4 = ConCMD4(data); - string result = "(CMD=4)充电桩参数字符形设置/查询应答 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=4)充电桩参数字符形设置/查询应答对象:" + JsonConvert.SerializeObject(CMD4); - ////Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 6: - { - CMD6 CMD6 = ConCMD6(data); - string result = "(CMD=6)充电桩对后台控制命令应答- 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=6)充电桩对后台控制命令应答对象:" + JsonConvert.SerializeObject(CMD6); - ////Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 8: - { - CMD8 CMD8 = ConCMD8(data); - string result = "(CMD=8) 充电桩对后台下发的充电桩开启充电控制应答 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=8) 充电桩对后台下发的充电桩开启充电控制应答对象:" + JsonConvert.SerializeObject(CMD8); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 10: - { - CMD10 CMD10 = ConCMD10(data); - string result = "(CMD=10)充电桩上传命令请求(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=10)充电桩上传命令请求(预留)对象:" + JsonConvert.SerializeObject(CMD10); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - #endregion - - #region 充电桩主动上传数据 - - case 102: - { - CMD102 CMD102 = ConCMD102(data); - string result = "(CMD=10)充电桩上传心跳包信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=10)充电桩上传心跳包信息对象:" + JsonConvert.SerializeObject(CMD102); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 104: - { - CMD104 CMD104 = ConCMD104(data); - string result = "(CMD=10)充电桩状态信息包上报 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=10)充电桩状态信息包上报对象:" + JsonConvert.SerializeObject(CMD104); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 106: - { - CMD106 CMD106 = ConCMD106(data); - string result = "(CMD=10)充电桩签到信息上报 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=10)充电桩签到信息上报对象:" + JsonConvert.SerializeObject(CMD106); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 108: - { - CMD108 CMD108 = ConCMD108(data); - string result = "(CMD=10)充电桩告警信息上报(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=10)充电桩告警信息上报(预留)对象:" + JsonConvert.SerializeObject(CMD108); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 110: - { - CMD110 CMD110 = ConCMD110(data); - string result = "(CMD=10)充电桩上报充电启动完成命令(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=10)充电桩上报充电启动完成命令(预留)对象:" + JsonConvert.SerializeObject(CMD110); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 112: - { - CMD112 CMD112 = ConCMD112(data); - string result = "(CMD=10)充电桩模块信息上报(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=10)充电桩模块信息上报对象:" + JsonConvert.SerializeObject(CMD112); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 114: - { - CMD114 CMD114 = ConCMD114(data); - string result = "(CMD=10)充电桩应答服务器查询最近一次充电各时段信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=10)充电桩应答服务器查询最近一次充电各时段信息对象:" + JsonConvert.SerializeObject(CMD114); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - #endregion - - #region 充电信息数据 - - case 202: - case 222: - { - CMD202 CMD202 = ConCMD202((UInt16)func, data); - string result = "充电桩上报充电记录信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "上报充电记录信息对象:" + JsonConvert.SerializeObject(CMD202); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 204: - { - CMD204 CMD204 = ConCMD204(data); - string result = "充电桩充电上传用户账户查询报文 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩充电上传用户账户查询报文对象:" + JsonConvert.SerializeObject(CMD204); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 206: - { - CMD206 CMD206 = ConCMD206(data); - string result = "充电桩充电上传用户密码验证报文 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩充电上传用户密码验证报文对象:" + JsonConvert.SerializeObject(CMD206); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 208: - { - CMD208 CMD208 = ConCMD208(data); - string result = "充电桩上报“即插即充”启动充电请求 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩上报“即插即充”启动充电请求对象:" + JsonConvert.SerializeObject(CMD208); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 210: - { - CMD210 CMD210 = ConCMD210(data); - string result = "充电桩上报“即插即充”启动充电结果 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩上报“即插即充”启动充电结果:" + JsonConvert.SerializeObject(CMD210); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - #endregion - - #region 直流充电桩 BMS 信息数据(预留) - case 302: - { - CMD302 CMD302 = ConCMD302(data); - string result = "充电桩上报BMS信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩上报BMS信息对象:" + JsonConvert.SerializeObject(CMD302); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 304: - { - CMD304 CMD304 = ConCMD304(data); - string result = "充电桩上报BMS信息(预留-暂时不用) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩上报BMS信息(预留-暂时不用)对象:" + JsonConvert.SerializeObject(CMD304); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - #endregion - - #region 历史记录 - case 402: - case 422: - { - CMD402 CMD402 = ConCMD402((UInt16)func, data); - string result = "充电桩上报历史的充电记录 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩上报历史的充电记录:" + JsonConvert.SerializeObject(CMD402); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - #endregion - - #region 升级命令 - case 1002: - { - CMD1002 CMD1002 = ConCMD1002(data); - string result = "充电桩回复服务器下发擦除指令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩回复服务器下发擦除指令对象:" + JsonConvert.SerializeObject(CMD1002); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1004: - { - CMD1004 CMD1004 = ConCMD1004(data); - string result = "充电桩应答服务器下发升级文件名指令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答服务器下发升级文件名指令对象:" + JsonConvert.SerializeObject(CMD1004); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1006: - { - CMD1006 CMD1006 = ConCMD1006(data); - string result = "充电桩应答服务器下发升级文件大小指令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答服务器下发升级文件大小指令对象:" + JsonConvert.SerializeObject(CMD1006); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1008: - { - CMD1008 CMD1008 = ConCMD1008(data); - string result = "充电桩应答服务器下发升级文件数据指令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答服务器下发升级文件数据指令对象:" + JsonConvert.SerializeObject(CMD1008); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1010: - { - CMD1010 CMD1010 = ConCMD1010(data); - string result = "充电桩应答服务器下发升级文件数据结束指令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答服务器下发升级文件数据结束指令对象:" + JsonConvert.SerializeObject(CMD1010); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1012: - { - CMD1012 CMD1012 = ConCMD1012(data); - string result = "充电桩应答服务器下发重启指令- 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答服务器下发重启指令对象:" + JsonConvert.SerializeObject(CMD1012); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1022: - { - CMD1022 CMD1022 = ConCMD1022(data); - string result = "充电桩主动请求升级命令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩主动请求升级命令对象:" + JsonConvert.SerializeObject(CMD1022); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - #endregion - - #region 与计费策略相关的指令 - case 1102: - { - CMD1102 CMD1102 = ConCMD1102(data); - string result = "充电桩应答后台服务器查询24时电费计价策略信息- 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答后台服务器查询24时电费计价策略信息对象:" + JsonConvert.SerializeObject(CMD1102); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1104: - { - CMD1104 CMD1104 = ConCMD1104(data); - string result = "充电桩应答后台服务器设置24时电费计价策略信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答后台服务器设置24时电费计价策略信息对象:" + JsonConvert.SerializeObject(CMD1104); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1106: - { - CMD1106 CMD1106 = ConCMD1106(data); - string result = "充电桩应答后台服务器设置分时段计价策略信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答后台服务器设置分时段计价策略信息对象:" + JsonConvert.SerializeObject(CMD1106); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1108: - { - CMD1108 CMD1108 = ConCMD1108(data); - string result = "充电桩回复分时电费计价策略信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩回复分时电费计价策略信息对象:" + JsonConvert.SerializeObject(CMD1108); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - #endregion - - #region 白名单报文 - case 1302: - { - CMD1302 CMD1302 = ConCMD1302(data); - string result = "充电桩应答白名单操作日志数据包 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答白名单操作日志数据包对象:" + JsonConvert.SerializeObject(CMD1302); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - #endregion - - #region FTP远程升级和FTP方式日志上传 - case 1402: - { - CMD1402 CMD1402 = ConCMD1402(data); - string result = "充电桩应答服务器下发FTP远程升级命令- 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答服务器下发FTP远程升级命令对象:" + JsonConvert.SerializeObject(CMD1402); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1403: - { - CMD1403 CMD1403 = ConCMD1403(data); - string result = "充电桩应答FTP升级包下载进度 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答FTP升级包下载进度对象:" + JsonConvert.SerializeObject(CMD1403); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1407: - { - CMD1407 CMD1407 = ConCMD1407(data); - string result = "充电桩应答服务器下发获取充电桩日志命令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "充电桩应答服务器下发获取充电桩日志命令对象:" + JsonConvert.SerializeObject(CMD1407); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - #endregion - - #region 协议方式日志上传 - case 1501: - { - CMD1501 CMD1501 = ConCMD1501(data); - string result = "(CMD=1501)申请上传文件 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=1501)申请上传文件对象:" + JsonConvert.SerializeObject(CMD1501); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - case 1503: - { - CMD1503 CMD1503 = ConCMD1503(data); - string result = "(CMD=10)充电桩上传命令请求(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=10)充电桩上传命令请求(预留)对象:" + JsonConvert.SerializeObject(CMD1503); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - - } - break; - case 1505://接收完成,要保存关闭 - { - CMD1505 CMD1505 = ConCMD1505(data); - string result = "(CMD=10)充电桩上传命令请求(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; - result += "\r\n" + "(CMD=10)充电桩上传命令请求(预留)对象:" + JsonConvert.SerializeObject(CMD1505); - //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); - } - break; - #endregion - } - } - - - public CMD2 ConCMD2(byte[] data) - { - CMD2 CMD2 = null; - if (data != null && data.Length > 0) - { - CMD2 = new CMD2(); - CMD2.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD2.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD2.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD2.Type = data[44]; - CMD2.SAddress = ByteUtils.DToUInt32(data, 45); - CMD2.SNum = data[50]; - CMD2.SResult = data[51]; - CMD2.SData = Encoding.ASCII.GetString(data, 52, (data.Length - 52)); - - } - return CMD2; - } - public CMD4 ConCMD4(byte[] data) - { - CMD4 CMD4 = null; - if (data != null && data.Length > 0) - { - CMD4 = new CMD4(); - CMD4.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD4.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD4.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD4.Type = data[44]; - CMD4.SAddress = ByteUtils.DToUInt32(data, 45); - CMD4.SResult = data[49]; - CMD4.SData = Encoding.ASCII.GetString(data, 50, (data.Length - 51)); - - } - return CMD4; - } - public CMD6 ConCMD6(byte[] data) - { - CMD6 CMD6 = null; - if (data != null && data.Length > 0) - { - CMD6 = new CMD6(); - CMD6.value01 = ByteUtils.DToUInt16(data, 8); - CMD6.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD6.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD6.ChargMuzzle = data[44]; - CMD6.CommandMark = ByteUtils.DToUInt32(data, 45); - CMD6.CommandNum = data[49]; - CMD6.CommandResult = data[50]; - } - return CMD6; - } - public CMD8 ConCMD8(byte[] data) - { - CMD8 CMD8 = null; - if (data != null && data.Length > 0) - { - CMD8 = new CMD8(); - CMD8.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD8.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD8.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD8.ChargMuzzle = data[44]; - CMD8.CommandResult = ByteUtils.DToUInt16(data, 45); - CMD8.ChargSerialNum = Encoding.ASCII.GetString(data, 49, 32); - } - return CMD8; - } - public CMD10 ConCMD10(byte[] data) - { - CMD10 CMD10 = null; - if (data != null && data.Length > 0) - { - CMD10 = new CMD10(); - CMD10.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD10.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD10.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); ; - CMD10.ChargGunNum = data[44]; - CMD10.RequestStaIP = ByteUtils.DToUInt32(data, 45); - CMD10.Parameter = (float)((ByteUtils.DToUInt32(data, 49)) * 0.01); - } - return CMD10; - } - public CMD102 ConCMD102(byte[] data) - { - CMD102 CMD102 = null; - if (data != null && data.Length > 0) - { - CMD102 = new CMD102(); - CMD102.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD102.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD102.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); ; - CMD102.HeartNum = ByteUtils.DToUInt16(data, 44); - CMD102.GunStatus[0] = data[46]; - CMD102.GunStatus[1] = data[47]; - CMD102.GunStatus[2] = data[48]; - CMD102.GunStatus[3] = data[49]; - CMD102.GunStatus[4] = data[50]; - CMD102.GunStatus[5] = data[51]; - CMD102.GunStatus[6] = data[52]; - CMD102.GunStatus[7] = data[53]; - CMD102.GunStatus[8] = data[54]; - CMD102.GunStatus[9] = data[55]; - CMD102.GunStatus[10] = data[56]; - CMD102.GunStatus[11] = data[57]; - CMD102.GunStatus[12] = data[58]; - CMD102.GunStatus[13] = data[59]; - CMD102.GunStatus[14] = data[60]; - CMD102.GunStatus[15] = data[61]; - } - return CMD102; - } - public CMD104 ConCMD104(byte[] data) - { - CMD104 CMD104 = null; - if (data != null && data.Length > 0) - { - CMD104 = new CMD104(); - - CMD104.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD104.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD104.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD104.ChargGunNum = data[44]; - CMD104.ChargNum = data[45]; - CMD104.ChargGunType = data[46]; - CMD104.WorkState = data[47]; - CMD104.SOCNOW = data[48]; - CMD104.MaxAlarmCode = Encoding.ASCII.GetString(data, 49, 4); - CMD104.ConnecteState = data[53]; - CMD104.TotalCost = (float)(ByteUtils.DToUInt32(data, 54) * 0.01); - CMD104.Reserved3 = ByteUtils.DToUInt32(data, 58); - CMD104.Reserved4 = ByteUtils.DToUInt32(data, 62); - if (data[46] == 1) - { - CMD104.DcChargVoltage = ByteUtils.DToUInt16(data, 66); - CMD104.DcChargCurrent = ByteUtils.DToUInt16(data, 68); - CMD104.BMSDemVoltage = ByteUtils.DToUInt16(data, 70); - CMD104.BMSDemCurrent = ByteUtils.DToUInt16(data, 72); - } - else - { - CMD104.DcChargVoltage = 0; - CMD104.DcChargCurrent = 0; - CMD104.BMSDemVoltage = 0; - CMD104.BMSDemCurrent = 0; - } - - - - CMD104.BMSchargMode = data[74]; - CMD104.AcChargVoltageA = ByteUtils.DToUInt16(data, 75); - CMD104.AcChargVoltageB = ByteUtils.DToUInt16(data, 77); - CMD104.AcChargVoltageC = ByteUtils.DToUInt16(data, 79); - CMD104.AcChargCurrentA = ByteUtils.DToUInt16(data, 81); - CMD104.AcChargCurrentB = ByteUtils.DToUInt16(data, 83); - CMD104.AcChargCurrentC = ByteUtils.DToUInt16(data, 85); - CMD104.RemainTime = ByteUtils.DToUInt16(data, 87); - CMD104.ChargTime = ByteUtils.DToUInt32(data, 89); - CMD104.TotalChargkwh = ByteUtils.DToUInt32(data, 93); - CMD104.StartAmmeterValue = (float)(ByteUtils.DToUInt32(data, 97) * 0.01); - CMD104.AmmeterValue = (float)(ByteUtils.DToUInt32(data, 101) * 0.01); - CMD104.ChargStartMode = data[105]; - CMD104.ChargStrategy = data[106]; - CMD104.ChargStrategyPara = ByteUtils.DToUInt32(data, 107); - CMD104.AppointmentSign = data[111]; - CMD104.ChargID = Encoding.ASCII.GetString(data, 112, 32); - CMD104.OutTime = data[144]; - CMD104.StartTime = Encoding.ASCII.GetString(data, 145, 8); - CMD104.InitialBalance = ByteUtils.DToUInt32(data, 153); - CMD104.Reserved5 = ByteUtils.DToUInt32(data, 157); - CMD104.ChargPower = (float)(ByteUtils.DToUInt32(data, 161) * 0.1); - CMD104.Reserved6 = ByteUtils.DToUInt32(data, 165); - CMD104.Reserved7 = ByteUtils.DToUInt32(data, 169); - CMD104.Reserved8 = ByteUtils.DToUInt32(data, 173); - CMD104.OutletTemp = data[177]; - CMD104.Temperature = data[178]; - CMD104.ChargGunTemp = data[179]; - CMD104.VINNum = Encoding.ASCII.GetString(data, 180, 18); - CMD104.DoorState = data[198]; - CMD104.ChargSerialNum = Encoding.ASCII.GetString(data, 199, 32); - CMD104.TotalElectricity = ByteUtils.DToUInt32(data, 231); - CMD104.ServiceCharge = ByteUtils.DToUInt32(data, 235); - CMD104.HomingState = data[239]; - CMD104.GroundLockedState = data[240]; - CMD104.KilojoulesElec = data[241]; - CMD104.DcACElectricity = ((float)(ByteUtils.DToUInt32(data, 242) * 0.001)).ToString("F1"); - CMD104.ChargMode = data[246]; - CMD104.ChargeOrDisSign = data[247]; - } - return CMD104; - } - public CMD106 ConCMD106(byte[] data) - { - CMD106 CMD106 = null; - if (data != null && data.Length > 0) - { - CMD106 = new CMD106(); - CMD106.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD106.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD106.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD106.Sign = data[44]; - CMD106.ChargVersion = ByteUtils.DToUInt32(data, 45); - CMD106.ChargProType = ByteUtils.DToUInt16(data, 49); - CMD106.StartNum = ByteUtils.DToUInt32(data, 51); - CMD106.DataUploadMode = data[55]; - CMD106.SignInterval = ByteUtils.DToUInt16(data, 56); - CMD106.RunVariable = data[58]; - CMD106.ChargGunNum = data[59]; - CMD106.HeartReportCycle = data[60]; - CMD106.TimeoutNum = data[61]; - CMD106.RecordNum = ByteUtils.DToUInt32(data, 62); - CMD106.SystemTime = Encoding.ASCII.GetString(data, 66, 8); - CMD106.Reserved3 = Encoding.ASCII.GetString(data, 74, 8); - CMD106.Reserved4 = Encoding.ASCII.GetString(data, 82, 8); - CMD106.Reserved5 = Encoding.ASCII.GetString(data, 90, 8); - CMD106.RandomNum = ByteUtils.DToUInt32(data, 98); - CMD106.ProtocolVersion = ByteUtils.DToUInt16(data, 102); - CMD106.WhiteVersionNum = ByteUtils.DToUInt16(data, 104); - CMD106.DeviceType = data[108]; - CMD106.AssetCoding = Encoding.ASCII.GetString(data, 109, 32); - } - return CMD106; - } - public CMD108 ConCMD108(byte[] data) - { - CMD108 CMD108 = null; - if (data != null && data.Length > 0) - { - CMD108 = new CMD108(); - CMD108.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD108.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD108.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD108.AlarmBitInfo = Encoding.ASCII.GetString(data, 44, 32); - } - return CMD108; - } - public CMD110 ConCMD110(byte[] data) - { - CMD110 CMD110 = null; - if (data != null && data.Length > 0) - { - CMD110 = new CMD110(); - CMD110.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD110.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD110.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD110.ChargGunNum = data[44]; - CMD110.ChargeFail = ByteUtils.DToUInt32(data, 45); - CMD110.SendMessage = ByteUtils.DToUInt16(data, 49); - CMD110.Reserved3 = ByteUtils.DToUInt16(data, 51); - CMD110.Reserved4 = ByteUtils.DToUInt32(data, 53); - byte version1 = data[58]; - byte version2 = data[59]; - byte version3 = data[60]; - CMD110.BRMBMSVersionNum = "v" + version1.ToString() + version2.ToString() + version3.ToString(); - CMD110.BRMBatteryType = data[61]; - CMD110.BRMRatedCapacity = ByteUtils.DToUInt32(data, 62); - CMD110.BRMRatedVoltage = ByteUtils.DToUInt32(data, 66); - CMD110.BRMBatteryManu = ByteUtils.DToUInt32(data, 70); - CMD110.BRMBatteryPackID = ByteUtils.DToUInt32(data, 74); - CMD110.BRMDateYear = ByteUtils.DToUInt16(data, 78); - CMD110.BRMDateMonth = data[80]; - CMD110.BRMDateDay = data[81]; - CMD110.BRMChargeCount = ByteUtils.DToUInt32(data, 82); - CMD110.BRMTitleMark = data[86]; - CMD110.Reserved5 = data[87]; - CMD110.BRMVINID = Encoding.ASCII.GetString(data, 88, 17); - - byte VersionSerialNum = data[105]; - byte day = data[106]; - byte month = data[107]; - ushort year = ByteUtils.DToUInt16(data, 108); - - - CMD110.BRMBMSSoftVerNum = VersionSerialNum.ToString() + year.ToString() + "年" + month.ToString() + "月" + day.ToString() + "日"; - CMD110.MaxChargVoltage = (float)(ByteUtils.DToUInt32(data, 113) * 0.1); - CMD110.MaxChargCurrent = (float)(ByteUtils.DToUInt32(data, 117) * 0.1); - CMD110.TotalEnergy = (float)(ByteUtils.DToUInt32(data, 121) * 0.1); - CMD110.MaxTotalVoltage = (float)(ByteUtils.DToUInt32(data, 125) * 0.1); - CMD110.MaxTemp = data[129]; - CMD110.ChargeState = (float)(ByteUtils.DToUInt16(data, 130) * 0.1); - CMD110.CellVoltage = (float)(ByteUtils.DToUInt32(data, 132) * 0.1); - CMD110.ChargSerialNum = Encoding.ASCII.GetString(data, 136, 32); - } - return CMD110; - } - public CMD112 ConCMD112(byte[] data) - { - CMD112 CMD112 = null; - if (data != null && data.Length > 0) - { - CMD112 = new CMD112(); - CMD112.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD112.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD112.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD112.ReportMode = data[44]; - CMD112.ModuleNum = data[45]; - CMD112.ModuleType = data[46]; - CMD112.ACModuleversion1 = ByteUtils.DToUInt16(data, 47); - CMD112.DCModuleversion1 = ByteUtils.DToUInt16(data, 49); - CMD112.ModuleState1 = data[51]; - CMD112.ModuleOutVoltage1 = ByteUtils.DToUInt16(data, 52); - CMD112.ModuleOutCurrent1 = ByteUtils.DToUInt16(data, 54); - CMD112.ModuleAlarm1 = ByteUtils.DToUInt32(data, 56); - CMD112.ACModuleversion2 = ByteUtils.DToUInt16(data, 60); - CMD112.DCModuleversion2 = ByteUtils.DToUInt16(data, 62); - CMD112.ModuleState2 = data[64]; - CMD112.ModuleOutVoltage2 = ByteUtils.DToUInt16(data, 65); - CMD112.ModuleOutCurrent2 = ByteUtils.DToUInt16(data, 67); - CMD112.ModuleAlarm2 = ByteUtils.DToUInt32(data, 69); - } - return CMD112; - } - public CMD114 ConCMD114(byte[] data) - { - CMD114 CMD114 = null; - if (data != null && data.Length > 0) - { - CMD114 = new CMD114(); - CMD114.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD114.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD114.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD114.ChargGunNum = data[44]; - CMD114.WorkState = data[45]; - CMD114.StartChargTime = Encoding.ASCII.GetString(data, 46, 8); - /* - 7 54 - 8 56 - 9 58 - 10 60 - 11 62 - 12 64 - 13 66 - 14 68 - 15 70 - 16 72 - 17 74 - 18 76 - 19 78 - 20 80 - 21 82 - 22 84 - 23 86 - 24 88 - 25 90 - 26 92 - 27 94 - 28 96 - 29 98 - 30 100 - 31 102 - 32 104 - 33 106 - 34 108 - 35 110 - 36 112 - 37 114 - 38 116 - 39 118 - 40 120 - 41 122 - 42 124 - 43 126 - 44 128 - 45 130 - 46 132 - 47 134 - 48 136 - 49 138 - 50 140 - 51 142 - 52 144 - 53 146 - 54 148 - - */ - CMD114.Charge01 = ByteUtils.DToUInt16(data, 54); - CMD114.Charge02 = ByteUtils.DToUInt16(data, 56); - CMD114.Charge03 = ByteUtils.DToUInt16(data, 58); - CMD114.Charge04 = ByteUtils.DToUInt16(data, 60); - CMD114.Charge05 = ByteUtils.DToUInt16(data, 62); - CMD114.Charge06 = ByteUtils.DToUInt16(data, 64); - CMD114.Charge07 = ByteUtils.DToUInt16(data, 66); - CMD114.Charge08 = ByteUtils.DToUInt16(data, 68); - CMD114.Charge09 = ByteUtils.DToUInt16(data, 70); - CMD114.Charge10 = ByteUtils.DToUInt16(data, 72); - CMD114.Charge11 = ByteUtils.DToUInt16(data, 74); - CMD114.Charge12 = ByteUtils.DToUInt16(data, 76); - CMD114.Charge13 = ByteUtils.DToUInt16(data, 78); - CMD114.Charge14 = ByteUtils.DToUInt16(data, 80); - CMD114.Charge15 = ByteUtils.DToUInt16(data, 82); - CMD114.Charge16 = ByteUtils.DToUInt16(data, 84); - CMD114.Charge17 = ByteUtils.DToUInt16(data, 86); - CMD114.Charge18 = ByteUtils.DToUInt16(data, 88); - CMD114.Charge19 = ByteUtils.DToUInt16(data, 90); - CMD114.Charge20 = ByteUtils.DToUInt16(data, 92); - CMD114.Charge21 = ByteUtils.DToUInt16(data, 94); - CMD114.Charge22 = ByteUtils.DToUInt16(data, 96); - CMD114.Charge23 = ByteUtils.DToUInt16(data, 98); - CMD114.Charge24 = ByteUtils.DToUInt16(data, 100); - CMD114.Charge25 = ByteUtils.DToUInt16(data, 102); - CMD114.Charge26 = ByteUtils.DToUInt16(data, 104); - CMD114.Charge27 = ByteUtils.DToUInt16(data, 106); - CMD114.Charge29 = ByteUtils.DToUInt16(data, 108); - CMD114.Charge30 = ByteUtils.DToUInt16(data, 110); - CMD114.Charge31 = ByteUtils.DToUInt16(data, 112); - CMD114.Charge32 = ByteUtils.DToUInt16(data, 114); - CMD114.Charge33 = ByteUtils.DToUInt16(data, 116); - CMD114.Charge34 = ByteUtils.DToUInt16(data, 118); - CMD114.Charge35 = ByteUtils.DToUInt16(data, 120); - CMD114.Charge36 = ByteUtils.DToUInt16(data, 122); - CMD114.Charge37 = ByteUtils.DToUInt16(data, 124); - CMD114.Charge38 = ByteUtils.DToUInt16(data, 126); - CMD114.Charge39 = ByteUtils.DToUInt16(data, 128); - CMD114.Charge40 = ByteUtils.DToUInt16(data, 130); - CMD114.Charge41 = ByteUtils.DToUInt16(data, 132); - } - return CMD114; - } - public CMD202 ConCMD202(uint func, byte[] data) - { - CMD202 CMD202 = null; - if (data != null && data.Length > 0) - { - CMD202 = new CMD202(); - CMD202.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD202.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD202.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD202.PosType = data[44]; - CMD202.ChargGun = data[45]; - CMD202.ChargID = Encoding.ASCII.GetString(data, 46, 32); - CMD202.StartTime = Encoding.ASCII.GetString(data, 78, 8); - CMD202.EndTime = Encoding.ASCII.GetString(data, 86, 8); - CMD202.TimeSpan = ByteUtils.DToUInt32(data, 94); - CMD202.SOCStart = data[98]; - CMD202.SOCEnd = data[99]; - CMD202.EndReason = ByteUtils.DToUInt32(data, 100); - - if (func == 202) - { - CMD202.ChargCapacityNow = (ByteUtils.DToUInt32(data, 104) * 0.01).ToString("F2"); - CMD202.SAmmeterValue = (ByteUtils.DToUInt32(data, 108) * 0.01).ToString("F2"); - CMD202.EAmmeterValue = (ByteUtils.DToUInt32(data, 112) * 0.01).ToString("F2"); - - - CMD202.ChargCapacity01 = ByteUtils.DToUInt16(data, 167).ToString(); - CMD202.ChargCapacity02 = ByteUtils.DToUInt16(data, 169).ToString(); - CMD202.ChargCapacity03 = ByteUtils.DToUInt16(data, 171).ToString(); - CMD202.ChargCapacity04 = ByteUtils.DToUInt16(data, 173).ToString(); - CMD202.ChargCapacity05 = ByteUtils.DToUInt16(data, 175).ToString(); - CMD202.ChargCapacity06 = ByteUtils.DToUInt16(data, 177).ToString(); - CMD202.ChargCapacity07 = ByteUtils.DToUInt16(data, 179).ToString(); - CMD202.ChargCapacity08 = ByteUtils.DToUInt16(data, 181).ToString(); - CMD202.ChargCapacity09 = ByteUtils.DToUInt16(data, 183).ToString(); - CMD202.ChargCapacity10 = ByteUtils.DToUInt16(data, 185).ToString(); - CMD202.ChargCapacity11 = ByteUtils.DToUInt16(data, 187).ToString(); - CMD202.ChargCapacity12 = ByteUtils.DToUInt16(data, 189).ToString(); - CMD202.ChargCapacity13 = ByteUtils.DToUInt16(data, 191).ToString(); - CMD202.ChargCapacity14 = ByteUtils.DToUInt16(data, 193).ToString(); - CMD202.ChargCapacity15 = ByteUtils.DToUInt16(data, 195).ToString(); - CMD202.ChargCapacity16 = ByteUtils.DToUInt16(data, 197).ToString(); - CMD202.ChargCapacity17 = ByteUtils.DToUInt16(data, 199).ToString(); - CMD202.ChargCapacity18 = ByteUtils.DToUInt16(data, 201).ToString(); - CMD202.ChargCapacity19 = ByteUtils.DToUInt16(data, 203).ToString(); - CMD202.ChargCapacity20 = ByteUtils.DToUInt16(data, 205).ToString(); - CMD202.ChargCapacity21 = ByteUtils.DToUInt16(data, 207).ToString(); - CMD202.ChargCapacity22 = ByteUtils.DToUInt16(data, 209).ToString(); - CMD202.ChargCapacity23 = ByteUtils.DToUInt16(data, 211).ToString(); - CMD202.ChargCapacity24 = ByteUtils.DToUInt16(data, 213).ToString(); - CMD202.ChargCapacity25 = ByteUtils.DToUInt16(data, 215).ToString(); - CMD202.ChargCapacity26 = ByteUtils.DToUInt16(data, 217).ToString(); - CMD202.ChargCapacity27 = ByteUtils.DToUInt16(data, 219).ToString(); - CMD202.ChargCapacity28 = ByteUtils.DToUInt16(data, 221).ToString(); - CMD202.ChargCapacity29 = ByteUtils.DToUInt16(data, 223).ToString(); - CMD202.ChargCapacity30 = ByteUtils.DToUInt16(data, 225).ToString(); - CMD202.ChargCapacity31 = ByteUtils.DToUInt16(data, 227).ToString(); - CMD202.ChargCapacity32 = ByteUtils.DToUInt16(data, 229).ToString(); - CMD202.ChargCapacity33 = ByteUtils.DToUInt16(data, 231).ToString(); - CMD202.ChargCapacity34 = ByteUtils.DToUInt16(data, 233).ToString(); - CMD202.ChargCapacity35 = ByteUtils.DToUInt16(data, 235).ToString(); - CMD202.ChargCapacity36 = ByteUtils.DToUInt16(data, 237).ToString(); - CMD202.ChargCapacity37 = ByteUtils.DToUInt16(data, 239).ToString(); - CMD202.ChargCapacity38 = ByteUtils.DToUInt16(data, 241).ToString(); - CMD202.ChargCapacity39 = ByteUtils.DToUInt16(data, 243).ToString(); - CMD202.ChargCapacity40 = ByteUtils.DToUInt16(data, 245).ToString(); - CMD202.ChargCapacity41 = ByteUtils.DToUInt16(data, 247).ToString(); - CMD202.ChargCapacity42 = ByteUtils.DToUInt16(data, 249).ToString(); - CMD202.ChargCapacity43 = ByteUtils.DToUInt16(data, 251).ToString(); - CMD202.ChargCapacity44 = ByteUtils.DToUInt16(data, 253).ToString(); - CMD202.ChargCapacity45 = ByteUtils.DToUInt16(data, 255).ToString(); - CMD202.ChargCapacity46 = ByteUtils.DToUInt16(data, 257).ToString(); - CMD202.ChargCapacity47 = ByteUtils.DToUInt16(data, 259).ToString(); - CMD202.ChargCapacity48 = ByteUtils.DToUInt16(data, 261).ToString(); - - CMD202.StartMode = data[263]; - CMD202.ChargSerialNum = Encoding.ASCII.GetString(data, 264, 32); - CMD202.ChargServiceCost = ByteUtils.DToUInt32(data, 296); - CMD202.KilElectricity = data[300]; - CMD202.ParallelMark = data[301]; - CMD202.ChargeOrDisMark = data[302]; - CMD202.MeterEncData = Encoding.ASCII.GetString(data, 303, 34); - CMD202.MeterNum = Encoding.ASCII.GetString(data, 337, 6); - CMD202.MeterProVersion = ByteUtils.DToUInt16(data, 343); - CMD202.EncMode = data[345]; - } - else if (func == 222) - { - CMD202.ChargCapacityNow = (ByteUtils.DToUInt32(data, 104) * 0.001).ToString("F3"); - CMD202.SAmmeterValue = (ByteUtils.DToUInt32(data, 108) * 0.001).ToString("F3"); - CMD202.EAmmeterValue = (ByteUtils.DToUInt32(data, 112) * 0.001).ToString("F3"); - - - CMD202.ChargCapacity01 = (ByteUtils.DToUInt32(data, 167) * 0.001).ToString("F3"); - CMD202.ChargCapacity02 = (ByteUtils.DToUInt32(data, 171) * 0.001).ToString("F3"); - CMD202.ChargCapacity03 = (ByteUtils.DToUInt32(data, 175) * 0.001).ToString("F3"); - CMD202.ChargCapacity04 = (ByteUtils.DToUInt32(data, 179) * 0.001).ToString("F3"); - CMD202.ChargCapacity05 = (ByteUtils.DToUInt32(data, 183) * 0.001).ToString("F3"); - CMD202.ChargCapacity06 = (ByteUtils.DToUInt32(data, 187) * 0.001).ToString("F3"); - CMD202.ChargCapacity07 = (ByteUtils.DToUInt32(data, 191) * 0.001).ToString("F3"); - CMD202.ChargCapacity08 = (ByteUtils.DToUInt32(data, 195) * 0.001).ToString("F3"); - CMD202.ChargCapacity09 = (ByteUtils.DToUInt32(data, 199) * 0.001).ToString("F3"); - CMD202.ChargCapacity10 = (ByteUtils.DToUInt32(data, 203) * 0.001).ToString("F3"); - CMD202.ChargCapacity11 = (ByteUtils.DToUInt32(data, 207) * 0.001).ToString("F3"); - CMD202.ChargCapacity12 = (ByteUtils.DToUInt32(data, 211) * 0.001).ToString("F3"); - CMD202.ChargCapacity13 = (ByteUtils.DToUInt32(data, 215) * 0.001).ToString("F3"); - CMD202.ChargCapacity14 = (ByteUtils.DToUInt32(data, 219) * 0.001).ToString("F3"); - CMD202.ChargCapacity15 = (ByteUtils.DToUInt32(data, 223) * 0.001).ToString("F3"); - CMD202.ChargCapacity16 = (ByteUtils.DToUInt32(data, 227) * 0.001).ToString("F3"); - CMD202.ChargCapacity17 = (ByteUtils.DToUInt32(data, 231) * 0.001).ToString("F3"); - CMD202.ChargCapacity18 = (ByteUtils.DToUInt32(data, 235) * 0.001).ToString("F3"); - CMD202.ChargCapacity19 = (ByteUtils.DToUInt32(data, 239) * 0.001).ToString("F3"); - CMD202.ChargCapacity20 = (ByteUtils.DToUInt32(data, 243) * 0.001).ToString("F3"); - CMD202.ChargCapacity21 = (ByteUtils.DToUInt32(data, 247) * 0.001).ToString("F3"); - CMD202.ChargCapacity22 = (ByteUtils.DToUInt32(data, 251) * 0.001).ToString("F3"); - CMD202.ChargCapacity23 = (ByteUtils.DToUInt32(data, 255) * 0.001).ToString("F3"); - CMD202.ChargCapacity24 = (ByteUtils.DToUInt32(data, 259) * 0.001).ToString("F3"); - CMD202.ChargCapacity25 = (ByteUtils.DToUInt32(data, 263) * 0.001).ToString("F3"); - CMD202.ChargCapacity26 = (ByteUtils.DToUInt32(data, 267) * 0.001).ToString("F3"); - CMD202.ChargCapacity27 = (ByteUtils.DToUInt32(data, 271) * 0.001).ToString("F3"); - CMD202.ChargCapacity28 = (ByteUtils.DToUInt32(data, 275) * 0.001).ToString("F3"); - CMD202.ChargCapacity29 = (ByteUtils.DToUInt32(data, 279) * 0.001).ToString("F3"); - CMD202.ChargCapacity30 = (ByteUtils.DToUInt32(data, 283) * 0.001).ToString("F3"); - CMD202.ChargCapacity31 = (ByteUtils.DToUInt32(data, 287) * 0.001).ToString("F3"); - CMD202.ChargCapacity32 = (ByteUtils.DToUInt32(data, 291) * 0.001).ToString("F3"); - CMD202.ChargCapacity33 = (ByteUtils.DToUInt32(data, 295) * 0.001).ToString("F3"); - CMD202.ChargCapacity34 = (ByteUtils.DToUInt32(data, 299) * 0.001).ToString("F3"); - CMD202.ChargCapacity35 = (ByteUtils.DToUInt32(data, 303) * 0.001).ToString("F3"); - CMD202.ChargCapacity36 = (ByteUtils.DToUInt32(data, 307) * 0.001).ToString("F3"); - CMD202.ChargCapacity37 = (ByteUtils.DToUInt32(data, 311) * 0.001).ToString("F3"); - CMD202.ChargCapacity38 = (ByteUtils.DToUInt32(data, 315) * 0.001).ToString("F3"); - CMD202.ChargCapacity39 = (ByteUtils.DToUInt32(data, 319) * 0.001).ToString("F3"); - CMD202.ChargCapacity40 = (ByteUtils.DToUInt32(data, 323) * 0.001).ToString("F3"); - CMD202.ChargCapacity41 = (ByteUtils.DToUInt32(data, 327) * 0.001).ToString("F3"); - CMD202.ChargCapacity42 = (ByteUtils.DToUInt32(data, 331) * 0.001).ToString("F3"); - CMD202.ChargCapacity43 = (ByteUtils.DToUInt32(data, 335) * 0.001).ToString("F3"); - CMD202.ChargCapacity44 = (ByteUtils.DToUInt32(data, 339) * 0.001).ToString("F3"); - CMD202.ChargCapacity45 = (ByteUtils.DToUInt32(data, 343) * 0.001).ToString("F3"); - CMD202.ChargCapacity46 = (ByteUtils.DToUInt32(data, 347) * 0.001).ToString("F3"); - CMD202.ChargCapacity47 = (ByteUtils.DToUInt32(data, 351) * 0.001).ToString("F3"); - CMD202.ChargCapacity48 = (ByteUtils.DToUInt32(data, 355) * 0.001).ToString("F3"); - - CMD202.StartMode = data[359]; - CMD202.ChargSerialNum = Encoding.ASCII.GetString(data, 360, 32); - CMD202.ChargServiceCost = ByteUtils.DToUInt32(data, 392); - CMD202.KilElectricity = data[396]; - CMD202.ParallelMark = data[397]; - CMD202.ChargeOrDisMark = data[398]; - CMD202.MeterEncData = Encoding.ASCII.GetString(data, 399, 34); - CMD202.MeterNum = Encoding.ASCII.GetString(data, 433, 6); - CMD202.MeterProVersion = ByteUtils.DToUInt16(data, 439); - CMD202.EncMode = data[441]; - } - - CMD202.ChargeAmount = ByteUtils.DToUInt32(data, 116); - CMD202.IndexNum = BitConverter.ToInt32(data, 120); - CMD202.CardBalance = ByteUtils.DToUInt32(data, 124); - CMD202.ChargRecord = ByteUtils.DToUInt32(data, 128); - CMD202.SumChargRecord = ByteUtils.DToUInt32(data, 132); - CMD202.Reserved3 = data[136]; - CMD202.ChargStrategy = data[137]; - switch (data[137]) - { - case 1: - CMD202.ChargStrategyPara = ByteUtils.DToUInt32(data, 138).ToString(); - break; - case 2: - CMD202.ChargStrategyPara = (ByteUtils.DToUInt32(data, 138) * 0.01).ToString("F2"); - break; - case 3: - CMD202.ChargStrategyPara = (ByteUtils.DToUInt32(data, 138) * 0.01).ToString("F2"); - break; - } - - - - CMD202.CarVIN = Encoding.ASCII.GetString(data, 142, 17); - CMD202.CarID = Encoding.ASCII.GetString(data, 159, 8); - - - } - return CMD202; - } - public CMD204 ConCMD204(byte[] data) - { - CMD204 CMD204 = null; - if (data != null && data.Length > 0) - { - CMD204 = new CMD204(); - CMD204.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD204.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD204.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD204.ChargID = Encoding.ASCII.GetString(data, 44, 32); - CMD204.Balance = ByteUtils.DToUInt32(data, 76); - CMD204.BlacklistSign = data[80]; - CMD204.ChargCardPassword = Encoding.ASCII.GetString(data, 81, 32); - CMD204.RandomData = Encoding.ASCII.GetString(data, 113, 48); - CMD204.M1CardID = ByteUtils.DToUInt32(data, 161); - CMD204.Auth = data[165]; - CMD204.ChargGunNum = data[166]; - } - return CMD204; - } - public CMD206 ConCMD206(byte[] data) - { - CMD206 CMD206 = null; - if (data != null && data.Length > 0) - { - CMD206 = new CMD206(); - CMD206.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD206.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD206.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD206.ChargID = Encoding.ASCII.GetString(data, 44, 32); - CMD206.ChargPassword = Encoding.ASCII.GetString(data, 76, 32); - CMD206.RandomData = Encoding.ASCII.GetString(data, 108, 48); - } - return CMD206; - } - public CMD208 ConCMD208(byte[] data) - { - CMD208 CMD208 = null; - if (data != null && data.Length > 0) - { - CMD208 = new CMD208(); - CMD208.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD208.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD208.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD208.ChargGunNum = data[44]; - CMD208.VINNum = Encoding.ASCII.GetString(data, 45, 17); - CMD208.ChargStrategy = data[62]; - CMD208.ChargStrategyPara = ByteUtils.DToUInt32(data, 63); - } - return CMD208; - } - public CMD210 ConCMD210(byte[] data) - { - CMD210 CMD210 = null; - if (data != null && data.Length > 0) - { - CMD210 = new CMD210(); - CMD210.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD210.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD210.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD210.ChargGunNum = data[44]; - CMD210.StartResult = ByteUtils.DToUInt32(data, 45); - } - return CMD210; - } - public CMD222 ConCMD222(byte[] data) - { - CMD222 CMD222 = null; - if (data != null && data.Length > 0) - { - CMD222 = new CMD222(); - CMD222.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD222.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD222.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD222.PosType = data[44]; - CMD222.ChargGun = data[45]; - CMD222.ChargID = Encoding.ASCII.GetString(data, 46, 32); - CMD222.StartTime = Encoding.ASCII.GetString(data, 78, 8); - CMD222.EndTime = Encoding.ASCII.GetString(data, 86, 8); - CMD222.TimeSpan = ByteUtils.DToUInt32(data, 94); - CMD222.SOCStart = data[98]; - CMD222.SOCEnd = data[99]; - CMD222.EndReason = ByteUtils.DToUInt32(data, 100); - CMD222.ChargCapacityNow = ByteUtils.DToUInt32(data, 104); - CMD222.SAmmeterValue = ByteUtils.DToUInt32(data, 108); - CMD222.EAmmeterValue = ByteUtils.DToUInt32(data, 112); - CMD222.ChargeAmount = ByteUtils.DToUInt32(data, 116); - CMD222.IndexNum = ByteUtils.DToUInt32(data, 120); - CMD222.CardBalance = ByteUtils.DToUInt32(data, 124); - CMD222.ChargRecord = ByteUtils.DToUInt32(data, 128); - CMD222.SumChargRecord = ByteUtils.DToUInt32(data, 132); - CMD222.Reserved3 = data[136]; - CMD222.ChargStrategy = data[137]; - CMD222.ChargStrategyPara = ByteUtils.DToUInt32(data, 138); - CMD222.CarVIN = Encoding.ASCII.GetString(data, 142, 17); - CMD222.CarID = Encoding.ASCII.GetString(data, 159, 8); - CMD222.ChargCapacity01 = (int)ByteUtils.DToUInt32(data, 167); - CMD222.ChargCapacity02 = (int)ByteUtils.DToUInt32(data, 171); - CMD222.ChargCapacity03 = (int)ByteUtils.DToUInt32(data, 175); - CMD222.ChargCapacity04 = (int)ByteUtils.DToUInt32(data, 179); - CMD222.ChargCapacity05 = (int)ByteUtils.DToUInt32(data, 183); - CMD222.ChargCapacity06 = (int)ByteUtils.DToUInt32(data, 187); - CMD222.ChargCapacity07 = (int)ByteUtils.DToUInt32(data, 191); - CMD222.ChargCapacity08 = (int)ByteUtils.DToUInt32(data, 195); - CMD222.ChargCapacity09 = (int)ByteUtils.DToUInt32(data, 199); - CMD222.ChargCapacity10 = (int)ByteUtils.DToUInt32(data, 203); - CMD222.ChargCapacity11 = (int)ByteUtils.DToUInt32(data, 207); - CMD222.ChargCapacity12 = (int)ByteUtils.DToUInt32(data, 211); - CMD222.ChargCapacity13 = (int)ByteUtils.DToUInt32(data, 215); - CMD222.ChargCapacity14 = (int)ByteUtils.DToUInt32(data, 219); - CMD222.ChargCapacity15 = (int)ByteUtils.DToUInt32(data, 223); - CMD222.ChargCapacity16 = (int)ByteUtils.DToUInt32(data, 227); - CMD222.ChargCapacity17 = (int)ByteUtils.DToUInt32(data, 231); - CMD222.ChargCapacity18 = (int)ByteUtils.DToUInt32(data, 235); - CMD222.ChargCapacity19 = (int)ByteUtils.DToUInt32(data, 239); - CMD222.ChargCapacity20 = (int)ByteUtils.DToUInt32(data, 243); - CMD222.ChargCapacity21 = (int)ByteUtils.DToUInt32(data, 247); - CMD222.ChargCapacity22 = (int)ByteUtils.DToUInt32(data, 251); - CMD222.ChargCapacity23 = (int)ByteUtils.DToUInt32(data, 255); - CMD222.ChargCapacity24 = (int)ByteUtils.DToUInt32(data, 259); - CMD222.ChargCapacity25 = (int)ByteUtils.DToUInt32(data, 263); - CMD222.ChargCapacity26 = (int)ByteUtils.DToUInt32(data, 267); - CMD222.ChargCapacity27 = (int)ByteUtils.DToUInt32(data, 271); - CMD222.ChargCapacity28 = (int)ByteUtils.DToUInt32(data, 275); - CMD222.ChargCapacity29 = (int)ByteUtils.DToUInt32(data, 279); - CMD222.ChargCapacity30 = (int)ByteUtils.DToUInt32(data, 283); - CMD222.ChargCapacity31 = (int)ByteUtils.DToUInt32(data, 287); - CMD222.ChargCapacity32 = (int)ByteUtils.DToUInt32(data, 291); - CMD222.ChargCapacity33 = (int)ByteUtils.DToUInt32(data, 295); - CMD222.ChargCapacity34 = (int)ByteUtils.DToUInt32(data, 299); - CMD222.ChargCapacity35 = (int)ByteUtils.DToUInt32(data, 303); - CMD222.ChargCapacity36 = (int)ByteUtils.DToUInt32(data, 307); - CMD222.ChargCapacity37 = (int)ByteUtils.DToUInt32(data, 311); - CMD222.ChargCapacity38 = (int)ByteUtils.DToUInt32(data, 315); - CMD222.ChargCapacity39 = (int)ByteUtils.DToUInt32(data, 319); - CMD222.ChargCapacity40 = (int)ByteUtils.DToUInt32(data, 323); - CMD222.ChargCapacity41 = (int)ByteUtils.DToUInt32(data, 327); - CMD222.ChargCapacity42 = (int)ByteUtils.DToUInt32(data, 331); - CMD222.ChargCapacity43 = (int)ByteUtils.DToUInt32(data, 335); - CMD222.ChargCapacity44 = (int)ByteUtils.DToUInt32(data, 339); - CMD222.ChargCapacity45 = (int)ByteUtils.DToUInt32(data, 343); - CMD222.ChargCapacity46 = (int)ByteUtils.DToUInt32(data, 347); - CMD222.ChargCapacity47 = (int)ByteUtils.DToUInt32(data, 351); - CMD222.ChargCapacity48 = (int)ByteUtils.DToUInt32(data, 355); - CMD222.StartMode = data[359]; - CMD222.ChargSerialNum = Encoding.ASCII.GetString(data, 360, 32); - CMD222.ChargServiceCost = ByteUtils.DToUInt32(data, 392); - CMD222.KilElectricity = data[394]; - CMD222.ParallelMark = data[395]; - CMD222.ChargeOrDisMark = data[396]; - CMD222.MeterEncData = data[397]; - CMD222.MeterNum = Encoding.ASCII.GetString(data, 398, 6); - CMD222.MeterProVersion = ByteUtils.DToUInt16(data, 404); - CMD222.EncMode = data[408]; - } - return CMD222; - } - public CMD302 ConCMD302(byte[] data) - { - CMD302 CMD302 = null; - if (data != null && data.Length > 0) - { - CMD302 = new CMD302(); - CMD302.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD302.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD302.MessageOrderNum = ByteUtils.DToUInt16(data, 12); - CMD302.ChargGunNum = ByteUtils.DToUInt16(data, 14); - CMD302.ASCIINum = Encoding.ASCII.GetString(data, 16, 32); - CMD302.WorkState = data[48]; - CMD302.connectState = data[49]; - CMD302.BRMBMSVersionNum = data[50]; - CMD302.BRMBatteryType = data[51]; - CMD302.BRMRatedCapacity = ByteUtils.DToUInt32(data, 52); - CMD302.BRMRatedVoltage = ByteUtils.DToUInt32(data, 56); - CMD302.BRMBatteryManu = ByteUtils.DToUInt32(data, 60); - CMD302.BRMBatteryPackID = ByteUtils.DToUInt32(data, 64); - CMD302.BRMDateYear = ByteUtils.DToUInt16(data, 68); - CMD302.BRMDateMonth = data[70]; - CMD302.BRMDateDay = data[71]; - CMD302.BRMChargeCount = ByteUtils.DToUInt32(data, 72); - CMD302.BRMTitleMark = data[76]; - CMD302.Reserved3 = data[77]; - CMD302.BRMVINID = Encoding.ASCII.GetString(data, 78, 17); - CMD302.BRMBMSSoftVerNum = ByteUtils.DToUInt16(data, 95); - CMD302.MaxChargVoltage = ByteUtils.DToUInt32(data, 103); - CMD302.MaxChargCurrent = ByteUtils.DToUInt32(data, 107); - CMD302.TotalEnergy = ByteUtils.DToUInt32(data, 111); - CMD302.MaxTotalVoltage = ByteUtils.DToUInt32(data, 115); - CMD302.MaxTemp = data[119]; - CMD302.ChargeState = ByteUtils.DToUInt16(data, 120); - CMD302.CellVoltage = ByteUtils.DToUInt32(data, 122); - CMD302.ChargePrepared = data[126]; - CMD302.BCLVoltage = ByteUtils.DToUInt32(data, 127); - CMD302.BCLCurrent = ByteUtils.DToUInt32(data, 131); - CMD302.BCLChargMode = data[135]; - CMD302.BCSVoltageValue = ByteUtils.DToUInt32(data, 136); - CMD302.BCSCurrentValue = ByteUtils.DToUInt32(data, 140); - CMD302.BCSVoltageMAX = ByteUtils.DToUInt32(data, 144); - CMD302.BCSBatteryNumMAX = data[145]; - CMD302.BCSChargState = ByteUtils.DToUInt16(data, 146); - CMD302.ReChargeTime = ByteUtils.DToUInt32(data, 148); - CMD302.BSMNum = data[152]; - CMD302.BSMMaxTemp = data[153]; - CMD302.MaxTempPointNum = data[154]; - CMD302.MinBatteryTemp = data[155]; - CMD302.MinTempPointNum = data[156]; - CMD302.voltageHighLow = data[157]; - CMD302.ChargStateHighLow = data[158]; - CMD302.BmsOvercurrent = data[159]; - CMD302.TempHigh = data[160]; - CMD302.InsulatState = data[161]; - CMD302.ConnectState = data[162]; - CMD302.AllowCharge = data[163]; - CMD302.SOCTargetValue = data[164]; - CMD302.SumVoltageSetValue = data[165]; - CMD302.VoltageSetValue = data[166]; - CMD302.ChargeEnd = data[167]; - CMD302.InsulatFault = data[168]; - CMD302.OvertempFault = data[169]; - CMD302.Overtemp = data[170]; - CMD302.ConnectorFault = data[171]; - CMD302.ChargOvertempFault = data[172]; - CMD302.HVoltageFault = data[173]; - CMD302.VoltageSenseFault = data[174]; - CMD302.OtherFault = data[175]; - CMD302.Overcurrent = data[176]; - CMD302.VoltageAnomaly = data[177]; - CMD302.VoltageAnomaly = data[178]; - CMD302.EndChargState = data[179]; - CMD302.MinVoltage = data[180]; - CMD302.MaxVoltage = data[181]; - CMD302.MinChargTemp = data[182]; - CMD302.MaxChargTemp = data[183]; - CMD302.ReceiveTimeout1 = data[184]; - CMD302.ReceiveTimeout2 = data[185]; - CMD302.ReceiveTimeout3 = data[186]; - CMD302.ReceiveTimeout4 = data[187]; - CMD302.ReceiveTimeout5 = data[188]; - CMD302.ReceiveTimeout6 = data[189]; - CMD302.ReceiveTimeout7 = data[190]; - CMD302.Other = data[191]; - } - return CMD302; - } - public CMD304 ConCMD304(byte[] data) - { - CMD304 CMD304 = null; - if (data != null && data.Length > 0) - { - CMD304 = new CMD304(); - CMD304.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD304.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD304.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD304.WorkState = data[44]; - CMD304.connectState = data[45]; - CMD304.BRMMessage = Encoding.ASCII.GetString(data, 46, 64); - CMD304.VBIMessage = Encoding.ASCII.GetString(data, 110, 64); - CMD304.ChargParameter = Encoding.ASCII.GetString(data, 174, 16); - CMD304.ReadyState = ByteUtils.DToUInt16(data, 190); - CMD304.ChargDemand = ByteUtils.DToUInt16(data, 198); - CMD304.TotalState = Encoding.ASCII.GetString(data, 206, 16); - CMD304.StateInfo = ByteUtils.DToUInt32(data, 222); - CMD304.StopCharg = ByteUtils.DToUInt32(data, 226); - CMD304.StatisticData = ByteUtils.DToUInt32(data, 230); - CMD304.BEMMessage = ByteUtils.DToUInt32(data, 234); - } - return CMD304; - } - public CMD402 ConCMD402(uint func, byte[] data) - { - CMD402 CMD402 = null; - if (data != null && data.Length > 0) - { - CMD402 = new CMD402(); - CMD402.Reserved1 = ByteUtils.DToUInt16(data, 8); - CMD402.Reserved2 = ByteUtils.DToUInt16(data, 10); - CMD402.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD402.PosType = data[44]; - CMD402.ChargGun = data[45]; - CMD402.ChargCardID = Encoding.ASCII.GetString(data, 46, 32); - CMD402.ChargStartTime = Encoding.ASCII.GetString(data, 78, 8); - CMD402.ChargEndTime = Encoding.ASCII.GetString(data, 86, 8); - CMD402.ChargTimeLength = ByteUtils.DToUInt32(data, 94); - CMD402.SOCStart = data[98]; - CMD402.SOCEnd = data[99]; - CMD402.ChargEndReason = Encoding.ASCII.GetString(data, 100, 4); - if (func == 402) - { - CMD402.ChargCapacity = (ByteUtils.ToUInt32(data, 104) * 0.01).ToString("F2"); - - - CMD402.ChargCapacity01 = ((ByteUtils.DToUInt16(data, 167)) * 0.01).ToString("F2"); - CMD402.ChargCapacity02 = ((ByteUtils.DToUInt16(data, 169)) * 0.01).ToString("F2"); - CMD402.ChargCapacity03 = ((ByteUtils.DToUInt16(data, 171)) * 0.01).ToString("F2"); - CMD402.ChargCapacity04 = ((ByteUtils.DToUInt16(data, 173)) * 0.01).ToString("F2"); - CMD402.ChargCapacity05 = ((ByteUtils.DToUInt16(data, 175)) * 0.01).ToString("F2"); - CMD402.ChargCapacity06 = ((ByteUtils.DToUInt16(data, 177)) * 0.01).ToString("F2"); - CMD402.ChargCapacity07 = ((ByteUtils.DToUInt16(data, 179)) * 0.01).ToString("F2"); - CMD402.ChargCapacity08 = ((ByteUtils.DToUInt16(data, 181)) * 0.01).ToString("F2"); - CMD402.ChargCapacity09 = ((ByteUtils.DToUInt16(data, 183)) * 0.01).ToString("F2"); - CMD402.ChargCapacity10 = ((ByteUtils.DToUInt16(data, 185)) * 0.01).ToString("F2"); - CMD402.ChargCapacity11 = ((ByteUtils.DToUInt16(data, 187)) * 0.01).ToString("F2"); - CMD402.ChargCapacity12 = ((ByteUtils.DToUInt16(data, 189)) * 0.01).ToString("F2"); - CMD402.ChargCapacity13 = ((ByteUtils.DToUInt16(data, 191)) * 0.01).ToString("F2"); - CMD402.ChargCapacity14 = ((ByteUtils.DToUInt16(data, 193)) * 0.01).ToString("F2"); - CMD402.ChargCapacity15 = ((ByteUtils.DToUInt16(data, 195)) * 0.01).ToString("F2"); - CMD402.ChargCapacity16 = ((ByteUtils.DToUInt16(data, 197)) * 0.01).ToString("F2"); - CMD402.ChargCapacity17 = ((ByteUtils.DToUInt16(data, 199)) * 0.01).ToString("F2"); - CMD402.ChargCapacity18 = ((ByteUtils.DToUInt16(data, 201)) * 0.01).ToString("F2"); - CMD402.ChargCapacity19 = ((ByteUtils.DToUInt16(data, 203)) * 0.01).ToString("F2"); - CMD402.ChargCapacity20 = ((ByteUtils.DToUInt16(data, 205)) * 0.01).ToString("F2"); - CMD402.ChargCapacity21 = ((ByteUtils.DToUInt16(data, 207)) * 0.01).ToString("F2"); - CMD402.ChargCapacity22 = ((ByteUtils.DToUInt16(data, 209)) * 0.01).ToString("F2"); - CMD402.ChargCapacity23 = ((ByteUtils.DToUInt16(data, 211)) * 0.01).ToString("F2"); - CMD402.ChargCapacity24 = ((ByteUtils.DToUInt16(data, 213)) * 0.01).ToString("F2"); - CMD402.ChargCapacity25 = ((ByteUtils.DToUInt16(data, 215)) * 0.01).ToString("F2"); - CMD402.ChargCapacity26 = ((ByteUtils.DToUInt16(data, 217)) * 0.01).ToString("F2"); - CMD402.ChargCapacity27 = ((ByteUtils.DToUInt16(data, 219)) * 0.01).ToString("F2"); - CMD402.ChargCapacity28 = ((ByteUtils.DToUInt16(data, 221)) * 0.01).ToString("F2"); - CMD402.ChargCapacity29 = ((ByteUtils.DToUInt16(data, 223)) * 0.01).ToString("F2"); - CMD402.ChargCapacity30 = ((ByteUtils.DToUInt16(data, 225)) * 0.01).ToString("F2"); - CMD402.ChargCapacity31 = ((ByteUtils.DToUInt16(data, 227)) * 0.01).ToString("F2"); - CMD402.ChargCapacity32 = ((ByteUtils.DToUInt16(data, 229)) * 0.01).ToString("F2"); - CMD402.ChargCapacity33 = ((ByteUtils.DToUInt16(data, 231)) * 0.01).ToString("F2"); - CMD402.ChargCapacity34 = ((ByteUtils.DToUInt16(data, 233)) * 0.01).ToString("F2"); - CMD402.ChargCapacity35 = ((ByteUtils.DToUInt16(data, 235)) * 0.01).ToString("F2"); - CMD402.ChargCapacity36 = ((ByteUtils.DToUInt16(data, 237)) * 0.01).ToString("F2"); - CMD402.ChargCapacity37 = ((ByteUtils.DToUInt16(data, 239)) * 0.01).ToString("F2"); - CMD402.ChargCapacity38 = ((ByteUtils.DToUInt16(data, 241)) * 0.01).ToString("F2"); - CMD402.ChargCapacity39 = ((ByteUtils.DToUInt16(data, 243)) * 0.01).ToString("F2"); - CMD402.ChargCapacity40 = ((ByteUtils.DToUInt16(data, 245)) * 0.01).ToString("F2"); - CMD402.ChargCapacity41 = ((ByteUtils.DToUInt16(data, 247)) * 0.01).ToString("F2"); - CMD402.ChargCapacity42 = ((ByteUtils.DToUInt16(data, 249)) * 0.01).ToString("F2"); - CMD402.ChargCapacity43 = ((ByteUtils.DToUInt16(data, 251)) * 0.01).ToString("F2"); - CMD402.ChargCapacity44 = ((ByteUtils.DToUInt16(data, 253)) * 0.01).ToString("F2"); - CMD402.ChargCapacity45 = ((ByteUtils.DToUInt16(data, 255)) * 0.01).ToString("F2"); - CMD402.ChargCapacity46 = ((ByteUtils.DToUInt16(data, 257)) * 0.01).ToString("F2"); - CMD402.ChargCapacity47 = ((ByteUtils.DToUInt16(data, 259)) * 0.01).ToString("F2"); - CMD402.ChargCapacity48 = ((ByteUtils.DToUInt16(data, 261)) * 0.01).ToString("F2"); - - CMD402.StartMode = data[263]; - CMD402.SerialNum = Encoding.ASCII.GetString(data, 264, 32); - CMD402.ChargServiceCost = ByteUtils.DToUInt32(data, 296); - CMD402.KilElectricity = (data[300] * 0.001).ToString("F4"); - CMD402.ParallelMark = data[301]; - } - else if (func == 422) - { - CMD402.ChargCapacity = (ByteUtils.ToUInt32(data, 104) * 0.001).ToString("F3"); - - - CMD402.ChargCapacity01 = ((ByteUtils.DToUInt32(data, 167) * 0.001)).ToString("F3"); - CMD402.ChargCapacity02 = ((ByteUtils.DToUInt32(data, 171) * 0.001)).ToString("F3"); - CMD402.ChargCapacity03 = ((ByteUtils.DToUInt32(data, 175) * 0.001)).ToString("F3"); - CMD402.ChargCapacity04 = ((ByteUtils.DToUInt32(data, 179) * 0.001)).ToString("F3"); - CMD402.ChargCapacity05 = ((ByteUtils.DToUInt32(data, 183) * 0.001)).ToString("F3"); - CMD402.ChargCapacity06 = ((ByteUtils.DToUInt32(data, 187) * 0.001)).ToString("F3"); - CMD402.ChargCapacity07 = ((ByteUtils.DToUInt32(data, 191) * 0.001)).ToString("F3"); - CMD402.ChargCapacity08 = ((ByteUtils.DToUInt32(data, 195) * 0.001)).ToString("F3"); - CMD402.ChargCapacity09 = ((ByteUtils.DToUInt32(data, 199) * 0.001)).ToString("F3"); - CMD402.ChargCapacity10 = ((ByteUtils.DToUInt32(data, 203) * 0.001)).ToString("F3"); - CMD402.ChargCapacity11 = ((ByteUtils.DToUInt32(data, 207) * 0.001)).ToString("F3"); - CMD402.ChargCapacity12 = ((ByteUtils.DToUInt32(data, 211) * 0.001)).ToString("F3"); - CMD402.ChargCapacity13 = ((ByteUtils.DToUInt32(data, 215) * 0.001)).ToString("F3"); - CMD402.ChargCapacity14 = ((ByteUtils.DToUInt32(data, 219) * 0.001)).ToString("F3"); - CMD402.ChargCapacity15 = ((ByteUtils.DToUInt32(data, 223) * 0.001)).ToString("F3"); - CMD402.ChargCapacity16 = ((ByteUtils.DToUInt32(data, 227) * 0.001)).ToString("F3"); - CMD402.ChargCapacity17 = ((ByteUtils.DToUInt32(data, 231) * 0.001)).ToString("F3"); - CMD402.ChargCapacity18 = ((ByteUtils.DToUInt32(data, 235) * 0.001)).ToString("F3"); - CMD402.ChargCapacity19 = ((ByteUtils.DToUInt32(data, 239) * 0.001)).ToString("F3"); - CMD402.ChargCapacity20 = ((ByteUtils.DToUInt32(data, 243) * 0.001)).ToString("F3"); - CMD402.ChargCapacity21 = ((ByteUtils.DToUInt32(data, 247) * 0.001)).ToString("F3"); - CMD402.ChargCapacity22 = ((ByteUtils.DToUInt32(data, 251) * 0.001)).ToString("F3"); - CMD402.ChargCapacity23 = ((ByteUtils.DToUInt32(data, 255) * 0.001)).ToString("F3"); - CMD402.ChargCapacity24 = ((ByteUtils.DToUInt32(data, 259) * 0.001)).ToString("F3"); - CMD402.ChargCapacity25 = ((ByteUtils.DToUInt32(data, 263) * 0.001)).ToString("F3"); - CMD402.ChargCapacity26 = ((ByteUtils.DToUInt32(data, 267) * 0.001)).ToString("F3"); - CMD402.ChargCapacity27 = ((ByteUtils.DToUInt32(data, 271) * 0.001)).ToString("F3"); - CMD402.ChargCapacity28 = ((ByteUtils.DToUInt32(data, 275) * 0.001)).ToString("F3"); - CMD402.ChargCapacity29 = ((ByteUtils.DToUInt32(data, 279) * 0.001)).ToString("F3"); - CMD402.ChargCapacity30 = ((ByteUtils.DToUInt32(data, 283) * 0.001)).ToString("F3"); - CMD402.ChargCapacity31 = ((ByteUtils.DToUInt32(data, 287) * 0.001)).ToString("F3"); - CMD402.ChargCapacity32 = ((ByteUtils.DToUInt32(data, 291) * 0.001)).ToString("F3"); - CMD402.ChargCapacity33 = ((ByteUtils.DToUInt32(data, 295) * 0.001)).ToString("F3"); - CMD402.ChargCapacity34 = ((ByteUtils.DToUInt32(data, 299) * 0.001)).ToString("F3"); - CMD402.ChargCapacity35 = ((ByteUtils.DToUInt32(data, 303) * 0.001)).ToString("F3"); - CMD402.ChargCapacity36 = ((ByteUtils.DToUInt32(data, 307) * 0.001)).ToString("F3"); - CMD402.ChargCapacity37 = ((ByteUtils.DToUInt32(data, 311) * 0.001)).ToString("F3"); - CMD402.ChargCapacity38 = ((ByteUtils.DToUInt32(data, 315) * 0.001)).ToString("F3"); - CMD402.ChargCapacity39 = ((ByteUtils.DToUInt32(data, 319) * 0.001)).ToString("F3"); - CMD402.ChargCapacity40 = ((ByteUtils.DToUInt32(data, 323) * 0.001)).ToString("F3"); - CMD402.ChargCapacity41 = ((ByteUtils.DToUInt32(data, 327) * 0.001)).ToString("F3"); - CMD402.ChargCapacity42 = ((ByteUtils.DToUInt32(data, 331) * 0.001)).ToString("F3"); - CMD402.ChargCapacity43 = ((ByteUtils.DToUInt32(data, 335) * 0.001)).ToString("F3"); - CMD402.ChargCapacity44 = ((ByteUtils.DToUInt32(data, 339) * 0.001)).ToString("F3"); - CMD402.ChargCapacity45 = ((ByteUtils.DToUInt32(data, 343) * 0.001)).ToString("F3"); - CMD402.ChargCapacity46 = ((ByteUtils.DToUInt32(data, 347) * 0.001)).ToString("F3"); - CMD402.ChargCapacity47 = ((ByteUtils.DToUInt32(data, 351) * 0.001)).ToString("F3"); - CMD402.ChargCapacity48 = ((ByteUtils.DToUInt32(data, 355) * 0.001)).ToString("F3"); - CMD402.StartMode = data[359]; - CMD402.SerialNum = Encoding.ASCII.GetString(data, 360, 32); - CMD402.ChargServiceCost = ByteUtils.DToUInt32(data, 392); - CMD402.KilElectricity = (data[396] * 0.001).ToString("F4"); - CMD402.ParallelMark = data[397]; - } - - CMD402.SAmmeterValue = ByteUtils.DToUInt32(data, 108); - CMD402.EAmmeterValue = ByteUtils.DToUInt32(data, 112); - CMD402.ChargeAmount = ByteUtils.DToUInt32(data, 116); - CMD402.IndexNum = ByteUtils.DToUInt32(data, 120); - CMD402.InitialBalance = ByteUtils.DToUInt32(data, 124); - CMD402.ChargRecordIndex = ByteUtils.DToUInt32(data, 128); - CMD402.TotalChargeRecord = ByteUtils.DToUInt32(data, 132); - CMD402.Reserved3 = data[136]; - CMD402.ChargStrategy = data[137]; - switch (data[137]) - { - case 1: - CMD402.ChargStrategyPara = (ByteUtils.ToUInt32(data, 138)).ToString(); - break; - case 2: - CMD402.ChargStrategyPara = ((float)ByteUtils.ToUInt32(data, 138) * 0.01).ToString("F2"); - break; - case 3: - CMD402.ChargStrategyPara = ((float)ByteUtils.ToUInt32(data, 138) * 0.01).ToString("F3"); - break; - } - - - CMD402.VINCar = Encoding.ASCII.GetString(data, 142, 17); - CMD402.CarID = Encoding.ASCII.GetString(data, 159, 8); - - } - return CMD402; - } - public CMD1002 ConCMD1002(byte[] data) - { - CMD1002 CMD1002 = null; - if (data != null && data.Length > 0) - { - CMD1002 = new CMD1002(); - CMD1002.ErasurePercentage = data[8]; - } - return CMD1002; - } - public CMD1004 ConCMD1004(byte[] data) - { - CMD1004 CMD1004 = null; - if (data != null && data.Length > 0) - { - CMD1004 = new CMD1004(); - CMD1004.DataLength = data[8]; - } - return CMD1004; - } - public CMD1006 ConCMD1006(byte[] data) - { - CMD1006 CMD1006 = null; - if (data != null && data.Length > 0) - { - CMD1006 = new CMD1006(); - CMD1006.ResponseFlag = data[8]; - } - return CMD1006; - } - public CMD1008 ConCMD1008(byte[] data) - { - CMD1008 CMD1008 = null; - if (data != null && data.Length > 0) - { - CMD1008 = new CMD1008(); - CMD1008.ReceiveSN = data[8]; - CMD1008.WriteFlag = data[9]; - CMD1008.Reserved1 = (short)ByteUtils.DToUInt16(data, 10); - CMD1008.Reserved2 = (int)ByteUtils.DToUInt32(data, 12); - } - return CMD1008; - } - public CMD1010 ConCMD1010(byte[] data) - { - CMD1010 CMD1010 = null; - if (data != null && data.Length > 0) - { - CMD1010 = new CMD1010(); - CMD1010.Reserved1 = ByteUtils.DToUInt16(data, 8); - } - return CMD1010; - } - public CMD1012 ConCMD1012(byte[] data) - { - CMD1012 CMD1012 = null; - if (data != null && data.Length > 0) - { - CMD1012 = new CMD1012(); - CMD1012.Reserved1 = (int)ByteUtils.DToUInt32(data, 8); - } - return CMD1012; - } - public CMD1022 ConCMD1022(byte[] data) - { - CMD1022 CMD1022 = null; - if (data != null && data.Length > 0) - { - CMD1022 = new CMD1022(); - CMD1022.EquipmentCode = (int)ByteUtils.DToUInt32(data, 8); - CMD1022.ProjectCode = (int)ByteUtils.DToUInt32(data, 12); - CMD1022.SoftwareVersion = (int)ByteUtils.DToUInt32(data, 16); - CMD1022.ReceiveFileSizeMax = (int)ByteUtils.DToUInt32(data, 20); - CMD1022.DeviceDescripte = Encoding.ASCII.GetString(data, 24, 32); - CMD1022.CommandFlag = (int)ByteUtils.DToUInt32(data, 56); - CMD1022.Offset = (int)ByteUtils.DToUInt32(data, 60); - CMD1022.ContinuatSN = data[64]; - CMD1022.DataLength = (int)ByteUtils.DToUInt32(data, 65); - } - return CMD1022; - } - public CMD1102 ConCMD1102(byte[] data) - { - CMD1102 CMD1102 = null; - if (data != null && data.Length > 0) - { - CMD1102 = new CMD1102(); - CMD1102.StartHour1 = data[8]; - CMD1102.STartMin1 = data[9]; - CMD1102.EndHour1 = data[10]; - CMD1102.EndMin1 = data[11]; - CMD1102.Rate1 = ByteUtils.DToUInt32(data, 12); - - CMD1102.StartHour2 = data[16]; - CMD1102.STartMin2 = data[17]; - CMD1102.EndHour2 = data[18]; - CMD1102.EndMin2 = data[19]; - CMD1102.Rate2 = ByteUtils.DToUInt32(data, 20); - - CMD1102.StartHour3 = data[24]; - CMD1102.STartMin3 = data[25]; - CMD1102.EndHour3 = data[26]; - CMD1102.EndMin3 = data[27]; - CMD1102.Rate3 = ByteUtils.DToUInt32(data, 28); - - CMD1102.StartHour4 = data[32]; - CMD1102.STartMin4 = data[33]; - CMD1102.EndHour4 = data[34]; - CMD1102.EndMin4 = data[35]; - CMD1102.Rate4 = ByteUtils.DToUInt32(data, 36); - - CMD1102.StartHour5 = data[40]; - CMD1102.STartMin5 = data[41]; - CMD1102.EndHour5 = data[42]; - CMD1102.EndMin5 = data[43]; - CMD1102.Rate5 = ByteUtils.DToUInt32(data, 44); - - CMD1102.StartHour6 = data[48]; - CMD1102.STartMin6 = data[49]; - CMD1102.EndHour6 = data[50]; - CMD1102.EndMin6 = data[51]; - CMD1102.Rate6 = ByteUtils.DToUInt32(data, 52); - - CMD1102.StartHour7 = data[56]; - CMD1102.STartMin7 = data[57]; - CMD1102.EndHour7 = data[58]; - CMD1102.EndMin7 = data[59]; - CMD1102.Rate7 = ByteUtils.DToUInt32(data, 60); - - CMD1102.StartHour8 = data[64]; - CMD1102.STartMin8 = data[65]; - CMD1102.EndHour8 = data[66]; - CMD1102.EndMin8 = data[67]; - CMD1102.Rate8 = ByteUtils.DToUInt32(data, 68); - - CMD1102.StartHour9 = data[72]; - CMD1102.STartMin9 = data[73]; - CMD1102.EndHour9 = data[74]; - CMD1102.EndMin9 = data[75]; - CMD1102.Rate9 = ByteUtils.DToUInt32(data, 76); - - CMD1102.StartHour10 = data[80]; - CMD1102.STartMin10 = data[81]; - CMD1102.EndHour10 = data[82]; - CMD1102.EndMin10 = data[83]; - CMD1102.Rate10 = ByteUtils.DToUInt32(data, 84); - - CMD1102.StartHour11 = data[88]; - CMD1102.STartMin11 = data[89]; - CMD1102.EndHour11 = data[90]; - CMD1102.EndMin11 = data[91]; - CMD1102.Rate11 = ByteUtils.DToUInt32(data, 92); - - CMD1102.StartHour12 = data[96]; - CMD1102.STartMin12 = data[97]; - CMD1102.EndHour12 = data[98]; - CMD1102.EndMin12 = data[99]; - CMD1102.Rate12 = ByteUtils.DToUInt32(data, 100); - } - return CMD1102; - } - public CMD1104 ConCMD1104(byte[] data) - { - CMD1104 CMD1104 = null; - if (data != null && data.Length > 0) - { - CMD1104 = new CMD1104(); - CMD1104.ConfirmResult = data[8]; - } - return CMD1104; - } - public CMD1106 ConCMD1106(byte[] data) - { - CMD1106 CMD1106 = null; - if (data != null && data.Length > 0) - { - CMD1106 = new CMD1106(); - CMD1106.ConfirmResult = data[8]; - } - return CMD1106; - } - public CMD1108 ConCMD1108(byte[] data) - { - CMD1108 CMD1108 = null; - if (data != null && data.Length > 0) - { - CMD1108 = new CMD1108(); - CMD1108.StartHour1 = data[8]; - CMD1108.STartMin1 = data[9]; - CMD1108.EndHour1 = data[10]; - CMD1108.EndMin1 = data[11]; - CMD1108.Rate1 = ByteUtils.DToUInt32(data, 12); - - CMD1108.StartHour2 = data[16]; - CMD1108.STartMin2 = data[17]; - CMD1108.EndHour2 = data[18]; - CMD1108.EndMin2 = data[19]; - CMD1108.Rate2 = ByteUtils.DToUInt32(data, 20); - - CMD1108.StartHour3 = data[24]; - CMD1108.STartMin3 = data[25]; - CMD1108.EndHour3 = data[26]; - CMD1108.EndMin3 = data[27]; - CMD1108.Rate3 = ByteUtils.DToUInt32(data, 28); - - CMD1108.StartHour4 = data[32]; - CMD1108.STartMin4 = data[33]; - CMD1108.EndHour4 = data[34]; - CMD1108.EndMin4 = data[35]; - CMD1108.Rate4 = ByteUtils.DToUInt32(data, 36); - - CMD1108.StartHour5 = data[40]; - CMD1108.STartMin5 = data[41]; - CMD1108.EndHour5 = data[42]; - CMD1108.EndMin5 = data[43]; - CMD1108.Rate5 = ByteUtils.DToUInt32(data, 44); - - CMD1108.StartHour6 = data[48]; - CMD1108.STartMin6 = data[49]; - CMD1108.EndHour6 = data[50]; - CMD1108.EndMin6 = data[51]; - CMD1108.Rate6 = ByteUtils.DToUInt32(data, 52); - - CMD1108.StartHour7 = data[56]; - CMD1108.STartMin7 = data[57]; - CMD1108.EndHour7 = data[58]; - CMD1108.EndMin7 = data[59]; - CMD1108.Rate7 = ByteUtils.DToUInt32(data, 60); - - CMD1108.StartHour8 = data[64]; - CMD1108.STartMin8 = data[65]; - CMD1108.EndHour8 = data[66]; - CMD1108.EndMin8 = data[67]; - CMD1108.Rate8 = ByteUtils.DToUInt32(data, 68); - - CMD1108.StartHour9 = data[72]; - CMD1108.STartMin9 = data[73]; - CMD1108.EndHour9 = data[74]; - CMD1108.EndMin9 = data[75]; - CMD1108.Rate9 = ByteUtils.DToUInt32(data, 76); - - CMD1108.StartHour10 = data[80]; - CMD1108.STartMin10 = data[81]; - CMD1108.EndHour10 = data[82]; - CMD1108.EndMin10 = data[83]; - CMD1108.Rate10 = ByteUtils.DToUInt32(data, 84); - - CMD1108.StartHour11 = data[88]; - CMD1108.STartMin11 = data[89]; - CMD1108.EndHour11 = data[90]; - CMD1108.EndMin11 = data[91]; - CMD1108.Rate11 = ByteUtils.DToUInt32(data, 92); - - CMD1108.StartHour12 = data[96]; - CMD1108.STartMin12 = data[97]; - CMD1108.EndHour12 = data[98]; - CMD1108.EndMin12 = data[99]; - CMD1108.Rate12 = ByteUtils.DToUInt32(data, 100); - - } - return CMD1108; - } - public CMD1302 ConCMD1302(byte[] data) - { - CMD1302 CMD1302 = null; - if (data != null && data.Length > 0) - { - CMD1302 = new CMD1302(); - - CMD1302.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD1302.WhitelistType = data[44]; - CMD1302.Operate = data[45]; - CMD1302.ListVersioe = ByteUtils.DToUInt32(data, 46); - CMD1302.OperatResult = data[50]; - } - return CMD1302; - } - public CMD1402 ConCMD1402(byte[] data) - { - CMD1402 CMD1402 = null; - if (data != null && data.Length > 0) - { - CMD1402 = new CMD1402(); - - CMD1402.Result = data[12]; - } - return CMD1402; - } - public CMD1403 ConCMD1403(byte[] data) - { - CMD1403 CMD1403 = null; - if (data != null && data.Length > 0) - { - CMD1403 = new CMD1403(); - - CMD1403.ScheduleResult = data[12]; - } - return CMD1403; - } - public CMD1407 ConCMD1407(byte[] data) - { - CMD1407 CMD1407 = null; - if (data != null && data.Length > 0) - { - CMD1407 = new CMD1407(); - - CMD1407.Result = data[12]; - } - return CMD1407; - } - public CMD1501 ConCMD1501(byte[] data) - { - CMD1501 CMD1501 = null; - if (data != null && data.Length > 0) - { - CMD1501 = new CMD1501(); - - CMD1501.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); - CMD1501.UpFileName = Encoding.ASCII.GetString(data, 44, 128); - } - return CMD1501; - } - public CMD1503 ConCMD1503(byte[] data) - { - CMD1503 CMD1503 = null; - if (data != null && data.Length > 0) - { - CMD1503 = new CMD1503(); - - CMD1503.DataLength = ByteUtils.DToUInt32(data, 12); - CMD1503.MessageNum = ByteUtils.DToUInt32(data, 16); - CMD1503.LogData = Encoding.ASCII.GetString(data, 20, (data.Length - 21)); ; - } - return CMD1503; - } - public CMD1505 ConCMD1505(byte[] data) - { - CMD1505 CMD1505 = null; - if (data != null && data.Length > 0) - { - CMD1505 = new CMD1505(); - } - return CMD1505; - } - } -} diff --git a/HybirdFrameworkEntity/MsgModel/Encode.cs b/HybirdFrameworkEntity/MsgModel/Encode.cs deleted file mode 100644 index 142150b..0000000 --- a/HybirdFrameworkEntity/MsgModel/Encode.cs +++ /dev/null @@ -1,2792 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace HybirdFrameworkEntity -{ - public class Encode - { - #region 服务器向充电桩设置/查询工作参数和命令 - /// - /// (CMD=1)后台服务器下发充电桩整形工作参数 - /// - /// - /// - /// - /// - /// - public byte[] Send1(byte type, uint startAddress, byte num, byte[] setData) - { - APDUModel APDUModel; - - CMD1 CMD1 = new CMD1(); - CMD1.Type = type; - CMD1.SetAddress = startAddress; - CMD1.SelectNum = num; - CMD1.SetByteNum = (ushort)(num * 4); - CMD1.SetData = setData; - - byte[] bytes = new ChargerSendCMD().SendRCMD1(out APDUModel, CMD1); - - if (APDUModel != null) - { - string result = "1后台服务器下发充电桩整形工作参数-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - /// - /// (CMD=3) - /// - /// - /// - /// - public byte[] Send3(byte type, uint startAddress, byte[] setData) - { - APDUModel APDUModel; - - - CMD3 CMD3 = new CMD3(); - CMD3.Reserved1 = 0; - CMD3.Reserved2 = 0; - CMD3.Type = type; - CMD3.SAddress = startAddress; - CMD3.SBytes = cmd3StartAddress[startAddress]; - CMD3.SData = setData; - - byte[] bytes = new ChargerSendCMD().SendRCMD3(out APDUModel, CMD3); - - if (APDUModel != null) - { - string result = "3后台服务器下发充电桩字符型参数-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - - /// - /// 后台服务器下发充电桩控制命令 - /// - /// - /// 充电枪口 - /// 启始命令地址 - /// 命令个数 - /// 命令参数 - public byte[] Send5(byte chargeMuzzle, uint startAddress, byte num, byte[] setData) - { - - APDUModel APDUModel; - - CMD5 CMD = new CMD5(); - CMD.RechargeableMuzzle = chargeMuzzle; - CMD.CommandAddress = startAddress; - CMD.CommandNum = num; - CMD.CommandLength = (ushort)(num * 4); - CMD.CommandData = setData; - - - byte[] bytes = new ChargerSendCMD().SendRCMD5(out APDUModel, CMD); - - if (APDUModel != null) - { - string result = "5后台服务器下发充电桩控制命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - - - /// - /// 后台服务器下发充电桩开启充电控制命令 - /// - /// - /// - public byte[] Send7(CMD7 CMD) - { - APDUModel APDUModel; - - byte[] bytes = new ChargerSendCMD().SendRCMD7(out APDUModel, CMD); - if (APDUModel != null) - { - - string result = "7后台服务器下发充电桩开启充电控制命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - - - - public byte[] Send9(byte chargeMuzzle, uint executeResult, uint address, byte[] setData) - { - APDUModel APDUModel; - - CMD9 CMD = new CMD9(); - - CMD.ChargGunNum = chargeMuzzle; - CMD.FWResult = executeResult; - CMD.CommandAddress = address; - CMD.DataLength = 4; - CMD.Datas = new byte[4]; - - byte[] bytes = new ChargerSendCMD().SendRCMD9(out APDUModel, CMD); - - if (APDUModel != null) - { - string result = "9后台服务器应答桩上传命令请求(预留)-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - - #endregion - - #region 充电桩主动上传数据 - /// - /// 服务器应答心跳包信息 - /// - /// - /// 心跳应答 - public byte[] Send101(ushort heartbeatNum) - { - APDUModel APDUModel; - - CMD101 CMD = new CMD101(); - - CMD.HearResponse = heartbeatNum; - - byte[] bytes = new ChargerSendCMD().SendRCMD101(out APDUModel, CMD); - if (APDUModel != null) - { - - string result = "101服务器应答心跳包信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - /// - /// 服务器应答充电桩状态信息包 - /// - /// - /// 充电口号 - /// 是否立即上报一次104报文 0-否 、1-是 - public byte[] Send103(byte chargeNum, bool reportMessage) - { - APDUModel APDUModel; - - - CMD103 CMD = new CMD103(); - CMD.ChargNum = chargeNum; - CMD.Reported = reportMessage; - - - byte[] bytes = new ChargerSendCMD().SendRCMD103(out APDUModel, CMD); - if (APDUModel != null) - { - string result = "103服务器应答充电桩状态信息包-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - /// - /// 服务器应答充电桩签到命令 - /// - /// - /// - public byte[] Send105(CMD105 CMD) - { - APDUModel APDUModel; - - byte[] bytes = new ChargerSendCMD().SendRCMD105(out APDUModel, CMD); - if (APDUModel != null) - { - string result = "105服务器应答充电桩签到命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - /// - /// 服务器应答充电桩告警信息 - /// - /// - public byte[] Send107() - { - APDUModel APDUModel; - - CMD107 CMD = new CMD107(); - - byte[] bytes = new ChargerSendCMD().SendRCMD107(out APDUModel, CMD); - if (APDUModel != null) - { - string result = "107服务器应答充电桩告警信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - /// - /// 服务器应答充电桩告警信息 - /// - /// - public byte[] Send109() - { - APDUModel APDUModel; - - - - CMD109 CMD = new CMD109(); - - - byte[] bytes = new ChargerSendCMD().SendRCMD109(out APDUModel, CMD); - if (APDUModel != null) - { - string result = "109服务器应答充电桩启动完成命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - public byte[] Send111(byte messageType) - { - APDUModel APDUModel; - - - CMD111 CMD = new CMD111(); - - CMD.MessageType = messageType; - - - byte[] bytes = new ChargerSendCMD().SendRCMD111(out APDUModel, CMD); - if (APDUModel != null) - { - string result = "111服务器应答充电桩上报模块信息(预留)-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - /// - /// 服务器查询最近一次充电各时段信息 - /// - /// - /// 充电口号 - /// 标志 - public byte[] Send113(byte chargeNum, byte sign) - { - APDUModel APDUModel; - - CMD113 CMD = new CMD113(); - - CMD.ChargNum = chargeNum; - CMD.Sign = sign; - - - byte[] bytes = new ChargerSendCMD().SendRCMD113(out APDUModel, CMD); - if (APDUModel != null) - { - string result = "113服务器查询最近一次充电各时段信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - } - return bytes; - } - - #endregion - - #region 充电信息数据 - - /// - /// (CMD=5) - /// - /// - /// - /// - public byte[] Send201(CMD201 CMD, uint func) - { - - byte[] bytes = new ChargerSendCMD().SendRCMD201(out APDUModel APDUModel, CMD, func); - string result = "201服务器应答充电桩上报充电信息报文-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - - - public byte[] Send203(CMD203 CMD) - { - byte[] bytes = new ChargerSendCMD().SendRCMD203(out APDUModel APDUModel, CMD); - string result = "203服务器应答账户查询信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - - - public byte[] Send205(uint value03, uint value04) - { - CMD205 CMD = new CMD205(); - CMD.Reserved1 = 0; - CMD.Reserved2 = 0; - CMD.ResponseCode = value03; - if (CMD.ResponseCode == 0) - { - CMD.Balance = value04; - } - else - { - CMD.Balance = 0; - } - - byte[] bytes = new ChargerSendCMD().SendRCMD205(out APDUModel APDUModel, CMD); - string result = "205服务器应答充电密码验证报文(预留)-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - - - public byte[] Send207(CMD208 CMD208, string value06, string value07, byte value08, byte value09, uint value10, ulong value11) - { - CMD207 CMD = new CMD207(); - CMD.Reserved1 = 0; - CMD.Reserved2 = 0; - CMD.ASCIINum = CMD208.ASCIINum; - CMD.ChargGunNum = CMD208.ChargGunNum; - CMD.VINNum = CMD208.VINNum; - CMD.VINBindAccount = value06; - CMD.ChargSerialNum = value07; - CMD.VerifyResult = value08; - CMD.VerifyCause = value09; - CMD.RechBalance = value10; - CMD.StopCode = value11; - byte[] bytes = new ChargerSendCMD().SendRCMD207(out APDUModel APDUModel, CMD); - string result = "207平台回复“即插即充”请求充电结果-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - - - public byte[] Send209(CMD210 CMD210, string value05) - { - CMD209 CMD = new CMD209(); - CMD.Reserved1 = CMD210.Reserved1; - CMD.Reserved2 = CMD210.Reserved2; - CMD.ASCIINum = CMD210.ASCIINum; - CMD.ChargGunNum = CMD210.ChargGunNum; - CMD.VINNum = value05; - byte[] bytes = new ChargerSendCMD().SendRCMD209(out APDUModel APDUModel, CMD); - string result = "209平台回复“即插即充”启动充电结果-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send221(CMD221 CMD221, uint value05) - { - CMD221 CMD = new CMD221(); - CMD.Reserved1 = CMD221.Reserved1; - CMD.Reserved2 = CMD221.Reserved2; - CMD.ChargNum = CMD221.ChargNum; - CMD.ChargID = CMD221.ChargID; - CMD.IndexNum = value05; - byte[] bytes = new ChargerSendCMD().SendRCMD221(out APDUModel APDUModel, CMD); - string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - - #endregion - - #region 直流充电桩 BMS 信息数据(预留) - - public byte[] Send301() - { - CMD301 CMD = new CMD301(); - CMD.Reserved1 = 0; - CMD.Reserved2 = 0; - byte[] bytes = new ChargerSendCMD().SendRCMD301(out APDUModel APDUModel, CMD); - string result = "301服务器应答充电桩上报BMS信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - - public byte[] Send303() - { - CMD303 CMD = new CMD303(); - CMD.Reserved1 = 0; - CMD.Reserved2 = 0; - byte[] bytes = new ChargerSendCMD().SendRCMD303(out APDUModel APDUModel, CMD); - string result = "303服务器应答充电桩上报BMS信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - #endregion - - #region 历史记录 - - public byte[] Send401(string chargingSerialNum, uint startIndex) - { - CMD401 CMD = new CMD401(); - CMD.Reserved1 = 0; - CMD.Reserved2 = 0; - CMD.SelectIndex = startIndex; - CMD.ChargSerialNum = chargingSerialNum; - byte[] bytes = new ChargerSendCMD().SendRCMD401(out APDUModel APDUModel, CMD); - string result = "401/421服务器查询充电桩历史充电记录-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - #endregion - - #region 升级命令 - - public byte[] Send1001(uint instruct) - { - CMD1001 CMD = new CMD1001(); - CMD.CInstruction = instruct; - byte[] bytes = new ChargerSendCMD().SendRCMD1001(out APDUModel APDUModel, CMD); - string result = "1001服务器下发擦除指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1003(string fileName) - { - CMD1003 CMD = new CMD1003(); - CMD.Filename = fileName; - byte[] bytes = new ChargerSendCMD().SendRCMD1003(out APDUModel APDUModel, CMD); - string result = "1003服务器下发升级文件名指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1005(uint fileLength) - { - CMD1005 CMD = new CMD1005(); - CMD.FileLength = fileLength; - byte[] bytes = new ChargerSendCMD().SendRCMD1005(out APDUModel APDUModel, CMD); - string result = "1005服务器下发升级文件大小-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1007(string updata) - { - CMD1007 CMD = new CMD1007(); - CMD.UpFileData = updata; - byte[] bytes = new ChargerSendCMD().SendRCMD1007(out APDUModel APDUModel, CMD); - string result = "1007服务器下发升级文件数据-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1009(uint Reserved1) - { - CMD1009 CMD = new CMD1009(); - CMD.Reserved1 = Reserved1; - byte[] bytes = new ChargerSendCMD().SendRCMD1009(out APDUModel APDUModel, CMD); - string result = "1009服务器下发升级文件数据结束指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1011(uint Reserved1) - { - CMD1011 CMD = new CMD1011(); - CMD.Reserved1 = 0; - byte[] bytes = new ChargerSendCMD().SendRCMD1011(out APDUModel APDUModel, CMD); - string result = "1011服务器下发重启指令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1021(uint results, string description) - { - CMD1021 CMD = new CMD1021(); - CMD.ResponseResult = results; - CMD.ResponsExplain = description; - byte[] bytes = new ChargerSendCMD().SendRCMD1021(out APDUModel APDUModel, CMD); - string result = "1021服务器回复充电桩主动请求升级命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - #endregion - - #region 与计费策略相关的指令 - - - public byte[] Send1101() - { - byte[] bytes = new ChargerSendCMD().SendRCMD1101(out APDUModel APDUModel); - string result = "1101后台服务器查询24时电费计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1103(CMD1103 CMD) - { - byte[] bytes = new ChargerSendCMD().SendRCMD1103(out APDUModel APDUModel, CMD); - string result = "1103后台服务器设置24时段电费计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1105(CMD1105 CMD) - { - byte[] bytes = new ChargerSendCMD().SendRCMD1105(out APDUModel APDUModel, CMD); - string result = "1105后台服务器设置分时段计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1107() - { - byte[] bytes = new ChargerSendCMD().SendRCMD1107(out APDUModel APDUModel); - string result = "1107后台服务器查询分时电费计价策略信息-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - #endregion - - #region 白名单报文 - - - public byte[] Send1301(CMD1301 CMD) - { - byte[] bytes = new ChargerSendCMD().SendRCMD1301(out APDUModel APDUModel, CMD); - string result = "1301服务器下发白名单操作日志数据包-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - #endregion - - #region FTP 远程升级和 FTP 方式日志上传 - - public byte[] Send1401(CMD1401 CMD) - { - byte[] bytes = new ChargerSendCMD().SendRCMD1401(out APDUModel APDUModel, CMD); - string result = "1401服务器下发FTP远程升级命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1406(CMD1406 CMD) - { - byte[] bytes = new ChargerSendCMD().SendRCMD1406(out APDUModel APDUModel, CMD); - string result = "1406服务器下发获取充电桩日志信息命令-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - #endregion - - #region 协议方式日志上传 - - public byte[] Send1502(uint responseCode) - { - CMD1502 CMD = new CMD1502(); - - CMD.AnswerCode = responseCode; - byte[] bytes = new ChargerSendCMD().SendRCMD1502(out APDUModel APDUModel, CMD); - string result = "cmd1502 服务器允许上传-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1504(uint logo, uint successReservedMessageNum) - { - CMD1504 CMD = new CMD1504(); - CMD.Reserved1 = 0; - CMD.Reserved2 = 0; - CMD.Sign = logo; - CMD.ReceiveMessageNum = successReservedMessageNum; - byte[] bytes = new ChargerSendCMD().SendRCMD1504(out APDUModel APDUModel, CMD); - string result = "1504服务器应答上传日志-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - - public byte[] Send1506() - { - CMD1506 CMD = new CMD1506(); - CMD.Reserved1 = 0; - CMD.Reserved1 = 0; - byte[] bytes = new ChargerSendCMD().SendRCMD1506(out APDUModel APDUModel, CMD); - string result = "1506当前文件接收完成-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; - - //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); - return bytes; - } - #endregion - - /// - /// - /// - Dictionary cmd3StartAddress = new Dictionary() - { - {1, 32}, - {2, 8}, - {3, 8}, - {4, 8}, - {5, 6}, - {6, 16}, - {7, 256}, - {8, 16}, - {9, 16}, - {10, 256}, - {11, 128}, - {12, 12}, - {13, 64}, - {14, 8}, - {15, 256}, - {16, 256}, - {17, 256}, - {18, 256}, - {19, 256}, - { 20, 256}, - }; - - } - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1DataInfo(CMD1 CMD1) - { - byte[] results = null; - if (CMD1 != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD1.WorkingData_Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD1.WorkingData_Reserved2)); - lstContent.Add(CMD1.Type); - lstContent.AddRange(BitConverter.GetBytes(CMD1.SetAddress));//起始地址 - lstContent.Add(CMD1.SelectNum);//查询个数 - lstContent.AddRange(BitConverter.GetBytes(CMD1.SetByteNum));//参数字节数 - if (CMD1.Type == 1) - { - lstContent.AddRange(CMD1.SetData); - } - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD3DataInfo(CMD3 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.Add(CMD.Type); - lstContent.AddRange(BitConverter.GetBytes(CMD.SAddress)); - lstContent.AddRange(BitConverter.GetBytes(CMD.SBytes)); - if (CMD.Type == 1) - { - lstContent.AddRange(CMD.SData); - } - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD5DataInfo(CMD5 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.Add(CMD.RechargeableMuzzle); - lstContent.AddRange(BitConverter.GetBytes(CMD.CommandAddress)); - lstContent.Add(CMD.CommandNum); - lstContent.AddRange(BitConverter.GetBytes(CMD.CommandLength)); - lstContent.AddRange(CMD.CommandData); - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD7DataInfo(CMD7 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved)); - lstContent.Add(CMD.ChargMuzzle); - lstContent.AddRange(BitConverter.GetBytes(CMD.ChargeType)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ChargeStopPassword)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ChargStrategy)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ChargStrategyPara)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ScheduleStartupTime)); - lstContent.Add(CMD.OutTime); - lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.CardNumber, 32)); - lstContent.Add(CMD.NetOutageSign); - lstContent.AddRange(BitConverter.GetBytes(CMD.MaxElectric)); - lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.SerialNum, 32)); - lstContent.Add(CMD.BMSVoltage); - lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); - lstContent.Add(CMD.DisOrChargeMark); - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD9DataInfo(CMD9 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); - lstContent.AddRange(BitConverter.GetBytes(CMD.FWResult)); - lstContent.AddRange(BitConverter.GetBytes(CMD.CommandAddress)); - lstContent.AddRange(BitConverter.GetBytes(CMD.DataLength)); - lstContent.AddRange(CMD.Datas); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD101DataInfo(CMD101 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.HearResponse)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD103DataInfo(CMD103 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.Add(CMD.ChargNum); - lstContent.Add(Convert.ToByte(CMD.Reported)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD105DataInfo(CMD105 CMD105) - { - byte[] results = null; - if (CMD105 != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD105.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD105.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD105.NumResponse)); - lstContent.Add(CMD105.LoginVerify); - lstContent.Add(CMD105.EncryptionFlag); - if (CMD105.EncryptionFlag == 1) - { - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD105.RSAComModule)); - lstContent.AddRange(BitConverter.GetBytes(CMD105.RSAComSecret)); - } - lstContent.Add(CMD105.StSign); - lstContent.AddRange(BitConverter.GetBytes(CMD105.BCDTime)); - lstContent.Add(CMD105.MessageUpload); - if (CMD105.EncryptionFlag == 1) - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD105.AESSecretKey)); - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD107DataInfo(CMD107 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - //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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD109DataInfo(CMD109 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD111DataInfo(CMD111 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.MessageType)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD113DataInfo(CMD113 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.Add(CMD.ChargNum); - lstContent.Add(Convert.ToByte(CMD.Sign)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD201DataInfo(CMD201 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ChargNum)); - lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ChargID, 32)); - lstContent.AddRange(BitConverter.GetBytes(CMD.IndexNum)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ValidMark)); - lstContent.AddRange(BitConverter.GetBytes(CMD.InitialCost)); - lstContent.AddRange(BitConverter.GetBytes(CMD.DiscountCost)); - lstContent.AddRange(BitConverter.GetBytes(CMD.NetCost)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); - lstContent.AddRange(BitConverter.GetBytes(CMD.NetElectricCost)); - lstContent.AddRange(BitConverter.GetBytes(CMD.NetServiceCost)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD203DataInfo(CMD203 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ResCode)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); - lstContent.AddRange(BitConverter.GetBytes(CMD.SumEleRate)); - lstContent.AddRange(BitConverter.GetBytes(CMD.EleRate)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ChargPassword)); - lstContent.AddRange(BitConverter.GetBytes(CMD.VINSign)); - lstContent.AddRange(BitConverter.GetBytes(CMD.CarIDVerify)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved3)); - lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.SerialNum, 32)); - lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VIN, 17)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD205DataInfo(CMD205 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ResponseCode)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD207DataInfo(CMD207 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ASCIINum, 32)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); - lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VINNum, 17)); - lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VINBindAccount, 32)); - lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ChargSerialNum, 32)); - lstContent.AddRange(BitConverter.GetBytes(CMD.VerifyResult)); - lstContent.AddRange(BitConverter.GetBytes(CMD.VerifyCause)); - lstContent.AddRange(BitConverter.GetBytes(CMD.RechBalance)); - lstContent.AddRange(BitConverter.GetBytes(CMD.StopCode)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD209DataInfo(CMD209 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ASCIINum, 32)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); - lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VINNum, 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD221DataInfo(CMD221 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ChargNum)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ChargID)); - lstContent.AddRange(BitConverter.GetBytes(CMD.IndexNum)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ValidMark)); - lstContent.AddRange(BitConverter.GetBytes(CMD.InitialCost)); - lstContent.AddRange(BitConverter.GetBytes(CMD.DiscountCost)); - lstContent.AddRange(BitConverter.GetBytes(CMD.NetCost)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); - lstContent.AddRange(BitConverter.GetBytes(CMD.NetElectricCost)); - lstContent.AddRange(BitConverter.GetBytes(CMD.NetServiceCost)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD301DataInfo(CMD301 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD303DataInfo(CMD303 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD401DataInfo(CMD401 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.SelectIndex)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ChargSerialNum)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1001DataInfo(CMD1001 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.CInstruction)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1003DataInfo(CMD1003 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(Encoding.ASCII.GetBytes(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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1005DataInfo(CMD1005 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1007DataInfo(CMD1007 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.UpFileData)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1009DataInfo(CMD1009 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1011DataInfo(CMD1011 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1021DataInfo(CMD1021 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.AddRange(BitConverter.GetBytes(CMD.ResponseResult)); - lstContent.AddRange(Encoding.UTF8.GetBytes(CMD.ResponsExplain)); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1101DataInfo(CMD1101 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1103DataInfo(CMD1103 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.Add(CMD.StartHour1); - lstContent.Add(CMD.STartMin1); - lstContent.Add(CMD.EndHour1); - lstContent.Add(CMD.EndMin1); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate1)); - - lstContent.Add(CMD.StartHour2); - lstContent.Add(CMD.STartMin2); - lstContent.Add(CMD.EndHour2); - lstContent.Add(CMD.EndMin2); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate2)); - - lstContent.Add(CMD.StartHour3); - lstContent.Add(CMD.STartMin3); - lstContent.Add(CMD.EndHour3); - lstContent.Add(CMD.EndMin3); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate3)); - - lstContent.Add(CMD.StartHour4); - lstContent.Add(CMD.STartMin4); - lstContent.Add(CMD.EndHour4); - lstContent.Add(CMD.EndMin4); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate4)); - - lstContent.Add(CMD.StartHour5); - lstContent.Add(CMD.STartMin5); - lstContent.Add(CMD.EndHour5); - lstContent.Add(CMD.EndMin5); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate5)); - - lstContent.Add(CMD.StartHour6); - lstContent.Add(CMD.STartMin6); - lstContent.Add(CMD.EndHour6); - lstContent.Add(CMD.EndMin6); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate6)); - - lstContent.Add(CMD.StartHour7); - lstContent.Add(CMD.STartMin7); - lstContent.Add(CMD.EndHour7); - lstContent.Add(CMD.EndMin7); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate7)); - - lstContent.Add(CMD.StartHour8); - lstContent.Add(CMD.STartMin8); - lstContent.Add(CMD.EndHour8); - lstContent.Add(CMD.EndMin8); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate8)); - - lstContent.Add(CMD.StartHour9); - lstContent.Add(CMD.STartMin9); - lstContent.Add(CMD.EndHour9); - lstContent.Add(CMD.EndMin9); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate9)); - - lstContent.Add(CMD.StartHour10); - lstContent.Add(CMD.STartMin10); - lstContent.Add(CMD.EndHour10); - lstContent.Add(CMD.EndMin10); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate10)); - - lstContent.Add(CMD.StartHour11); - lstContent.Add(CMD.STartMin11); - lstContent.Add(CMD.EndHour11); - lstContent.Add(CMD.EndMin11); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate11)); - - lstContent.Add(CMD.StartHour12); - lstContent.Add(CMD.STartMin12); - lstContent.Add(CMD.EndHour12); - lstContent.Add(CMD.EndMin12); - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1105DataInfo(CMD1105 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - lstContent.Add(CMD.StartHour1); - lstContent.Add(CMD.STartMin1); - lstContent.Add(CMD.EndHour1); - lstContent.Add(CMD.EndMin1); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate1)); - - lstContent.Add(CMD.StartHour2); - lstContent.Add(CMD.STartMin2); - lstContent.Add(CMD.EndHour2); - lstContent.Add(CMD.EndMin2); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate2)); - - lstContent.Add(CMD.StartHour3); - lstContent.Add(CMD.STartMin3); - lstContent.Add(CMD.EndHour3); - lstContent.Add(CMD.EndMin3); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate3)); - lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate3)); - - lstContent.Add(CMD.StartHour4); - lstContent.Add(CMD.STartMin4); - lstContent.Add(CMD.EndHour4); - lstContent.Add(CMD.EndMin4); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate4)); - lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate4)); - - lstContent.Add(CMD.StartHour5); - lstContent.Add(CMD.STartMin5); - lstContent.Add(CMD.EndHour5); - lstContent.Add(CMD.EndMin5); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate5)); - lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate5)); - - lstContent.Add(CMD.StartHour6); - lstContent.Add(CMD.STartMin6); - lstContent.Add(CMD.EndHour6); - lstContent.Add(CMD.EndMin6); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate6)); - lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate6)); - - lstContent.Add(CMD.StartHour7); - lstContent.Add(CMD.STartMin7); - lstContent.Add(CMD.EndHour7); - lstContent.Add(CMD.EndMin7); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate7)); - lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate7)); - - lstContent.Add(CMD.StartHour8); - lstContent.Add(CMD.STartMin8); - lstContent.Add(CMD.EndHour8); - lstContent.Add(CMD.EndMin8); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate8)); - lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate8)); - - lstContent.Add(CMD.StartHour9); - lstContent.Add(CMD.STartMin9); - lstContent.Add(CMD.EndHour9); - lstContent.Add(CMD.EndMin9); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate9)); - lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate9)); - - lstContent.Add(CMD.StartHour10); - lstContent.Add(CMD.STartMin10); - lstContent.Add(CMD.EndHour10); - lstContent.Add(CMD.EndMin10); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate10)); - lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate10)); - - lstContent.Add(CMD.StartHour11); - lstContent.Add(CMD.STartMin11); - lstContent.Add(CMD.EndHour11); - lstContent.Add(CMD.EndMin11); - lstContent.AddRange(BitConverter.GetBytes(CMD.Rate11)); - lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate11)); - - lstContent.Add(CMD.StartHour12); - lstContent.Add(CMD.STartMin12); - lstContent.Add(CMD.EndHour12); - lstContent.Add(CMD.EndMin12); - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1107DataInfo(CMD1107 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 针对CMD1301 充电卡号 不足30byte补\0 - /// - /// - /// - 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; - } - - - /// - /// 获取鉴权消息体字节数组 - /// 白名单1-充电卡号 32byte\2-VIN码 17byte - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1301DataInfo(CMD1301 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ASCIINum), 32)); - lstContent.Add(CMD.WhitelistType); - lstContent.Add(CMD.Operate); - lstContent.AddRange(BitConverter.GetBytes(CMD.WhitelistVersioNum)); - //操作为查询 即=4,后面字段不需要 - if (CMD.Operate != 4) - { - lstContent.AddRange(BitConverter.GetBytes(CMD.WhitelistNum)); - if (CMD.WhitelistType == 1) - { - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID01), 32)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID02), 32)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID03), 32)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID04), 32)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID05), 32)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID06), 32)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID07), 32)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID08), 32)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID09), 32)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID10), 32)); - } - else - { - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID01), 17)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID02), 17)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID03), 17)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID04), 17)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID05), 17)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID06), 17)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID07), 17)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID08), 17)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID09), 17)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID10), 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1401DataInfo(CMD1401 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes((ushort)(Convert.ToSingle(CMD.UpFileVersioNum) * 100))); - - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ServerIP), 32)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.UserName), 16)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.Password), 16)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.DownloadPath), 64)); - - lstContent.Add(CMD.ExecutiveMode); - lstContent.Add(CMD.DeviceType); - - 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 lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1406DataInfo(CMD1406 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.Add(CMD.LogType); - - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ServerIP), 32)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.UserName), 16)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.Password), 16)); - lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.LogPath), 32)); - lstContent.Add(CMD.ExecutiveMode); - - 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; - - - model.dataDomain = GetRCMD1502DataInfo(CMD); //数据域 - model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度 - - List lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1502DataInfo(CMD1502 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.AnswerCode)); - - 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; - - model.dataDomain = GetRCMD1504DataInfo(CMD); //数据域 - model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度 - - List lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1504DataInfo(CMD1504 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Sign)); - lstContent.AddRange(BitConverter.GetBytes(CMD.ReceiveMessageNum)); - - 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; - - - model.dataDomain = GetRCMD1506DataInfo(CMD); //数据域 - model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度 - - List lstResult = new List(); - lstResult.AddRange(APCI(model).ToArray()); - result = lstResult.ToArray(); - - APDUModel = model; - return result; - } - - /// - /// 获取鉴权消息体字节数组 - /// - /// - /// 鉴权消息体字节数组 - private byte[] GetRCMD1506DataInfo(CMD1506 CMD) - { - byte[] results = null; - if (CMD != null) - { - List lstContent = new List(); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); - - results = lstContent.ToArray(); - } - return results; - } - #endregion - - List APCI(APDUModel baseApci) - { - List lstResult = null; - if (baseApci != null) - { - lstResult = new List(); - //起始域 - lstResult.Add(baseApci.OriginDomain1); - lstResult.Add(baseApci.OriginDomain2); - //长度域 - byte[] packLens = BitConverter.GetBytes(baseApci.LengthDomain); - lstResult.AddRange(packLens); - //信息域 - lstResult.Add(baseApci.infoDomain); - //序列号域 - lstResult.Add(baseApci.SerialNumberDomain); - //源地址 - byte[] packSrcs = BitConverter.GetBytes(baseApci.CMD); - lstResult.AddRange(packSrcs); - //数据域 - lstResult.AddRange(baseApci.dataDomain); - - baseApci.checksumDomain = checksumDomain(lstResult.ToArray()); - //校验和域 - lstResult.Add(baseApci.checksumDomain); - } - return lstResult; - } - /// - /// 数据包发送-计算校验和 - /// - /// - /// - public static byte checksumDomain(byte[] data) - { - int checksum = 0; - - for (int i = 6; i < data.Count(); i++)//这里没校验域所以不减一 - { - checksum += data[i]; - } - - //foreach (byte b in data) - //{ - // checksum += b; - //} - // 取校验和的低8位 - return (byte)(checksum & 0xFF); - } - } -} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Manager/CmnChargingsEqmInfo.cs b/HybirdFrameworkServices/Charger/BatCharging.Manager/CmnChargingsEqmInfo.cs new file mode 100644 index 0000000..5c80ccd --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Manager/CmnChargingsEqmInfo.cs @@ -0,0 +1,117 @@ +using DotNetty.Transport.Channels; +using System; + +namespace HybirdFrameworkServices +{ + public class CmnChargingsEqmInfo + { + #region + private static object lockObj = new object(); //߳ͬ + #endregion + + #region ֶ + /// + /// վ + /// + internal static string _station_no = ""; + /// + /// վ + /// + public static string F_StationNo + { + get + { + return _station_no; + } + set + { + lock (lockObj) + { + _station_no = value; + } + } + } + + /// + /// λгʵʱ + /// + internal static float[] _bin_powers = new float[7] { 0, 0, 0, 0, 0, 0, 0 }; + /// + /// λгʵʱ + /// + public static float[] F_BinPowers + { + get + { + return _bin_powers; + } + set + { + lock (lockObj) + { + _bin_powers = value; + } + } + } + #endregion ֶ + + #region ֶ + public static string _OUTCHR01IPADDR = "172.0.30.30"; + public static string _OUTCHR02IPADDR = "172.0.30.31"; + public static string _OUTCHR03IPADDR = "172.0.30.32"; + public static string _OUTCHR04IPADDR = "172.0.30.33"; + + public static int _OUTCHR01PORT = 4567; + public static int _OUTCHR02PORT = 4567; + public static int _OUTCHR03PORT = 4567; + public static int _OUTCHR04PORT = 4567; + + public static IChannelId _ID; + public static string _CHR0IPADDR = "0.0.0.0"; + public static int _CHR0PORT = 4567; + public static string _EQMCODE = ""; + + + public volatile static ChargerMgrTool _CHR01 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR02 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR03 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR04 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR05 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR06 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR07 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + + public volatile static ChargerMgrTool _CHR08 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR09 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR10 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR11 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR12 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR13 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR14 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + + public volatile static ChargerMgrTool _CHR15 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR16 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR17 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR18 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR19 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR20 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR21 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + + public volatile static ChargerMgrTool _CHR22 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR23 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + public volatile static ChargerMgrTool _CHR24 = new ChargerMgrTool(_ID, _CHR0IPADDR, _CHR0PORT, _EQMCODE); + + #endregion ֶ + + #region ״ֵ̬ + + public static byte _CHR01WORKVAL = 0; + public static byte _CHR02WORKVAL = 0; + public static byte _CHR03WORKVAL = 0; + public static byte _CHR04WORKVAL = 0; + public static byte _CHR05WORKVAL = 0; + public static byte _CHR06WORKVAL = 0; + public static byte _CHR07WORKVAL = 0; + public static byte[] _CHRSWORKVAL = new byte[] { 0, 0, 0, 0, 0, 0, 0 }; + #endregion ״ֵ̬ + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/APDUModel.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/APDUModel.cs new file mode 100644 index 0000000..f0b176c --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/APDUModel.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class APDUModel + { + /// + /// 起始域 + /// + public byte OriginDomain1 { get; set; } = 0xAA; + /// + /// 起始域2 + /// + public byte OriginDomain2 { get; set; } = 0xF5; + /// + /// 长度域 + /// + public UInt16 LengthDomain { get; set; } + /// + /// 信息域 + /// + /// 除了 CMD=1202 加密能用 RSA 加密方式, + /// 其他报文若是加密,全部是采用 AES方式加密。 + /// bit0-3 当前协议是V2.6值填0x02 + /// + public byte infoDomain { get; set; } + /// + /// 序列号域 + /// + public byte SerialNumberDomain { get; set; } + /// + /// 命令代CMD + /// + public UInt16 CMD { get; set; } + /// + /// 数据域 + /// + public byte[] dataDomain = new byte[0]; + /// + /// 校验和域 + /// + public byte checksumDomain { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD10.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD10.cs new file mode 100644 index 0000000..9a61392 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD10.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD10 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 充电枪号 + /// + public byte ChargGunNum { get; set; } + /// + /// 请求启始地址 + /// + public uint RequestStaIP { get; set; } + /// + /// 参数 + /// + public float Parameter { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1002.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1002.cs new file mode 100644 index 0000000..c1865b2 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1002.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1002 + { + /// + /// 擦除完成百分比 + /// 当为 100%时表示擦除完成 + /// + public byte ErasurePercentage { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1004.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1004.cs new file mode 100644 index 0000000..5f736bb --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1004.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1004 + { + /// + /// 允许服务发送的升级数据报文数据长度 + /// 1. CMD=1007 的数据长度不能超过此限制, 建议不超过 4096 byte + /// + public int DataLength { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1006.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1006.cs new file mode 100644 index 0000000..f8f1af4 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1006.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1006 + { + /// + /// 响应标志 + /// 0-正常 、1-大小异常 + /// + public int ResponseFlag { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1008.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1008.cs new file mode 100644 index 0000000..1ce8e04 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1008.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1008 + { + /// + /// 正确接收到SN + /// + public byte ReceiveSN { get; set; } + /// + /// 写入成功标志 + /// 0-写入成功 、1-写入失败 + /// + public byte WriteFlag { get; set; } + /// + /// 预留 + /// + public short Reserved1 { get; set; } + /// + /// 预留 + /// + public int Reserved2 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1010.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1010.cs new file mode 100644 index 0000000..85b194d --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1010.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1010 + { + /// + /// 预留 + /// + public int Reserved1 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1012.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1012.cs new file mode 100644 index 0000000..46a878f --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1012.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1012 + { + /// + /// 预留 + /// + public int Reserved1 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD102.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD102.cs new file mode 100644 index 0000000..b148c5d --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD102.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD102 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 心跳序号 + /// + public ushort HeartNum { get; set; } + /// + /// 各枪状态 16位 + /// HEX,每位代表一个枪,可 + /// 表示 1~128 枪的状态 + /// 0-未插入枪 + /// 1-已插枪 + /// + public byte[] GunStatus = new byte[16]; + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1022.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1022.cs new file mode 100644 index 0000000..62eabc4 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1022.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1022 + { + /// + /// 设备代号 + /// 1-V6-SEV-AC-M1-STM32F207 交流桩 + /// + public int EquipmentCode { get; set; } + /// + /// 项目代码 + /// 每个项目都一个代码,平台升级软件映射表与桩实际编码对应。 + /// 如101-101 项目协议标准后台 协议项目102-云快充后台协议项目 + /// + public int ProjectCode { get; set; } + /// + /// 当前软件版本 类型为小端整型(INT),如: + /// 0x09 0x52 00 00 表示:0x5209,则版本号为:210.01 + /// + public int SoftwareVersion { get; set; } + /// + /// 最大可接收文件大小 单位K + /// + public int ReceiveFileSizeMax { get; set; } + /// + /// 设备描述 字符串类型“如 V6交流桩” 32 + /// + public string DeviceDescripte { get; set; } + /// + /// 命令标识 + /// 0x6e657874 -表示断点续传 + /// 未定义的,都表示从重开始 + /// + public int CommandFlag { get; set; } + /// + /// 断点续传文件启始偏移位置 + /// 文件启始偏移位置 + /// + public int Offset { get; set; } + /// + /// 断点续传 SN + /// 只有断点续传下有效,在接下来的CMD = 1007 包头部的sn + /// + public byte ContinuatSN { get; set; } + /// + /// 允许服务发送的升级数据报文数据长度 + /// 断电续传 CMD=1007的数据长度不能超过此限制, 建议不超过1024byte,默认 512 + /// + public int DataLength { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD104.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD104.cs new file mode 100644 index 0000000..a44f570 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD104.cs @@ -0,0 +1,289 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD104 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 充电枪数量 + /// + public byte ChargGunNum { get; set; } + /// + /// 充电口(枪)号 + /// 编码从 1 开始,如有 2 枪,那这 + /// 个字段的值为 1、2 两个值 + /// + public byte ChargNum { get; set; } + /// + /// 充电枪类型 BIT0~BIT1: + /// 1=直流; + /// 2=交流; + /// + public byte ChargGunType { get; set; } + /// + /// 工作状态 + /// 0-空闲中 + /// 1-正准备开始充电 + /// 2-充电进行中 + /// 3-充电结束 + /// 4-启动失败 + /// 5-预约状态 + /// 6-系统故障(不能给汽车充电) + /// 7-暂停服务 + /// + public byte WorkState { get; set; } + /// + /// 当前 SOC % + /// + public byte SOCNOW { get; set; } + /// + /// 当前最高告警编码 + /// + public string MaxAlarmCode { get; set; } + /// + /// 车连接状态 + /// 0- 断开 1-半连接 2-连接 + /// 直流目前只有 0 和 2 状态 + /// 交流目前有 0、1、2 三种状态 + /// 只有状态不为 0 时,手机才能下 + /// 发开机指令 + /// + public byte ConnecteState { get; set; } + /// + /// 本次充电累计充电费用 + /// 从本次充电开始到目前的累计 + /// 充电费用(包括电费与服务费), + /// 这里是整型,要乘以 0.01 才能 + /// 得到真实的金额 + /// + public float TotalCost { get; set; } + /// + /// 内部变量 2 + /// + public uint Reserved3 { get; set; } + /// + /// 内部变量 3 + /// + public uint Reserved4 { get; set; } + /// + /// 直流充电电压 + /// + public ushort DcChargVoltage { get; set; } + /// + /// 直流充电电流 + /// + public ushort DcChargCurrent { get; set; } + /// + /// BMS 需求电压 + /// + public ushort BMSDemVoltage { get; set; } + /// + /// BMS 需求电流 + /// + public ushort BMSDemCurrent { get; set; } + /// + /// BMS 充电模式 + /// + public byte BMSchargMode { get; set; } + /// + /// 交流 A 相充电电压 + /// + public ushort AcChargVoltageA { get; set; } + /// + /// 交流 B 相充电电压 + /// + public ushort AcChargVoltageB { get; set; } + /// + /// 交流 C 相充电电压 + /// + public ushort AcChargVoltageC { get; set; } + /// + /// 交流 A 相充电电流 + /// + public ushort AcChargCurrentA { get; set; } + /// + /// 交流 B 相充电电流 + /// + public ushort AcChargCurrentB { get; set; } + /// + /// 交流 C 相充电电流 + /// + public ushort AcChargCurrentC { get; set; } + /// + /// 剩余充电时间(min + /// + public ushort RemainTime { get; set; } + /// + /// 充电时长(秒) + /// + public uint ChargTime { get; set; } + /// + /// 本次充电累计充电电量(0.01kwh) + /// + public uint TotalChargkwh { get; set; } + /// + /// 充电前电表读数 + /// + public float StartAmmeterValue { get; set; } + /// + /// 当前电表读数 + /// + public float AmmeterValue { get; set; } + /// + /// 充电启动方式 + /// 0:本地刷卡启动 + /// 1:后台启动 + /// 2:本地管理员启动 + /// 3:远程 VIN 验证启动 + /// 4:远程密码验证启动 + /// 5:本地 VIN 验证启动 + /// 6:迪文界面流程启动 + /// + public byte ChargStartMode { get; set; } + /// + /// 充电策略 + /// 0 自动充满 + /// 1 按时间充满 + /// 2 定金额 + /// 3 按电量充满 + /// + public byte ChargStrategy { get; set; } + /// + /// 充电策略参数 + /// 时间单位为 1 秒 + /// 金额单位为 0.01 元 + /// 电量时单位为 0.01kw + /// + public uint ChargStrategyPara { get; set; } + /// + /// 预约标志 + /// 0-无预约(无效) + /// 1-预约有效 + /// + public byte AppointmentSign { get; set; } + /// + /// 充电/预约卡号 + /// + public string ChargID { get; set; } + /// + /// 预约超时时间 单位分钟 + /// + public byte OutTime { get; set; } + /// + /// 预约/开始充电开始时间 + /// + public string StartTime { get; set; } + /// + /// 充电前卡余额 + /// + public uint InitialBalance { get; set; } + /// + /// 预留 + /// + public uint Reserved5 { get; set; } + /// + /// 充电功率 0.1Kw/BIT + /// + public float ChargPower { get; set; } + /// + /// 系统变量 3 + /// + public uint Reserved6 { get; set; } + /// + /// 系统变量 4 + /// + public uint Reserved7 { get; set; } + /// + /// 系统变量 5 + /// + public uint Reserved8 { get; set; } + /// + /// 出风口温度 + /// + public byte OutletTemp { get; set; } + /// + /// 环境温度 + /// + public byte Temperature { get; set; } + /// + /// 充电枪温度 + /// + public byte ChargGunTemp { get; set; } + /// + /// 车辆 VIN 码 + /// + public string VINNum { get; set; } + /// + /// 舱门状态 + /// BIT0: + /// 0:不在舱-开门; + /// 1:在舱-关门 + /// BIT1: + /// 0:充电用户不允许限充电功率 + /// 1:充电用户允许限充电功率 + /// + public byte DoorState { get; set; } + /// + /// 充电流水号 32 + /// + public string ChargSerialNum { get; set; } + /// + /// 本次充电累计充电电费 + /// + public uint TotalElectricity { get; set; } + /// + /// 本次充电累计充电服务费 + /// + public uint ServiceCharge { get; set; } + /// + /// 枪归位状态 + /// 0:归位 + /// 1:离位 + /// + public byte HomingState { get; set; } + /// + /// 地锁状态 1 + /// 0:开锁 + /// 1:闭锁 + /// + public byte GroundLockedState { get; set; } + /// + /// 千分位电量 + /// + public byte KilojoulesElec { get; set; } + /// + /// 直流桩交流电表电量 + /// + public string DcACElectricity { get; set; } + /// + /// 当前充电模式 + /// 0/1-单枪充电 + /// 2-单机柜双枪并充充电 + /// 3-双机柜双枪并充充电 + /// + public byte ChargMode { get; set; } + /// + /// 充放电标志 + /// 1-充电 + /// 0xf1-放电 + /// 非协议定义值,都表示充电 + /// + public byte ChargeOrDisSign { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD106.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD106.cs new file mode 100644 index 0000000..f963bbd --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD106.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD106 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 标志 + /// 0-不支持加密 + /// 1-支持 ASE 加密 + /// + public byte Sign { get; set; } + /// + /// 充电桩软件版本 + /// + /// 类型为小端整形(INT),如: + /// 0x09 0x52 00 00 表示:0x5209, 则版本号为:210.01 + /// + public uint ChargVersion { get; set; } + /// + /// 充电桩项目类型 + /// + public ushort ChargProType { get; set; } + /// + /// 启动次数 + /// + public uint StartNum { get; set; } + /// + /// 数据上传模式 + /// 1:应答模式 + /// 2:主动上报模式 + /// + public byte DataUploadMode { get; set; } + /// + /// 签到间隔时间 分钟 + /// + public ushort SignInterval { get; set; } + /// + /// 运行内部变量 + /// 0:正常工作模式 + /// 1:IAP 模式 + /// + public byte RunVariable { get; set; } + /// + /// 充电枪个数 + /// + public byte ChargGunNum { get; set; } + /// + /// 心跳上报周期 + /// + public byte HeartReportCycle { get; set; } + /// + /// 心跳包检测超时次数 + /// + public byte TimeoutNum { get; set; } + /// + /// 充电记录数量 + /// + public uint RecordNum { get; set; } + /// + /// 当前充电桩系统时间 + /// + public string SystemTime { get; set; } + /// + /// 预留 + /// + public string Reserved3 { get; set; } + /// + /// 预留 + /// + public string Reserved4 { get; set; } + /// + /// 预留 + /// + public string Reserved5 { get; set; } + /// + /// 桩生成随机数 + /// + public uint RandomNum { get; set; } + /// + /// 桩后台通信协议版本 (十进制 30 表示 V3.0) + /// + public ushort ProtocolVersion { get; set; } + /// + /// 白名单版本号 + /// + public uint WhiteVersionNum { get; set; } + /// + /// 设备类型 + /// 0 充电桩 + /// 1 集中器 + /// + public byte DeviceType { get; set; } + /// + /// 充电桩资产编码 32 + /// + public string AssetCoding { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD108.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD108.cs new file mode 100644 index 0000000..a429b95 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD108.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD108 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 告警位信息 32 + /// + public string AlarmBitInfo { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD110.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD110.cs new file mode 100644 index 0000000..3f0a22c --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD110.cs @@ -0,0 +1,153 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD110 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 充电枪号 + /// + public byte ChargGunNum { get; set; } + /// + /// 充电失败原因 0成功 + /// + public uint ChargeFail { get; set; } + /// + /// 发送此报文原因 + /// + public ushort SendMessage { get; set; } + /// + /// 预留 + /// + public ushort Reserved3 { get; set; } + /// + /// 预留 + /// + public uint Reserved4 { get; set; } + /// + /// BRM-BMS 通讯协议版本号 3 + /// + public string BRMBMSVersionNum { get; set; } + /// + /// BRM-电池类型 + /// 0x01-铅酸电池, + /// 0x02-镍氢电池, + /// 0x03-磷酸铁锂电池, + /// 0x04-锰酸锂电池, + /// 0x05-钴酸锂电池, + /// 0x06- 三元次料电池, + /// 0x07-聚合物锂离子电池, + /// 0x08-钛酸锂电池, + /// 0xff-其他电池 + /// + public byte BRMBatteryType { get; set; } + /// + /// BRM-整车动力蓄电池系统额定容量/Ah + /// + public uint BRMRatedCapacity { get; set; } + /// + /// BRM-整车动力蓄电池系统额定总电压/V + /// + public uint BRMRatedVoltage { get; set; } + /// + /// BRM-电池生产厂商 + /// + public uint BRMBatteryManu { get; set; } + /// + /// BRM-电池组序号 + /// + public uint BRMBatteryPackID { get; set; } + /// + /// BRM-电池组生厂日期:年 + /// 如 0x07 0xdf 表示 2015 + /// + public ushort BRMDateYear { get; set; } + /// + /// BRM-电池组生厂日期:月 + /// + public byte BRMDateMonth { get; set; } + /// + /// BRM-电池组生厂日期:日 + /// + public byte BRMDateDay { get; set; } + /// + /// BRM-电池组充电次数 + /// + public uint BRMChargeCount { get; set; } + /// + /// BRM-电池组产权标识 + /// 0X01-表示租赁 + /// 0x01 表示车自有 + /// + public byte BRMTitleMark { get; set; } + /// + /// 预留 + /// + public byte Reserved5 { get; set; } + /// + /// BRM-车辆识别码 vin 17 + /// + public string BRMVINID { get; set; } + /// + /// BRM-BMS 软件版本号 + /// + /// Byte1 表示版本流水号: + /// 0x01~0xfe; + /// byte2 表示日:0x01 表示 1日; + /// byte3:0x01 表示 1 月; + /// byte4 和 byte5 表示年:0x07 + /// 0xdf 表示 2015 年; + /// Byte6和byte7、byte8预留, + /// 填 0xffffff + /// + public string BRMBMSSoftVerNum { get; set; } + /// + /// BCP-单体动力蓄电池最高允许充电电压 + /// + public float MaxChargVoltage { get; set; } + /// + /// BCP-最高允许充电电流 + /// + public float MaxChargCurrent { get; set; } + /// + /// BCP-动力蓄电池标称总能量 + /// + public float TotalEnergy { get; set; } + /// + /// BCP-最高允许充电总电压 + /// + public float MaxTotalVoltage { get; set; } + /// + /// BCP-最高允许温度 + /// + public byte MaxTemp { get; set; } + /// + /// BCP-整车动力蓄电池荷电状态 + /// + public float ChargeState { get; set; } + /// + /// BCP-整车动力蓄电池当前电池电压 + /// + public float CellVoltage { get; set; } + /// + /// 充电流水号 32 + /// + public string ChargSerialNum { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1102.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1102.cs new file mode 100644 index 0000000..6eadb1a --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1102.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1102 + { + /// + /// 开始小时 0~24 + /// + public byte StartHour1 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin1 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour1 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin1 { get; set; } + /// + /// 费率1 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate1 { get; set; } + + public byte StartHour2 { get; set; } + public byte STartMin2 { get; set; } + public byte EndHour2 { get; set; } + public byte EndMin2 { get; set; } + public uint Rate2 { get; set; } + + public byte StartHour3 { get; set; } + public byte STartMin3 { get; set; } + public byte EndHour3 { get; set; } + public byte EndMin3 { get; set; } + public uint Rate3 { get; set; } + + public byte StartHour4 { get; set; } + public byte STartMin4 { get; set; } + public byte EndHour4 { get; set; } + public byte EndMin4 { get; set; } + public uint Rate4 { get; set; } + + public byte StartHour5 { get; set; } + public byte STartMin5 { get; set; } + public byte EndHour5 { get; set; } + public byte EndMin5 { get; set; } + public uint Rate5 { get; set; } + + public byte StartHour6 { get; set; } + public byte STartMin6 { get; set; } + public byte EndHour6 { get; set; } + public byte EndMin6 { get; set; } + public uint Rate6 { get; set; } + + public byte StartHour7 { get; set; } + public byte STartMin7 { get; set; } + public byte EndHour7 { get; set; } + public byte EndMin7 { get; set; } + public uint Rate7 { get; set; } + + public byte StartHour8 { get; set; } + public byte STartMin8 { get; set; } + public byte EndHour8 { get; set; } + public byte EndMin8 { get; set; } + public uint Rate8 { get; set; } + + public byte StartHour9 { get; set; } + public byte STartMin9 { get; set; } + public byte EndHour9 { get; set; } + public byte EndMin9 { get; set; } + public uint Rate9 { get; set; } + + public byte StartHour10 { get; set; } + public byte STartMin10 { get; set; } + public byte EndHour10 { get; set; } + public byte EndMin10 { get; set; } + public uint Rate10 { get; set; } + + public byte StartHour11 { get; set; } + public byte STartMin11 { get; set; } + public byte EndHour11 { get; set; } + public byte EndMin11 { get; set; } + public uint Rate11 { get; set; } + + public byte StartHour12 { get; set; } + public byte STartMin12 { get; set; } + public byte EndHour12 { get; set; } + public byte EndMin12 { get; set; } + public uint Rate12 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1104.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1104.cs new file mode 100644 index 0000000..540177e --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1104.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1104 + { + /// + /// 确认结果 + /// 0-成功 、1-失败 + /// + public byte ConfirmResult { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1106.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1106.cs new file mode 100644 index 0000000..4ee7b57 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1106.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1106 + { + /// + /// 确认结果 + /// 0-成功 、1-失败 + /// + public byte ConfirmResult { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1108.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1108.cs new file mode 100644 index 0000000..95a8e54 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1108.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1108 + { + /// + /// 开始小时 0~24 + /// + public byte StartHour1 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin1 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour1 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin1 { get; set; } + /// + /// 费率1 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate1 { get; set; } + + public byte StartHour2 { get; set; } + public byte STartMin2 { get; set; } + public byte EndHour2 { get; set; } + public byte EndMin2 { get; set; } + public uint Rate2 { get; set; } + + public byte StartHour3 { get; set; } + public byte STartMin3 { get; set; } + public byte EndHour3 { get; set; } + public byte EndMin3 { get; set; } + public uint Rate3 { get; set; } + + public byte StartHour4 { get; set; } + public byte STartMin4 { get; set; } + public byte EndHour4 { get; set; } + public byte EndMin4 { get; set; } + public uint Rate4 { get; set; } + + public byte StartHour5 { get; set; } + public byte STartMin5 { get; set; } + public byte EndHour5 { get; set; } + public byte EndMin5 { get; set; } + public uint Rate5 { get; set; } + + public byte StartHour6 { get; set; } + public byte STartMin6 { get; set; } + public byte EndHour6 { get; set; } + public byte EndMin6 { get; set; } + public uint Rate6 { get; set; } + + public byte StartHour7 { get; set; } + public byte STartMin7 { get; set; } + public byte EndHour7 { get; set; } + public byte EndMin7 { get; set; } + public uint Rate7 { get; set; } + + public byte StartHour8 { get; set; } + public byte STartMin8 { get; set; } + public byte EndHour8 { get; set; } + public byte EndMin8 { get; set; } + public uint Rate8 { get; set; } + + public byte StartHour9 { get; set; } + public byte STartMin9 { get; set; } + public byte EndHour9 { get; set; } + public byte EndMin9 { get; set; } + public uint Rate9 { get; set; } + + public byte StartHour10 { get; set; } + public byte STartMin10 { get; set; } + public byte EndHour10 { get; set; } + public byte EndMin10 { get; set; } + public uint Rate10 { get; set; } + + public byte StartHour11 { get; set; } + public byte STartMin11 { get; set; } + public byte EndHour11 { get; set; } + public byte EndMin11 { get; set; } + public uint Rate11 { get; set; } + + public byte StartHour12 { get; set; } + public byte STartMin12 { get; set; } + public byte EndHour12 { get; set; } + public byte EndMin12 { get; set; } + public uint Rate12 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD112.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD112.cs new file mode 100644 index 0000000..cc96963 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD112.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD112 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 上报方式 + /// 0-主动上报 + /// 1-被动查询 + /// + public byte ReportMode { get; set; } + /// + /// 模块数量 + /// + public byte ModuleNum { get; set; } + /// + /// 模块类型 + /// 0:500V 标准; + /// 1:750V 标准; + /// 2:500V恒功率模块; + /// 3:750V 恒功率模块; + /// 4:低压 250V 模块; + /// 5:第二代恒功率模块; + /// 6:低压档 100V 模块; + /// + public byte ModuleType { get; set; } + /// + /// 模块 1 AC 版本 + /// + public ushort ACModuleversion1 { get; set; } + /// + /// 模块 1 DC 版本 + /// + public ushort DCModuleversion1 { get; set; } + /// + /// 模块 1 状态 + /// 0:离线 + /// 1:在线 + /// + public byte ModuleState1 { get; set; } + /// + /// 模块 1 输出电压 + /// + public ushort ModuleOutVoltage1 { get; set; } + /// + /// 模块 1 输出电流 + /// + public ushort ModuleOutCurrent1 { get; set; } + /// + /// 模块 1 告警 + /// + public uint ModuleAlarm1 { get; set; } + /// + /// 模块 2 AC 版本 + /// + public ushort ACModuleversion2 { get; set; } + /// + /// 模块 2 DC 版本 + /// + public ushort DCModuleversion2 { get; set; } + /// + /// 模块 2 状态 + /// 0:离线 + /// 1:在线 + /// + public byte ModuleState2 { get; set; } + /// + /// 模块 2 输出电压 + /// + public ushort ModuleOutVoltage2 { get; set; } + /// + /// 模块 2 输出电流 + /// + public ushort ModuleOutCurrent2 { get; set; } + /// + /// 模块 2 告警 + /// + public uint ModuleAlarm2 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD114.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD114.cs new file mode 100644 index 0000000..799bb24 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD114.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD114 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 + /// + public string ASCIINum { get; set; } + /// + /// 充电枪号 + /// + public byte ChargGunNum { get; set; } + /// + /// 工作状态 + /// 0-空闲中 + /// 1-正准备开始充电 + /// 2-充电进行中 + /// 3-充电结束 + /// 4-启动失败 + /// 5-预约状态 + /// 6-系统故障(不能给汽车充电) + /// + public byte WorkState { get; set; } + /// + /// 开始充电开始时间 + /// + public string StartChargTime { get; set; } + /// 时段 1 充电电量 [00:00:00~00:30:00] + public ushort Charge01 { get; set; } + /// 时段 2 充电电量 [00:30:00~01:00:00] + public ushort Charge02 { get; set; } + /// 时段 3 充电电量 [01:00:00~01:30:00] + public ushort Charge03 { get; set; } + /// 时段 4 充电电量 [01:30:00~02:00:00] + public ushort Charge04 { get; set; } + /// 时段 5 充电电量 [02:00:00~02:30:00] + public ushort Charge05 { get; set; } + /// 时段 6 充电电量 [02:30:00~03:00:00] + public ushort Charge06 { get; set; } + /// 时段 7 充电电量 [03:00:00~03:30:00] + public ushort Charge07 { get; set; } + /// 时段 8 充电电量 [03:30:00~04:00:00] + public ushort Charge08 { get; set; } + /// 时段 9 充电电量 [04:00:00~04:30:00] + public ushort Charge09 { get; set; } + /// 时段 10 充电电量 [04:30:00~05:00:00] + public ushort Charge10 { get; set; } + /// 时段 11 充电电量 [05:00:00~05:30:00] + public ushort Charge11 { get; set; } + /// 时段 12 充电电量 [05:30:00~06:00:00] + public ushort Charge12 { get; set; } + /// 时段 13 充电电量 [06:00:00~06:30:00] + public ushort Charge13 { get; set; } + /// 时段 14 充电电量 [06:30:00~07:00:00] + public ushort Charge14 { get; set; } + /// 时段 15 充电电量 [07:00:00~07:30:00] + public ushort Charge15 { get; set; } + /// 时段 16 充电电量 [07:30:00~08:00:00] + public ushort Charge16 { get; set; } + /// 时段 17 充电电量 [08:00:00~08:30:00] + public ushort Charge17 { get; set; } + /// 时段 18 充电电量 [08:30:00~09:00:00] + public ushort Charge18 { get; set; } + /// 时段 19 充电电量 [09:00:00~09:30:00] + public ushort Charge19 { get; set; } + /// 时段 20 充电电量 [09:30:00~10:00:00] + public ushort Charge20 { get; set; } + /// 时段 21 充电电量 [10:00:00~10:30:00] + public ushort Charge21 { get; set; } + /// 时段 22 充电电量 [10:30:00~11:00:00] + public ushort Charge22 { get; set; } + /// 时段 23 充电电量 [11:00:00~11:30:00] + public ushort Charge23 { get; set; } + /// 时段 24 充电电量 [11:30:00~12:00:00] + public ushort Charge24 { get; set; } + /// 时段 25 充电电量 [12:00:00~12:30:00] + public ushort Charge25 { get; set; } + /// 时段 26 充电电量 [12:30:00~13:00:00] + public ushort Charge26 { get; set; } + /// 时段 27 充电电量 [13:00:00~13:30:00] + public ushort Charge27 { get; set; } + /// 时段 28 充电电量 [13:30:00~14:00:00] + public ushort Charge28 { get; set; } + /// 时段 29 充电电量 [14:00:00~14:30:00] + public ushort Charge29 { get; set; } + /// 时段 30 充电电量 [14:30:00~15:00:00] + public ushort Charge30 { get; set; } + /// 时段 31 充电电量 [15:00:00~15:30:00] + public ushort Charge31 { get; set; } + /// 时段 32 充电电量 [15:30:00~16:00:00] + public ushort Charge32 { get; set; } + /// 时段 33 充电电量 [16:00:00~16:30:00] + public ushort Charge33 { get; set; } + /// 时段 34 充电电量 [16:30:00~17:00:00] + public ushort Charge34 { get; set; } + /// 时段 35 充电电量 [17:00:00~17:30:00] + public ushort Charge35 { get; set; } + /// 时段 36 充电电量 [17:30:00~18:00:00] + public ushort Charge36 { get; set; } + /// 时段 37 充电电量 [18:00:00~18:30:00] + public ushort Charge37 { get; set; } + /// 时段 38 充电电量 [18:30:00~19:00:00] + public ushort Charge38 { get; set; } + /// 时段 39 充电电量 [19:00:00~19:30:00] + public ushort Charge39 { get; set; } + /// 时段 40 充电电量 [19:30:00~20:00:00] + public ushort Charge40 { get; set; } + /// 时段 41 充电电量 [20:00:00~20:30:00] + public ushort Charge41 { get; set; } + /// 时段 42 充电电量 [20:30:00~21:00:00] + public ushort Charge42 { get; set; } + /// 时段 43 充电电量 [21:00:00~21:30:00] + public ushort Charge43 { get; set; } + /// 时段 44 充电电量 [21:30:00~22:00:00] + public ushort Charge44 { get; set; } + /// 时段 45 充电电量 [22:00:00~22:30:00] + public ushort Charge45 { get; set; } + /// 时段 46 充电电量 [22:30:00~23:00:00] + public ushort Charge46 { get; set; } + /// 时段 47 充电电量 [23:00:00~23:30:00] + public ushort Charge47 { get; set; } + /// 时段 48 充电电量 [23:30:00~00:00:00] + public ushort Charge48 { get; set; } + + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1302.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1302.cs new file mode 100644 index 0000000..8f78ab1 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1302.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1302 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 白名单类型 + /// 1-充电卡号 + /// 2-VIN 码 + /// + public byte WhitelistType { get; set; } + /// + /// 操作 + /// 0:增加 + /// 2:清空 + /// 4:查询白名单版本号 + /// + public byte Operate { get; set; } + /// + /// 名单版本 + /// + /// 当前充电系统最新的名单版本号。为 0 时 + /// 则充电系统将清空白名单。 + /// + public uint ListVersioe { get; set; } + /// + /// 操作结果 + /// 0:更新成功;其他:更新失败 + /// + public byte OperatResult { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1402.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1402.cs new file mode 100644 index 0000000..aa5e894 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1402.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1402 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 结果 + /// 1:收到开始连接 + /// 2:版本号一致,不执行下载 + /// 3:充电中,空闲执行下载 + /// 4.:其他原因,执行失败 + /// + public byte Result { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1403.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1403.cs new file mode 100644 index 0000000..14079bd --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1403.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Net.WebRequestMethods; + +namespace HybirdFrameworkServices +{ + public class CMD1403 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 进度结果 + /// 1:ftp 地址连接失败 + /// 2:ftp 服务登录失败 + /// 3:目录无权限 + /// 4:下载失败 + /// 5:下载 50% + /// 6:下载完成,进入升级模式 + /// + public byte ScheduleResult { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1407.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1407.cs new file mode 100644 index 0000000..67f66f0 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1407.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Net.WebRequestMethods; + +namespace HybirdFrameworkServices +{ + public class CMD1407 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 结果 + /// 0:成功 + /// 1:ftp 地址连接失败 + /// 2:ftp 服务登录失败 + /// 3:目录无权限 + /// 4:其他错误 + /// + public byte Result { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1501.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1501.cs new file mode 100644 index 0000000..7634adc --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1501.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1501 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 申请上传文件名 128 + /// + public string UpFileName { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1503.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1503.cs new file mode 100644 index 0000000..34f79e5 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1503.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1503 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 本次数据长度 + /// + public uint DataLength { get; set; } + /// + /// 本次报文编号 新文件数据上传的第一包的数据从1 开始累加,服务器收到重复的编号要丢弃掉 + /// + public uint MessageNum { get; set; } + /// + /// 日志数据 + /// + public string LogData { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1505.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1505.cs new file mode 100644 index 0000000..cb9002c --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1505.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1505 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1506.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1506.cs new file mode 100644 index 0000000..fecfa51 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1506.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1506 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD2.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD2.cs new file mode 100644 index 0000000..aef928b --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD2.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD2 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32位 ASCII 编码 + /// + public string ASCIINum { get; set; } + /// + /// 类型 + /// 0-查询 + /// 1-设置 + /// + public byte Type { get; set; } + /// + /// 设置/查询参数启始地址 + /// + public uint SAddress { get; set; } + /// + /// 设置/查询个数 1 同设置命令地址 + /// + public byte SNum { get; set; } + /// + /// 设置/查询结果 + /// 0 表示成功 + /// 其它失败 + /// + public byte SResult { get; set; } + /// + /// 查询参数信息 + /// + public string SData { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD202.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD202.cs new file mode 100644 index 0000000..4b7c2ec --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD202.cs @@ -0,0 +1,387 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD202 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 + /// + public string ASCIINum { get; set; } + /// + /// 充电枪位置类型 + /// 1-直流 + /// 2-交流 + /// + public byte PosType { get; set; } + /// + /// 充电枪口 + /// + public byte ChargGun { get; set; } + /// + /// 充电卡号 32 + /// + public string ChargID { get; set; } + /// + /// 充电开始时间 + /// + public string StartTime { get; set; } + /// + /// 充电结束时间 + /// + public string EndTime { get; set; } + /// + /// 充电时间长度 + /// + public uint TimeSpan { get; set; } + /// + /// 开始 SOC + /// + public byte SOCStart { get; set; } + /// + /// 结束 SOC + /// + public byte SOCEnd { get; set; } + /// + /// 充电结束原因 + /// + public uint EndReason { get; set; } + /// + /// 本次充电电量 + /// + public string ChargCapacityNow { get; set; } + /// + /// 充电前电表读数 + /// + public string SAmmeterValue { get; set; } + /// + /// 充电后电表读数 + /// + public string EAmmeterValue { get; set; } + /// + /// 本次充电金额 + /// + public uint ChargeAmount { get; set; } + /// + /// 内部索引号 + /// + public int IndexNum { get; set; } + /// + /// 充电前卡余额 + /// + public uint CardBalance { get; set; } + /// + /// 当前充电记录索引 + /// + public uint ChargRecord { get; set; } + /// + /// 总充电记录条目 + /// + public uint SumChargRecord { get; set; } + /// + /// 预留 + /// + public byte Reserved3 { get; set; } + /// + /// 充电策略 + /// 0:充满为止 + /// 1:时间控制充电 + /// 2:金额控制充电 + /// 3:电量控制充电 + /// + public byte ChargStrategy { get; set; } + /// + /// 充电策略参数 + /// 时间单位为 1 秒 + /// 金额单位为 0.01 元 + /// 电量时单位为 0.01kw + /// + public string ChargStrategyPara { get; set; } + /// + /// 车辆 VIN 17 + /// + public string CarVIN { get; set; } + /// + /// 车牌号 + /// + public string CarID { get; set; } + /// + /// 时段 1 充电电量 + /// 命令 202 报文此字段是 2 字节, + /// 命令 222 报文此字段是 4 字节 + /// + public string ChargCapacity01 { get; set; } + /// + /// + /// + public string ChargCapacity02 { get; set; } + /// + /// + /// + public string ChargCapacity03 { get; set; } + /// + /// + /// + public string ChargCapacity04 { get; set; } + /// + /// + /// + public string ChargCapacity05 { get; set; } + /// + /// + /// + public string ChargCapacity06 { get; set; } + /// + /// + /// + public string ChargCapacity07 { get; set; } + /// + /// + /// + public string ChargCapacity08 { get; set; } + /// + /// + /// + public string ChargCapacity09 { get; set; } + /// + /// + /// + public string ChargCapacity10 { get; set; } + /// + /// + /// + public string ChargCapacity11 { get; set; } + /// + /// + /// + public string ChargCapacity12 { get; set; } + /// + /// + /// + public string ChargCapacity13 { get; set; } + /// + /// + /// + public string ChargCapacity14 { get; set; } + /// + /// + /// + public string ChargCapacity15 { get; set; } + /// + /// + /// + public string ChargCapacity16 { get; set; } + /// + /// + /// + public string ChargCapacity17 { get; set; } + /// + /// + /// + public string ChargCapacity18 { get; set; } + /// + /// + /// + public string ChargCapacity19 { get; set; } + /// + /// + /// + public string ChargCapacity20 { get; set; } + /// + /// + /// + public string ChargCapacity21 { get; set; } + /// + /// + /// + public string ChargCapacity22 { get; set; } + /// + /// + /// + public string ChargCapacity23 { get; set; } + /// + /// + /// + public string ChargCapacity24 { get; set; } + /// + /// + /// + public string ChargCapacity25 { get; set; } + /// + /// + /// + public string ChargCapacity26 { get; set; } + /// + /// + /// + public string ChargCapacity27 { get; set; } + /// + /// + /// + public string ChargCapacity28 { get; set; } + /// + /// + /// + public string ChargCapacity29 { get; set; } + /// + /// + /// + public string ChargCapacity30 { get; set; } + /// + /// + /// + public string ChargCapacity31 { get; set; } + /// + /// + /// + public string ChargCapacity32 { get; set; } + /// + /// + /// + public string ChargCapacity33 { get; set; } + /// + /// + /// + public string ChargCapacity34 { get; set; } + /// + /// + /// + public string ChargCapacity35 { get; set; } + /// + /// + /// + public string ChargCapacity36 { get; set; } + /// + /// + /// + public string ChargCapacity37 { get; set; } + /// + /// + /// + public string ChargCapacity38 { get; set; } + /// + /// + /// + public string ChargCapacity39 { get; set; } + /// + /// + /// + public string ChargCapacity40 { get; set; } + /// + /// + /// + public string ChargCapacity41 { get; set; } + /// + /// + /// + public string ChargCapacity42 { get; set; } + /// + /// + /// + public string ChargCapacity43 { get; set; } + /// + /// + /// + public string ChargCapacity44 { get; set; } + /// + /// + /// + public string ChargCapacity45 { get; set; } + /// + /// + /// + public string ChargCapacity46 { get; set; } + /// + /// + /// + public string ChargCapacity47 { get; set; } + /// + /// 时段 48 充电电量 + /// 命令 202 报文此字段是 2 字节, + /// 命令 222 报文此字段是 4 字节 + /// + public string ChargCapacity48 { get; set; } + /// + /// 启动方式 + /// 0:本地刷卡启动 + /// 1:后台启动 + /// 2:本地管理员启动 + /// 3:远程 VIN 验证启动 + /// 4:远程密码验证启动 + /// 5:本地 VIN 验证启动 + /// 6:迪文界面流程启动 + /// + public byte StartMode { get; set; } + /// + /// 充电流水号 32 + /// + public string ChargSerialNum { get; set; } + /// + /// 充电服务费 + /// + public uint ChargServiceCost { get; set; } + /// + /// 千分位电量 + /// + public byte KilElectricity { get; set; } + /// + /// 并充标志 + /// 0/1-单枪充电 + /// 2-单机柜双枪并充充电 + /// 3-双机柜双枪并充充电 + /// + public byte ParallelMark { get; set; } + /// + /// 充放电标志 + /// + /// 2-充电 + /// 0xf1-放电 + /// 非协议定义值,都表示充电 + /// + public byte ChargeOrDisMark { get; set; } + /// + /// 电表加密数据 + /// + /// 瑞银电表解密后数据内容为: + /// 17 字节枪口识别号(BCD) + /// 4 字节计量开始时间(秒时戳, HEX) + /// 4 字节计量结束时间(秒时戳, HEX) + /// 4 字节正向充电电量(3 位小数, HEX) + /// 4 字节电表安装时间(秒时戳, HEX) + /// 1 字节端钮历史状态(0 正常,1 发生过端钮盖打开时间) + /// + public string MeterEncData { get; set; } + /// + /// 电表表号 6 + /// + public string MeterNum { get; set; } + /// + /// 电表协议版本 + /// + public ushort MeterProVersion { get; set; } + /// + /// 加密方式 + /// 当前加密方式(工厂模式下配置,抄读无任何限制) + /// 00:软件 AES128 加密 + /// 01:RJMU 国密 SM1(暂不支持) + /// 02:RJMU 国密 SM4(暂不支持) + /// 03:国网 ESAM 加密 + /// 04:ECC256 签名算法 + /// 05:其他 + /// + public byte EncMode { get; set; } + + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD204.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD204.cs new file mode 100644 index 0000000..c09003d --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD204.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD204 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 + /// + public string ASCIINum { get; set; } + /// + /// 充电卡号 32 + /// + /// ASCII 码,不足补’\0’ + /// 默认卡号是固定 16 位,不足会在前面补‘0’,如卡号 + /// “12233445566”默认是上传“0000112233445566” + /// + public string ChargID { get; set; } + /// + /// 充电卡余额 + /// + public uint Balance { get; set; } + /// + /// 充电卡黑白名单标志 + /// 0x00-正常卡 + /// 0x01-黑卡 + /// + public byte BlacklistSign { get; set; } + /// + /// 用户充电卡密码 32 + /// 用户输入密码(约定 6 位)后,对密码进 + /// 行 MD5 32 位加密的密文 + /// 用户选择无密码时,每个字节均为 0x00 + /// + public string ChargCardPassword { get; set; } + /// + /// 卡扇区数据随机数 + /// + public string RandomData { get; set; } + /// + /// M1 卡序号 + /// + public uint M1CardID { get; set; } + /// + /// 认证方式 + /// 0:刷卡认证 + /// 1:密码充电认证 + /// + public byte Auth { get; set; } + /// + /// 充电枪号 + /// + public byte ChargGunNum { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD206.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD206.cs new file mode 100644 index 0000000..20d0fce --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD206.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD206 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 + /// + public string ASCIINum { get; set; } + /// + /// 充电卡号 + /// + public string ChargID { get; set; } + /// + /// 用户充电密码 + /// + public string ChargPassword { get; set; } + /// + /// 卡扇区数据随机数 + /// + public string RandomData { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD208.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD208.cs new file mode 100644 index 0000000..a6274b1 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD208.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD208 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 + /// + public string ASCIINum { get; set; } + /// + /// 充电枪号 + /// + public byte ChargGunNum { get; set; } + /// + /// 车辆 VIN 码 17 + /// + public string VINNum { get; set; } + /// + /// 充电满策略 + /// 0:充满为止 + /// 1:时间控制充电 + /// 2:金额控制充电 + /// 3:电量控制充电 + /// + public byte ChargStrategy { get; set; } + /// + /// 充电满策略参数 + /// 时间单位为 1 秒 + /// 金额单位为 0.01 元 + /// 电量时单位为 0.01kw + /// + public uint ChargStrategyPara { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD210.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD210.cs new file mode 100644 index 0000000..1644b52 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD210.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD210 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 + /// + public string ASCIINum { get; set; } + /// + /// 充电枪号 + /// + public byte ChargGunNum { get; set; } + /// + /// 启动结果 0正常 + /// + public uint StartResult { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD221.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD221.cs new file mode 100644 index 0000000..e98e811 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD221.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD221 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电口号 + /// + public byte ChargNum { get; set; } + /// + /// 充电卡号 32 + /// + public string ChargID { get; set; } + /// + /// 内部索引号 + /// + public uint IndexNum { get; set; } + /// + /// 7、8、9 字段有效标志 + /// 0- 无效 + /// 1- 有效 + /// + public byte ValidMark { get; set; } + /// + /// 充电优惠前金额 + /// + public uint InitialCost { get; set; } + /// + /// 充电折扣金额 + /// + public uint DiscountCost { get; set; } + /// + /// 充电实扣金额 + /// + public uint NetCost { get; set; } + /// + /// 用户剩余金额 + /// + public uint Balance { get; set; } + /// + /// 充电实扣电费 + /// + public uint NetElectricCost { get; set; } + /// + /// 充电实扣服务费 + /// + public uint NetServiceCost { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD222.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD222.cs new file mode 100644 index 0000000..e3841f2 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD222.cs @@ -0,0 +1,387 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD222 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 + /// + public string ASCIINum { get; set; } + /// + /// 充电枪位置类型 + /// 1-直流 + /// 2-交流 + /// + public byte PosType { get; set; } + /// + /// 充电枪口 + /// + public byte ChargGun { get; set; } + /// + /// 充电卡号 32 + /// + public string ChargID { get; set; } + /// + /// 充电开始时间 + /// + public string StartTime { get; set; } + /// + /// 充电结束时间 + /// + public string EndTime { get; set; } + /// + /// 充电时间长度 + /// + public uint TimeSpan { get; set; } + /// + /// 开始 SOC + /// + public byte SOCStart { get; set; } + /// + /// 结束 SOC + /// + public byte SOCEnd { get; set; } + /// + /// 充电结束原因 + /// + public uint EndReason { get; set; } + /// + /// 本次充电电量 + /// + public uint ChargCapacityNow { get; set; } + /// + /// 充电前电表读数 + /// + public uint SAmmeterValue { get; set; } + /// + /// 充电后电表读数 + /// + public uint EAmmeterValue { get; set; } + /// + /// 本次充电金额 + /// + public uint ChargeAmount { get; set; } + /// + /// 内部索引号 + /// + public uint IndexNum { get; set; } + /// + /// 充电前卡余额 + /// + public uint CardBalance { get; set; } + /// + /// 当前充电记录索引 + /// + public uint ChargRecord { get; set; } + /// + /// 总充电记录条目 + /// + public uint SumChargRecord { get; set; } + /// + /// 预留 + /// + public byte Reserved3 { get; set; } + /// + /// 充电策略 + /// 0:充满为止 + /// 1:时间控制充电 + /// 2:金额控制充电 + /// 3:电量控制充电 + /// + public byte ChargStrategy { get; set; } + /// + /// 充电策略参数 + /// + /// 时间单位为 1 秒 + /// 金额单位为 0.01 元 + /// 电量时单位为 0.01kw + /// + public uint ChargStrategyPara { get; set; } + /// + /// 车辆 VIN 17 + /// + public string CarVIN { get; set; } + /// + /// 车牌号 + /// + public string CarID { get; set; } + /// + /// 时段 1 充电电量 + /// 命令 202 报文此字段是 2 字节, + /// 命令 222 报文此字段是 4 字节 + /// + public int ChargCapacity01 { get; set; } + /// + /// + /// + public int ChargCapacity02 { get; set; } + /// + /// + /// + public int ChargCapacity03 { get; set; } + /// + /// + /// + public int ChargCapacity04 { get; set; } + /// + /// + /// + public int ChargCapacity05 { get; set; } + /// + /// + /// + public int ChargCapacity06 { get; set; } + /// + /// + /// + public int ChargCapacity07 { get; set; } + /// + /// + /// + public int ChargCapacity08 { get; set; } + /// + /// + /// + public int ChargCapacity09 { get; set; } + /// + /// + /// + public int ChargCapacity10 { get; set; } + /// + /// + /// + public int ChargCapacity11 { get; set; } + /// + /// + /// + public int ChargCapacity12 { get; set; } + /// + /// + /// + public int ChargCapacity13 { get; set; } + /// + /// + /// + public int ChargCapacity14 { get; set; } + /// + /// + /// + public int ChargCapacity15 { get; set; } + /// + /// + /// + public int ChargCapacity16 { get; set; } + /// + /// + /// + public int ChargCapacity17 { get; set; } + /// + /// + /// + public int ChargCapacity18 { get; set; } + /// + /// + /// + public int ChargCapacity19 { get; set; } + /// + /// + /// + public int ChargCapacity20 { get; set; } + /// + /// + /// + public int ChargCapacity21 { get; set; } + /// + /// + /// + public int ChargCapacity22 { get; set; } + /// + /// + /// + public int ChargCapacity23 { get; set; } + /// + /// + /// + public int ChargCapacity24 { get; set; } + /// + /// + /// + public int ChargCapacity25 { get; set; } + /// + /// + /// + public int ChargCapacity26 { get; set; } + /// + /// + /// + public int ChargCapacity27 { get; set; } + /// + /// + /// + public int ChargCapacity28 { get; set; } + /// + /// + /// + public int ChargCapacity29 { get; set; } + /// + /// + /// + public int ChargCapacity30 { get; set; } + /// + /// + /// + public int ChargCapacity31 { get; set; } + /// + /// + /// + public int ChargCapacity32 { get; set; } + /// + /// + /// + public int ChargCapacity33 { get; set; } + /// + /// + /// + public int ChargCapacity34 { get; set; } + /// + /// + /// + public int ChargCapacity35 { get; set; } + /// + /// + /// + public int ChargCapacity36 { get; set; } + /// + /// + /// + public int ChargCapacity37 { get; set; } + /// + /// + /// + public int ChargCapacity38 { get; set; } + /// + /// + /// + public int ChargCapacity39 { get; set; } + /// + /// + /// + public int ChargCapacity40 { get; set; } + /// + /// + /// + public int ChargCapacity41 { get; set; } + /// + /// + /// + public int ChargCapacity42 { get; set; } + /// + /// + /// + public int ChargCapacity43 { get; set; } + /// + /// + /// + public int ChargCapacity44 { get; set; } + /// + /// + /// + public int ChargCapacity45 { get; set; } + /// + /// + /// + public int ChargCapacity46 { get; set; } + /// + /// + /// + public int ChargCapacity47 { get; set; } + /// + /// 时段 48 充电电量 + /// 命令 202 报文此字段是 2 字节, + /// 命令 222 报文此字段是 4 字节 + /// + public int ChargCapacity48 { get; set; } + /// + /// 启动方式 + /// 0:本地刷卡启动 + /// 1:后台启动 + /// 2:本地管理员启动 + /// 3:远程 VIN 验证启动 + /// 4:远程密码验证启动 + /// 5:本地 VIN 验证启动 + /// 6:迪文界面流程启动 + /// + public byte StartMode { get; set; } + /// + /// 充电流水号 32 + /// + public string ChargSerialNum { get; set; } + /// + /// 充电服务费 + /// + public uint ChargServiceCost { get; set; } + /// + /// 千分位电量 + /// + public byte KilElectricity { get; set; } + /// + /// 并充标志 + /// 0/1-单枪充电 + /// 2-单机柜双枪并充充电 + /// 3-双机柜双枪并充充电 + /// + public byte ParallelMark { get; set; } + /// + /// 充放电标志 + /// + /// 2-充电 + /// 0xf1-放电 + /// 非协议定义值,都表示充电 + /// + public byte ChargeOrDisMark { get; set; } + /// + /// 电表加密数据 + /// + /// 瑞银电表解密后数据内容为: + /// 17 字节枪口识别号(BCD) + /// 4 字节计量开始时间(秒时戳, HEX) + /// 4 字节计量结束时间(秒时戳, HEX) + /// 4 字节正向充电电量(3 位小数, HEX) + /// 4 字节电表安装时间(秒时戳, HEX) + /// 1 字节端钮历史状态(0 正常,1 发生过端钮盖打开时间) + /// + public byte MeterEncData { get; set; } + /// + /// 电表表号 6 + /// + public string MeterNum { get; set; } + /// + /// 电表协议版本 + /// + public ushort MeterProVersion { get; set; } + /// + /// 加密方式 + /// 当前加密方式(工厂模式下配置,抄读无任何限制) + /// 00:软件 AES128 加密 + /// 01:RJMU 国密 SM1(暂不支持) + /// 02:RJMU 国密 SM4(暂不支持) + /// 03:国网 ESAM 加密 + /// 04:ECC256 签名算法 + /// 05:其他 + /// + public byte EncMode { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD302.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD302.cs new file mode 100644 index 0000000..e579a71 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD302.cs @@ -0,0 +1,350 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD302 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 报文次序计数 + /// + public ushort MessageOrderNum { get; set; } + /// + /// 充电枪号 + /// + public ushort ChargGunNum { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 工作状态 + /// 0-空闲中 + /// 1-正准备开始充电 + /// 2-充电进行中 + /// 3-充电结束 + /// 4-启动失败 + /// 5-预约状态 + /// 6-系统故障(不能给汽车充电) + /// + public byte WorkState { get; set; } + /// + /// 车连接状态 + /// 0-断开 + /// 1-半连接 + /// 2-连接 + /// + public byte connectState { get; set; } + /// + /// BRM-BMS 通讯协议版本号 + /// + public byte BRMBMSVersionNum { get; set; } + /// + /// BRM-电池类型 + /// 0x01-铅酸电池, + /// 0x02-镍氢电池, + /// 0x03-磷酸铁锂电池, + /// 0x04-锰酸锂电池, + /// 0x05-钴酸锂电池, + /// 0x06-三元次料电池, + /// 0x07-聚合物锂离子电池, + /// 0x08-钛酸锂电池, + /// 0xff-其他电池 + /// + public byte BRMBatteryType { get; set; } + /// + /// BRM-整车动力蓄电池系统额定容量/Ah + /// + public uint BRMRatedCapacity { get; set; } + /// + /// BRM-整车动力蓄电池系统额定总电压/V + /// + public uint BRMRatedVoltage { get; set; } + /// + /// BRM-电池生产厂商 + /// + public uint BRMBatteryManu { get; set; } + /// + /// BRM-电池组序号 + /// + public uint BRMBatteryPackID { get; set; } + /// + /// BRM-电池组生厂日期:年 + /// + public ushort BRMDateYear { get; set; } + /// + /// BRM-电池组生厂日期:月 + /// + public byte BRMDateMonth { get; set; } + /// + /// BRM-电池组生厂日期:日 + /// + public byte BRMDateDay { get; set; } + /// + /// BRM-电池组充电次数 + /// + public uint BRMChargeCount { get; set; } + /// + /// BRM-电池组产权标识 + /// 0X01-表示租赁 + /// 0x01 表示车自有 + /// + public byte BRMTitleMark { get; set; } + /// + /// 预留 + /// + public byte Reserved3 { get; set; } + /// + /// BRM-车辆识别码 vin 17 + /// + public string BRMVINID { get; set; } + /// + /// BRM-BMS 软件版本号 + /// Byte1 表示版本流水号:0x01~0xfe; + /// byte2 表示日:0x01 表示 1 日; + /// byte3:0x01 表示 1 月; + /// byte4 和 byte5 表示年:0x07 0xdf 表示2015 年; + /// Byte6 和 byte7、byte8 预留,填 0xffffff + /// + public ulong BRMBMSSoftVerNum { get; set; } + /// + /// BCP-单体动力蓄电池最高允许充电电压 + /// + public uint MaxChargVoltage { get; set; } + /// + /// BCP-最高允许充电电流 + /// + public uint MaxChargCurrent { get; set; } + /// + /// BCP-动力蓄电池标称总能量 + /// + public uint TotalEnergy { get; set; } + /// + /// BCP-最高允许充电总电压 + /// + public uint MaxTotalVoltage { get; set; } + /// + /// BCP-最高允许温度 + /// + public byte MaxTemp { get; set; } + /// + /// BCP-整车动力蓄电池荷电状态 + /// + public ushort ChargeState { get; set; } + /// + /// BCP-整车动力蓄电池当前电池电压 + /// + public uint CellVoltage { get; set; } + /// + /// BRO-BMS 是否充电准备好 + /// + public byte ChargePrepared { get; set; } + /// + /// BCL-电压需求 + /// + public uint BCLVoltage { get; set; } + /// + /// BCL-电流需求 + /// + public uint BCLCurrent { get; set; } + /// + /// BCL-充电模式 + /// + public byte BCLChargMode { get; set; } + /// + /// BCS-充电电压测量值 + /// + public uint BCSVoltageValue { get; set; } + /// + /// BCS-充电电流测量值 + /// + public uint BCSCurrentValue { get; set; } + /// + /// BCS-最高单体动力蓄电池电压 + /// + public uint BCSVoltageMAX { get; set; } + /// + /// BCS-最高单体动力蓄电池组号 + /// + public byte BCSBatteryNumMAX { get; set; } + /// + /// BCS-当前荷电状态soc% + /// + public ushort BCSChargState { get; set; } + /// + /// 估算剩余充电时间 + /// + public uint ReChargeTime { get; set; } + /// + /// BSM-最高单体动力蓄电池电压所在编号 + /// + public byte BSMNum { get; set; } + /// + /// BSM-最高动力蓄电池温度 + /// + public byte BSMMaxTemp { get; set; } + /// + /// BSM-最高温度检测点编号 + /// + public byte MaxTempPointNum { get; set; } + /// + /// BSM-最低动力蓄电池温度 + /// + public byte MinBatteryTemp { get; set; } + /// + /// BSM-最低动力蓄电池温度检测点编号 + /// + public byte MinTempPointNum { get; set; } + /// + /// BSM-单体动力蓄电池电压过高或过低 + /// 0x00-正常 + /// 0x01-过高 + /// 0x10-过低 + /// + public byte voltageHighLow { get; set; } + /// + /// BSM-整车动力蓄电池荷电状态 soc 过高或过低 + /// + public byte ChargStateHighLow { get; set; } + /// + /// BSM-动力蓄电池充电过电流 + /// + public byte BmsOvercurrent { get; set; } + /// + /// BSM-动力蓄电池温度过高 + /// + public byte TempHigh { get; set; } + /// + /// BSM-动力蓄电池绝缘状态 + /// + public byte InsulatState { get; set; } + /// + /// BSM-动力蓄电池组输出连接器连接状态 + /// + public byte ConnectState { get; set; } + /// + /// BSM-允许充电 + /// + public byte AllowCharge { get; set; } + /// + /// BST-BMS 达到所需求的SOC 目标值 + /// + public byte SOCTargetValue { get; set; } + /// + /// BST-BMS 达到总电压的设定值 + /// + public byte SumVoltageSetValue { get; set; } + /// + /// BST-达到单体电压的设定值 + /// + public byte VoltageSetValue { get; set; } + /// + /// BST-充电机主动终止 + /// + public byte ChargeEnd { get; set; } + /// + /// BST-绝缘故障 + /// + public byte InsulatFault { get; set; } + /// + /// BST-输出连接器过温故障1 + /// + public byte OvertempFault { get; set; } + /// + /// BST-BMS 元件,输出连接器过温10x00-正常,0x01-故障,0x10-不可信状态 + /// + public byte Overtemp { get; set; } + /// + /// BST-充电连接器故障 + /// + public byte ConnectorFault { get; set; } + /// + /// BST-电池组温度过高故障 + /// + public byte ChargOvertempFault { get; set; } + /// + /// BST-高压继电器故障 + /// + public byte HVoltageFault { get; set; } + /// + /// BST-检测点 2 电压检测故障 + /// + public byte VoltageSenseFault { get; set; } + /// + /// BST-其他故障 + /// + public byte OtherFault { get; set; } + /// + /// BST-电流过大 + /// + public byte Overcurrent { get; set; } + /// + /// BST-电压异常 + /// + public byte VoltageAnomaly { get; set; } + /// + /// BSD-终止荷电状态 soc + /// + public ushort EndChargState { get; set; } + /// + /// BSD-动力蓄电池单体最低电压 + /// + public uint MinVoltage { get; set; } + /// + /// BSD-动力蓄电池单体最高电压 + /// + public uint MaxVoltage { get; set; } + /// + /// BSD-动力蓄电池最低温度 + /// + public byte MinChargTemp { get; set; } + /// + /// BSD-动力蓄电池最高温度 + /// + public byte MaxChargTemp { get; set; } + /// + /// BEM-接收SPN2560=0x00 的充电机辨识报文超时 + /// + public byte ReceiveTimeout1 { get; set; } + /// + /// BEM-接收SPN2560=0xaa 的充电机辨识报文超时 + /// + public byte ReceiveTimeout2 { get; set; } + /// + /// BEM-接收充电机的时间同步和最大输出能力报文超时 + /// + public byte ReceiveTimeout3 { get; set; } + /// + /// BEM-接收充电机完成充电准备报文超时 + /// + public byte ReceiveTimeout4 { get; set; } + /// + /// BEM-接收充电机充电状态报文超时 + /// + public byte ReceiveTimeout5 { get; set; } + /// + /// BEM-接收充电机终止充电报文超时 + /// + public byte ReceiveTimeout6 { get; set; } + /// + /// BEM-接收充电机充电统计报文超时 + /// + public byte ReceiveTimeout7 { get; set; } + /// + /// BEM-其他 + /// + public byte Other { get; set; } + + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD304.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD304.cs new file mode 100644 index 0000000..8ab998c --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD304.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD304 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 + /// + public string ASCIINum { get; set; } + /// + /// 工作状态 + /// 0-空闲中 + /// 1-正准备开始充电 + /// 2-充电进行中 + /// 3-充电结束 + /// 4-启动失败 + /// 5-预约状态 + /// 6-系统故障(不能给汽车充电) + /// + public byte WorkState { get; set; } + /// + /// 车连接状态 + /// 0-断开 + /// 1-半连接 + /// 2-连接 + /// + public byte connectState { get; set; } + /// + /// BRM 车辆辨识报文 64 + /// + public string BRMMessage { get; set; } + /// + /// VBI 报文 64 + /// + public string VBIMessage { get; set; } + /// + /// BCP 动力蓄电池充电参数 16 + /// + public string ChargParameter { get; set; } + /// + /// BRO 电池充电准备就绪状态 + /// + public ulong ReadyState { get; set; } + /// + /// BCL 电池充电需求 + /// + public ulong ChargDemand { get; set; } + /// + /// BCS 电池充电总状态 16 + /// + public string TotalState { get; set; } + /// + /// BSM 动力蓄电池状态信息 + /// + public uint StateInfo { get; set; } + /// + /// BST 中止充电 + /// + public uint StopCharg { get; set; } + /// + /// BSD BMS 统计数据 + /// + public uint StatisticData { get; set; } + /// + /// BEM 报文 + /// + public uint BEMMessage { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD4.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD4.cs new file mode 100644 index 0000000..90196d1 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD4.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD4 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32位 + /// + public string ASCIINum { get; set; } + /// + /// 类型 + /// + public byte Type { get; set; } + /// + /// 设置/查询参数启始地址 + /// + public uint SAddress { get; set; } + /// + /// 设置/查询结果 + /// + public byte SResult { get; set; } + /// + /// 设置参数信息 + /// + public string SData { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD402.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD402.cs new file mode 100644 index 0000000..fd93a76 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD402.cs @@ -0,0 +1,274 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD402 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32byte ASCLL 编码 + /// + public string ASCIINum { get; set; } + /// + /// 充电桩位置类型 + /// 1-直流 2-交流 + /// + public byte PosType { get; set; } + /// + /// 充电枪口 + /// + + public byte ChargGun { get; set; } + /// + /// 充电卡号 32byte ASCLL + /// + public string ChargCardID { get; set; } + /// + /// 充电开始时间 标准时间 + /// + public string ChargStartTime { get; set; } + /// + /// 充电结束时间 标准时间 + /// + public string ChargEndTime { get; set; } + /// + /// 4byte 单位秒 + /// + public uint ChargTimeLength { get; set; } + /// + /// 开始SOC + /// + public byte SOCStart { get; set; } + /// + /// 结束SOC + /// + public byte SOCEnd { get; set; } + /// + /// 充电结束原因 4byte + /// + public string ChargEndReason { get; set; } + /// + /// 本次充电电量 + /// 命令 402 报文此字段单位是0.01kWh/bit + /// 命令 422 报 文 此 字 段 单 位 是0.001kWh/bit + /// + public string ChargCapacity { get; set; } + /// + /// 充电前电表读数 + /// + public uint SAmmeterValue { get; set; } + /// + /// 充电后电表读数 + /// + public uint EAmmeterValue { get; set; } + /// + /// 本次充电金额 + /// + public uint ChargeAmount { get; set; } + /// + /// 内部索引号 + /// 每一条充电记录都唯一编号有符号整形,-1 表示查询失败 + /// + public uint IndexNum { get; set; } + /// + /// 充电之前卡余额 + /// 只有在刷卡启动及卡里有金额的应用模式才有效 + /// + public uint InitialBalance { get; set; } + /// + /// 当前充电记录索引 + /// + public uint ChargRecordIndex { get; set; } + /// + /// 总充电记录条目 + /// + public uint TotalChargeRecord { get; set; } + /// + /// 预留 + /// + public byte Reserved3 { get; set; } + /// + /// 充电策略 + /// 0-充满为止 、1-时间控制充电 、2-金额控制充电 、3-电量控制充电 + /// + public byte ChargStrategy { get; set; } + /// + /// 充电策略参数 + /// 时间单位为1秒 + /// 金额单位为0.01元 + /// 电量时单位为0.01kw + /// + public string ChargStrategyPara { get; set; } + /// + /// 车辆VIN 直流桩上传,没有填’\0’ + /// + public string VINCar { get; set; } + /// + /// 车牌号 + /// + public string CarID { get; set; } + + + /// + /// 时段 1 充电电量 + /// 48 时段费率模型(1103)生效:[00:00:00~00:30:00] + /// 分时段费率模型(1105)生效:时段 1 + /// 命令 402 报文此字段是 2 字节,单位是 0.01kWh/bit + /// 命令 422 报文此字段是 4 字节,单位是 0.001kWh/bit + /// + public string ChargCapacity01 { get; set; } + /// + /// 时段 2 充电电量 + /// 48 时段费率模型(1103)生效:[00:30:00~01:00:00] + /// 分时段费率模型(1105)生效:时段 2 + /// 命令 402 报文此字段是 2 字节,单位是 0.01kWh/bit + /// 命令 422 报文此字段是 4 字节,单位是 0.001kWh/bit + /// + public string ChargCapacity02 { get; set; } + /// + /// 时段 3 充电电量 + /// 48 时段费率模型(1103)生效: [01:00:00~01:30:00] + /// 分时段费率模型(1105)生效:时段 3 + /// 命令 402 报文此字段是 2 字节,单位是 0.01kWh/bit + /// 命令 422 报文此字段是 4 字节,单位是 0.001kWh/bit + /// + public string ChargCapacity03 { get; set; } + /// + /// 时段 4 充电电量 + /// 48 时段费率模型(1103)生效: [01:30:00~02:00:00] + /// 分时段费率模型(1105)生效:时段 4 + /// 命令 402 报文此字段是 2 字节,单位是 0.01kWh/bit + /// 命令 422 报文此字段是 4 字节,单位是 0.001kWh/bit + /// + public string ChargCapacity04 { get; set; } + /// + /// 时段 5 充电电量 + /// 48 时段费率模型(1103)生效:[02:00:00~02:30:00] + /// 分时段费率模型(1105)生效:时段 5 + /// 命令 402 报文此字段是 2 字节,单位是 0.01kWh/bit + /// 命令 422 报文此字段是 4 字节,单位是 0.001kWh/bit + /// + public string ChargCapacity05 { get; set; } + + /// + /// 时段 6 充电电量 + /// 48 时段费率模型(1103)生效: [02:30:00~03:00:00] + /// 分时段费率模型(1105)生效:时段 6 + /// + public string ChargCapacity06 { get; set; } + /// + /// 48 时段费率模型(1103)生效:[03:00:00~03:30:00] + /// 分时段费率模型(1105)生效:时段 7 + /// + public string ChargCapacity07 { get; set; } + /// + /// 48 时段费率模型(1103)生效:[03:30:00~04:00:00] + /// 分时段费率模型(1105)生效:时段 8 + /// + public string ChargCapacity08 { get; set; } + /// + /// 48 时段费率模型(1103)生效:[04:00:00~04:30:00] + /// 分时段费率模型(1105)生效:时段 9 + /// + public string ChargCapacity09 { get; set; } + /// + /// 48 时段费率模型(1103)生效: [04:30:00~05:00:00] + /// 分时段费率模型(1105)生效:时段 10 + /// + public string ChargCapacity10 { get; set; } + /// + /// 48 时段费率模型(1103)生效:[05:00:00~05:30:00] + /// 分时段费率模型(1105)生效:时段 11 + /// + public string ChargCapacity11 { get; set; } + /// + /// 48 时段费率模型(1103)生效: [05:30:00~06:00:00] + /// 分时段费率模型(1105)生效:时段 12(分时段最大时段数) + /// + public string ChargCapacity12 { get; set; } + /// + /// 48 时段费率模型(1103)生效:[06:00:00~06:30:00] + /// + public string ChargCapacity13 { get; set; } + /// + /// 48 时段费率模型(1103)生效:[06:30:00~07:00:00] + /// + public string ChargCapacity14 { get; set; } + /// + /// 48 时段费率模型(1103)生效:半小时一个时段 + /// + public string ChargCapacity15 { get; set; } + public string ChargCapacity16 { get; set; } + public string ChargCapacity17 { get; set; } + public string ChargCapacity18 { get; set; } + public string ChargCapacity19 { get; set; } + public string ChargCapacity20 { get; set; } + public string ChargCapacity21 { get; set; } + public string ChargCapacity22 { get; set; } + public string ChargCapacity23 { get; set; } + public string ChargCapacity24 { get; set; } + public string ChargCapacity25 { get; set; } + public string ChargCapacity26 { get; set; } + public string ChargCapacity27 { get; set; } + public string ChargCapacity28 { get; set; } + public string ChargCapacity29 { get; set; } + public string ChargCapacity30 { get; set; } + public string ChargCapacity31 { get; set; } + public string ChargCapacity32 { get; set; } + public string ChargCapacity33 { get; set; } + public string ChargCapacity34 { get; set; } + public string ChargCapacity35 { get; set; } + public string ChargCapacity36 { get; set; } + public string ChargCapacity37 { get; set; } + public string ChargCapacity38 { get; set; } + public string ChargCapacity39 { get; set; } + public string ChargCapacity40 { get; set; } + public string ChargCapacity41 { get; set; } + public string ChargCapacity42 { get; set; } + public string ChargCapacity43 { get; set; } + public string ChargCapacity44 { get; set; } + public string ChargCapacity45 { get; set; } + public string ChargCapacity46 { get; set; } + public string ChargCapacity47 { get; set; } + /// + /// [23:30:00~00:00:00] + /// + public string ChargCapacity48 { get; set; } + /// + /// 启动方式 0-本地刷卡启动 、1-后台启动 、2-本地管理员启动 + /// + public byte StartMode { get; set; } + /// + /// 充电流水号 + /// + public string SerialNum { get; set; } + /// + /// 充电服务费 + /// + public uint ChargServiceCost { get; set; } + /// + /// 千分位电量 + /// 如平台不对电量第三位小数做强检要求可忽略本字段。 + /// 如本字段为:0x09,千分位电量为 0.009Kw* h + /// + public string KilElectricity { get; set; } + /// + /// 并充标志 + /// 0/1-单枪充电 + /// 2-单机柜双枪并充充电 + /// 3-双机柜双枪并充充电 + /// + public byte ParallelMark { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD6.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD6.cs new file mode 100644 index 0000000..0026d48 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD6.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD6 + { + /// + /// 预留 + /// + public ushort value01 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32位 + /// + public string ASCIINum { get; set; } + /// + /// 充电枪口 + /// + public byte ChargMuzzle { get; set; } + /// + /// 命令起始标志 + /// + public uint CommandMark { get; set; } + /// + /// 命令个数 + /// + public byte CommandNum { get; set; } + /// + /// 命令执行结果 + /// + public byte CommandResult { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD8.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD8.cs new file mode 100644 index 0000000..ca52b9a --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD8.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD8 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 充电枪口 + /// + public byte ChargMuzzle { get; set; } + /// + /// 命令执行结果 + /// 0 表示成功 + /// 其它失败 + /// + public uint CommandResult { get; set; } + /// + /// 充电流水号 32 + /// + public string ChargSerialNum { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1.cs new file mode 100644 index 0000000..51aefb8 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1.cs @@ -0,0 +1,270 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1 + { + /// + /// 预留 + /// + public ushort WorkingData_Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort WorkingData_Reserved2 { get; set; } + /// + /// 类型 + /// 0查询 + /// 1设置 + /// + public byte Type { get; set; } + /// + /// 设置/查询参数起始地址 + /// + public uint SetAddress { get; set; } + /// + /// 设置/查询个数 + /// + public byte SelectNum { get; set; } + /// + /// 设置参数字节数 + /// + public ushort SetByteNum { get; set; } + /// + /// 设置数据 + /// + public byte[] SetData { get; set; } + + /* + + 1 签到时间间隔 4 按照分钟为单位(默认 30 分) + 2 充电桩项目类型 4 内部参数,一般用于查询 + 3 充电枪个数 4 内部参数,一般用于查询 + 4 通道号 4 内部参数,一般用于查询 + 5 最高充电电压 4 + 6 最大充电电流 4 + 7 读卡器类型 4 + 1:MT622 + 2:ID 读卡器 + 硬件决定的,运营的后台不需要 + 设置或查询此项 + 8 读卡器波特率 4 + 硬件决定的,运营的后台不需要 + 设置或查询此项 + 9 充电卡片协议编号 4 + 10 后台验证 4 0-不验证 1-验证 + 11 车牌验证 4 0-不验证 1-验证 + 12 车卡 VIN 绑定 4 0-不绑定 1-绑定 + 13 BMS 单体保护电压 4 + 14 BMS 充电保护温度 4 + 15* 调试地址 1 4 0 保持不变 + 16 调试地址 2 4 0 保持不变 + 17 调试地址 3 4 0 保持不变 + 18 调试地址 4 4 0 保持不变 + 19 调试地址 5 4 0 保持不变 + 20 定时上报间隔 4 + 上报模式,定时上报的间隔 + 单位:秒;缺省:15 秒 + 21 心跳上报周期 4 0 保持不变缺省=3 秒 + 22 心跳包检测超时次数 4 0 保持不变缺省=3 秒 + 23 + 充电桩状态信息报上报 + 周期 + 4 0 保持不变缺省=3 秒 + 24 通信模式 4 + 1:应答模式 + 2:主动上报模式 + 25* 中心服务器地址 4 按照字节顺序注 3) + 26* 中心服务器端口 4 低字节在前注 4) + 27 服务费价格 4 + 28 全时段电费费率 4 + 29 广告灯开启起始小时 4 + 30 广告灯开启起始分钟 4 + 31 广告灯关闭起始小时 4 + 32 广告灯关闭起始分钟 4 + 33 调试控制地址 4 内部调试用,运营平台不需实现 + 34 调试控制数据 4 要与调试控制地址一起发送 + 35 过压值 4 放大 10 倍 + 36 欠压值 4 放大 10 倍 + 37 过流值 4 放大 10 倍 + 39 辅源类型 4 1-12V 2-24V + 40 充电枪类型 4 + 41 控制板软件版本 4 + 只支持读,而且在 M3+U1+U2 + 平台中才有效 + 42 采集板软件版本 4 + 只支持读,而且在 M3+U1+U2 + 平台中才有效 + 43 模块类型 4 + 0:500V 标准;1:750V 标准; + 2:500V 恒功率模块;3:750V 恒 + 功率模块;4:低压 250V 模块;5: + 第二代恒功率模块;6:低压档 + 100V 模块;内部参数,可设可查, + 一般只用于查询 + 44 组号 4 + 监 控 组 号 , 与 模 块 组 号 一 致 + (0-9);内部参数,可设可查, + 一般只用于查询 + 45 地址 4 + 监控地址(1-10);内部参数,可 + 设可查,一般只用于查询 + 46 最大组号 4 + 监控最大组号(0-9);内部参数, + 可设可查,一般只用于查询 + 47 最大地址 4 + 监控最大地址号(1-10);内部参 + 数,可设可查,一般只用于查询 + 48 双充模式 4 + 1:双枪单充;2:双枪双充;内 + 部参数,可设可查,一般只用于 + 查询 + 49 界面类型 4 + 0:标准界面;1:N 个双枪单屏 + 类型;内部参数,可设可查,一 + 般只用于查询 + 50 预留 IO 类型 4 + 0:预留;1:N 枪单屏功能(一 + 般只设主机);2:群充 IO;3: + SOC 显示灯;内部参数,可设可 + 查,一般只用于查询 + 51 环境低温值 4 + 放大 10 倍;内部参数,可设可查, + 一般只用于查询 + 52 群充模块数量 4 + 放大 1 倍;内部参数,可设可查, + 一般只用于查询 + 53 指示灯类型 4 + 0:各枪各自的指示灯或 N 个双 + 枪单屏类型; 1:整个系统只有 + 一个指示灯;内部参数,可设可 + 查,一般只用于查询 + 54 电表类型 4 + 0:没有电表 + 1:DLT645-2007(地址号:01) ; + 2:DLT645-2007(科陆电表,带 + CT 上传,地址号:01);3: + DLT645-2007(广播帧,不用设 + 电表地址);4:DLT645-2007(地 + 址号:01,主机带机柜总电表(地 + 址号:02)));内部参数,可设可 + 查,一般只用于查询 + 55 充电卡类型 4 + 0:本公司旧标准 M1 充电卡 1:本 + 公司支持用户自定义密钥 M1 + 卡;内部参数,可设可查,一般 + 只用于查询 + 注:类型 0 的卡基本不用了,后 + 续一般都是支持类型 1 卡 + 56 CAN3 外部通信地址 4 + 1-100;内部参数,可设可查,一 + 般只用于查询 + 57 BMS 类型 4 + 0:新旧国标兼容(默认);1:旧 + 国标协议;02:国标与普天自适 + 应协议;03:普天地标协议;内 + 部参数,可设可查,一般只用于 + 查询 + 58 充电卡后台验证 4 + 1:后台验证使能;2:不使能; + 内部参数,可设可查,一般只用 + 于查询 + 59 认证方式 4 + 1:认证优先;2:充电优先;内 + 部参数,可设可查,一般只用于 + 查询 + 60 充电限电压 4 + 放大 10 倍;内部参数,可设可查, + 一般只用于查询 + 61 充电限电流 4 + 放大 10 倍;内部参数,可设可查, + 一般只用于查询 + 62 快充段-起始小时 4 + 放大 1 倍;内部参数,可设可查, + 一般只用于查询 + 63 快充段-起始分钟 4 + 放大 1 倍;内部参数,可设可查, + 一般只用于查询 + 64 快充段-结束小时 4 + 放大 1 倍;内部参数,可设可查, + 一般只用于查询 + 65 快充段-结束分钟 4 + 放大 1 倍;内部参数,可设可查, + 一般只用于查询 + 66 状态 A 和状态 B 4 见注 7 + 67 模块电压 4 放大 10 倍 + 68 绝缘正电压 4 放大 10 倍 + 69 绝缘负电压 4 放大 10 倍 + 70 绝缘阻抗 4 放大 1 倍 + 71 枪正端温度保护 4 偏移量-50,-50 - 200 + 72 枪负端温度保护 4 偏移量-50,-50 - 200 + 73 模块数量 4 0-255 + 74 电表电能 4 放大 100 倍,kwh + 75 后台支持计费优惠功能 4 + 0-不支持 + 1-支持 + 若后台支持计费优惠功能,报文 + 201 要回应相应的优惠字段 + 76 环境过温保护 4 偏移量-50,-50 - 200 + 77 延迟充电段-起始小时 4 + 放大 1 倍;内部参数,可设可查, + 一般只用于查询 + 78 延迟充电段-起始分钟 4 + 放大 1 倍;内部参数,可设可查, + 一般只用于查询 + 79 延迟充电段-结束小时 4 + 放大 1 倍;内部参数,可设可查, + 一般只用于查询 + 80 延迟充电段-结束分钟 4 + 放大 1 倍;内部参数,可设可查, + 一般只用于查询 + 81 白名单版本号 4 只能查询,不能设置 + 82 遥测 104 报文 4 + 83 强制解锁一次 4 + 只有在充电结束且发生解锁故障 + 时候才会生效。 + 枪锁软锁未解除下,此命令无效。 + 84 控制板复位 4 只能在非充电过程中触发 + 85 急停 4 + 充电中下发急停会导致本地停 + 机,慎重使用。 + 1:软急停触发 + 0:软急停解除 + 输入调试变量 6005 解除 + 输入调试变量 6005 触发 + 86 本地锁枪动作 4 + 只能在非充电期间且本地未发生 + 闭锁失败情况下下发。 + 1:枪锁上软锁 + 0:枪锁解软锁 + 界面输入调试变量 6000 解锁 + 界面输入调试变量 6001 闭锁 + 87 软件更新自检 4 + 充电桩检查并且执行最新官方可 + 升级性软件,非充电下发。 + 0xAA01:表示升级监控 + 0xAA02:表示升级 CCU-H2 板 + 0xAA03:表示升级 DCDC 模块 + 0xAA04:表示升级 ACDC 模块 + 0xAA05:表示升级绝缘板 + 0xAA06:表示升级功率控制板 + 其他: + 88 离线时默认限功率 4 + 后台限功率 + 0-不限功率 + 100-限功率 10KW + 1000-限功率 100KW + 89 最高允许 SOC 4 大于 100 表示不限制 + 90 AES 密钥 32 设置索引 90,设置个数 8 + 91 更新余额 8 + 前 4 字节枪号 + 后 4 字节余额值,单位 0.0001 + 元 + + */ + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1001.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1001.cs new file mode 100644 index 0000000..4dba180 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1001.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1001 + { + /// + /// 擦除查询指令 + /// 擦除:0xaa55 有效 + /// 查询:0x0000 有效 + /// + public uint CInstruction { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1003.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1003.cs new file mode 100644 index 0000000..86cf10c --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1003.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1003 + { + /// + /// 文件名(小于128byte) 128 + /// asicc 码,不需要带结束符’\0 + /// + public string Filename { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1005.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1005.cs new file mode 100644 index 0000000..668ede3 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1005.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1005 + { + /// + /// 文件长度 + /// 单位 BYTE + /// + public uint FileLength { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1007.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1007.cs new file mode 100644 index 0000000..496de3a --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1007.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1007 + { + /// + /// 升级文件数据 4 + /// 单位 BYTE + /// + public string UpFileData { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1009.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1009.cs new file mode 100644 index 0000000..a31167f --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1009.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1009 + { + public uint Reserved1 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD101.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD101.cs new file mode 100644 index 0000000..ef8345c --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD101.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD101 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 心跳应答(累加,到最大值时为 65535,重新累加) + /// + public ushort HearResponse { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1011.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1011.cs new file mode 100644 index 0000000..9b9fe53 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1011.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1011 + { + /// + /// 预留1 长度4byte + /// + public uint Reserved1 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1021.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1021.cs new file mode 100644 index 0000000..9b7a25c --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1021.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1021 + { + /// + /// 响应结果 + /// 0-响应成功 1-设备代号有误,不允许升级 + /// 2-项 目 代 码 不 存在,不允许升级 + /// 3-文件大小出错,停止升级 + /// 说明:非 0 都表示失败 + /// + public uint ResponseResult { get; set; } + /// + /// 响应说明 + /// 字符串,对响应的文字说明 + /// + public string ResponsExplain { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD103.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD103.cs new file mode 100644 index 0000000..ec91eca --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD103.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD103 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电口号(这个字段与 104 报文字段 5 一致) + /// + public byte ChargNum { get; set; } + /// + /// 是否立即上报一次104 报文 + /// 0:否 + /// 1:是 + /// + public bool Reported { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD105.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD105.cs new file mode 100644 index 0000000..3e5ed8c --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD105.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD105 + { + /// + /// 备用1 + /// + public ushort Reserved1 { get; set; } + /// + /// 备用2 + /// + public ushort Reserved2 { get; set; } + /// + /// 匹配码。106报文随机数应答 + /// + public uint NumResponse { get; set; } + /// + /// 登入验证 + /// 0-不启用 CMD1202 认证 + /// 1-启用 CMD1202 登入认证 + /// + public byte LoginVerify { get; set; } + /// + /// 加密标识 + /// + public byte EncryptionFlag { get; set; } + /// + /// RSA 公共模数 长度128 字段(加密标识)5值为 1 时填充 128 + /// + public string RSAComModule { get; set; } + /// + /// RSA 公密 4 字段 5 值为 1 时填充 + /// + public uint RSAComSecret { get; set; } + /// + /// 启停用标志 1 + /// 0x00-正常使用 + /// 0x55-暂停服务(只对在充电机空闲时有效) + /// + public byte StSign { get; set; } + /// + /// 平台标准BCD时间 充电桩校时 + /// + public ulong BCDTime { get; set; } + /// + /// 平台是否支持三位小数222 报文上传 + /// 0xDE-平台支持 222 三位小数上传 + /// 其他-使用 202 报文上传订单 + /// + public byte MessageUpload { get; set; } + /// + /// AES 秘钥 32 + /// 32位 + /// + public string AESSecretKey { get; set; } + } +} diff --git a/HybirdFrameworkEntity/DbModel/Class1.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD107.cs similarity index 67% rename from HybirdFrameworkEntity/DbModel/Class1.cs rename to HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD107.cs index 01e077e..7f2f221 100644 --- a/HybirdFrameworkEntity/DbModel/Class1.cs +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD107.cs @@ -4,9 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace HybirdFrameworkEntity.DbModel +namespace HybirdFrameworkServices { - internal class Class1 + public class CMD107 { + } } diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD109.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD109.cs new file mode 100644 index 0000000..850b36d --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD109.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD109 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1101.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1101.cs new file mode 100644 index 0000000..1da41b1 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1101.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1101 + { + + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1103.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1103.cs new file mode 100644 index 0000000..0a98d5d --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1103.cs @@ -0,0 +1,299 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1103 + { + #region 1 + /// + /// 开始小时 0~24 + /// + public byte StartHour1 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin1 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour1 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin1 { get; set; } + /// + /// 费率1 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate1 { get; set; } + #endregion 1 + + #region 2 + /// + /// 开始小时 0~24 + /// + public byte StartHour2 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin2 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour2 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin2 { get; set; } + /// + /// 费率2 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate2 { get; set; } + #endregion 2 + + #region 3 + /// + /// 开始小时 0~24 + /// + public byte StartHour3 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin3 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour3 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin3 { get; set; } + /// + /// 费率3 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate3 { get; set; } + #endregion 3 + + #region 4 + /// + /// 开始小时 0~24 + /// + public byte StartHour4 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin4 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour4 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin4 { get; set; } + /// + /// 费率4 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate4 { get; set; } + #endregion 4 + + #region 5 + /// + /// 开始小时 0~24 + /// + public byte StartHour5 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin5 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour5 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin5 { get; set; } + /// + /// 费率5 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate5 { get; set; } + #endregion 5 + + #region 6 + /// + /// 开始小时 0~24 + /// + public byte StartHour6 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin6 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour6 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin6 { get; set; } + /// + /// 费率6 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate6 { get; set; } + #endregion 6 + + #region 7 + /// + /// 开始小时 0~24 + /// + public byte StartHour7 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin7 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour7 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin7 { get; set; } + /// + /// 费率7 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate7 { get; set; } + #endregion 7 + + #region 8 + /// + /// 开始小时 0~24 + /// + public byte StartHour8 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin8 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour8 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin8 { get; set; } + /// + /// 费率8 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate8 { get; set; } + #endregion 8 + + #region 9 + /// + /// 开始小时 0~24 + /// + public byte StartHour9 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin9 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour9 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin9 { get; set; } + /// + /// 费率9 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate9 { get; set; } + #endregion 9 + + #region 10 + /// + /// 开始小时 0~24 + /// + public byte StartHour10 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin10 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour10 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin10 { get; set; } + /// + /// 费率10 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate10 { get; set; } + #endregion 10 + + #region 11 + /// + /// 开始小时 0~24 + /// + public byte StartHour11 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin11 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour11 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin11 { get; set; } + /// + /// 费率11 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate11 { get; set; } + #endregion 11 + + #region 12 + /// + /// 开始小时 0~24 + /// + public byte StartHour12 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin12 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour12 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin12 { get; set; } + /// + /// 费率12 + /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 + /// + public uint Rate12 { get; set; } + #endregion 12 + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1105.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1105.cs new file mode 100644 index 0000000..a53d570 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1105.cs @@ -0,0 +1,359 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1105 + { + #region 1 + /// + /// 开始小时 0~24 + /// + public byte StartHour1 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin1 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour1 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin1 { get; set; } + /// + /// 充电费率1 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate1 { get; set; } + /// + /// 服务费率1 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate1 { get; set; } + #endregion 1 + + #region 2 + /// + /// 开始小时 0~24 + /// + public byte StartHour2 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin2 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour2 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin2 { get; set; } + /// + /// 充电费率2 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate2 { get; set; } + /// + /// 服务费率2 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate2 { get; set; } + #endregion 2 + + #region 3 + /// + /// 开始小时 0~24 + /// + public byte StartHour3 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin3 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour3 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin3 { get; set; } + /// + /// 充电费率3 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate3 { get; set; } + /// + /// 服务费率3 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate3 { get; set; } + #endregion 3 + + #region 4 + /// + /// 开始小时 0~24 + /// + public byte StartHour4 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin4 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour4 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin4 { get; set; } + /// + /// 充电费率4 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate4 { get; set; } + /// + /// 服务费率4 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate4 { get; set; } + #endregion 4 + + #region 5 + /// + /// 开始小时 0~24 + /// + public byte StartHour5 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin5 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour5 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin5 { get; set; } + /// + /// 充电费率5 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate5 { get; set; } + /// + /// 服务费率5 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate5 { get; set; } + #endregion 5 + + #region 6 + /// + /// 开始小时 0~24 + /// + public byte StartHour6 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin6 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour6 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin6 { get; set; } + /// + /// 充电费率6 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate6 { get; set; } + /// + /// 服务费率6 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate6 { get; set; } + #endregion 6 + + #region 7 + /// + /// 开始小时 0~24 + /// + public byte StartHour7 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin7 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour7 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin7 { get; set; } + /// + /// 充电费率7 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate7 { get; set; } + /// + /// 服务费率7 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate7 { get; set; } + #endregion 7 + + #region 8 + /// + /// 开始小时 0~24 + /// + public byte StartHour8 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin8 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour8 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin8 { get; set; } + /// + /// 充电费率8 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate8 { get; set; } + /// + /// 服务费率8 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate8 { get; set; } + #endregion 8 + + #region 9 + /// + /// 开始小时 0~24 + /// + public byte StartHour9 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin9 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour9 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin9 { get; set; } + /// + /// 充电费率9 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate9 { get; set; } + /// + /// 服务费率9 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate9 { get; set; } + #endregion 9 + + #region 10 + /// + /// 开始小时 0~24 + /// + public byte StartHour10 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin10 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour10 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin10 { get; set; } + /// + /// 充电费率10 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate10 { get; set; } + /// + /// 服务费率10 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate10 { get; set; } + #endregion 10 + + #region 11 + /// + /// 开始小时 0~24 + /// + public byte StartHour11 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin11 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour11 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin11 { get; set; } + /// + /// 充电费率11 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate11 { get; set; } + /// + /// 服务费率11 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate11 { get; set; } + #endregion 11 + + #region 12 + /// + /// 开始小时 0~24 + /// + public byte StartHour12 { get; set; } + /// + /// 开始分钟 0或30 + /// + public byte STartMin12 { get; set; } + /// + /// 结束小时 0~24 + /// + public byte EndHour12 { get; set; } + /// + /// 结束分钟 0或30 + /// + public byte EndMin12 { get; set; } + /// + /// 充电费率12 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint Rate12 { get; set; } + /// + /// 服务费率12 + /// 该时段内每度电的电费,用整型值表示,要乘 0.0001才能得到真实的值(BIN) + /// + public uint reserveRate12 { get; set; } + #endregion 12 + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1107.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1107.cs new file mode 100644 index 0000000..7929661 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1107.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1107 + { + + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD111.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD111.cs new file mode 100644 index 0000000..04cfc3d --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD111.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD111 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 报文类型 + /// 0-应答 + /// 1-查询 + /// + public ushort MessageType { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD113.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD113.cs new file mode 100644 index 0000000..db0f9ae --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD113.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD113 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电口号 + /// + public byte ChargNum { get; set; } + /// + /// 标志 + /// 1-查询 + /// + public byte Sign { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1301.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1301.cs new file mode 100644 index 0000000..ec8e60c --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1301.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1301 + { + /// + /// 预留1 长度2byte + /// + public ushort Reserved1 { get; set; } + /// + /// 预留2 长度2byte + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 白名单类型 + /// 1-充电卡号 2-VIN 码 + /// + public byte WhitelistType { get; set; } + /// + /// 操作 + /// 0 增加 2 清空 4:查询白名单版本号(7.8 字段不需要) + /// + public byte Operate { get; set; } + /// + /// 白名单版本号 + /// 当前下发的名单版本号。服务器向充电系统发送的版本号为0 时则充电系统将清空白名单。 + /// + public uint WhitelistVersioNum { get; set; } + /// + /// 下发的白名单条数 + /// + public uint WhitelistNum { get; set; } + + + /// + /// 车辆VIN/充电卡号 + /// 卡号不足 32 位的,在尾部填’\0’字段 4 类型为充电卡时,此字段为 32字节, + /// 类型为 VIN 时,此字段为 32 字节 + /// + public string VINCarID01 { get; set; } + public string VINCarID02 { get; set; } + public string VINCarID03 { get; set; } + public string VINCarID04 { get; set; } + public string VINCarID05 { get; set; } + public string VINCarID06 { get; set; } + public string VINCarID07 { get; set; } + public string VINCarID08 { get; set; } + public string VINCarID09 { get; set; } + public string VINCarID10 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1401.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1401.cs new file mode 100644 index 0000000..539878b --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1401.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1401 + { + /// + /// 预留1 长度2byte + /// + public ushort Reserved1 { get; set; } + /// + /// 预留2 长度2byte + /// + public ushort Reserved2 { get; set; } + /// + /// 升级软件文件版本号 + /// HEX 整形,例如:209.02 表示为:A6 51 + /// + public string UpFileVersioNum { get; set; } + /// + /// FTP 服务器 IP 地址 32 + /// 例:IP:16.80.1.20 指令为:0x10 0x50 0x01 0x14 + ///该字段为空时,使用本地默认FTP 地址。建议默认使用 IP 方式 + /// + public string ServerIP { get; set; } + /// + /// ftp用户名 16byte 不足补)0x00 16 + /// + public string UserName { get; set; } + /// + /// ftp密码 16byte 不足补)0x00 16 + /// + public string Password { get; set; } + /// + /// ftp下载路径 64byte 64 + ///字符串,不足补 0x00,示例: + /// ftp://172.16.4.254/SINEXCEL + ///dcharg.bin 情况下: + ///此字段填充 + ///”/SINEXCEL /dcharg.bin” + /// + public string DownloadPath { get; set; } + /// + /// 执行方式 1:空闲执行 + /// + public byte ExecutiveMode { get; set; } + /// + /// 本次升级设备类型 + /// 0/1: 交 直 流 主 监 控 板(TCU/S7/S1/交流桩) + /// 2:CCU -充电控制器 + /// 3:DCDC 模块 + /// 4:ACDC 模块 + /// 5: 群充控制器 + /// 6:分体机主机控制器 + /// 7.V6-STM32-AC V6 交流桩 + /// 8.V6-GD-AC V6 交流桩 + /// 若没有下发此字段,默认就是升级充电机 TCU/S1/S7 主控制器 + /// + public byte DeviceType { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1406.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1406.cs new file mode 100644 index 0000000..f08bd93 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1406.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1406 + { + /// + /// 预留1 长度2byte + /// + public ushort Reserved1 { get; set; } + /// + /// 预留2 长度2byte + /// + public ushort Reserved2 { get; set; } + /// + /// 获取日志类型 + /// 1.bms 日志 2.系统日志 3.记录日志 4.全部日志 + /// + public byte LogType { get; set; } + /// + /// FTP 服务器 IP 地址 32 + /// 例:IP:16.80.1.20 指令为:0x10 0x50 0x01 0x14 + ///该字段为空时,使用本地默认FTP 地址。建议默认使用 IP 方式 + /// + public string ServerIP { get; set; } + /// + /// ftp用户名 16byte 不足补)0x00 16 + /// + public string UserName { get; set; } + /// + /// ftp密码 16byte 不足补)0x00 16 + /// + public string Password { get; set; } + /// + /// ftp存放日志路径 32 + /// + public string LogPath { get; set; } + /// + /// 执行方式 1:空闲执行 2:立即执行 + /// + public byte ExecutiveMode { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1502.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1502.cs new file mode 100644 index 0000000..ca823fc --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1502.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1502 + { + /// + /// 预留1 长度2byte + /// + public ushort Reserved1 { get; set; } + /// + /// 预留2 长度2byte + /// + public ushort Reserved2 { get; set; } + /// + /// 应答码 + /// 0-允许发送 其他-不支持日志上传 + /// + public uint AnswerCode { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1504.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1504.cs new file mode 100644 index 0000000..f6c3e93 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD1504.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD1504 + { + /// + /// 预留1 长度2byte + /// + public ushort Reserved1 { get; set; } + /// + /// 预留2 长度2byte + /// + public ushort Reserved2 { get; set; } + /// + /// 标识 + /// 0-正常接收 + /// 1-接收出错,中断此次日志上传 + /// + public uint Sign { get; set; } + /// + /// 已成功接收的报文编号 + /// 这个要与最后一次收到的 1503 报文中的字段 4 一样。 + /// + public uint ReceiveMessageNum { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD201.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD201.cs new file mode 100644 index 0000000..0099e15 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD201.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD201 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电口号 + /// + public byte ChargNum { get; set; } + /// + /// 充电卡号 32 + /// + public string ChargID { get; set; } + /// + /// 内部索引号 + /// + public int IndexNum { get; set; } + /// + /// 7、8、9 字段有效标志 + /// 0- 无效 + /// 1- 有效 + /// + public byte ValidMark { get; set; } + /// + /// 充电优惠前金额 + /// + public uint InitialCost { get; set; } + /// + /// 充电折扣金额 + /// + public uint DiscountCost { get; set; } + /// + /// 充电实扣金额 + /// + public uint NetCost { get; set; } + /// + /// 用户剩余金额 + /// + public uint Balance { get; set; } + /// + /// 充电实扣电费 + /// + public uint NetElectricCost { get; set; } + /// + /// 充电实扣服务费 + /// + public uint NetServiceCost { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD203.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD203.cs new file mode 100644 index 0000000..b396e14 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD203.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD203 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 响应码 + /// 0:有效帐户 + /// 1:非法帐户(黑卡等) + /// 2:余额不足 + /// 3:把黑卡恢复成正常卡 + /// 4:把正常卡变黑卡 + /// 5:非法卡号(卡号不存在) + /// 6:挂失 + /// 7:销卡(桩端写卡) + /// 8.密码错误 + /// 9.功能不支持 + /// + public uint ResCode { get; set; } + /// + /// 帐户余额 + /// + public uint Balance { get; set; } + /// + /// 全时段电费费率 + /// + public ushort SumEleRate { get; set; } + /// + /// 服务费率(预留) + /// + public ushort EleRate { get; set; } + /// + /// 充电密码验证 + /// 0-不验证 + /// 1-验证 + /// + public byte ChargPassword { get; set; } + /// + /// 验证 VIN 标志 + /// 0-不验证 + /// 1-验证 + /// + public byte VINSign { get; set; } + /// + /// 车牌验证(预留 + /// 0-不验证 + /// 1-验证 + /// + public byte CarIDVerify { get; set; } + /// + /// 预留 + /// + public byte Reserved3 { get; set; } + /// + /// 流水号 32 + /// 后台不下发则本地生成(推荐 ASCII) + /// + public string SerialNum { get; set; } + /// + /// VIN 17 + /// + public string VIN { get; set; } + /// + /// 充电枪号 + /// + public byte ChargGunNum { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD205.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD205.cs new file mode 100644 index 0000000..e7dd384 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD205.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD205 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 响应码 + /// 0:密码正确 + /// 其它:密码错误 + /// + public uint ResponseCode { get; set; } + /// + /// 帐户余额(密码正确是填真实数据,否则填 0) + /// + public uint Balance { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD207.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD207.cs new file mode 100644 index 0000000..aa952f9 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD207.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD207 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码(ASCII 编码) + /// + public string ASCIINum { get; set; } + /// + /// 充电枪号 + /// + public ushort ChargGunNum { get; set; } + /// + /// 车辆 VIN 码(ASCII 编码) + /// + public string VINNum { get; set; } + /// + /// 车辆 VIN 绑定账号(ASCII 编码,可以是卡号/账号等,如无则填 0xff. 离线充电则由桩填写空) + /// + public string VINBindAccount { get; set; } + /// + /// 充电流水号(ASCII 编码,验证通过平台应下发本次充电的流水号,离线的话由桩本地生成流水号。) + /// + public string ChargSerialNum { get; set; } + /// + /// 验证结果 + /// 1:成功可启动充电。 + /// 2:失败停止充电。 + /// + public byte VerifyResult { get; set; } + /// + /// 验证原因 + /// 当字段 7 为 2,此字段有意义: + /// 1:余额不足 + /// 2:车辆被冻结 + /// 3:黑名单车辆 + /// 4:未知车辆 + /// 5:当前车辆不允许 VIN 充电, + /// 6:其他原因 + /// + public byte VerifyCause { get; set; } + /// + /// 可充电余额 + /// + public uint RechBalance { get; set; } + /// + /// 屏幕停机密码 + /// (ASIIC 编码,密码纯数字。当桩即插即充启动成功后, + /// 可以在屏幕上输入此密码进行停机,如果没有则填 0xff。) + /// + public ulong StopCode { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD209.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD209.cs new file mode 100644 index 0000000..87b1e91 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD209.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD209 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电桩编码 32 + /// + public string ASCIINum { get; set; } + /// + /// 充电枪号 + /// + public byte ChargGunNum { get; set; } + /// + /// 车辆 VIN 码 17 + /// + public string VINNum { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD3.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD3.cs new file mode 100644 index 0000000..0eaa77a --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD3.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD3 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 类型 + /// 0查询 + /// 1设置 + /// + public byte Type { get; set; } + /// + /// 设置/查询参数起始地址 + /// + public uint SAddress { get; set; } + /// + /// 设置参数字节数 + /// + public ushort SBytes { get; set; } + /// + /// 设置数据 + /// + public byte[] SData { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD301.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD301.cs new file mode 100644 index 0000000..903b73a --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD301.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD301 + { + /// + /// 预留1 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留2 + /// + public ushort Reserved2 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD303.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD303.cs new file mode 100644 index 0000000..26d0f82 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD303.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD303 + { + /// + /// 预留1 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留2 + /// + public ushort Reserved2 { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD401.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD401.cs new file mode 100644 index 0000000..2ca03be --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD401.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD401 + { + /// + /// 预留1 长度2byte + /// + public ushort Reserved1 { get; set; } + /// + /// 预留2 长度2byte + /// + public ushort Reserved2 { get; set; } + /// + /// 查询记录起始索引 + /// 值越大表示越旧, + /// 0 表示查询最近一条充电记录 + /// 1 表示查询最近倒数第 2 次充电记录,以此类推 + /// + public uint SelectIndex { get; set; } + /// + /// 充电流水号 32 + /// + public string ChargSerialNum { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD5.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD5.cs new file mode 100644 index 0000000..3455bb1 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD5.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD5 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电口 + /// + public byte RechargeableMuzzle { get; set; } + /// + /// 起始命令地址 + /// 1-----预留 + /// 2-----停止充电 + /// 3-----预留 + /// 4-----充电控制方式 + /// 5-----预留 + /// 6-----预留 + /// 7-----电阻模式输出电压 + /// 8-----电阻模式输出电流 + /// 9-----充电模式 + /// 10----取消预约充电 + /// 11----设备重启 + /// 12----进入升级模式 + /// 13----进入正常应用模式 + /// 14----立即上报一次签到106 报文 + /// 15----立即上报一次桩状态信息 104 报文 + /// 16----扫描支付成功 + /// 17----实时充电(限制)最大充电功率 + /// 18----负载类型 + /// 19----绝缘检测 + /// 20----模块类型 + /// 21----本地计费 + /// 22----刷卡密码输入流程 + /// 23----充电暂停服务 + /// 24----输出电压较准 + /// 25----离线时默认限功率 + /// 26----充电机限电流 + /// + public uint CommandAddress { get; set; } + /// + /// 命令个数 + /// + public byte CommandNum { get; set; } + /// + /// 命令参数长度 + /// + public ushort CommandLength { get; set; } + /// + /// 命令参数 + /// + public byte[] CommandData { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD7.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD7.cs new file mode 100644 index 0000000..41633c2 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD7.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD7 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved { get; set; } + /// + /// 充电枪口 + /// + public byte ChargMuzzle { get; set; } + /// + /// 充电生效类型 + /// 0:即时充电 + /// 1:定时启动充电 + /// 2:预约充电 + /// + public uint ChargeType { get; set; } + /// + /// 界面充电停止密码 + /// 此字段为整数形字段建议为用户卡号最后 4 位, + /// 若服务器没有下发此字段, + /// 桩默认取充电卡号的最后 4 + /// 位 , 如 卡 号 + /// “1122334455667788”,其 + /// 最后 4 位是“7788”,而不 + /// 是 0,若后台不下发此字段, + /// 默认使用 0 填充,此数为 0 + /// 时桩自动取字段10的未 4/6 + /// 位当做停止充电密码。 + /// + public uint ChargeStopPassword { get; set; } + /// + /// 充电策略 + /// 0:充满为止 + /// 1:按时间充电 + /// 2:按金额充电 + /// 3:按电量充电 + /// + public uint ChargStrategy { get; set; } + /// + /// 充电策略参数 + /// 时间单位为 1 秒 + /// 金额单位为 0.01 元 + /// 电量时单位为 0.01kw + /// + public uint ChargStrategyPara { get; set; } + /// + /// 预约/定时启动时间(标准时间) + /// + public ulong ScheduleStartupTime { get; set; } + /// + /// 预约超时时间(单位分钟) + /// + public byte OutTime { get; set; } + /// + /// 用户卡号/用户识别号(内容只能”0~9、A~Z、a~z 字符 ASCII 码,不够长度填’\0’) + /// + public string CardNumber { get; set; } + /// + /// 断网充电标志 + /// 0-不允许 + /// 1-允许 + /// + public byte NetOutageSign { get; set; } + /// + /// 离线时本次最大可充电总电量 + /// 分辨率 0.01kw若字段 11、12 都是 0,表示不限制离线可充电量,即允许客户在桩离线时充满电 + /// + public uint MaxElectric { get; set; } + /// + /// 充电流水号 32 + /// + public string SerialNum { get; set; } + /// + /// BMS 辅源电压 + /// + public byte BMSVoltage { get; set; } + /// + /// 用户账号余额 + /// + public uint Balance { get; set; } + /// + /// 充放电标志 + /// + public byte DisOrChargeMark { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD9.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD9.cs new file mode 100644 index 0000000..042290f --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD9.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class CMD9 + { + /// + /// 预留 + /// + public ushort Reserved1 { get; set; } + /// + /// 预留 + /// + public ushort Reserved2 { get; set; } + /// + /// 充电枪号 + /// + public byte ChargGunNum { get; set; } + /// + /// 执行结果 + /// + public uint FWResult { get; set; } + /// + /// 命令地址 + /// + public uint CommandAddress { get; set; } + /// + /// 数据长度 + /// + public uint DataLength { get; set; } + /// + /// 数据 + /// + public byte[] Datas { get; set; } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Service/ByteUtils.cs b/HybirdFrameworkServices/Charger/BatCharging.Service/ByteUtils.cs new file mode 100644 index 0000000..ea11f5f --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Service/ByteUtils.cs @@ -0,0 +1,299 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class ByteUtils + { + /// + /// 十六进制字符串转字符串 + /// + /// + /// + public static string StrHex2Str(string strHex) + { + byte[] keyWord = new byte[strHex.Length / 2]; + string strResult = ""; + for (int i = 0; i < keyWord.Length; i++) + { + try + { + keyWord[i] = (byte)(0xff & Convert.ToInt32(strHex.Substring(i * 2, 2), 16)); + strResult += Convert.ToChar(keyWord[i]).ToString(); + } + catch (Exception e) + { + e.ToString(); + } + } + + return strResult; + } + + /// + /// 字符串转16进制字符串 + /// + /// + /// + public static string Str2HexStr(string strSrc) + { + char[] chTemp = strSrc.ToCharArray(); + string strResult = ""; + foreach (var ch in chTemp) + { + int value = Convert.ToInt32(ch); + strResult += String.Format("{0:X}", value); + } + + //strResult = "6000" + strResult; + return strResult; + } + + /// + /// 根据高位优先的原理的两字节数据解析返回一个16为无符号整数 + /// + /// 原字节数组(含有两字节) + /// 返回无符号整数 + public static ushort ToUInt16(byte[] value) + { + return (ushort)((value[0] << 8) | (value[1] & 0x00FF)); + } + + /// + /// 根据高位优先的原理的两字节数据解析返回一个16为无符号整数 + /// + /// 原字节数组 + /// 缓冲区偏移 + /// 返回无符号整数 + public static UInt16 ToUInt16(byte[] value, int offset) + { + return (ushort)((value[offset] << 8) | (value[offset + 1] & 0x00FF)); + } + /// + /// 根据高位优先颠倒的原理的两字节数据解析返回一个16为无符号整数 + /// + /// 原字节数组 + /// 缓冲区偏移 + /// 返回无符号整数 + public static UInt16 DToUInt16(byte[] value, int offset) + { + return (ushort)(value[offset] + (value[offset + 1] << 8)); + } + + public static UInt32 ToUInt32(byte[] value, int offset) + { + UInt16 low = (ushort)((value[offset + 1] << 8) | (value[offset] & 0x00FF)); + UInt16 height = (ushort)((value[offset + 3] << 8) | (value[offset + 2] & 0x00FF)); + + return (UInt32)(height << 16 | low); + } + public static UInt32 DToUInt32(byte[] value, int offset) + { + UInt16 low = (ushort)((value[offset + 1] << 8) | (value[offset] & 0x00FF)); + UInt16 height = (ushort)((value[offset + 3] << 8) | (value[offset + 2] & 0x00FF)); + + return (UInt32)(height << 16 | low); + } + + + /// + /// 16进制数高地位对调 + /// + /// + /// + public static byte[] Int16ToByteArray(Int16 value) //16进制数高地位对调 + { + byte[] bytesResult = new byte[2]; + byte[] temp = new byte[2]; + + BitConverter.GetBytes(Convert.ToInt16(value)).CopyTo(temp, 0); + + bytesResult[0] = temp[1]; + bytesResult[1] = temp[0]; + + return bytesResult; + } + /// + /// 32进制数高地位对调 + /// + /// + /// + public static byte[] Int32ToByteArray(Int32 value) //16进制数高地位对调 + { + byte[] bytesResult = new byte[4]; + byte[] temp = new byte[4]; + + BitConverter.GetBytes(Convert.ToInt32(value)).CopyTo(temp, 0); + + bytesResult[0] = temp[3]; + bytesResult[1] = temp[2]; + bytesResult[2] = temp[1]; + bytesResult[3] = temp[0]; + + return bytesResult; + } + + /// + /// 获取16进制字符串的字节数组 + /// + /// hexString 16进制字符串 + /// 字节数组 + public static byte[] ToByteByHexStr(string hexString) + { + if (hexString == null) + return null; + + hexString = hexString.Replace(" ", ""); + if ((hexString.Length % 2) != 0) + hexString += " "; + byte[] returnBytes = new byte[hexString.Length / 2]; + for (int i = 0; i < returnBytes.Length; i++) + returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16); + return returnBytes; + } + /// + /// 获取32进制字符串的字节数组 + /// + /// hexString 16进制字符串 + /// 字节数组 + public static byte[] ToByteByHexStr32(string hexString, int leng) + { + byte[] bytes = new byte[leng]; + // 使用UTF8编码将字符串转换为字节数组 + byte[] byteArray = Encoding.ASCII.GetBytes(hexString); + + // 如果需要确保数组长度为32字节,可以添加逻辑来处理长度不足的情况 + if (byteArray.Length < leng) + { + Array.Copy(byteArray, 0, bytes, 0, byteArray.Length); + } + //else if (byteArray.Length > leng) + //{ + // // 长度超过32字节,可以截断或者抛出异常 + // Array.Copy(byteArray, 0, new byte[leng], 0, leng); // 截断数组到32字节 + //} + return bytes; + } + + /// + /// 获取16进制字符串的字节数组 + /// + /// hexString 16进制字符串 + /// 字节数组 + public static byte[] ToByteByStr(string strValue) + { + #region 转化到十六进制字符串 + + char[] chTemp = strValue.ToCharArray(); + string strHex = ""; + foreach (var ch in chTemp) + { + int value = Convert.ToInt32(ch); + strHex += String.Format("{0:X}", value); + } + + #endregion 转化到十六进制字符串 + + if (strHex == null) + return null; + + strHex = strHex.Replace(" ", ""); + if ((strHex.Length % 2) != 0) + strHex += " "; + byte[] returnBytes = new byte[strHex.Length / 2]; + for (int i = 0; i < returnBytes.Length; i++) + returnBytes[i] = Convert.ToByte(strHex.Substring(i * 2, 2), 16); + + return returnBytes; + } + + public static string BytesToHexStr(byte[] data) + { + StringBuilder sb = new StringBuilder(data.Length * 3); + foreach (byte b in data) + sb.Append(Convert.ToString(b, 16).PadLeft(2, '0') + " "); + return sb.ToString().ToUpper(); + } + + /// + /// 字节转换成布尔数组 + /// + /// + /// + public static bool[] ByteToBoolArray(byte value) + { + bool[] array = new bool[8]; + for (int i = 0; i <= 7; i++) + { + //对于byte的每bit进行判定 + array[i] = (value & 1) == 1; //判定byte的最后一位是否为1,若为1,则是true;否则是false + value = (byte)(value >> 1); //将byte右移一位 + } + + return array; + } + + + /// + /// UInt16转换成布尔数组 + /// + /// 16位无符号整形 + /// 布尔数组 + public static bool[] UInt16ToBoolArray(ushort value) + { + bool[] array = new bool[16]; + for (int i = 0; i <= 15; i++) + { + //对于byte的每bit进行判定 + array[i] = (value & 1) == 1; //判定byte的最后一位是否为1,若为1,则是true;否则是false + value = (ushort)(value >> 1); //将byte右移一位 + } + + return array; + } + + public static string CP56time2aToStr(byte[] bytes) + { + return "20" + Convert.ToInt32(bytes[6]).ToString("00") + "-" + Convert.ToInt32(bytes[5]).ToString("00") + + "-" + Convert.ToInt32(bytes[4]).ToString("00") + " " + Convert.ToInt32(bytes[3]).ToString("00") + + ":" + Convert.ToInt32(bytes[2]).ToString("00") + ":" + + (ToFUInt16(bytes, 0) / 1000).ToString("00"); + } + + public static ushort ToFUInt16(byte[] value, int offset) + { + return (ushort)((value[offset + 1] << 8) | (value[offset] & 0x00FF)); + } + + /// + /// BCD码转byte + /// + /// + /// + public static byte BCDToByte(byte value) + { + //高四位 + byte high = (byte)((value >> 4 & 0xF)); + //低四位 + byte low = (byte)(value & 0xF); + return (byte)(high * 10 + low); + } + + /// + /// byte转BCD码 + /// + /// + /// + public static byte ByteToBCD(byte value) + { + //高四位 + byte high = (byte)(value / 10); + //低四位 + byte low = (byte)(value % 10); + return (byte)(high << 4 | low); + } + } +} diff --git a/HybirdFrameworkServices/Charger/BatCharging.Service/ChargerMgrTool.cs b/HybirdFrameworkServices/Charger/BatCharging.Service/ChargerMgrTool.cs new file mode 100644 index 0000000..e812993 --- /dev/null +++ b/HybirdFrameworkServices/Charger/BatCharging.Service/ChargerMgrTool.cs @@ -0,0 +1,5190 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Reflection; +using System.Threading.Tasks; +using System.Threading; +using HybirdFrameworkEntity; +using System.Text; +using Newtonsoft.Json; +using System.Linq; +using DotNetty.Transport.Channels; +using HybirdFrameworkServices.Netty; + +namespace HybirdFrameworkServices +{ + /// + /// 1ų + /// + public class ChargerMgrTool + { + Server Server = new Server(); + #region + + private object lockObj = new object(); //߳ͬ + + #endregion + + #region ֶ + + #region Ϣ + private IChannelId _id; + public IChannelId ID + { + get { return _id; } + set + { + lock (lockObj) + { + _id = value; + } + } + } + + /// + /// IPַ + /// + private string _ip_addr; + + /// + /// IPַ + /// + public string F_IPAddr + { + get { return _ip_addr; } + set + { + lock (lockObj) + { + _ip_addr = value; + } + } + } + + /// + /// ˿ں + /// + private int _ip_port = 4567; + + /// + /// ˿ں + /// + public int F_Port + { + get { return _ip_port; } + set + { + lock (lockObj) + { + _ip_port = value; + } + } + } + + /// + /// ͨѶǷ + /// + private bool _net_connected = false; + + /// + /// ͨѶǷ + /// + public bool F_NetConnected + { + get { return _net_connected; } + set + { + lock (lockObj) + { + _net_connected = value; + } + } + } + + /// + /// ǷѾȨ + /// + private bool _is_authed = false; + + /// + /// վǷѾȨ + /// + public bool F_IsAuthed + { + get { return _is_authed; } + set + { + lock (lockObj) + { + _is_authed = value; + } + } + } + + + /// + /// ͨѶж϶߳ʱʱ䣨λ룩 + /// + private int _net_check_time_out = 30; + + /// + /// ͨѶж϶߳ʱʱ䣨λ룩 + /// + public int F_NetCheckTimeOut + { + get { return _net_check_time_out; } + set + { + lock (lockObj) + { + _net_check_time_out = value; + } + } + } + + /// + /// + /// + private string _eqmcode; + /// + /// + /// + public string F_EqmCode + { + get { return _eqmcode; } + set + { + lock (lockObj) + { + _eqmcode = value; + } + } + } + + /// + /// ܱʶ + /// + private bool _sign; + /// + /// ܱʶ + /// + public bool F_Sign + { + get { return _sign; } + set + { + lock (lockObj) + { + _sign = value; + } + } + } + + /// + /// ʱ + /// + private DateTime _recving_data_time = DateTime.Now; + + /// + /// ʱ + /// + public DateTime F_RecvingDataTime + { + get { return _recving_data_time; } + set + { + lock (lockObj) + { + _recving_data_time = value; + } + } + } + /// + /// ۼֵ + /// + private ushort _accumulation; + /// + /// ۼֵ + /// + public ushort F_Accumulation + { + get + { + return _accumulation; + } + set + { + lock (lockObj) + { + _accumulation = value; + } + } + } + + + + + /// + /// ǷѾʼ + /// + private bool _is_charged = false; + + /// + /// ǷѾʼ + /// + public bool F_IsCharged + { + get { return _is_charged; } + set + { + lock (lockObj) + { + _is_charged = value; + } + } + } + + /// + /// Ƿֹͣ + /// + private bool _is_stoped = false; + + /// + /// Ƿֹͣ + /// + public bool F_IsStoped + { + get { return _is_stoped; } + set + { + lock (lockObj) + { + _is_stoped = value; + } + } + } + + + /// + /// 翪ʼʱ䣨Ĭ2000-1-1 + /// + private DateTime _charging_start_time = Convert.ToDateTime("2000-1-1"); + + /// + /// 翪ʼʱ䣨Ĭ2000-1-1 + /// + public DateTime F_ChargingStartTime + { + get { return _charging_start_time; } + set + { + lock (lockObj) + { + _charging_start_time = value; + } + } + } + + /// + /// ֹͣʱ䣨Ĭ2000-1-1 + /// + private DateTime _charging_stop_time = Convert.ToDateTime("2000-1-1"); + + /// + /// ֹͣʱ䣨Ĭ2000-1-1 + /// + public DateTime F_ChargingStopTime + { + get { return _charging_stop_time; } + set + { + lock (lockObj) + { + _charging_stop_time = value; + } + } + } + + /// + /// óֹͣԭ.0ͣ 1׮쳣,ǿͣ + /// + private byte _stop_reason = 0; + + /// + /// óֹͣԭ.0ͣ 1׮쳣,ǿͣ + /// + public byte F_StopReason + { + get { return _stop_reason; } + set + { + lock (lockObj) + { + _stop_reason = value; + } + } + } + + /// + /// ѭԶָֹͣյظֹͣɺΪFalse + /// + private bool _is_can_send_stop_cmd = true; + + /// + /// óֹͣԭ.0ͣ 1׮쳣,ǿͣ + /// + public bool F_IsCanSendStopCmd + { + get { return _is_can_send_stop_cmd; } + set + { + lock (lockObj) + { + _is_can_send_stop_cmd = value; + } + } + } + + /// + /// ¼ǷѾ͸ƽ̨ + /// + internal bool _record_to_cloud_sended = false; + + /// + /// ¼ǷѾ͸ƽ̨ + /// + public bool F_RecordToCloudSended + { + get { return _record_to_cloud_sended; } + set + { + lock (lockObj) + { + _record_to_cloud_sended = value; + } + } + } + + + /// + /// ״̬-ңݰеõ0:12ɣ3/ŵͣ + /// + private byte _workstate; + + /// + /// ״̬-ңݰеõ0:12ɣ3/ŵͣ + /// + public byte F_WorkState + { + get { return _workstate; } + set + { + lock (lockObj) + { + _workstate = value; + } + } + } + + /// + /// + /// + private bool _is_fault; + + /// + /// -true:ϣfalse: + /// + public bool F_IsFault + { + get { return _is_fault; } + set + { + lock (lockObj) + { + _is_fault = value; + } + } + } + + /// + /// + /// + private bool _is_alarm; + + /// + /// -true:false: + /// + public bool F_IsAlarm + { + get { return _is_alarm; } + set + { + lock (lockObj) + { + _is_alarm = value; + } + } + } + + /// + /// + /// + private int _fault_number = 0; + + /// + /// + /// + public int F_FaultNumber + { + get { return _fault_number; } + set + { + lock (lockObj) + { + _fault_number = value; + } + } + } + + /// + /// ϱб + /// + private List _fault_alaram_no_list = new List(); + + /// + /// ϱб + /// + public List F_FaultAlarmNoList + { + get { return _fault_alaram_no_list; } + set + { + lock (lockObj) + { + _fault_alaram_no_list = value; + } + } + } + + /// + ///SOC + /// + private byte _soc = 0; + + /// + /// SOC + /// + public byte F_SOC + { + get { return _soc; } + set + { + lock (lockObj) + { + _soc = value; + } + } + } + + /// + ///ʵʱ繦 + /// + private float _power = 0; + + /// + /// ʵʱ繦 + /// + public float F_Power + { + get { return _power; } + set + { + lock (lockObj) + { + _power = value; + } + } + } + + + //private int alarmProcessCounter = 0; + /// + /// + /// + private static ushort HeartBeatProcessCounter = 0; + + + + + + #endregion Ϣ + + + #region Ϣ + + + + #endregion Ϣ + + #endregion ֶ + + #region ṹ + + public ChargerMgrTool() + { + } + + + /// + /// ṹ + /// + /// IPַ + /// ˿ں + public ChargerMgrTool(string ipAddr, int port) + { + _ip_addr = ipAddr; + _ip_port = port; + } + + /// + /// + /// + /// IPַ + /// ˿ں + /// Ŀĵַֽ + public ChargerMgrTool(IChannelId id, string ipAddr, int port, string eqmcode) + { + _id = id; + _ip_addr = ipAddr; + _ip_port = port; + _eqmcode = eqmcode; + } + + #endregion ṹ + + #region ¼ + + + #endregion ¼ + + #region ¼ + + #endregion ¼ + + #region ͨѶ߳ + /// + /// ̺߳Ͷ߳ + /// + public void ChargerNetHeartBeatThread() + { + Thread chrgConnectedThread = new Thread(ChargerHeartBeatFunc); + chrgConnectedThread.IsBackground = true; + chrgConnectedThread.Start(); + } + /// + /// жǷ߳ + /// + public void ChargerNetCheckThread() + { + Thread chargerThread = new Thread(ChargerNetCheckFunc); + chargerThread.IsBackground = true; + chargerThread.Start(); + } + /// + /// + /// + public void ChargerHeartBeatFunc() + { + while (F_IsAuthed) + { + Thread.Sleep(2000); + byte[] bytes = Send101(F_Accumulation); + + if (Server != null) + { + Server.Send(bytes); + } + } + } + + + /// + /// жǷ߳.£30δյϢΪߣҪ + /// + private void ChargerNetCheckFunc() + { + while (F_IsAuthed) + { + Thread.Sleep(2000); + + DateTime recvTime = DateTime.Now; + int seconds = Convert.ToInt32(recvTime.Subtract(F_RecvingDataTime).TotalSeconds); + if (seconds >= _net_check_time_out) + { + //ChargerDisConnect(); + } + } + } + #endregion ͨѶ߳ + + #region ݽ + + + public void decode(string IP, string port, byte[] data) + { + switch (IP) + { + case "1": + + break; + case "2": + break; + case "3": + break; + case "4": + break; + case "5": + break; + } + int func = (ushort)(data[6] + (data[6 + 1] << 8)); + F_RecvingDataTime = DateTime.Now; + switch (func) + { + #region /ѯ + + case 2: + { + CMD2 CMD2 = ConCMD2(data); + string result = "(CMD=2)׮/ѯӦ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=2)׮/ѯӦ" + JsonConvert.SerializeObject(CMD2); + ////Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 4: + { + CMD4 CMD4 = ConCMD4(data); + string result = "(CMD=4)׮ַ/ѯӦ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=4)׮ַ/ѯӦ" + JsonConvert.SerializeObject(CMD4); + ////Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 6: + { + CMD6 CMD6 = ConCMD6(data); + string result = "(CMD=6)׮Ժ̨Ӧ- ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=6)׮Ժ̨Ӧ" + JsonConvert.SerializeObject(CMD6); + ////Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 8: + { + CMD8 CMD8 = ConCMD8(data); + string result = "(CMD=8) ׮Ժ̨·ij׮Ӧ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=8) ׮Ժ̨·ij׮Ӧ" + JsonConvert.SerializeObject(CMD8); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 10: + { + CMD10 CMD10 = ConCMD10(data); + string result = "(CMD=10)׮ϴ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ϴ(Ԥ)" + JsonConvert.SerializeObject(CMD10); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + #endregion + + #region ׮ϴ + + case 102: + { + CMD102 CMD102 = ConCMD102(data); + string result = "(CMD=10)׮ϴϢ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ϴϢ" + JsonConvert.SerializeObject(CMD102); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + HeartBeatProcessCounter += 1; + byte[] bytes = Send101(HeartBeatProcessCounter); + + if (Server != null) + { + Server.Send(bytes); + } + } + break; + case 104: + { + CMD104 CMD104 = ConCMD104(data); + string result = "(CMD=10)׮״̬Ϣϱ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮״̬Ϣϱ" + JsonConvert.SerializeObject(CMD104); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 106: + { + CMD106 CMD106 = ConCMD106(data); + string result = "(CMD=10)׮ǩϢϱ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ǩϢϱ" + JsonConvert.SerializeObject(CMD106); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + if (CMD106 != null) + { + F_EqmCode = CMD106.ASCIINum; + F_Sign = CMD106.Sign == 1 ? true : false; + } + } + break; + case 108: + { + CMD108 CMD108 = ConCMD108(data); + string result = "(CMD=10)׮澯Ϣϱ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮澯Ϣϱ(Ԥ)" + JsonConvert.SerializeObject(CMD108); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 110: + { + CMD110 CMD110 = ConCMD110(data); + string result = "(CMD=10)׮ϱ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ϱ(Ԥ)" + JsonConvert.SerializeObject(CMD110); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 112: + { + CMD112 CMD112 = ConCMD112(data); + string result = "(CMD=10)׮ģϢϱ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ģϢϱ" + JsonConvert.SerializeObject(CMD112); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 114: + { + CMD114 CMD114 = ConCMD114(data); + string result = "(CMD=10)׮ӦѯһγʱϢ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ӦѯһγʱϢ" + JsonConvert.SerializeObject(CMD114); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region Ϣ + + case 202: + case 222: + { + CMD202 CMD202 = ConCMD202((UInt16)func, data); + string result = "׮ϱ¼Ϣ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "ϱ¼Ϣ" + JsonConvert.SerializeObject(CMD202); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 204: + { + CMD204 CMD204 = ConCMD204(data); + string result = "׮ϴû˻ѯ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϴû˻ѯĶ" + JsonConvert.SerializeObject(CMD204); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 206: + { + CMD206 CMD206 = ConCMD206(data); + string result = "׮ϴû֤ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϴû֤Ķ" + JsonConvert.SerializeObject(CMD206); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 208: + { + CMD208 CMD208 = ConCMD208(data); + string result = "׮ϱ弴䡱 - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϱ弴䡱" + JsonConvert.SerializeObject(CMD208); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 210: + { + CMD210 CMD210 = ConCMD210(data); + string result = "׮ϱ弴䡱 - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϱ弴䡱" + JsonConvert.SerializeObject(CMD210); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region ֱ׮ BMS Ϣ(Ԥ) + case 302: + { + CMD302 CMD302 = ConCMD302(data); + string result = "׮ϱBMSϢ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϱBMSϢ" + JsonConvert.SerializeObject(CMD302); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 304: + { + CMD304 CMD304 = ConCMD304(data); + string result = "׮ϱBMSϢ(Ԥ-ʱ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϱBMSϢ(Ԥ-ʱ)" + JsonConvert.SerializeObject(CMD304); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region ʷ¼ + case 402: + case 422: + { + CMD402 CMD402 = ConCMD402((UInt16)func, data); + string result = "׮ϱʷij¼ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ϱʷij¼" + JsonConvert.SerializeObject(CMD402); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + #endregion + + #region + case 1002: + { + CMD1002 CMD1002 = ConCMD1002(data); + string result = "׮ظ·ָ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ظ·ָ" + JsonConvert.SerializeObject(CMD1002); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1004: + { + CMD1004 CMD1004 = ConCMD1004(data); + string result = "׮Ӧ·ļָ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ļָ" + JsonConvert.SerializeObject(CMD1004); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1006: + { + CMD1006 CMD1006 = ConCMD1006(data); + string result = "׮Ӧ·ļСָ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ļСָ" + JsonConvert.SerializeObject(CMD1006); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1008: + { + CMD1008 CMD1008 = ConCMD1008(data); + string result = "׮Ӧ·ļָ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ļָ" + JsonConvert.SerializeObject(CMD1008); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1010: + { + CMD1010 CMD1010 = ConCMD1010(data); + string result = "׮Ӧ·ļݽָ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ļݽָ" + JsonConvert.SerializeObject(CMD1010); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1012: + { + CMD1012 CMD1012 = ConCMD1012(data); + string result = "׮Ӧ·ָ- ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ָ" + JsonConvert.SerializeObject(CMD1012); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1022: + { + CMD1022 CMD1022 = ConCMD1022(data); + string result = "׮ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮" + JsonConvert.SerializeObject(CMD1022); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region ƷѲصָ + case 1102: + { + CMD1102 CMD1102 = ConCMD1102(data); + string result = "׮Ӧ̨ѯ24ʱѼƼ۲Ϣ- ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ̨ѯ24ʱѼƼ۲Ϣ" + JsonConvert.SerializeObject(CMD1102); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1104: + { + CMD1104 CMD1104 = ConCMD1104(data); + string result = "׮Ӧ̨24ʱѼƼ۲Ϣ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ̨24ʱѼƼ۲Ϣ" + JsonConvert.SerializeObject(CMD1104); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1106: + { + CMD1106 CMD1106 = ConCMD1106(data); + string result = "׮Ӧ̨÷ʱμƼ۲Ϣ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ̨÷ʱμƼ۲Ϣ" + JsonConvert.SerializeObject(CMD1106); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1108: + { + CMD1108 CMD1108 = ConCMD1108(data); + string result = "׮ظʱѼƼ۲Ϣ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ظʱѼƼ۲Ϣ" + JsonConvert.SerializeObject(CMD1108); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region + case 1302: + { + CMD1302 CMD1302 = ConCMD1302(data); + string result = "׮Ӧ־ݰ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ־ݰ" + JsonConvert.SerializeObject(CMD1302); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region FTPԶFTPʽ־ϴ + case 1402: + { + CMD1402 CMD1402 = ConCMD1402(data); + string result = "׮Ӧ·FTPԶ- ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·FTPԶ" + JsonConvert.SerializeObject(CMD1402); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1403: + { + CMD1403 CMD1403 = ConCMD1403(data); + string result = "׮ӦFTPؽ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮ӦFTPؽȶ" + JsonConvert.SerializeObject(CMD1403); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1407: + { + CMD1407 CMD1407 = ConCMD1407(data); + string result = "׮Ӧ·ȡ׮־ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "׮Ӧ·ȡ׮־" + JsonConvert.SerializeObject(CMD1407); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + + #region Э鷽ʽ־ϴ + case 1501: + { + CMD1501 CMD1501 = ConCMD1501(data); + string result = "(CMD=1501ϴļ - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=1501ϴļ" + JsonConvert.SerializeObject(CMD1501); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + case 1503: + { + CMD1503 CMD1503 = ConCMD1503(data); + string result = "(CMD=10)׮ϴ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ϴ(Ԥ)" + JsonConvert.SerializeObject(CMD1503); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + + } + break; + case 1505://ɣҪر + { + CMD1505 CMD1505 = ConCMD1505(data); + string result = "(CMD=10)׮ϴ(Ԥ) - ֽݣ" + ByteUtils.BytesToHexStr(data) + ""; + result += "\r\n" + "(CMD=10)׮ϴ(Ԥ)" + JsonConvert.SerializeObject(CMD1505); + //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + ""); + } + break; + #endregion + } + } + + + #endregion ݽ + + #region ݷ + + #region ׮/ѯ + /// + /// (CMD=1)̨·׮ι + /// + /// + /// + /// + /// + /// + public byte[] Send1(byte type, uint startAddress, byte num, byte[] setData) + { + APDUModel APDUModel; + + CMD1 CMD1 = new CMD1(); + CMD1.Type = type; + CMD1.SetAddress = startAddress; + CMD1.SelectNum = num; + CMD1.SetByteNum = (ushort)(num * 4); + CMD1.SetData = setData; + + byte[] bytes = new ChargerSendCMD().SendRCMD1(out APDUModel, CMD1); + + if (APDUModel != null) + { + string result = "1̨·׮ι-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// (CMD=3) + /// + /// + /// + /// + public byte[] Send3(byte type, uint startAddress, byte[] setData) + { + APDUModel APDUModel; + + + CMD3 CMD3 = new CMD3(); + CMD3.Reserved1 = 0; + CMD3.Reserved2 = 0; + CMD3.Type = type; + CMD3.SAddress = startAddress; + CMD3.SBytes = cmd3StartAddress[startAddress]; + CMD3.SData = setData; + + byte[] bytes = new ChargerSendCMD().SendRCMD3(out APDUModel, CMD3); + + if (APDUModel != null) + { + string result = "3̨·׮ַͲ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + + /// + /// ̨·׮ + /// + /// + /// ǹ + /// ʼַ + /// + /// + public byte[] Send5(byte chargeMuzzle, uint startAddress, byte num, byte[] setData) + { + + APDUModel APDUModel; + + CMD5 CMD = new CMD5(); + CMD.RechargeableMuzzle = chargeMuzzle; + CMD.CommandAddress = startAddress; + CMD.CommandNum = num; + CMD.CommandLength = (ushort)(num * 4); + CMD.CommandData = setData; + + + byte[] bytes = new ChargerSendCMD().SendRCMD5(out APDUModel, CMD); + + if (APDUModel != null) + { + string result = "5̨·׮-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + + + /// + /// ̨·׮ + /// + /// + /// + public byte[] Send7(CMD7 CMD) + { + APDUModel APDUModel; + + byte[] bytes = new ChargerSendCMD().SendRCMD7(out APDUModel, CMD); + if (APDUModel != null) + { + + string result = "7̨·׮-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + + + + public byte[] Send9(byte chargeMuzzle, uint executeResult, uint address, byte[] setData) + { + APDUModel APDUModel; + + CMD9 CMD = new CMD9(); + + CMD.ChargGunNum = chargeMuzzle; + CMD.FWResult = executeResult; + CMD.CommandAddress = address; + CMD.DataLength = 4; + CMD.Datas = new byte[4]; + + byte[] bytes = new ChargerSendCMD().SendRCMD9(out APDUModel, CMD); + + if (APDUModel != null) + { + string result = "9̨Ӧ׮ϴ(Ԥ)-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + + #endregion + + #region ׮ϴ + /// + /// ӦϢ + /// + /// + /// Ӧ + public byte[] Send101(ushort heartbeatNum) + { + APDUModel APDUModel; + + CMD101 CMD = new CMD101(); + + CMD.HearResponse = heartbeatNum; + + byte[] bytes = new ChargerSendCMD().SendRCMD101(out APDUModel, CMD); + if (APDUModel != null) + { + + string result = "101ӦϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// Ӧ׮״̬Ϣ + /// + /// + /// ں + /// Ƿϱһ104 0- 1- + public byte[] Send103(byte chargeNum, bool reportMessage) + { + APDUModel APDUModel; + + + CMD103 CMD = new CMD103(); + CMD.ChargNum = chargeNum; + CMD.Reported = reportMessage; + + + byte[] bytes = new ChargerSendCMD().SendRCMD103(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "103Ӧ׮״̬Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// Ӧ׮ǩ + /// + /// + /// + public byte[] Send105(CMD105 CMD) + { + APDUModel APDUModel; + + byte[] bytes = new ChargerSendCMD().SendRCMD105(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "105Ӧ׮ǩ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// Ӧ׮澯Ϣ + /// + /// + public byte[] Send107() + { + APDUModel APDUModel; + + CMD107 CMD = new CMD107(); + + byte[] bytes = new ChargerSendCMD().SendRCMD107(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "107Ӧ׮澯Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// Ӧ׮澯Ϣ + /// + /// + public byte[] Send109() + { + APDUModel APDUModel; + + + + CMD109 CMD = new CMD109(); + + + byte[] bytes = new ChargerSendCMD().SendRCMD109(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "109Ӧ׮-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + public byte[] Send111(byte messageType) + { + APDUModel APDUModel; + + + CMD111 CMD = new CMD111(); + + CMD.MessageType = messageType; + + + byte[] bytes = new ChargerSendCMD().SendRCMD111(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "111Ӧ׮ϱģϢԤ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + /// + /// ѯһγʱϢ + /// + /// + /// ں + /// ־ + public byte[] Send113(byte chargeNum, byte sign) + { + APDUModel APDUModel; + + CMD113 CMD = new CMD113(); + + CMD.ChargNum = chargeNum; + CMD.Sign = sign; + + + byte[] bytes = new ChargerSendCMD().SendRCMD113(out APDUModel, CMD); + if (APDUModel != null) + { + string result = "113ѯһγʱϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + } + return bytes; + } + + #endregion + + #region Ϣ + + /// + /// (CMD=5) + /// + /// + /// + /// + public byte[] Send201(CMD201 CMD, uint func) + { + + byte[] bytes = new ChargerSendCMD().SendRCMD201(out APDUModel APDUModel, CMD, func); + string result = "201Ӧ׮ϱϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + + public byte[] Send203(CMD203 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD203(out APDUModel APDUModel, CMD); + string result = "203Ӧ˻ѯϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + + public byte[] Send205(uint value03, uint value04) + { + CMD205 CMD = new CMD205(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + CMD.ResponseCode = value03; + if (CMD.ResponseCode == 0) + { + CMD.Balance = value04; + } + else + { + CMD.Balance = 0; + } + + byte[] bytes = new ChargerSendCMD().SendRCMD205(out APDUModel APDUModel, CMD); + string result = "205Ӧ֤ģԤ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + + public byte[] Send207(CMD208 CMD208, string value06, string value07, byte value08, byte value09, uint value10, ulong value11) + { + CMD207 CMD = new CMD207(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + CMD.ASCIINum = CMD208.ASCIINum; + CMD.ChargGunNum = CMD208.ChargGunNum; + CMD.VINNum = CMD208.VINNum; + CMD.VINBindAccount = value06; + CMD.ChargSerialNum = value07; + CMD.VerifyResult = value08; + CMD.VerifyCause = value09; + CMD.RechBalance = value10; + CMD.StopCode = value11; + byte[] bytes = new ChargerSendCMD().SendRCMD207(out APDUModel APDUModel, CMD); + string result = "207ƽ̨ظ弴䡱-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + + public byte[] Send209(CMD210 CMD210, string value05) + { + CMD209 CMD = new CMD209(); + CMD.Reserved1 = CMD210.Reserved1; + CMD.Reserved2 = CMD210.Reserved2; + CMD.ASCIINum = CMD210.ASCIINum; + CMD.ChargGunNum = CMD210.ChargGunNum; + CMD.VINNum = value05; + byte[] bytes = new ChargerSendCMD().SendRCMD209(out APDUModel APDUModel, CMD); + string result = "209ƽ̨ظ弴䡱-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send221(CMD221 CMD221, uint value05) + { + CMD221 CMD = new CMD221(); + CMD.Reserved1 = CMD221.Reserved1; + CMD.Reserved2 = CMD221.Reserved2; + CMD.ChargNum = CMD221.ChargNum; + CMD.ChargID = CMD221.ChargID; + CMD.IndexNum = value05; + byte[] bytes = new ChargerSendCMD().SendRCMD221(out APDUModel APDUModel, CMD); + string result = "վӦŵϱģ״̬-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + #endregion + + #region ֱ׮ BMS Ϣ(Ԥ) + + public byte[] Send301() + { + CMD301 CMD = new CMD301(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + byte[] bytes = new ChargerSendCMD().SendRCMD301(out APDUModel APDUModel, CMD); + string result = "301Ӧ׮ϱBMSϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + + public byte[] Send303() + { + CMD303 CMD = new CMD303(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + byte[] bytes = new ChargerSendCMD().SendRCMD303(out APDUModel APDUModel, CMD); + string result = "303Ӧ׮ϱBMSϢ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + #region ʷ¼ + + public byte[] Send401(string chargingSerialNum, uint startIndex) + { + CMD401 CMD = new CMD401(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + CMD.SelectIndex = startIndex; + CMD.ChargSerialNum = chargingSerialNum; + byte[] bytes = new ChargerSendCMD().SendRCMD401(out APDUModel APDUModel, CMD); + string result = "401/421ѯ׮ʷ¼-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + #region + + public byte[] Send1001(uint instruct) + { + CMD1001 CMD = new CMD1001(); + CMD.CInstruction = instruct; + byte[] bytes = new ChargerSendCMD().SendRCMD1001(out APDUModel APDUModel, CMD); + string result = "1001·ָ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1003(string fileName) + { + CMD1003 CMD = new CMD1003(); + CMD.Filename = fileName; + byte[] bytes = new ChargerSendCMD().SendRCMD1003(out APDUModel APDUModel, CMD); + string result = "1003·ļָ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1005(uint fileLength) + { + CMD1005 CMD = new CMD1005(); + CMD.FileLength = fileLength; + byte[] bytes = new ChargerSendCMD().SendRCMD1005(out APDUModel APDUModel, CMD); + string result = "1005·ļС-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1007(string updata) + { + CMD1007 CMD = new CMD1007(); + CMD.UpFileData = updata; + byte[] bytes = new ChargerSendCMD().SendRCMD1007(out APDUModel APDUModel, CMD); + string result = "1007·ļ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1009(uint Reserved1) + { + CMD1009 CMD = new CMD1009(); + CMD.Reserved1 = Reserved1; + byte[] bytes = new ChargerSendCMD().SendRCMD1009(out APDUModel APDUModel, CMD); + string result = "1009·ļݽָ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1011(uint Reserved1) + { + CMD1011 CMD = new CMD1011(); + CMD.Reserved1 = 0; + byte[] bytes = new ChargerSendCMD().SendRCMD1011(out APDUModel APDUModel, CMD); + string result = "1011·ָ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1021(uint results, string description) + { + CMD1021 CMD = new CMD1021(); + CMD.ResponseResult = results; + CMD.ResponsExplain = description; + byte[] bytes = new ChargerSendCMD().SendRCMD1021(out APDUModel APDUModel, CMD); + string result = "1021ظ׮-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + #region ƷѲصָ + + + public byte[] Send1101() + { + byte[] bytes = new ChargerSendCMD().SendRCMD1101(out APDUModel APDUModel); + string result = "1101̨ѯ24ʱѼƼ۲Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1103(CMD1103 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD1103(out APDUModel APDUModel, CMD); + string result = "1103̨24ʱεѼƼ۲Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1105(CMD1105 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD1105(out APDUModel APDUModel, CMD); + string result = "1105̨÷ʱμƼ۲Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1107() + { + byte[] bytes = new ChargerSendCMD().SendRCMD1107(out APDUModel APDUModel); + string result = "1107̨ѯʱѼƼ۲Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + #region + + + public byte[] Send1301(CMD1301 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD1301(out APDUModel APDUModel, CMD); + string result = "1301·־ݰ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + #endregion + + #region FTP Զ FTP ʽ־ϴ + + public byte[] Send1401(CMD1401 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD1401(out APDUModel APDUModel, CMD); + string result = "1401·FTPԶ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1406(CMD1406 CMD) + { + byte[] bytes = new ChargerSendCMD().SendRCMD1406(out APDUModel APDUModel, CMD); + string result = "1406·ȡ׮־Ϣ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + #region Э鷽ʽ־ϴ + + public byte[] Send1502(uint responseCode) + { + CMD1502 CMD = new CMD1502(); + + CMD.AnswerCode = responseCode; + byte[] bytes = new ChargerSendCMD().SendRCMD1502(out APDUModel APDUModel, CMD); + string result = "cmd1502 ϴ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1504(uint logo, uint successReservedMessageNum) + { + CMD1504 CMD = new CMD1504(); + CMD.Reserved1 = 0; + CMD.Reserved2 = 0; + CMD.Sign = logo; + CMD.ReceiveMessageNum = successReservedMessageNum; + byte[] bytes = new ChargerSendCMD().SendRCMD1504(out APDUModel APDUModel, CMD); + string result = "1504Ӧϴ־-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + + public byte[] Send1506() + { + CMD1506 CMD = new CMD1506(); + CMD.Reserved1 = 0; + CMD.Reserved1 = 0; + byte[] bytes = new ChargerSendCMD().SendRCMD1506(out APDUModel APDUModel, CMD); + string result = "1506ǰļ-ֽݣ" + ByteUtils.BytesToHexStr(bytes) + ""; + + //Log.LogInstance.WriteLog(result, LogType.Information, "SendLog"); + return bytes; + } + #endregion + + /// + /// + /// + Dictionary cmd3StartAddress = new Dictionary() + { + {1, 32}, + {2, 8}, + {3, 8}, + {4, 8}, + {5, 6}, + {6, 16}, + {7, 256}, + {8, 16}, + {9, 16}, + {10, 256}, + {11, 128}, + {12, 12}, + {13, 64}, + {14, 8}, + {15, 256}, + {16, 256}, + {17, 256}, + {18, 256}, + {19, 256}, + { 20, 256}, + }; + + #endregion + + #region ݽ + + public CMD2 ConCMD2(byte[] data) + { + CMD2 CMD2 = null; + if (data != null && data.Length > 0) + { + CMD2 = new CMD2(); + CMD2.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD2.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD2.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD2.Type = data[44]; + CMD2.SAddress = ByteUtils.DToUInt32(data, 45); + CMD2.SNum = data[50]; + CMD2.SResult = data[51]; + CMD2.SData = Encoding.ASCII.GetString(data, 52, (data.Length - 52)); + + } + return CMD2; + } + public CMD4 ConCMD4(byte[] data) + { + CMD4 CMD4 = null; + if (data != null && data.Length > 0) + { + CMD4 = new CMD4(); + CMD4.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD4.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD4.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD4.Type = data[44]; + CMD4.SAddress = ByteUtils.DToUInt32(data, 45); + CMD4.SResult = data[49]; + CMD4.SData = Encoding.ASCII.GetString(data, 50, (data.Length - 51)); + + } + return CMD4; + } + public CMD6 ConCMD6(byte[] data) + { + CMD6 CMD6 = null; + if (data != null && data.Length > 0) + { + CMD6 = new CMD6(); + CMD6.value01 = ByteUtils.DToUInt16(data, 8); + CMD6.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD6.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD6.ChargMuzzle = data[44]; + CMD6.CommandMark = ByteUtils.DToUInt32(data, 45); + CMD6.CommandNum = data[49]; + CMD6.CommandResult = data[50]; + } + return CMD6; + } + public CMD8 ConCMD8(byte[] data) + { + CMD8 CMD8 = null; + if (data != null && data.Length > 0) + { + CMD8 = new CMD8(); + CMD8.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD8.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD8.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD8.ChargMuzzle = data[44]; + CMD8.CommandResult = ByteUtils.DToUInt16(data, 45); + CMD8.ChargSerialNum = Encoding.ASCII.GetString(data, 49, 32); + } + return CMD8; + } + public CMD10 ConCMD10(byte[] data) + { + CMD10 CMD10 = null; + if (data != null && data.Length > 0) + { + CMD10 = new CMD10(); + CMD10.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD10.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD10.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); ; + CMD10.ChargGunNum = data[44]; + CMD10.RequestStaIP = ByteUtils.DToUInt32(data, 45); + CMD10.Parameter = (float)((ByteUtils.DToUInt32(data, 49)) * 0.01); + } + return CMD10; + } + public CMD102 ConCMD102(byte[] data) + { + CMD102 CMD102 = null; + if (data != null && data.Length > 0) + { + CMD102 = new CMD102(); + CMD102.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD102.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD102.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); ; + CMD102.HeartNum = ByteUtils.DToUInt16(data, 44); + CMD102.GunStatus[0] = data[46]; + CMD102.GunStatus[1] = data[47]; + CMD102.GunStatus[2] = data[48]; + CMD102.GunStatus[3] = data[49]; + CMD102.GunStatus[4] = data[50]; + CMD102.GunStatus[5] = data[51]; + CMD102.GunStatus[6] = data[52]; + CMD102.GunStatus[7] = data[53]; + CMD102.GunStatus[8] = data[54]; + CMD102.GunStatus[9] = data[55]; + CMD102.GunStatus[10] = data[56]; + CMD102.GunStatus[11] = data[57]; + CMD102.GunStatus[12] = data[58]; + CMD102.GunStatus[13] = data[59]; + CMD102.GunStatus[14] = data[60]; + CMD102.GunStatus[15] = data[61]; + } + return CMD102; + } + public CMD104 ConCMD104(byte[] data) + { + CMD104 CMD104 = null; + if (data != null && data.Length > 0) + { + CMD104 = new CMD104(); + + CMD104.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD104.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD104.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD104.ChargGunNum = data[44]; + CMD104.ChargNum = data[45]; + CMD104.ChargGunType = data[46]; + CMD104.WorkState = data[47]; + CMD104.SOCNOW = data[48]; + CMD104.MaxAlarmCode = Encoding.ASCII.GetString(data, 49, 4); + CMD104.ConnecteState = data[53]; + CMD104.TotalCost = (float)(ByteUtils.DToUInt32(data, 54) * 0.01); + CMD104.Reserved3 = ByteUtils.DToUInt32(data, 58); + CMD104.Reserved4 = ByteUtils.DToUInt32(data, 62); + if (data[46] == 1) + { + CMD104.DcChargVoltage = ByteUtils.DToUInt16(data, 66); + CMD104.DcChargCurrent = ByteUtils.DToUInt16(data, 68); + CMD104.BMSDemVoltage = ByteUtils.DToUInt16(data, 70); + CMD104.BMSDemCurrent = ByteUtils.DToUInt16(data, 72); + } + else + { + CMD104.DcChargVoltage = 0; + CMD104.DcChargCurrent = 0; + CMD104.BMSDemVoltage = 0; + CMD104.BMSDemCurrent = 0; + } + + + + CMD104.BMSchargMode = data[74]; + CMD104.AcChargVoltageA = ByteUtils.DToUInt16(data, 75); + CMD104.AcChargVoltageB = ByteUtils.DToUInt16(data, 77); + CMD104.AcChargVoltageC = ByteUtils.DToUInt16(data, 79); + CMD104.AcChargCurrentA = ByteUtils.DToUInt16(data, 81); + CMD104.AcChargCurrentB = ByteUtils.DToUInt16(data, 83); + CMD104.AcChargCurrentC = ByteUtils.DToUInt16(data, 85); + CMD104.RemainTime = ByteUtils.DToUInt16(data, 87); + CMD104.ChargTime = ByteUtils.DToUInt32(data, 89); + CMD104.TotalChargkwh = ByteUtils.DToUInt32(data, 93); + CMD104.StartAmmeterValue = (float)(ByteUtils.DToUInt32(data, 97) * 0.01); + CMD104.AmmeterValue = (float)(ByteUtils.DToUInt32(data, 101) * 0.01); + CMD104.ChargStartMode = data[105]; + CMD104.ChargStrategy = data[106]; + CMD104.ChargStrategyPara = ByteUtils.DToUInt32(data, 107); + CMD104.AppointmentSign = data[111]; + CMD104.ChargID = Encoding.ASCII.GetString(data, 112, 32); + CMD104.OutTime = data[144]; + CMD104.StartTime = Encoding.ASCII.GetString(data, 145, 8); + CMD104.InitialBalance = ByteUtils.DToUInt32(data, 153); + CMD104.Reserved5 = ByteUtils.DToUInt32(data, 157); + CMD104.ChargPower = (float)(ByteUtils.DToUInt32(data, 161) * 0.1); + CMD104.Reserved6 = ByteUtils.DToUInt32(data, 165); + CMD104.Reserved7 = ByteUtils.DToUInt32(data, 169); + CMD104.Reserved8 = ByteUtils.DToUInt32(data, 173); + CMD104.OutletTemp = data[177]; + CMD104.Temperature = data[178]; + CMD104.ChargGunTemp = data[179]; + CMD104.VINNum = Encoding.ASCII.GetString(data, 180, 18); + CMD104.DoorState = data[198]; + CMD104.ChargSerialNum = Encoding.ASCII.GetString(data, 199, 32); + CMD104.TotalElectricity = ByteUtils.DToUInt32(data, 231); + CMD104.ServiceCharge = ByteUtils.DToUInt32(data, 235); + CMD104.HomingState = data[239]; + CMD104.GroundLockedState = data[240]; + CMD104.KilojoulesElec = data[241]; + CMD104.DcACElectricity = ((float)(ByteUtils.DToUInt32(data, 242) * 0.001)).ToString("F1"); + CMD104.ChargMode = data[246]; + CMD104.ChargeOrDisSign = data[247]; + } + return CMD104; + } + public CMD106 ConCMD106(byte[] data) + { + CMD106 CMD106 = null; + if (data != null && data.Length > 0) + { + CMD106 = new CMD106(); + CMD106.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD106.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD106.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD106.Sign = data[44]; + CMD106.ChargVersion = ByteUtils.DToUInt32(data, 45); + CMD106.ChargProType = ByteUtils.DToUInt16(data, 49); + CMD106.StartNum = ByteUtils.DToUInt32(data, 51); + CMD106.DataUploadMode = data[55]; + CMD106.SignInterval = ByteUtils.DToUInt16(data, 56); + CMD106.RunVariable = data[58]; + CMD106.ChargGunNum = data[59]; + CMD106.HeartReportCycle = data[60]; + CMD106.TimeoutNum = data[61]; + CMD106.RecordNum = ByteUtils.DToUInt32(data, 62); + CMD106.SystemTime = Encoding.ASCII.GetString(data, 66, 8); + CMD106.Reserved3 = Encoding.ASCII.GetString(data, 74, 8); + CMD106.Reserved4 = Encoding.ASCII.GetString(data, 82, 8); + CMD106.Reserved5 = Encoding.ASCII.GetString(data, 90, 8); + CMD106.RandomNum = ByteUtils.DToUInt32(data, 98); + CMD106.ProtocolVersion = ByteUtils.DToUInt16(data, 102); + CMD106.WhiteVersionNum = ByteUtils.DToUInt16(data, 104); + CMD106.DeviceType = data[108]; + CMD106.AssetCoding = Encoding.ASCII.GetString(data, 109, 32); + } + return CMD106; + } + public CMD108 ConCMD108(byte[] data) + { + CMD108 CMD108 = null; + if (data != null && data.Length > 0) + { + CMD108 = new CMD108(); + CMD108.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD108.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD108.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD108.AlarmBitInfo = Encoding.ASCII.GetString(data, 44, 32); + } + return CMD108; + } + public CMD110 ConCMD110(byte[] data) + { + CMD110 CMD110 = null; + if (data != null && data.Length > 0) + { + CMD110 = new CMD110(); + CMD110.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD110.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD110.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD110.ChargGunNum = data[44]; + CMD110.ChargeFail = ByteUtils.DToUInt32(data, 45); + CMD110.SendMessage = ByteUtils.DToUInt16(data, 49); + CMD110.Reserved3 = ByteUtils.DToUInt16(data, 51); + CMD110.Reserved4 = ByteUtils.DToUInt32(data, 53); + byte version1 = data[58]; + byte version2 = data[59]; + byte version3 = data[60]; + CMD110.BRMBMSVersionNum = "v" + version1.ToString() + version2.ToString() + version3.ToString(); + CMD110.BRMBatteryType = data[61]; + CMD110.BRMRatedCapacity = ByteUtils.DToUInt32(data, 62); + CMD110.BRMRatedVoltage = ByteUtils.DToUInt32(data, 66); + CMD110.BRMBatteryManu = ByteUtils.DToUInt32(data, 70); + CMD110.BRMBatteryPackID = ByteUtils.DToUInt32(data, 74); + CMD110.BRMDateYear = ByteUtils.DToUInt16(data, 78); + CMD110.BRMDateMonth = data[80]; + CMD110.BRMDateDay = data[81]; + CMD110.BRMChargeCount = ByteUtils.DToUInt32(data, 82); + CMD110.BRMTitleMark = data[86]; + CMD110.Reserved5 = data[87]; + CMD110.BRMVINID = Encoding.ASCII.GetString(data, 88, 17); + + byte VersionSerialNum = data[105]; + byte day = data[106]; + byte month = data[107]; + ushort year = ByteUtils.DToUInt16(data, 108); + + + CMD110.BRMBMSSoftVerNum = VersionSerialNum.ToString() + year.ToString() + "" + month.ToString() + "" + day.ToString() + ""; + CMD110.MaxChargVoltage = (float)(ByteUtils.DToUInt32(data, 113) * 0.1); + CMD110.MaxChargCurrent = (float)(ByteUtils.DToUInt32(data, 117) * 0.1); + CMD110.TotalEnergy = (float)(ByteUtils.DToUInt32(data, 121) * 0.1); + CMD110.MaxTotalVoltage = (float)(ByteUtils.DToUInt32(data, 125) * 0.1); + CMD110.MaxTemp = data[129]; + CMD110.ChargeState = (float)(ByteUtils.DToUInt16(data, 130) * 0.1); + CMD110.CellVoltage = (float)(ByteUtils.DToUInt32(data, 132) * 0.1); + CMD110.ChargSerialNum = Encoding.ASCII.GetString(data, 136, 32); + } + return CMD110; + } + public CMD112 ConCMD112(byte[] data) + { + CMD112 CMD112 = null; + if (data != null && data.Length > 0) + { + CMD112 = new CMD112(); + CMD112.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD112.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD112.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD112.ReportMode = data[44]; + CMD112.ModuleNum = data[45]; + CMD112.ModuleType = data[46]; + CMD112.ACModuleversion1 = ByteUtils.DToUInt16(data, 47); + CMD112.DCModuleversion1 = ByteUtils.DToUInt16(data, 49); + CMD112.ModuleState1 = data[51]; + CMD112.ModuleOutVoltage1 = ByteUtils.DToUInt16(data, 52); + CMD112.ModuleOutCurrent1 = ByteUtils.DToUInt16(data, 54); + CMD112.ModuleAlarm1 = ByteUtils.DToUInt32(data, 56); + CMD112.ACModuleversion2 = ByteUtils.DToUInt16(data, 60); + CMD112.DCModuleversion2 = ByteUtils.DToUInt16(data, 62); + CMD112.ModuleState2 = data[64]; + CMD112.ModuleOutVoltage2 = ByteUtils.DToUInt16(data, 65); + CMD112.ModuleOutCurrent2 = ByteUtils.DToUInt16(data, 67); + CMD112.ModuleAlarm2 = ByteUtils.DToUInt32(data, 69); + } + return CMD112; + } + public CMD114 ConCMD114(byte[] data) + { + CMD114 CMD114 = null; + if (data != null && data.Length > 0) + { + CMD114 = new CMD114(); + CMD114.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD114.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD114.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD114.ChargGunNum = data[44]; + CMD114.WorkState = data[45]; + CMD114.StartChargTime = Encoding.ASCII.GetString(data, 46, 8); + /* + 7 54 + 8 56 + 9 58 + 10 60 + 11 62 + 12 64 + 13 66 + 14 68 + 15 70 + 16 72 + 17 74 + 18 76 + 19 78 + 20 80 + 21 82 + 22 84 + 23 86 + 24 88 + 25 90 + 26 92 + 27 94 + 28 96 + 29 98 + 30 100 + 31 102 + 32 104 + 33 106 + 34 108 + 35 110 + 36 112 + 37 114 + 38 116 + 39 118 + 40 120 + 41 122 + 42 124 + 43 126 + 44 128 + 45 130 + 46 132 + 47 134 + 48 136 + 49 138 + 50 140 + 51 142 + 52 144 + 53 146 + 54 148 + + */ + CMD114.Charge01 = ByteUtils.DToUInt16(data, 54); + CMD114.Charge02 = ByteUtils.DToUInt16(data, 56); + CMD114.Charge03 = ByteUtils.DToUInt16(data, 58); + CMD114.Charge04 = ByteUtils.DToUInt16(data, 60); + CMD114.Charge05 = ByteUtils.DToUInt16(data, 62); + CMD114.Charge06 = ByteUtils.DToUInt16(data, 64); + CMD114.Charge07 = ByteUtils.DToUInt16(data, 66); + CMD114.Charge08 = ByteUtils.DToUInt16(data, 68); + CMD114.Charge09 = ByteUtils.DToUInt16(data, 70); + CMD114.Charge10 = ByteUtils.DToUInt16(data, 72); + CMD114.Charge11 = ByteUtils.DToUInt16(data, 74); + CMD114.Charge12 = ByteUtils.DToUInt16(data, 76); + CMD114.Charge13 = ByteUtils.DToUInt16(data, 78); + CMD114.Charge14 = ByteUtils.DToUInt16(data, 80); + CMD114.Charge15 = ByteUtils.DToUInt16(data, 82); + CMD114.Charge16 = ByteUtils.DToUInt16(data, 84); + CMD114.Charge17 = ByteUtils.DToUInt16(data, 86); + CMD114.Charge18 = ByteUtils.DToUInt16(data, 88); + CMD114.Charge19 = ByteUtils.DToUInt16(data, 90); + CMD114.Charge20 = ByteUtils.DToUInt16(data, 92); + CMD114.Charge21 = ByteUtils.DToUInt16(data, 94); + CMD114.Charge22 = ByteUtils.DToUInt16(data, 96); + CMD114.Charge23 = ByteUtils.DToUInt16(data, 98); + CMD114.Charge24 = ByteUtils.DToUInt16(data, 100); + CMD114.Charge25 = ByteUtils.DToUInt16(data, 102); + CMD114.Charge26 = ByteUtils.DToUInt16(data, 104); + CMD114.Charge27 = ByteUtils.DToUInt16(data, 106); + CMD114.Charge29 = ByteUtils.DToUInt16(data, 108); + CMD114.Charge30 = ByteUtils.DToUInt16(data, 110); + CMD114.Charge31 = ByteUtils.DToUInt16(data, 112); + CMD114.Charge32 = ByteUtils.DToUInt16(data, 114); + CMD114.Charge33 = ByteUtils.DToUInt16(data, 116); + CMD114.Charge34 = ByteUtils.DToUInt16(data, 118); + CMD114.Charge35 = ByteUtils.DToUInt16(data, 120); + CMD114.Charge36 = ByteUtils.DToUInt16(data, 122); + CMD114.Charge37 = ByteUtils.DToUInt16(data, 124); + CMD114.Charge38 = ByteUtils.DToUInt16(data, 126); + CMD114.Charge39 = ByteUtils.DToUInt16(data, 128); + CMD114.Charge40 = ByteUtils.DToUInt16(data, 130); + CMD114.Charge41 = ByteUtils.DToUInt16(data, 132); + } + return CMD114; + } + public CMD202 ConCMD202(uint func, byte[] data) + { + CMD202 CMD202 = null; + if (data != null && data.Length > 0) + { + CMD202 = new CMD202(); + CMD202.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD202.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD202.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD202.PosType = data[44]; + CMD202.ChargGun = data[45]; + CMD202.ChargID = Encoding.ASCII.GetString(data, 46, 32); + CMD202.StartTime = Encoding.ASCII.GetString(data, 78, 8); + CMD202.EndTime = Encoding.ASCII.GetString(data, 86, 8); + CMD202.TimeSpan = ByteUtils.DToUInt32(data, 94); + CMD202.SOCStart = data[98]; + CMD202.SOCEnd = data[99]; + CMD202.EndReason = ByteUtils.DToUInt32(data, 100); + + if (func == 202) + { + CMD202.ChargCapacityNow = (ByteUtils.DToUInt32(data, 104) * 0.01).ToString("F2"); + CMD202.SAmmeterValue = (ByteUtils.DToUInt32(data, 108) * 0.01).ToString("F2"); + CMD202.EAmmeterValue = (ByteUtils.DToUInt32(data, 112) * 0.01).ToString("F2"); + + + CMD202.ChargCapacity01 = ByteUtils.DToUInt16(data, 167).ToString(); + CMD202.ChargCapacity02 = ByteUtils.DToUInt16(data, 169).ToString(); + CMD202.ChargCapacity03 = ByteUtils.DToUInt16(data, 171).ToString(); + CMD202.ChargCapacity04 = ByteUtils.DToUInt16(data, 173).ToString(); + CMD202.ChargCapacity05 = ByteUtils.DToUInt16(data, 175).ToString(); + CMD202.ChargCapacity06 = ByteUtils.DToUInt16(data, 177).ToString(); + CMD202.ChargCapacity07 = ByteUtils.DToUInt16(data, 179).ToString(); + CMD202.ChargCapacity08 = ByteUtils.DToUInt16(data, 181).ToString(); + CMD202.ChargCapacity09 = ByteUtils.DToUInt16(data, 183).ToString(); + CMD202.ChargCapacity10 = ByteUtils.DToUInt16(data, 185).ToString(); + CMD202.ChargCapacity11 = ByteUtils.DToUInt16(data, 187).ToString(); + CMD202.ChargCapacity12 = ByteUtils.DToUInt16(data, 189).ToString(); + CMD202.ChargCapacity13 = ByteUtils.DToUInt16(data, 191).ToString(); + CMD202.ChargCapacity14 = ByteUtils.DToUInt16(data, 193).ToString(); + CMD202.ChargCapacity15 = ByteUtils.DToUInt16(data, 195).ToString(); + CMD202.ChargCapacity16 = ByteUtils.DToUInt16(data, 197).ToString(); + CMD202.ChargCapacity17 = ByteUtils.DToUInt16(data, 199).ToString(); + CMD202.ChargCapacity18 = ByteUtils.DToUInt16(data, 201).ToString(); + CMD202.ChargCapacity19 = ByteUtils.DToUInt16(data, 203).ToString(); + CMD202.ChargCapacity20 = ByteUtils.DToUInt16(data, 205).ToString(); + CMD202.ChargCapacity21 = ByteUtils.DToUInt16(data, 207).ToString(); + CMD202.ChargCapacity22 = ByteUtils.DToUInt16(data, 209).ToString(); + CMD202.ChargCapacity23 = ByteUtils.DToUInt16(data, 211).ToString(); + CMD202.ChargCapacity24 = ByteUtils.DToUInt16(data, 213).ToString(); + CMD202.ChargCapacity25 = ByteUtils.DToUInt16(data, 215).ToString(); + CMD202.ChargCapacity26 = ByteUtils.DToUInt16(data, 217).ToString(); + CMD202.ChargCapacity27 = ByteUtils.DToUInt16(data, 219).ToString(); + CMD202.ChargCapacity28 = ByteUtils.DToUInt16(data, 221).ToString(); + CMD202.ChargCapacity29 = ByteUtils.DToUInt16(data, 223).ToString(); + CMD202.ChargCapacity30 = ByteUtils.DToUInt16(data, 225).ToString(); + CMD202.ChargCapacity31 = ByteUtils.DToUInt16(data, 227).ToString(); + CMD202.ChargCapacity32 = ByteUtils.DToUInt16(data, 229).ToString(); + CMD202.ChargCapacity33 = ByteUtils.DToUInt16(data, 231).ToString(); + CMD202.ChargCapacity34 = ByteUtils.DToUInt16(data, 233).ToString(); + CMD202.ChargCapacity35 = ByteUtils.DToUInt16(data, 235).ToString(); + CMD202.ChargCapacity36 = ByteUtils.DToUInt16(data, 237).ToString(); + CMD202.ChargCapacity37 = ByteUtils.DToUInt16(data, 239).ToString(); + CMD202.ChargCapacity38 = ByteUtils.DToUInt16(data, 241).ToString(); + CMD202.ChargCapacity39 = ByteUtils.DToUInt16(data, 243).ToString(); + CMD202.ChargCapacity40 = ByteUtils.DToUInt16(data, 245).ToString(); + CMD202.ChargCapacity41 = ByteUtils.DToUInt16(data, 247).ToString(); + CMD202.ChargCapacity42 = ByteUtils.DToUInt16(data, 249).ToString(); + CMD202.ChargCapacity43 = ByteUtils.DToUInt16(data, 251).ToString(); + CMD202.ChargCapacity44 = ByteUtils.DToUInt16(data, 253).ToString(); + CMD202.ChargCapacity45 = ByteUtils.DToUInt16(data, 255).ToString(); + CMD202.ChargCapacity46 = ByteUtils.DToUInt16(data, 257).ToString(); + CMD202.ChargCapacity47 = ByteUtils.DToUInt16(data, 259).ToString(); + CMD202.ChargCapacity48 = ByteUtils.DToUInt16(data, 261).ToString(); + + CMD202.StartMode = data[263]; + CMD202.ChargSerialNum = Encoding.ASCII.GetString(data, 264, 32); + CMD202.ChargServiceCost = ByteUtils.DToUInt32(data, 296); + CMD202.KilElectricity = data[300]; + CMD202.ParallelMark = data[301]; + CMD202.ChargeOrDisMark = data[302]; + CMD202.MeterEncData = Encoding.ASCII.GetString(data, 303, 34); + CMD202.MeterNum = Encoding.ASCII.GetString(data, 337, 6); + CMD202.MeterProVersion = ByteUtils.DToUInt16(data, 343); + CMD202.EncMode = data[345]; + } + else if (func == 222) + { + CMD202.ChargCapacityNow = (ByteUtils.DToUInt32(data, 104) * 0.001).ToString("F3"); + CMD202.SAmmeterValue = (ByteUtils.DToUInt32(data, 108) * 0.001).ToString("F3"); + CMD202.EAmmeterValue = (ByteUtils.DToUInt32(data, 112) * 0.001).ToString("F3"); + + + CMD202.ChargCapacity01 = (ByteUtils.DToUInt32(data, 167) * 0.001).ToString("F3"); + CMD202.ChargCapacity02 = (ByteUtils.DToUInt32(data, 171) * 0.001).ToString("F3"); + CMD202.ChargCapacity03 = (ByteUtils.DToUInt32(data, 175) * 0.001).ToString("F3"); + CMD202.ChargCapacity04 = (ByteUtils.DToUInt32(data, 179) * 0.001).ToString("F3"); + CMD202.ChargCapacity05 = (ByteUtils.DToUInt32(data, 183) * 0.001).ToString("F3"); + CMD202.ChargCapacity06 = (ByteUtils.DToUInt32(data, 187) * 0.001).ToString("F3"); + CMD202.ChargCapacity07 = (ByteUtils.DToUInt32(data, 191) * 0.001).ToString("F3"); + CMD202.ChargCapacity08 = (ByteUtils.DToUInt32(data, 195) * 0.001).ToString("F3"); + CMD202.ChargCapacity09 = (ByteUtils.DToUInt32(data, 199) * 0.001).ToString("F3"); + CMD202.ChargCapacity10 = (ByteUtils.DToUInt32(data, 203) * 0.001).ToString("F3"); + CMD202.ChargCapacity11 = (ByteUtils.DToUInt32(data, 207) * 0.001).ToString("F3"); + CMD202.ChargCapacity12 = (ByteUtils.DToUInt32(data, 211) * 0.001).ToString("F3"); + CMD202.ChargCapacity13 = (ByteUtils.DToUInt32(data, 215) * 0.001).ToString("F3"); + CMD202.ChargCapacity14 = (ByteUtils.DToUInt32(data, 219) * 0.001).ToString("F3"); + CMD202.ChargCapacity15 = (ByteUtils.DToUInt32(data, 223) * 0.001).ToString("F3"); + CMD202.ChargCapacity16 = (ByteUtils.DToUInt32(data, 227) * 0.001).ToString("F3"); + CMD202.ChargCapacity17 = (ByteUtils.DToUInt32(data, 231) * 0.001).ToString("F3"); + CMD202.ChargCapacity18 = (ByteUtils.DToUInt32(data, 235) * 0.001).ToString("F3"); + CMD202.ChargCapacity19 = (ByteUtils.DToUInt32(data, 239) * 0.001).ToString("F3"); + CMD202.ChargCapacity20 = (ByteUtils.DToUInt32(data, 243) * 0.001).ToString("F3"); + CMD202.ChargCapacity21 = (ByteUtils.DToUInt32(data, 247) * 0.001).ToString("F3"); + CMD202.ChargCapacity22 = (ByteUtils.DToUInt32(data, 251) * 0.001).ToString("F3"); + CMD202.ChargCapacity23 = (ByteUtils.DToUInt32(data, 255) * 0.001).ToString("F3"); + CMD202.ChargCapacity24 = (ByteUtils.DToUInt32(data, 259) * 0.001).ToString("F3"); + CMD202.ChargCapacity25 = (ByteUtils.DToUInt32(data, 263) * 0.001).ToString("F3"); + CMD202.ChargCapacity26 = (ByteUtils.DToUInt32(data, 267) * 0.001).ToString("F3"); + CMD202.ChargCapacity27 = (ByteUtils.DToUInt32(data, 271) * 0.001).ToString("F3"); + CMD202.ChargCapacity28 = (ByteUtils.DToUInt32(data, 275) * 0.001).ToString("F3"); + CMD202.ChargCapacity29 = (ByteUtils.DToUInt32(data, 279) * 0.001).ToString("F3"); + CMD202.ChargCapacity30 = (ByteUtils.DToUInt32(data, 283) * 0.001).ToString("F3"); + CMD202.ChargCapacity31 = (ByteUtils.DToUInt32(data, 287) * 0.001).ToString("F3"); + CMD202.ChargCapacity32 = (ByteUtils.DToUInt32(data, 291) * 0.001).ToString("F3"); + CMD202.ChargCapacity33 = (ByteUtils.DToUInt32(data, 295) * 0.001).ToString("F3"); + CMD202.ChargCapacity34 = (ByteUtils.DToUInt32(data, 299) * 0.001).ToString("F3"); + CMD202.ChargCapacity35 = (ByteUtils.DToUInt32(data, 303) * 0.001).ToString("F3"); + CMD202.ChargCapacity36 = (ByteUtils.DToUInt32(data, 307) * 0.001).ToString("F3"); + CMD202.ChargCapacity37 = (ByteUtils.DToUInt32(data, 311) * 0.001).ToString("F3"); + CMD202.ChargCapacity38 = (ByteUtils.DToUInt32(data, 315) * 0.001).ToString("F3"); + CMD202.ChargCapacity39 = (ByteUtils.DToUInt32(data, 319) * 0.001).ToString("F3"); + CMD202.ChargCapacity40 = (ByteUtils.DToUInt32(data, 323) * 0.001).ToString("F3"); + CMD202.ChargCapacity41 = (ByteUtils.DToUInt32(data, 327) * 0.001).ToString("F3"); + CMD202.ChargCapacity42 = (ByteUtils.DToUInt32(data, 331) * 0.001).ToString("F3"); + CMD202.ChargCapacity43 = (ByteUtils.DToUInt32(data, 335) * 0.001).ToString("F3"); + CMD202.ChargCapacity44 = (ByteUtils.DToUInt32(data, 339) * 0.001).ToString("F3"); + CMD202.ChargCapacity45 = (ByteUtils.DToUInt32(data, 343) * 0.001).ToString("F3"); + CMD202.ChargCapacity46 = (ByteUtils.DToUInt32(data, 347) * 0.001).ToString("F3"); + CMD202.ChargCapacity47 = (ByteUtils.DToUInt32(data, 351) * 0.001).ToString("F3"); + CMD202.ChargCapacity48 = (ByteUtils.DToUInt32(data, 355) * 0.001).ToString("F3"); + + CMD202.StartMode = data[359]; + CMD202.ChargSerialNum = Encoding.ASCII.GetString(data, 360, 32); + CMD202.ChargServiceCost = ByteUtils.DToUInt32(data, 392); + CMD202.KilElectricity = data[396]; + CMD202.ParallelMark = data[397]; + CMD202.ChargeOrDisMark = data[398]; + CMD202.MeterEncData = Encoding.ASCII.GetString(data, 399, 34); + CMD202.MeterNum = Encoding.ASCII.GetString(data, 433, 6); + CMD202.MeterProVersion = ByteUtils.DToUInt16(data, 439); + CMD202.EncMode = data[441]; + } + + CMD202.ChargeAmount = ByteUtils.DToUInt32(data, 116); + CMD202.IndexNum = BitConverter.ToInt32(data, 120); + CMD202.CardBalance = ByteUtils.DToUInt32(data, 124); + CMD202.ChargRecord = ByteUtils.DToUInt32(data, 128); + CMD202.SumChargRecord = ByteUtils.DToUInt32(data, 132); + CMD202.Reserved3 = data[136]; + CMD202.ChargStrategy = data[137]; + switch (data[137]) + { + case 1: + CMD202.ChargStrategyPara = ByteUtils.DToUInt32(data, 138).ToString(); + break; + case 2: + CMD202.ChargStrategyPara = (ByteUtils.DToUInt32(data, 138) * 0.01).ToString("F2"); + break; + case 3: + CMD202.ChargStrategyPara = (ByteUtils.DToUInt32(data, 138) * 0.01).ToString("F2"); + break; + } + + + + CMD202.CarVIN = Encoding.ASCII.GetString(data, 142, 17); + CMD202.CarID = Encoding.ASCII.GetString(data, 159, 8); + + + } + return CMD202; + } + public CMD204 ConCMD204(byte[] data) + { + CMD204 CMD204 = null; + if (data != null && data.Length > 0) + { + CMD204 = new CMD204(); + CMD204.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD204.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD204.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD204.ChargID = Encoding.ASCII.GetString(data, 44, 32); + CMD204.Balance = ByteUtils.DToUInt32(data, 76); + CMD204.BlacklistSign = data[80]; + CMD204.ChargCardPassword = Encoding.ASCII.GetString(data, 81, 32); + CMD204.RandomData = Encoding.ASCII.GetString(data, 113, 48); + CMD204.M1CardID = ByteUtils.DToUInt32(data, 161); + CMD204.Auth = data[165]; + CMD204.ChargGunNum = data[166]; + } + return CMD204; + } + public CMD206 ConCMD206(byte[] data) + { + CMD206 CMD206 = null; + if (data != null && data.Length > 0) + { + CMD206 = new CMD206(); + CMD206.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD206.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD206.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD206.ChargID = Encoding.ASCII.GetString(data, 44, 32); + CMD206.ChargPassword = Encoding.ASCII.GetString(data, 76, 32); + CMD206.RandomData = Encoding.ASCII.GetString(data, 108, 48); + } + return CMD206; + } + public CMD208 ConCMD208(byte[] data) + { + CMD208 CMD208 = null; + if (data != null && data.Length > 0) + { + CMD208 = new CMD208(); + CMD208.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD208.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD208.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD208.ChargGunNum = data[44]; + CMD208.VINNum = Encoding.ASCII.GetString(data, 45, 17); + CMD208.ChargStrategy = data[62]; + CMD208.ChargStrategyPara = ByteUtils.DToUInt32(data, 63); + } + return CMD208; + } + public CMD210 ConCMD210(byte[] data) + { + CMD210 CMD210 = null; + if (data != null && data.Length > 0) + { + CMD210 = new CMD210(); + CMD210.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD210.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD210.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD210.ChargGunNum = data[44]; + CMD210.StartResult = ByteUtils.DToUInt32(data, 45); + } + return CMD210; + } + public CMD222 ConCMD222(byte[] data) + { + CMD222 CMD222 = null; + if (data != null && data.Length > 0) + { + CMD222 = new CMD222(); + CMD222.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD222.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD222.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD222.PosType = data[44]; + CMD222.ChargGun = data[45]; + CMD222.ChargID = Encoding.ASCII.GetString(data, 46, 32); + CMD222.StartTime = Encoding.ASCII.GetString(data, 78, 8); + CMD222.EndTime = Encoding.ASCII.GetString(data, 86, 8); + CMD222.TimeSpan = ByteUtils.DToUInt32(data, 94); + CMD222.SOCStart = data[98]; + CMD222.SOCEnd = data[99]; + CMD222.EndReason = ByteUtils.DToUInt32(data, 100); + CMD222.ChargCapacityNow = ByteUtils.DToUInt32(data, 104); + CMD222.SAmmeterValue = ByteUtils.DToUInt32(data, 108); + CMD222.EAmmeterValue = ByteUtils.DToUInt32(data, 112); + CMD222.ChargeAmount = ByteUtils.DToUInt32(data, 116); + CMD222.IndexNum = ByteUtils.DToUInt32(data, 120); + CMD222.CardBalance = ByteUtils.DToUInt32(data, 124); + CMD222.ChargRecord = ByteUtils.DToUInt32(data, 128); + CMD222.SumChargRecord = ByteUtils.DToUInt32(data, 132); + CMD222.Reserved3 = data[136]; + CMD222.ChargStrategy = data[137]; + CMD222.ChargStrategyPara = ByteUtils.DToUInt32(data, 138); + CMD222.CarVIN = Encoding.ASCII.GetString(data, 142, 17); + CMD222.CarID = Encoding.ASCII.GetString(data, 159, 8); + CMD222.ChargCapacity01 = (int)ByteUtils.DToUInt32(data, 167); + CMD222.ChargCapacity02 = (int)ByteUtils.DToUInt32(data, 171); + CMD222.ChargCapacity03 = (int)ByteUtils.DToUInt32(data, 175); + CMD222.ChargCapacity04 = (int)ByteUtils.DToUInt32(data, 179); + CMD222.ChargCapacity05 = (int)ByteUtils.DToUInt32(data, 183); + CMD222.ChargCapacity06 = (int)ByteUtils.DToUInt32(data, 187); + CMD222.ChargCapacity07 = (int)ByteUtils.DToUInt32(data, 191); + CMD222.ChargCapacity08 = (int)ByteUtils.DToUInt32(data, 195); + CMD222.ChargCapacity09 = (int)ByteUtils.DToUInt32(data, 199); + CMD222.ChargCapacity10 = (int)ByteUtils.DToUInt32(data, 203); + CMD222.ChargCapacity11 = (int)ByteUtils.DToUInt32(data, 207); + CMD222.ChargCapacity12 = (int)ByteUtils.DToUInt32(data, 211); + CMD222.ChargCapacity13 = (int)ByteUtils.DToUInt32(data, 215); + CMD222.ChargCapacity14 = (int)ByteUtils.DToUInt32(data, 219); + CMD222.ChargCapacity15 = (int)ByteUtils.DToUInt32(data, 223); + CMD222.ChargCapacity16 = (int)ByteUtils.DToUInt32(data, 227); + CMD222.ChargCapacity17 = (int)ByteUtils.DToUInt32(data, 231); + CMD222.ChargCapacity18 = (int)ByteUtils.DToUInt32(data, 235); + CMD222.ChargCapacity19 = (int)ByteUtils.DToUInt32(data, 239); + CMD222.ChargCapacity20 = (int)ByteUtils.DToUInt32(data, 243); + CMD222.ChargCapacity21 = (int)ByteUtils.DToUInt32(data, 247); + CMD222.ChargCapacity22 = (int)ByteUtils.DToUInt32(data, 251); + CMD222.ChargCapacity23 = (int)ByteUtils.DToUInt32(data, 255); + CMD222.ChargCapacity24 = (int)ByteUtils.DToUInt32(data, 259); + CMD222.ChargCapacity25 = (int)ByteUtils.DToUInt32(data, 263); + CMD222.ChargCapacity26 = (int)ByteUtils.DToUInt32(data, 267); + CMD222.ChargCapacity27 = (int)ByteUtils.DToUInt32(data, 271); + CMD222.ChargCapacity28 = (int)ByteUtils.DToUInt32(data, 275); + CMD222.ChargCapacity29 = (int)ByteUtils.DToUInt32(data, 279); + CMD222.ChargCapacity30 = (int)ByteUtils.DToUInt32(data, 283); + CMD222.ChargCapacity31 = (int)ByteUtils.DToUInt32(data, 287); + CMD222.ChargCapacity32 = (int)ByteUtils.DToUInt32(data, 291); + CMD222.ChargCapacity33 = (int)ByteUtils.DToUInt32(data, 295); + CMD222.ChargCapacity34 = (int)ByteUtils.DToUInt32(data, 299); + CMD222.ChargCapacity35 = (int)ByteUtils.DToUInt32(data, 303); + CMD222.ChargCapacity36 = (int)ByteUtils.DToUInt32(data, 307); + CMD222.ChargCapacity37 = (int)ByteUtils.DToUInt32(data, 311); + CMD222.ChargCapacity38 = (int)ByteUtils.DToUInt32(data, 315); + CMD222.ChargCapacity39 = (int)ByteUtils.DToUInt32(data, 319); + CMD222.ChargCapacity40 = (int)ByteUtils.DToUInt32(data, 323); + CMD222.ChargCapacity41 = (int)ByteUtils.DToUInt32(data, 327); + CMD222.ChargCapacity42 = (int)ByteUtils.DToUInt32(data, 331); + CMD222.ChargCapacity43 = (int)ByteUtils.DToUInt32(data, 335); + CMD222.ChargCapacity44 = (int)ByteUtils.DToUInt32(data, 339); + CMD222.ChargCapacity45 = (int)ByteUtils.DToUInt32(data, 343); + CMD222.ChargCapacity46 = (int)ByteUtils.DToUInt32(data, 347); + CMD222.ChargCapacity47 = (int)ByteUtils.DToUInt32(data, 351); + CMD222.ChargCapacity48 = (int)ByteUtils.DToUInt32(data, 355); + CMD222.StartMode = data[359]; + CMD222.ChargSerialNum = Encoding.ASCII.GetString(data, 360, 32); + CMD222.ChargServiceCost = ByteUtils.DToUInt32(data, 392); + CMD222.KilElectricity = data[394]; + CMD222.ParallelMark = data[395]; + CMD222.ChargeOrDisMark = data[396]; + CMD222.MeterEncData = data[397]; + CMD222.MeterNum = Encoding.ASCII.GetString(data, 398, 6); + CMD222.MeterProVersion = ByteUtils.DToUInt16(data, 404); + CMD222.EncMode = data[408]; + } + return CMD222; + } + public CMD302 ConCMD302(byte[] data) + { + CMD302 CMD302 = null; + if (data != null && data.Length > 0) + { + CMD302 = new CMD302(); + CMD302.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD302.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD302.MessageOrderNum = ByteUtils.DToUInt16(data, 12); + CMD302.ChargGunNum = ByteUtils.DToUInt16(data, 14); + CMD302.ASCIINum = Encoding.ASCII.GetString(data, 16, 32); + CMD302.WorkState = data[48]; + CMD302.connectState = data[49]; + CMD302.BRMBMSVersionNum = data[50]; + CMD302.BRMBatteryType = data[51]; + CMD302.BRMRatedCapacity = ByteUtils.DToUInt32(data, 52); + CMD302.BRMRatedVoltage = ByteUtils.DToUInt32(data, 56); + CMD302.BRMBatteryManu = ByteUtils.DToUInt32(data, 60); + CMD302.BRMBatteryPackID = ByteUtils.DToUInt32(data, 64); + CMD302.BRMDateYear = ByteUtils.DToUInt16(data, 68); + CMD302.BRMDateMonth = data[70]; + CMD302.BRMDateDay = data[71]; + CMD302.BRMChargeCount = ByteUtils.DToUInt32(data, 72); + CMD302.BRMTitleMark = data[76]; + CMD302.Reserved3 = data[77]; + CMD302.BRMVINID = Encoding.ASCII.GetString(data, 78, 17); + CMD302.BRMBMSSoftVerNum = ByteUtils.DToUInt16(data, 95); + CMD302.MaxChargVoltage = ByteUtils.DToUInt32(data, 103); + CMD302.MaxChargCurrent = ByteUtils.DToUInt32(data, 107); + CMD302.TotalEnergy = ByteUtils.DToUInt32(data, 111); + CMD302.MaxTotalVoltage = ByteUtils.DToUInt32(data, 115); + CMD302.MaxTemp = data[119]; + CMD302.ChargeState = ByteUtils.DToUInt16(data, 120); + CMD302.CellVoltage = ByteUtils.DToUInt32(data, 122); + CMD302.ChargePrepared = data[126]; + CMD302.BCLVoltage = ByteUtils.DToUInt32(data, 127); + CMD302.BCLCurrent = ByteUtils.DToUInt32(data, 131); + CMD302.BCLChargMode = data[135]; + CMD302.BCSVoltageValue = ByteUtils.DToUInt32(data, 136); + CMD302.BCSCurrentValue = ByteUtils.DToUInt32(data, 140); + CMD302.BCSVoltageMAX = ByteUtils.DToUInt32(data, 144); + CMD302.BCSBatteryNumMAX = data[145]; + CMD302.BCSChargState = ByteUtils.DToUInt16(data, 146); + CMD302.ReChargeTime = ByteUtils.DToUInt32(data, 148); + CMD302.BSMNum = data[152]; + CMD302.BSMMaxTemp = data[153]; + CMD302.MaxTempPointNum = data[154]; + CMD302.MinBatteryTemp = data[155]; + CMD302.MinTempPointNum = data[156]; + CMD302.voltageHighLow = data[157]; + CMD302.ChargStateHighLow = data[158]; + CMD302.BmsOvercurrent = data[159]; + CMD302.TempHigh = data[160]; + CMD302.InsulatState = data[161]; + CMD302.ConnectState = data[162]; + CMD302.AllowCharge = data[163]; + CMD302.SOCTargetValue = data[164]; + CMD302.SumVoltageSetValue = data[165]; + CMD302.VoltageSetValue = data[166]; + CMD302.ChargeEnd = data[167]; + CMD302.InsulatFault = data[168]; + CMD302.OvertempFault = data[169]; + CMD302.Overtemp = data[170]; + CMD302.ConnectorFault = data[171]; + CMD302.ChargOvertempFault = data[172]; + CMD302.HVoltageFault = data[173]; + CMD302.VoltageSenseFault = data[174]; + CMD302.OtherFault = data[175]; + CMD302.Overcurrent = data[176]; + CMD302.VoltageAnomaly = data[177]; + CMD302.VoltageAnomaly = data[178]; + CMD302.EndChargState = data[179]; + CMD302.MinVoltage = data[180]; + CMD302.MaxVoltage = data[181]; + CMD302.MinChargTemp = data[182]; + CMD302.MaxChargTemp = data[183]; + CMD302.ReceiveTimeout1 = data[184]; + CMD302.ReceiveTimeout2 = data[185]; + CMD302.ReceiveTimeout3 = data[186]; + CMD302.ReceiveTimeout4 = data[187]; + CMD302.ReceiveTimeout5 = data[188]; + CMD302.ReceiveTimeout6 = data[189]; + CMD302.ReceiveTimeout7 = data[190]; + CMD302.Other = data[191]; + } + return CMD302; + } + public CMD304 ConCMD304(byte[] data) + { + CMD304 CMD304 = null; + if (data != null && data.Length > 0) + { + CMD304 = new CMD304(); + CMD304.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD304.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD304.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD304.WorkState = data[44]; + CMD304.connectState = data[45]; + CMD304.BRMMessage = Encoding.ASCII.GetString(data, 46, 64); + CMD304.VBIMessage = Encoding.ASCII.GetString(data, 110, 64); + CMD304.ChargParameter = Encoding.ASCII.GetString(data, 174, 16); + CMD304.ReadyState = ByteUtils.DToUInt16(data, 190); + CMD304.ChargDemand = ByteUtils.DToUInt16(data, 198); + CMD304.TotalState = Encoding.ASCII.GetString(data, 206, 16); + CMD304.StateInfo = ByteUtils.DToUInt32(data, 222); + CMD304.StopCharg = ByteUtils.DToUInt32(data, 226); + CMD304.StatisticData = ByteUtils.DToUInt32(data, 230); + CMD304.BEMMessage = ByteUtils.DToUInt32(data, 234); + } + return CMD304; + } + public CMD402 ConCMD402(uint func, byte[] data) + { + CMD402 CMD402 = null; + if (data != null && data.Length > 0) + { + CMD402 = new CMD402(); + CMD402.Reserved1 = ByteUtils.DToUInt16(data, 8); + CMD402.Reserved2 = ByteUtils.DToUInt16(data, 10); + CMD402.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD402.PosType = data[44]; + CMD402.ChargGun = data[45]; + CMD402.ChargCardID = Encoding.ASCII.GetString(data, 46, 32); + CMD402.ChargStartTime = Encoding.ASCII.GetString(data, 78, 8); + CMD402.ChargEndTime = Encoding.ASCII.GetString(data, 86, 8); + CMD402.ChargTimeLength = ByteUtils.DToUInt32(data, 94); + CMD402.SOCStart = data[98]; + CMD402.SOCEnd = data[99]; + CMD402.ChargEndReason = Encoding.ASCII.GetString(data, 100, 4); + if (func == 402) + { + CMD402.ChargCapacity = (ByteUtils.ToUInt32(data, 104) * 0.01).ToString("F2"); + + + CMD402.ChargCapacity01 = ((ByteUtils.DToUInt16(data, 167)) * 0.01).ToString("F2"); + CMD402.ChargCapacity02 = ((ByteUtils.DToUInt16(data, 169)) * 0.01).ToString("F2"); + CMD402.ChargCapacity03 = ((ByteUtils.DToUInt16(data, 171)) * 0.01).ToString("F2"); + CMD402.ChargCapacity04 = ((ByteUtils.DToUInt16(data, 173)) * 0.01).ToString("F2"); + CMD402.ChargCapacity05 = ((ByteUtils.DToUInt16(data, 175)) * 0.01).ToString("F2"); + CMD402.ChargCapacity06 = ((ByteUtils.DToUInt16(data, 177)) * 0.01).ToString("F2"); + CMD402.ChargCapacity07 = ((ByteUtils.DToUInt16(data, 179)) * 0.01).ToString("F2"); + CMD402.ChargCapacity08 = ((ByteUtils.DToUInt16(data, 181)) * 0.01).ToString("F2"); + CMD402.ChargCapacity09 = ((ByteUtils.DToUInt16(data, 183)) * 0.01).ToString("F2"); + CMD402.ChargCapacity10 = ((ByteUtils.DToUInt16(data, 185)) * 0.01).ToString("F2"); + CMD402.ChargCapacity11 = ((ByteUtils.DToUInt16(data, 187)) * 0.01).ToString("F2"); + CMD402.ChargCapacity12 = ((ByteUtils.DToUInt16(data, 189)) * 0.01).ToString("F2"); + CMD402.ChargCapacity13 = ((ByteUtils.DToUInt16(data, 191)) * 0.01).ToString("F2"); + CMD402.ChargCapacity14 = ((ByteUtils.DToUInt16(data, 193)) * 0.01).ToString("F2"); + CMD402.ChargCapacity15 = ((ByteUtils.DToUInt16(data, 195)) * 0.01).ToString("F2"); + CMD402.ChargCapacity16 = ((ByteUtils.DToUInt16(data, 197)) * 0.01).ToString("F2"); + CMD402.ChargCapacity17 = ((ByteUtils.DToUInt16(data, 199)) * 0.01).ToString("F2"); + CMD402.ChargCapacity18 = ((ByteUtils.DToUInt16(data, 201)) * 0.01).ToString("F2"); + CMD402.ChargCapacity19 = ((ByteUtils.DToUInt16(data, 203)) * 0.01).ToString("F2"); + CMD402.ChargCapacity20 = ((ByteUtils.DToUInt16(data, 205)) * 0.01).ToString("F2"); + CMD402.ChargCapacity21 = ((ByteUtils.DToUInt16(data, 207)) * 0.01).ToString("F2"); + CMD402.ChargCapacity22 = ((ByteUtils.DToUInt16(data, 209)) * 0.01).ToString("F2"); + CMD402.ChargCapacity23 = ((ByteUtils.DToUInt16(data, 211)) * 0.01).ToString("F2"); + CMD402.ChargCapacity24 = ((ByteUtils.DToUInt16(data, 213)) * 0.01).ToString("F2"); + CMD402.ChargCapacity25 = ((ByteUtils.DToUInt16(data, 215)) * 0.01).ToString("F2"); + CMD402.ChargCapacity26 = ((ByteUtils.DToUInt16(data, 217)) * 0.01).ToString("F2"); + CMD402.ChargCapacity27 = ((ByteUtils.DToUInt16(data, 219)) * 0.01).ToString("F2"); + CMD402.ChargCapacity28 = ((ByteUtils.DToUInt16(data, 221)) * 0.01).ToString("F2"); + CMD402.ChargCapacity29 = ((ByteUtils.DToUInt16(data, 223)) * 0.01).ToString("F2"); + CMD402.ChargCapacity30 = ((ByteUtils.DToUInt16(data, 225)) * 0.01).ToString("F2"); + CMD402.ChargCapacity31 = ((ByteUtils.DToUInt16(data, 227)) * 0.01).ToString("F2"); + CMD402.ChargCapacity32 = ((ByteUtils.DToUInt16(data, 229)) * 0.01).ToString("F2"); + CMD402.ChargCapacity33 = ((ByteUtils.DToUInt16(data, 231)) * 0.01).ToString("F2"); + CMD402.ChargCapacity34 = ((ByteUtils.DToUInt16(data, 233)) * 0.01).ToString("F2"); + CMD402.ChargCapacity35 = ((ByteUtils.DToUInt16(data, 235)) * 0.01).ToString("F2"); + CMD402.ChargCapacity36 = ((ByteUtils.DToUInt16(data, 237)) * 0.01).ToString("F2"); + CMD402.ChargCapacity37 = ((ByteUtils.DToUInt16(data, 239)) * 0.01).ToString("F2"); + CMD402.ChargCapacity38 = ((ByteUtils.DToUInt16(data, 241)) * 0.01).ToString("F2"); + CMD402.ChargCapacity39 = ((ByteUtils.DToUInt16(data, 243)) * 0.01).ToString("F2"); + CMD402.ChargCapacity40 = ((ByteUtils.DToUInt16(data, 245)) * 0.01).ToString("F2"); + CMD402.ChargCapacity41 = ((ByteUtils.DToUInt16(data, 247)) * 0.01).ToString("F2"); + CMD402.ChargCapacity42 = ((ByteUtils.DToUInt16(data, 249)) * 0.01).ToString("F2"); + CMD402.ChargCapacity43 = ((ByteUtils.DToUInt16(data, 251)) * 0.01).ToString("F2"); + CMD402.ChargCapacity44 = ((ByteUtils.DToUInt16(data, 253)) * 0.01).ToString("F2"); + CMD402.ChargCapacity45 = ((ByteUtils.DToUInt16(data, 255)) * 0.01).ToString("F2"); + CMD402.ChargCapacity46 = ((ByteUtils.DToUInt16(data, 257)) * 0.01).ToString("F2"); + CMD402.ChargCapacity47 = ((ByteUtils.DToUInt16(data, 259)) * 0.01).ToString("F2"); + CMD402.ChargCapacity48 = ((ByteUtils.DToUInt16(data, 261)) * 0.01).ToString("F2"); + + CMD402.StartMode = data[263]; + CMD402.SerialNum = Encoding.ASCII.GetString(data, 264, 32); + CMD402.ChargServiceCost = ByteUtils.DToUInt32(data, 296); + CMD402.KilElectricity = (data[300] * 0.001).ToString("F4"); + CMD402.ParallelMark = data[301]; + } + else if (func == 422) + { + CMD402.ChargCapacity = (ByteUtils.ToUInt32(data, 104) * 0.001).ToString("F3"); + + + CMD402.ChargCapacity01 = ((ByteUtils.DToUInt32(data, 167) * 0.001)).ToString("F3"); + CMD402.ChargCapacity02 = ((ByteUtils.DToUInt32(data, 171) * 0.001)).ToString("F3"); + CMD402.ChargCapacity03 = ((ByteUtils.DToUInt32(data, 175) * 0.001)).ToString("F3"); + CMD402.ChargCapacity04 = ((ByteUtils.DToUInt32(data, 179) * 0.001)).ToString("F3"); + CMD402.ChargCapacity05 = ((ByteUtils.DToUInt32(data, 183) * 0.001)).ToString("F3"); + CMD402.ChargCapacity06 = ((ByteUtils.DToUInt32(data, 187) * 0.001)).ToString("F3"); + CMD402.ChargCapacity07 = ((ByteUtils.DToUInt32(data, 191) * 0.001)).ToString("F3"); + CMD402.ChargCapacity08 = ((ByteUtils.DToUInt32(data, 195) * 0.001)).ToString("F3"); + CMD402.ChargCapacity09 = ((ByteUtils.DToUInt32(data, 199) * 0.001)).ToString("F3"); + CMD402.ChargCapacity10 = ((ByteUtils.DToUInt32(data, 203) * 0.001)).ToString("F3"); + CMD402.ChargCapacity11 = ((ByteUtils.DToUInt32(data, 207) * 0.001)).ToString("F3"); + CMD402.ChargCapacity12 = ((ByteUtils.DToUInt32(data, 211) * 0.001)).ToString("F3"); + CMD402.ChargCapacity13 = ((ByteUtils.DToUInt32(data, 215) * 0.001)).ToString("F3"); + CMD402.ChargCapacity14 = ((ByteUtils.DToUInt32(data, 219) * 0.001)).ToString("F3"); + CMD402.ChargCapacity15 = ((ByteUtils.DToUInt32(data, 223) * 0.001)).ToString("F3"); + CMD402.ChargCapacity16 = ((ByteUtils.DToUInt32(data, 227) * 0.001)).ToString("F3"); + CMD402.ChargCapacity17 = ((ByteUtils.DToUInt32(data, 231) * 0.001)).ToString("F3"); + CMD402.ChargCapacity18 = ((ByteUtils.DToUInt32(data, 235) * 0.001)).ToString("F3"); + CMD402.ChargCapacity19 = ((ByteUtils.DToUInt32(data, 239) * 0.001)).ToString("F3"); + CMD402.ChargCapacity20 = ((ByteUtils.DToUInt32(data, 243) * 0.001)).ToString("F3"); + CMD402.ChargCapacity21 = ((ByteUtils.DToUInt32(data, 247) * 0.001)).ToString("F3"); + CMD402.ChargCapacity22 = ((ByteUtils.DToUInt32(data, 251) * 0.001)).ToString("F3"); + CMD402.ChargCapacity23 = ((ByteUtils.DToUInt32(data, 255) * 0.001)).ToString("F3"); + CMD402.ChargCapacity24 = ((ByteUtils.DToUInt32(data, 259) * 0.001)).ToString("F3"); + CMD402.ChargCapacity25 = ((ByteUtils.DToUInt32(data, 263) * 0.001)).ToString("F3"); + CMD402.ChargCapacity26 = ((ByteUtils.DToUInt32(data, 267) * 0.001)).ToString("F3"); + CMD402.ChargCapacity27 = ((ByteUtils.DToUInt32(data, 271) * 0.001)).ToString("F3"); + CMD402.ChargCapacity28 = ((ByteUtils.DToUInt32(data, 275) * 0.001)).ToString("F3"); + CMD402.ChargCapacity29 = ((ByteUtils.DToUInt32(data, 279) * 0.001)).ToString("F3"); + CMD402.ChargCapacity30 = ((ByteUtils.DToUInt32(data, 283) * 0.001)).ToString("F3"); + CMD402.ChargCapacity31 = ((ByteUtils.DToUInt32(data, 287) * 0.001)).ToString("F3"); + CMD402.ChargCapacity32 = ((ByteUtils.DToUInt32(data, 291) * 0.001)).ToString("F3"); + CMD402.ChargCapacity33 = ((ByteUtils.DToUInt32(data, 295) * 0.001)).ToString("F3"); + CMD402.ChargCapacity34 = ((ByteUtils.DToUInt32(data, 299) * 0.001)).ToString("F3"); + CMD402.ChargCapacity35 = ((ByteUtils.DToUInt32(data, 303) * 0.001)).ToString("F3"); + CMD402.ChargCapacity36 = ((ByteUtils.DToUInt32(data, 307) * 0.001)).ToString("F3"); + CMD402.ChargCapacity37 = ((ByteUtils.DToUInt32(data, 311) * 0.001)).ToString("F3"); + CMD402.ChargCapacity38 = ((ByteUtils.DToUInt32(data, 315) * 0.001)).ToString("F3"); + CMD402.ChargCapacity39 = ((ByteUtils.DToUInt32(data, 319) * 0.001)).ToString("F3"); + CMD402.ChargCapacity40 = ((ByteUtils.DToUInt32(data, 323) * 0.001)).ToString("F3"); + CMD402.ChargCapacity41 = ((ByteUtils.DToUInt32(data, 327) * 0.001)).ToString("F3"); + CMD402.ChargCapacity42 = ((ByteUtils.DToUInt32(data, 331) * 0.001)).ToString("F3"); + CMD402.ChargCapacity43 = ((ByteUtils.DToUInt32(data, 335) * 0.001)).ToString("F3"); + CMD402.ChargCapacity44 = ((ByteUtils.DToUInt32(data, 339) * 0.001)).ToString("F3"); + CMD402.ChargCapacity45 = ((ByteUtils.DToUInt32(data, 343) * 0.001)).ToString("F3"); + CMD402.ChargCapacity46 = ((ByteUtils.DToUInt32(data, 347) * 0.001)).ToString("F3"); + CMD402.ChargCapacity47 = ((ByteUtils.DToUInt32(data, 351) * 0.001)).ToString("F3"); + CMD402.ChargCapacity48 = ((ByteUtils.DToUInt32(data, 355) * 0.001)).ToString("F3"); + CMD402.StartMode = data[359]; + CMD402.SerialNum = Encoding.ASCII.GetString(data, 360, 32); + CMD402.ChargServiceCost = ByteUtils.DToUInt32(data, 392); + CMD402.KilElectricity = (data[396] * 0.001).ToString("F4"); + CMD402.ParallelMark = data[397]; + } + + CMD402.SAmmeterValue = ByteUtils.DToUInt32(data, 108); + CMD402.EAmmeterValue = ByteUtils.DToUInt32(data, 112); + CMD402.ChargeAmount = ByteUtils.DToUInt32(data, 116); + CMD402.IndexNum = ByteUtils.DToUInt32(data, 120); + CMD402.InitialBalance = ByteUtils.DToUInt32(data, 124); + CMD402.ChargRecordIndex = ByteUtils.DToUInt32(data, 128); + CMD402.TotalChargeRecord = ByteUtils.DToUInt32(data, 132); + CMD402.Reserved3 = data[136]; + CMD402.ChargStrategy = data[137]; + switch (data[137]) + { + case 1: + CMD402.ChargStrategyPara = (ByteUtils.ToUInt32(data, 138)).ToString(); + break; + case 2: + CMD402.ChargStrategyPara = ((float)ByteUtils.ToUInt32(data, 138) * 0.01).ToString("F2"); + break; + case 3: + CMD402.ChargStrategyPara = ((float)ByteUtils.ToUInt32(data, 138) * 0.01).ToString("F3"); + break; + } + + + CMD402.VINCar = Encoding.ASCII.GetString(data, 142, 17); + CMD402.CarID = Encoding.ASCII.GetString(data, 159, 8); + + } + return CMD402; + } + public CMD1002 ConCMD1002(byte[] data) + { + CMD1002 CMD1002 = null; + if (data != null && data.Length > 0) + { + CMD1002 = new CMD1002(); + CMD1002.ErasurePercentage = data[8]; + } + return CMD1002; + } + public CMD1004 ConCMD1004(byte[] data) + { + CMD1004 CMD1004 = null; + if (data != null && data.Length > 0) + { + CMD1004 = new CMD1004(); + CMD1004.DataLength = data[8]; + } + return CMD1004; + } + public CMD1006 ConCMD1006(byte[] data) + { + CMD1006 CMD1006 = null; + if (data != null && data.Length > 0) + { + CMD1006 = new CMD1006(); + CMD1006.ResponseFlag = data[8]; + } + return CMD1006; + } + public CMD1008 ConCMD1008(byte[] data) + { + CMD1008 CMD1008 = null; + if (data != null && data.Length > 0) + { + CMD1008 = new CMD1008(); + CMD1008.ReceiveSN = data[8]; + CMD1008.WriteFlag = data[9]; + CMD1008.Reserved1 = (short)ByteUtils.DToUInt16(data, 10); + CMD1008.Reserved2 = (int)ByteUtils.DToUInt32(data, 12); + } + return CMD1008; + } + public CMD1010 ConCMD1010(byte[] data) + { + CMD1010 CMD1010 = null; + if (data != null && data.Length > 0) + { + CMD1010 = new CMD1010(); + CMD1010.Reserved1 = ByteUtils.DToUInt16(data, 8); + } + return CMD1010; + } + public CMD1012 ConCMD1012(byte[] data) + { + CMD1012 CMD1012 = null; + if (data != null && data.Length > 0) + { + CMD1012 = new CMD1012(); + CMD1012.Reserved1 = (int)ByteUtils.DToUInt32(data, 8); + } + return CMD1012; + } + public CMD1022 ConCMD1022(byte[] data) + { + CMD1022 CMD1022 = null; + if (data != null && data.Length > 0) + { + CMD1022 = new CMD1022(); + CMD1022.EquipmentCode = (int)ByteUtils.DToUInt32(data, 8); + CMD1022.ProjectCode = (int)ByteUtils.DToUInt32(data, 12); + CMD1022.SoftwareVersion = (int)ByteUtils.DToUInt32(data, 16); + CMD1022.ReceiveFileSizeMax = (int)ByteUtils.DToUInt32(data, 20); + CMD1022.DeviceDescripte = Encoding.ASCII.GetString(data, 24, 32); + CMD1022.CommandFlag = (int)ByteUtils.DToUInt32(data, 56); + CMD1022.Offset = (int)ByteUtils.DToUInt32(data, 60); + CMD1022.ContinuatSN = data[64]; + CMD1022.DataLength = (int)ByteUtils.DToUInt32(data, 65); + } + return CMD1022; + } + public CMD1102 ConCMD1102(byte[] data) + { + CMD1102 CMD1102 = null; + if (data != null && data.Length > 0) + { + CMD1102 = new CMD1102(); + CMD1102.StartHour1 = data[8]; + CMD1102.STartMin1 = data[9]; + CMD1102.EndHour1 = data[10]; + CMD1102.EndMin1 = data[11]; + CMD1102.Rate1 = ByteUtils.DToUInt32(data, 12); + + CMD1102.StartHour2 = data[16]; + CMD1102.STartMin2 = data[17]; + CMD1102.EndHour2 = data[18]; + CMD1102.EndMin2 = data[19]; + CMD1102.Rate2 = ByteUtils.DToUInt32(data, 20); + + CMD1102.StartHour3 = data[24]; + CMD1102.STartMin3 = data[25]; + CMD1102.EndHour3 = data[26]; + CMD1102.EndMin3 = data[27]; + CMD1102.Rate3 = ByteUtils.DToUInt32(data, 28); + + CMD1102.StartHour4 = data[32]; + CMD1102.STartMin4 = data[33]; + CMD1102.EndHour4 = data[34]; + CMD1102.EndMin4 = data[35]; + CMD1102.Rate4 = ByteUtils.DToUInt32(data, 36); + + CMD1102.StartHour5 = data[40]; + CMD1102.STartMin5 = data[41]; + CMD1102.EndHour5 = data[42]; + CMD1102.EndMin5 = data[43]; + CMD1102.Rate5 = ByteUtils.DToUInt32(data, 44); + + CMD1102.StartHour6 = data[48]; + CMD1102.STartMin6 = data[49]; + CMD1102.EndHour6 = data[50]; + CMD1102.EndMin6 = data[51]; + CMD1102.Rate6 = ByteUtils.DToUInt32(data, 52); + + CMD1102.StartHour7 = data[56]; + CMD1102.STartMin7 = data[57]; + CMD1102.EndHour7 = data[58]; + CMD1102.EndMin7 = data[59]; + CMD1102.Rate7 = ByteUtils.DToUInt32(data, 60); + + CMD1102.StartHour8 = data[64]; + CMD1102.STartMin8 = data[65]; + CMD1102.EndHour8 = data[66]; + CMD1102.EndMin8 = data[67]; + CMD1102.Rate8 = ByteUtils.DToUInt32(data, 68); + + CMD1102.StartHour9 = data[72]; + CMD1102.STartMin9 = data[73]; + CMD1102.EndHour9 = data[74]; + CMD1102.EndMin9 = data[75]; + CMD1102.Rate9 = ByteUtils.DToUInt32(data, 76); + + CMD1102.StartHour10 = data[80]; + CMD1102.STartMin10 = data[81]; + CMD1102.EndHour10 = data[82]; + CMD1102.EndMin10 = data[83]; + CMD1102.Rate10 = ByteUtils.DToUInt32(data, 84); + + CMD1102.StartHour11 = data[88]; + CMD1102.STartMin11 = data[89]; + CMD1102.EndHour11 = data[90]; + CMD1102.EndMin11 = data[91]; + CMD1102.Rate11 = ByteUtils.DToUInt32(data, 92); + + CMD1102.StartHour12 = data[96]; + CMD1102.STartMin12 = data[97]; + CMD1102.EndHour12 = data[98]; + CMD1102.EndMin12 = data[99]; + CMD1102.Rate12 = ByteUtils.DToUInt32(data, 100); + } + return CMD1102; + } + public CMD1104 ConCMD1104(byte[] data) + { + CMD1104 CMD1104 = null; + if (data != null && data.Length > 0) + { + CMD1104 = new CMD1104(); + CMD1104.ConfirmResult = data[8]; + } + return CMD1104; + } + public CMD1106 ConCMD1106(byte[] data) + { + CMD1106 CMD1106 = null; + if (data != null && data.Length > 0) + { + CMD1106 = new CMD1106(); + CMD1106.ConfirmResult = data[8]; + } + return CMD1106; + } + public CMD1108 ConCMD1108(byte[] data) + { + CMD1108 CMD1108 = null; + if (data != null && data.Length > 0) + { + CMD1108 = new CMD1108(); + CMD1108.StartHour1 = data[8]; + CMD1108.STartMin1 = data[9]; + CMD1108.EndHour1 = data[10]; + CMD1108.EndMin1 = data[11]; + CMD1108.Rate1 = ByteUtils.DToUInt32(data, 12); + + CMD1108.StartHour2 = data[16]; + CMD1108.STartMin2 = data[17]; + CMD1108.EndHour2 = data[18]; + CMD1108.EndMin2 = data[19]; + CMD1108.Rate2 = ByteUtils.DToUInt32(data, 20); + + CMD1108.StartHour3 = data[24]; + CMD1108.STartMin3 = data[25]; + CMD1108.EndHour3 = data[26]; + CMD1108.EndMin3 = data[27]; + CMD1108.Rate3 = ByteUtils.DToUInt32(data, 28); + + CMD1108.StartHour4 = data[32]; + CMD1108.STartMin4 = data[33]; + CMD1108.EndHour4 = data[34]; + CMD1108.EndMin4 = data[35]; + CMD1108.Rate4 = ByteUtils.DToUInt32(data, 36); + + CMD1108.StartHour5 = data[40]; + CMD1108.STartMin5 = data[41]; + CMD1108.EndHour5 = data[42]; + CMD1108.EndMin5 = data[43]; + CMD1108.Rate5 = ByteUtils.DToUInt32(data, 44); + + CMD1108.StartHour6 = data[48]; + CMD1108.STartMin6 = data[49]; + CMD1108.EndHour6 = data[50]; + CMD1108.EndMin6 = data[51]; + CMD1108.Rate6 = ByteUtils.DToUInt32(data, 52); + + CMD1108.StartHour7 = data[56]; + CMD1108.STartMin7 = data[57]; + CMD1108.EndHour7 = data[58]; + CMD1108.EndMin7 = data[59]; + CMD1108.Rate7 = ByteUtils.DToUInt32(data, 60); + + CMD1108.StartHour8 = data[64]; + CMD1108.STartMin8 = data[65]; + CMD1108.EndHour8 = data[66]; + CMD1108.EndMin8 = data[67]; + CMD1108.Rate8 = ByteUtils.DToUInt32(data, 68); + + CMD1108.StartHour9 = data[72]; + CMD1108.STartMin9 = data[73]; + CMD1108.EndHour9 = data[74]; + CMD1108.EndMin9 = data[75]; + CMD1108.Rate9 = ByteUtils.DToUInt32(data, 76); + + CMD1108.StartHour10 = data[80]; + CMD1108.STartMin10 = data[81]; + CMD1108.EndHour10 = data[82]; + CMD1108.EndMin10 = data[83]; + CMD1108.Rate10 = ByteUtils.DToUInt32(data, 84); + + CMD1108.StartHour11 = data[88]; + CMD1108.STartMin11 = data[89]; + CMD1108.EndHour11 = data[90]; + CMD1108.EndMin11 = data[91]; + CMD1108.Rate11 = ByteUtils.DToUInt32(data, 92); + + CMD1108.StartHour12 = data[96]; + CMD1108.STartMin12 = data[97]; + CMD1108.EndHour12 = data[98]; + CMD1108.EndMin12 = data[99]; + CMD1108.Rate12 = ByteUtils.DToUInt32(data, 100); + + } + return CMD1108; + } + public CMD1302 ConCMD1302(byte[] data) + { + CMD1302 CMD1302 = null; + if (data != null && data.Length > 0) + { + CMD1302 = new CMD1302(); + + CMD1302.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD1302.WhitelistType = data[44]; + CMD1302.Operate = data[45]; + CMD1302.ListVersioe = ByteUtils.DToUInt32(data, 46); + CMD1302.OperatResult = data[50]; + } + return CMD1302; + } + public CMD1402 ConCMD1402(byte[] data) + { + CMD1402 CMD1402 = null; + if (data != null && data.Length > 0) + { + CMD1402 = new CMD1402(); + + CMD1402.Result = data[12]; + } + return CMD1402; + } + public CMD1403 ConCMD1403(byte[] data) + { + CMD1403 CMD1403 = null; + if (data != null && data.Length > 0) + { + CMD1403 = new CMD1403(); + + CMD1403.ScheduleResult = data[12]; + } + return CMD1403; + } + public CMD1407 ConCMD1407(byte[] data) + { + CMD1407 CMD1407 = null; + if (data != null && data.Length > 0) + { + CMD1407 = new CMD1407(); + + CMD1407.Result = data[12]; + } + return CMD1407; + } + public CMD1501 ConCMD1501(byte[] data) + { + CMD1501 CMD1501 = null; + if (data != null && data.Length > 0) + { + CMD1501 = new CMD1501(); + + CMD1501.ASCIINum = Encoding.ASCII.GetString(data, 12, 32); + CMD1501.UpFileName = Encoding.ASCII.GetString(data, 44, 128); + } + return CMD1501; + } + public CMD1503 ConCMD1503(byte[] data) + { + CMD1503 CMD1503 = null; + if (data != null && data.Length > 0) + { + CMD1503 = new CMD1503(); + + CMD1503.DataLength = ByteUtils.DToUInt32(data, 12); + CMD1503.MessageNum = ByteUtils.DToUInt32(data, 16); + CMD1503.LogData = Encoding.ASCII.GetString(data, 20, (data.Length - 21)); ; + } + return CMD1503; + } + public CMD1505 ConCMD1505(byte[] data) + { + CMD1505 CMD1505 = null; + if (data != null && data.Length > 0) + { + CMD1505 = new CMD1505(); + } + return CMD1505; + } + + + + + + #endregion ݷ + } + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1DataInfo(CMD1 CMD1) + { + byte[] results = null; + if (CMD1 != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD1.WorkingData_Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD1.WorkingData_Reserved2)); + lstContent.Add(CMD1.Type); + lstContent.AddRange(BitConverter.GetBytes(CMD1.SetAddress));//ʼַ + lstContent.Add(CMD1.SelectNum);//ѯ + lstContent.AddRange(BitConverter.GetBytes(CMD1.SetByteNum));//ֽ + if (CMD1.Type == 1) + { + lstContent.AddRange(CMD1.SetData); + } + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD3DataInfo(CMD3 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.Add(CMD.Type); + lstContent.AddRange(BitConverter.GetBytes(CMD.SAddress)); + lstContent.AddRange(BitConverter.GetBytes(CMD.SBytes)); + if (CMD.Type == 1) + { + lstContent.AddRange(CMD.SData); + } + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD5DataInfo(CMD5 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.Add(CMD.RechargeableMuzzle); + lstContent.AddRange(BitConverter.GetBytes(CMD.CommandAddress)); + lstContent.Add(CMD.CommandNum); + lstContent.AddRange(BitConverter.GetBytes(CMD.CommandLength)); + lstContent.AddRange(CMD.CommandData); + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD7DataInfo(CMD7 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved)); + lstContent.Add(CMD.ChargMuzzle); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargeType)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargeStopPassword)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargStrategy)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargStrategyPara)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ScheduleStartupTime)); + lstContent.Add(CMD.OutTime); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.CardNumber, 32)); + lstContent.Add(CMD.NetOutageSign); + lstContent.AddRange(BitConverter.GetBytes(CMD.MaxElectric)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.SerialNum, 32)); + lstContent.Add(CMD.BMSVoltage); + lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); + lstContent.Add(CMD.DisOrChargeMark); + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD9DataInfo(CMD9 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); + lstContent.AddRange(BitConverter.GetBytes(CMD.FWResult)); + lstContent.AddRange(BitConverter.GetBytes(CMD.CommandAddress)); + lstContent.AddRange(BitConverter.GetBytes(CMD.DataLength)); + lstContent.AddRange(CMD.Datas); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD101DataInfo(CMD101 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.HearResponse)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD103DataInfo(CMD103 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.Add(CMD.ChargNum); + lstContent.Add(Convert.ToByte(CMD.Reported)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD105DataInfo(CMD105 CMD105) + { + byte[] results = null; + if (CMD105 != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD105.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD105.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD105.NumResponse)); + lstContent.Add(CMD105.LoginVerify); + lstContent.Add(CMD105.EncryptionFlag); + if (CMD105.EncryptionFlag == 1) + { + lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD105.RSAComModule)); + lstContent.AddRange(BitConverter.GetBytes(CMD105.RSAComSecret)); + } + lstContent.Add(CMD105.StSign); + lstContent.AddRange(BitConverter.GetBytes(CMD105.BCDTime)); + lstContent.Add(CMD105.MessageUpload); + if (CMD105.EncryptionFlag == 1) + lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD105.AESSecretKey)); + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD107DataInfo(CMD107 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + //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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD109DataInfo(CMD109 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD111DataInfo(CMD111 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.MessageType)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD113DataInfo(CMD113 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.Add(CMD.ChargNum); + lstContent.Add(Convert.ToByte(CMD.Sign)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD201DataInfo(CMD201 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargNum)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ChargID, 32)); + lstContent.AddRange(BitConverter.GetBytes(CMD.IndexNum)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ValidMark)); + lstContent.AddRange(BitConverter.GetBytes(CMD.InitialCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.DiscountCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetElectricCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetServiceCost)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD203DataInfo(CMD203 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ResCode)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); + lstContent.AddRange(BitConverter.GetBytes(CMD.SumEleRate)); + lstContent.AddRange(BitConverter.GetBytes(CMD.EleRate)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargPassword)); + lstContent.AddRange(BitConverter.GetBytes(CMD.VINSign)); + lstContent.AddRange(BitConverter.GetBytes(CMD.CarIDVerify)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved3)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.SerialNum, 32)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VIN, 17)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD205DataInfo(CMD205 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ResponseCode)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD207DataInfo(CMD207 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ASCIINum, 32)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VINNum, 17)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VINBindAccount, 32)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ChargSerialNum, 32)); + lstContent.AddRange(BitConverter.GetBytes(CMD.VerifyResult)); + lstContent.AddRange(BitConverter.GetBytes(CMD.VerifyCause)); + lstContent.AddRange(BitConverter.GetBytes(CMD.RechBalance)); + lstContent.AddRange(BitConverter.GetBytes(CMD.StopCode)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD209DataInfo(CMD209 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.ASCIINum, 32)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargGunNum)); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.VINNum, 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD221DataInfo(CMD221 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ChargNum)); + lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ChargID)); + lstContent.AddRange(BitConverter.GetBytes(CMD.IndexNum)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ValidMark)); + lstContent.AddRange(BitConverter.GetBytes(CMD.InitialCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.DiscountCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Balance)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetElectricCost)); + lstContent.AddRange(BitConverter.GetBytes(CMD.NetServiceCost)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD301DataInfo(CMD301 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD303DataInfo(CMD303 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD401DataInfo(CMD401 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.SelectIndex)); + lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ChargSerialNum)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1001DataInfo(CMD1001 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.CInstruction)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1003DataInfo(CMD1003 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(Encoding.ASCII.GetBytes(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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1005DataInfo(CMD1005 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1007DataInfo(CMD1007 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.UpFileData)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1009DataInfo(CMD1009 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1011DataInfo(CMD1011 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1021DataInfo(CMD1021 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.AddRange(BitConverter.GetBytes(CMD.ResponseResult)); + lstContent.AddRange(Encoding.UTF8.GetBytes(CMD.ResponsExplain)); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1101DataInfo(CMD1101 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1103DataInfo(CMD1103 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.Add(CMD.StartHour1); + lstContent.Add(CMD.STartMin1); + lstContent.Add(CMD.EndHour1); + lstContent.Add(CMD.EndMin1); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate1)); + + lstContent.Add(CMD.StartHour2); + lstContent.Add(CMD.STartMin2); + lstContent.Add(CMD.EndHour2); + lstContent.Add(CMD.EndMin2); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate2)); + + lstContent.Add(CMD.StartHour3); + lstContent.Add(CMD.STartMin3); + lstContent.Add(CMD.EndHour3); + lstContent.Add(CMD.EndMin3); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate3)); + + lstContent.Add(CMD.StartHour4); + lstContent.Add(CMD.STartMin4); + lstContent.Add(CMD.EndHour4); + lstContent.Add(CMD.EndMin4); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate4)); + + lstContent.Add(CMD.StartHour5); + lstContent.Add(CMD.STartMin5); + lstContent.Add(CMD.EndHour5); + lstContent.Add(CMD.EndMin5); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate5)); + + lstContent.Add(CMD.StartHour6); + lstContent.Add(CMD.STartMin6); + lstContent.Add(CMD.EndHour6); + lstContent.Add(CMD.EndMin6); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate6)); + + lstContent.Add(CMD.StartHour7); + lstContent.Add(CMD.STartMin7); + lstContent.Add(CMD.EndHour7); + lstContent.Add(CMD.EndMin7); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate7)); + + lstContent.Add(CMD.StartHour8); + lstContent.Add(CMD.STartMin8); + lstContent.Add(CMD.EndHour8); + lstContent.Add(CMD.EndMin8); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate8)); + + lstContent.Add(CMD.StartHour9); + lstContent.Add(CMD.STartMin9); + lstContent.Add(CMD.EndHour9); + lstContent.Add(CMD.EndMin9); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate9)); + + lstContent.Add(CMD.StartHour10); + lstContent.Add(CMD.STartMin10); + lstContent.Add(CMD.EndHour10); + lstContent.Add(CMD.EndMin10); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate10)); + + lstContent.Add(CMD.StartHour11); + lstContent.Add(CMD.STartMin11); + lstContent.Add(CMD.EndHour11); + lstContent.Add(CMD.EndMin11); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate11)); + + lstContent.Add(CMD.StartHour12); + lstContent.Add(CMD.STartMin12); + lstContent.Add(CMD.EndHour12); + lstContent.Add(CMD.EndMin12); + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1105DataInfo(CMD1105 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + lstContent.Add(CMD.StartHour1); + lstContent.Add(CMD.STartMin1); + lstContent.Add(CMD.EndHour1); + lstContent.Add(CMD.EndMin1); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate1)); + + lstContent.Add(CMD.StartHour2); + lstContent.Add(CMD.STartMin2); + lstContent.Add(CMD.EndHour2); + lstContent.Add(CMD.EndMin2); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate2)); + + lstContent.Add(CMD.StartHour3); + lstContent.Add(CMD.STartMin3); + lstContent.Add(CMD.EndHour3); + lstContent.Add(CMD.EndMin3); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate3)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate3)); + + lstContent.Add(CMD.StartHour4); + lstContent.Add(CMD.STartMin4); + lstContent.Add(CMD.EndHour4); + lstContent.Add(CMD.EndMin4); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate4)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate4)); + + lstContent.Add(CMD.StartHour5); + lstContent.Add(CMD.STartMin5); + lstContent.Add(CMD.EndHour5); + lstContent.Add(CMD.EndMin5); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate5)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate5)); + + lstContent.Add(CMD.StartHour6); + lstContent.Add(CMD.STartMin6); + lstContent.Add(CMD.EndHour6); + lstContent.Add(CMD.EndMin6); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate6)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate6)); + + lstContent.Add(CMD.StartHour7); + lstContent.Add(CMD.STartMin7); + lstContent.Add(CMD.EndHour7); + lstContent.Add(CMD.EndMin7); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate7)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate7)); + + lstContent.Add(CMD.StartHour8); + lstContent.Add(CMD.STartMin8); + lstContent.Add(CMD.EndHour8); + lstContent.Add(CMD.EndMin8); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate8)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate8)); + + lstContent.Add(CMD.StartHour9); + lstContent.Add(CMD.STartMin9); + lstContent.Add(CMD.EndHour9); + lstContent.Add(CMD.EndMin9); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate9)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate9)); + + lstContent.Add(CMD.StartHour10); + lstContent.Add(CMD.STartMin10); + lstContent.Add(CMD.EndHour10); + lstContent.Add(CMD.EndMin10); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate10)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate10)); + + lstContent.Add(CMD.StartHour11); + lstContent.Add(CMD.STartMin11); + lstContent.Add(CMD.EndHour11); + lstContent.Add(CMD.EndMin11); + lstContent.AddRange(BitConverter.GetBytes(CMD.Rate11)); + lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate11)); + + lstContent.Add(CMD.StartHour12); + lstContent.Add(CMD.STartMin12); + lstContent.Add(CMD.EndHour12); + lstContent.Add(CMD.EndMin12); + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1107DataInfo(CMD1107 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// CMD1301 翨 30byte\0 + /// + /// + /// + 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; + } + + + /// + /// ȡȨϢֽ + /// 1-翨 32byte\2-VIN 17byte + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1301DataInfo(CMD1301 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ASCIINum), 32)); + lstContent.Add(CMD.WhitelistType); + lstContent.Add(CMD.Operate); + lstContent.AddRange(BitConverter.GetBytes(CMD.WhitelistVersioNum)); + //Ϊѯ =4ֶβҪ + if (CMD.Operate != 4) + { + lstContent.AddRange(BitConverter.GetBytes(CMD.WhitelistNum)); + if (CMD.WhitelistType == 1) + { + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID01), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID02), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID03), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID04), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID05), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID06), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID07), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID08), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID09), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID10), 32)); + } + else + { + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID01), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID02), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID03), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID04), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID05), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID06), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID07), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID08), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID09), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.VINCarID10), 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1401DataInfo(CMD1401 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes((ushort)(Convert.ToSingle(CMD.UpFileVersioNum) * 100))); + + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ServerIP), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.UserName), 16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.Password), 16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.DownloadPath), 64)); + + lstContent.Add(CMD.ExecutiveMode); + lstContent.Add(CMD.DeviceType); + + 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); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1406DataInfo(CMD1406 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.Add(CMD.LogType); + + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.ServerIP), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.UserName), 16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.Password), 16)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.LogPath), 32)); + lstContent.Add(CMD.ExecutiveMode); + + 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; + + + model.dataDomain = GetRCMD1502DataInfo(CMD); // + model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1502DataInfo(CMD1502 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.AnswerCode)); + + 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; + + model.dataDomain = GetRCMD1504DataInfo(CMD); // + model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1504DataInfo(CMD1504 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Sign)); + lstContent.AddRange(BitConverter.GetBytes(CMD.ReceiveMessageNum)); + + 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; + + + model.dataDomain = GetRCMD1506DataInfo(CMD); // + model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //ij + + List lstResult = new List(); + lstResult.AddRange(APCI(model).ToArray()); + result = lstResult.ToArray(); + + APDUModel = model; + return result; + } + + /// + /// ȡȨϢֽ + /// + /// + /// ȨϢֽ + private byte[] GetRCMD1506DataInfo(CMD1506 CMD) + { + byte[] results = null; + if (CMD != null) + { + List lstContent = new List(); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved1)); + lstContent.AddRange(BitConverter.GetBytes(CMD.Reserved2)); + + results = lstContent.ToArray(); + } + return results; + } + #endregion + + List APCI(APDUModel baseApci) + { + List lstResult = null; + if (baseApci != null) + { + lstResult = new List(); + //ʼ + lstResult.Add(baseApci.OriginDomain1); + lstResult.Add(baseApci.OriginDomain2); + // + byte[] packLens = BitConverter.GetBytes(baseApci.LengthDomain); + lstResult.AddRange(packLens); + //Ϣ + lstResult.Add(baseApci.infoDomain); + //к + lstResult.Add(baseApci.SerialNumberDomain); + //Դַ + byte[] packSrcs = BitConverter.GetBytes(baseApci.CMD); + lstResult.AddRange(packSrcs); + // + lstResult.AddRange(baseApci.dataDomain); + + baseApci.checksumDomain = checksumDomain(lstResult.ToArray()); + //У + lstResult.Add(baseApci.checksumDomain); + } + return lstResult; + } + /// + /// ݰ-У + /// + /// + /// + public static byte checksumDomain(byte[] data) + { + int checksum = 0; + + for (int i = 6; i < data.Count(); i++)//ûУԲһ + { + checksum += data[i]; + } + + //foreach (byte b in data) + //{ + // checksum += b; + //} + // ȡУ͵ĵ8λ + return (byte)(checksum & 0xFF); + } + } +} diff --git a/HybirdFrameworkServices/Class1.cs b/HybirdFrameworkServices/Class1.cs deleted file mode 100644 index 4efe94f..0000000 --- a/HybirdFrameworkServices/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace HybirdFrameworkServices -{ - public class Class1 - { - - } -} diff --git a/HybirdFrameworkServices/HybirdFrameworkServices.csproj b/HybirdFrameworkServices/HybirdFrameworkServices.csproj index 90abea2..5379441 100644 --- a/HybirdFrameworkServices/HybirdFrameworkServices.csproj +++ b/HybirdFrameworkServices/HybirdFrameworkServices.csproj @@ -9,6 +9,7 @@ + @@ -20,7 +21,6 @@ - diff --git a/HybirdFrameworkServices/Netty/Server.cs b/HybirdFrameworkServices/Netty/Server.cs index c59fef1..d9f4751 100644 --- a/HybirdFrameworkServices/Netty/Server.cs +++ b/HybirdFrameworkServices/Netty/Server.cs @@ -1,6 +1,7 @@ using System.Collections.Concurrent; using System.Net; using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; using System.Threading.Channels; using DotNetty.Buffers; using DotNetty.Handlers.Logging; @@ -11,7 +12,6 @@ using DotNetty.Transport.Channels.Sockets; using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkServices.System; using log4net; -using Module.Socket.Tool; namespace HybirdFrameworkServices.Netty { @@ -31,7 +31,7 @@ namespace HybirdFrameworkServices.Netty private int _port = 9000; - public Server(int port) + public void connect(int port) { _port = port; IByteBuffer delimiter = Unpooled.CopiedBuffer(new byte[] { 0xAA, 0xF5 }); @@ -55,12 +55,13 @@ namespace HybirdFrameworkServices.Netty //pipeline.AddLast(msgHandler); //业务handler ,这里是实际处理业务的Handler - pipeline.AddLast(new CustomFrameDecoder4(new IByteBuffer[] { delimiter }, false, false)); + pipeline.AddLast(new CustomFrameDecoder(new IByteBuffer[] { delimiter }, false, false)); pipeline.AddLast(new CustomFrameEncoder()); - + //// 添加客户端连接监控Handler + //pipeline.AddLast(new ClientConnectionMonitorHandler()); //pipeline.AddLast("idleStateHandler", new IdleStateHandler(30, 0, 0)); // 触发读取超时 - //pipeline.AddLast(new ReconnectHandler(this)); - //pipeline.AddLast(new ClientHandler(this)); + //pipeline.AddLast(new ReconnectHandler(this)); + //pipeline.AddLast(new ClientHandler(this)); })); Begin(_port); } @@ -81,9 +82,13 @@ namespace HybirdFrameworkServices.Netty channel.WriteAndFlushAsync(bytes); } } - - - + public void Send(byte[] bytes,string id) + { + foreach (IChannel channel in _container.Values) + { + channel.WriteAndFlushAsync(bytes); + } + } /// /// ??netty @@ -93,6 +98,28 @@ namespace HybirdFrameworkServices.Netty Log.Info(this + " Dispose"); bossGroup?.ShutdownGracefullyAsync(); } + /// + /// 断开连接 + /// + public void Disconnect(string ip) + { + Log.Info(this + " Disconnect"); + + foreach (IChannel channel in _container.Values) + { + string input = channel.RemoteAddress.ToString(); + + // 正则表达式匹配IPv4地址和端口号 + string pattern = @"\[(::ffff:)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]:(\d+)"; + Match match = Regex.Match(input, pattern); + + // 获取IP地址(不包括IPv6前缀) + string ipAddress = match.Groups[2].Value; + if (ip == ipAddress) + channel.DisconnectAsync(); + } + + } } } diff --git a/HybirdFrameworkServices/Tool/ClientConnectionMonitorHandler.cs b/HybirdFrameworkServices/Tool/ClientConnectionMonitorHandler.cs new file mode 100644 index 0000000..7f863ec --- /dev/null +++ b/HybirdFrameworkServices/Tool/ClientConnectionMonitorHandler.cs @@ -0,0 +1,97 @@ +using DotNetty.Transport.Channels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Channels; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + public class ClientConnectionMonitorHandler : ChannelDuplexHandler + { + //ChannelInboundHandlerAdapter + /// + /// 监控连接 + /// + /// + public override void HandlerAdded(IChannelHandlerContext ctx) + { + Console.WriteLine("Client connected: " + ctx.Channel.RemoteAddress); + + string input = ctx.Channel.RemoteAddress.ToString(); + + // 正则表达式匹配IPv4地址和端口号 + string pattern = @"\[(::ffff:)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]:(\d+)"; + Match match = Regex.Match(input, pattern); + + // 获取IP地址(不包括IPv6前缀) + string ipAddress = match.Groups[2].Value; + switch (ipAddress) + { + case "127.0.0.1": + CmnChargingsEqmInfo._ID = ctx.Channel.Id; + CmnChargingsEqmInfo._CHR0IPADDR = ipAddress; + CmnChargingsEqmInfo._CHR0PORT = Convert.ToInt32(match.Groups[3].Value); + CmnChargingsEqmInfo._CHR01.ChargerNetHeartBeatThread(); + break; + case "127.0.0.2": + break; + case "127.0.0.3": + break; + case "127.0.0.4": + break; + case "127.0.0.5": + break; + case "127.0.0.6": + break; + case "127.0.0.7": + break; + case "127.0.0.8": + break; + } + } + /// + /// 监控断开 + /// + /// + public override void HandlerRemoved(IChannelHandlerContext ctx) + { + Console.WriteLine("Client disconnected: " + ctx.Channel.RemoteAddress); + string input = ctx.Channel.RemoteAddress.ToString(); + + // 正则表达式匹配IPv4地址和端口号 + string pattern = @"\[(::ffff:)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]:(\d+)"; + Match match = Regex.Match(input, pattern); + + // 获取IP地址(不包括IPv6前缀) + string ipAddress = match.Groups[2].Value; + switch (ipAddress) + { + case "127.0.0.1": + CmnChargingsEqmInfo._CHR01 = null; + break; + case "127.0.0.2": + break; + case "127.0.0.3": + break; + case "127.0.0.4": + break; + case "127.0.0.5": + break; + case "127.0.0.6": + break; + case "127.0.0.7": + break; + case "127.0.0.8": + break; + } + } + + public override void ExceptionCaught(IChannelHandlerContext ctx, Exception exception) + { + Console.WriteLine("Exception in ClientConnectionMonitorHandler: " + exception.Message); + } + } +} diff --git a/HybirdFrameworkServices/Tool/CustomFrameDecoder.cs b/HybirdFrameworkServices/Tool/CustomFrameDecoder.cs new file mode 100644 index 0000000..9e99cf4 --- /dev/null +++ b/HybirdFrameworkServices/Tool/CustomFrameDecoder.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DotNetty.Buffers; +using DotNetty.Codecs; +using DotNetty.Transport.Channels; +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using HybirdFrameworkEntity; + +namespace HybirdFrameworkServices +{ + public class CustomFrameDecoder : ByteToMessageDecoder + { + private readonly IByteBuffer[] delimiters; + private readonly bool stripDelimiter; + private readonly bool failFast; + + public CustomFrameDecoder(IByteBuffer[] delimiters, bool stripDelimiter, bool failFast) + { + this.delimiters = delimiters; + this.stripDelimiter = stripDelimiter; + this.failFast = failFast; + } + + protected override void Decode(IChannelHandlerContext ctx, IByteBuffer buffer, List output) + { + + // 查找分隔符 + IByteBuffer delimiter = FindDelimiter(buffer); + if (delimiter != null) + { + int delimiterIndex = IndexOf(buffer, delimiter);//分隔符索引 + int frameLengthIndex = delimiterIndex + delimiter.Capacity;//帧长度索引 + + if (delimiterIndex > 0) + { + buffer.SkipBytes(delimiterIndex); + return; + } + + if (buffer.ReadableBytes < frameLengthIndex + 7) + { + // 数据不足,等待更多数据 + return; + } + + // 读取长度字段 + int frameLength = buffer.GetUnsignedShortLE(buffer.ReaderIndex + frameLengthIndex); + int totalFrameLength = delimiterIndex + delimiter.Capacity + 2 + frameLength; + + if (buffer.ReadableBytes < totalFrameLength) + { + // 数据不足,等待更多数据 + return; + } + + byte[] bytes = new byte[frameLength]; + buffer.ReadBytes(bytes); + + { + string input = ctx.Channel.RemoteAddress.ToString(); + + // 正则表达式匹配IPv4地址和端口号 + string pattern = @"\[(::ffff:)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]:(\d+)"; + Match match = Regex.Match(input, pattern); + + // 获取IP地址(不包括IPv6前缀) + string ipAddress = match.Groups[2].Value; + // 获取端口号 + string port = match.Groups[3].Value; + + + int checksum = 0; + for (int i = 6; i < bytes.Count() - 1; i++)//这里有校验域所以减一 + { + checksum += bytes[i]; + } + + // 取校验和的低8位 + //byte b1 = (byte)(checksum & 0xFF); + //byte b2 = (byte)(bytes[bytes.Count() - 1] & 0xFF); + if ((byte)(bytes[bytes.Count() - 1] & 0xFF) == (byte)(checksum & 0xFF)) + { + var info = bytes[4]; + if ((info & (1 << 1)) != 0)//AES加密 + { + //这里要解密 + List byteList = bytes.ToList(); + byteList.Remove(8); + byteList.Remove(8);//移除前面两个长度 + bytes = byteList.ToArray(); + + new ChargerMgrTool().decode(ipAddress, port, bytes); + } + else //不加密 + { + new ChargerMgrTool().decode(ipAddress, port, bytes); + } + } + //ctx.Channel.WriteAndFlushAsync(bytes); + } + output.Add(bytes); + } + } + + private IByteBuffer FindDelimiter(IByteBuffer buffer) + { + foreach (IByteBuffer delimiter in delimiters) + { + int delimiterIndex = IndexOf(buffer, delimiter); + if (delimiterIndex >= 0) + { + return delimiter; + } + } + return null; + } + + private static int IndexOf(IByteBuffer haystack, IByteBuffer needle) + { + for (int i = haystack.ReaderIndex; i < haystack.WriterIndex; i++) + { + int num = i; + int j; + for (j = 0; j < needle.Capacity && haystack.GetByte(num) == needle.GetByte(j); j++) + { + num++; + if (num == haystack.WriterIndex && j != needle.Capacity - 1) + { + return -1; + } + } + + if (j == needle.Capacity) + { + return i - haystack.ReaderIndex; + } + } + + return -1; + } + + } + +} diff --git a/HybirdFrameworkServices/Tool/CustomFrameEncoder.cs b/HybirdFrameworkServices/Tool/CustomFrameEncoder.cs new file mode 100644 index 0000000..8da22a4 --- /dev/null +++ b/HybirdFrameworkServices/Tool/CustomFrameEncoder.cs @@ -0,0 +1,24 @@ +using DotNetty.Buffers; +using DotNetty.Codecs; +using DotNetty.Common.Utilities; +using DotNetty.Transport.Channels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HybirdFrameworkServices +{ + /// + /// 发送数据 + /// + public class CustomFrameEncoder : MessageToByteEncoder + { + + protected override void Encode(IChannelHandlerContext context, byte[] message, IByteBuffer output) + { + output.WriteBytes(message); + } + } +} diff --git a/Module.Socket.Tool/ClientConnectionMonitorHandler.cs b/Module.Socket.Tool/ClientConnectionMonitorHandler.cs new file mode 100644 index 0000000..c980d17 --- /dev/null +++ b/Module.Socket.Tool/ClientConnectionMonitorHandler.cs @@ -0,0 +1,99 @@ +using BatCharging.Manager; +using DotNetty.Transport.Channels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Channels; +using System.Threading.Tasks; + +namespace Module.Socket.Tool +{ + public class ClientConnectionMonitorHandler : ChannelDuplexHandler + { + //ChannelInboundHandlerAdapter + /// + /// 监控连接 + /// + /// + public override void HandlerAdded(IChannelHandlerContext ctx) + { + Console.WriteLine("Client connected: " + ctx.Channel.RemoteAddress); + + string input = ctx.Channel.RemoteAddress.ToString(); + + // 正则表达式匹配IPv4地址和端口号 + string pattern = @"\[(::ffff:)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]:(\d+)"; + Match match = Regex.Match(input, pattern); + + // 获取IP地址(不包括IPv6前缀) + string ipAddress = match.Groups[2].Value; + switch (ipAddress) + { + case "127.0.0.1": + CmnChargingsEqmInfo._ID = ctx.Channel.Id; + CmnChargingsEqmInfo._CHR0IPADDR = ipAddress; + CmnChargingsEqmInfo._CHR0PORT = Convert.ToInt32(match.Groups[3].Value); + CmnChargingsEqmInfo._CHR01.ChargerNetHeartBeatThread(); + break; + case "127.0.0.2": + break; + case "127.0.0.3": + break; + case "127.0.0.4": + break; + case "127.0.0.5": + break; + case "127.0.0.6": + break; + case "127.0.0.7": + break; + case "127.0.0.8": + break; + } + } + /// + /// 监控断开 + /// + /// + public override void HandlerRemoved(IChannelHandlerContext ctx) + { + Console.WriteLine("Client disconnected: " + ctx.Channel.RemoteAddress); + string input = ctx.Channel.RemoteAddress.ToString(); + + // 正则表达式匹配IPv4地址和端口号 + string pattern = @"\[(::ffff:)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]:(\d+)"; + Match match = Regex.Match(input, pattern); + + // 获取IP地址(不包括IPv6前缀) + string ipAddress = match.Groups[2].Value; + switch (ipAddress) + { + case "127.0.0.1": + CmnChargingsEqmInfo._CHR01 = null; + break; + case "127.0.0.2": + break; + case "127.0.0.3": + break; + case "127.0.0.4": + break; + case "127.0.0.5": + break; + case "127.0.0.6": + break; + case "127.0.0.7": + break; + case "127.0.0.8": + break; + } + } + + public override void ExceptionCaught(IChannelHandlerContext ctx, Exception exception) + { + Console.WriteLine("Exception in ClientConnectionMonitorHandler: " + exception.Message); + ctx.Channel.DisconnectAsync(); + } + } +} diff --git a/Module.Socket.Tool/CustomFrameDecoder4.cs b/Module.Socket.Tool/CustomFrameDecoder4.cs index c9fa457..b994945 100644 --- a/Module.Socket.Tool/CustomFrameDecoder4.cs +++ b/Module.Socket.Tool/CustomFrameDecoder4.cs @@ -10,6 +10,7 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; using HybirdFrameworkEntity; +using BatCharging.Service; namespace Module.Socket.Tool { @@ -81,8 +82,8 @@ namespace Module.Socket.Tool } // 取校验和的低8位 - byte b1 = (byte)(checksum & 0xFF); - byte b2 = (byte)(bytes[bytes.Count() - 1] & 0xFF); + //byte b1 = (byte)(checksum & 0xFF); + //byte b2 = (byte)(bytes[bytes.Count() - 1] & 0xFF); if ((byte)(bytes[bytes.Count() - 1] & 0xFF) == (byte)(checksum & 0xFF)) { var info = bytes[4]; @@ -94,11 +95,11 @@ namespace Module.Socket.Tool byteList.Remove(8);//移除前面两个长度 bytes = byteList.ToArray(); - new Decode().decode(ipAddress, port, bytes); + new ChargerMgrTool().decode(ipAddress, port, bytes); } else //不加密 { - new Decode().decode(ipAddress, port, bytes); + new ChargerMgrTool().decode(ipAddress, port, bytes); } } //ctx.Channel.WriteAndFlushAsync(bytes); diff --git a/Module.Socket.Tool/CustomFrameEncoder.cs b/Module.Socket.Tool/CustomFrameEncoder.cs index 578cf46..9765173 100644 --- a/Module.Socket.Tool/CustomFrameEncoder.cs +++ b/Module.Socket.Tool/CustomFrameEncoder.cs @@ -10,6 +10,9 @@ using System.Threading.Tasks; namespace Module.Socket.Tool { + /// + /// 发送数据 + /// public class CustomFrameEncoder : MessageToByteEncoder { diff --git a/Module.Socket.Tool/ReceivedEventArgs.cs b/Module.Socket.Tool/ReceivedEventArgs.cs deleted file mode 100644 index 154855a..0000000 --- a/Module.Socket.Tool/ReceivedEventArgs.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Module.Socket.Tool -{ - public class ViewLogEventArgs : EventArgs - { - public bool ConnectedStatus { get; set; } - public string IsContent { get; set; } - } - - public class TcpDataReceivedEventArgs : EventArgs - { - public byte[] Data { get; set; } - } - - public class TcpDataSendEventArgs : EventArgs - { - public byte[] Data { get; set; } - } - - - public class FireAlarmEventArgs : EventArgs - { - public int BmsNo { get; set; } - } - -} diff --git a/Module.Socket.Tool/TcpClientBmsTool.cs b/Module.Socket.Tool/TcpClientBmsTool.cs deleted file mode 100644 index ea8e015..0000000 --- a/Module.Socket.Tool/TcpClientBmsTool.cs +++ /dev/null @@ -1,486 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace Module.Socket.Tool -{ - public class TcpClientBmsTool - { - TcpClient ClientTcp = new TcpClient(); - NetworkStream ClientStream; - private readonly object LockHandler = new object(); - - /// - /// 确定的已接收缓存字节数组 - /// - private byte[] FixedBuffer; - - /// - /// 上次接收剩余字节 - /// - private List RemainBuffer = new List(); - - /// - /// 缓存字节长度 - /// - private int BufferSize; - /// - /// 客户端是否已经连接 - /// - private bool IsConnected = false; - - private Thread DataMonitoringThread; - private Thread ConnectMonitoringThread; - - public event EventHandler ConnectedStatusChanged; - public event EventHandler DataReceived; - public event EventHandler DataSended; - - - /// - /// 客户端IP地址 - /// - public string ClientIP { get; set; } - /// - /// 客户端端口号 - /// - public int ClientPort { get; set; } - - /// - /// 客户端任务线程是否已经开始运行 - /// - public bool RaskThreadIsStart { get; set; } = true; - - /// - /// 数据接收事件是否被阻塞 - /// - public bool DataReceivedEventIsSuspend { get; set; } = false; - - /// - /// 读数据超时时间(毫秒) - /// - public int ReadTimeout { get; set; } = 1000; - - public TcpClientBmsTool() { } - - public TcpClientBmsTool(string ipAddr, int port) - { - ClientIP = ipAddr; - ClientPort = port; - } - - /// - /// 客户端连接 - /// - public virtual void ClientConnect() - { - try - { - Disconnect(); - ClientTcp.Connect(ClientIP, ClientPort); - ClientStream = ClientTcp.GetStream(); - - bool state = ClientTcp.Connected; - if (state == false) - { - IsConnected = false; - SetConnectStatusEvent("连接失败"); - TerminateThreadsTCPStream(); - } - else - { - IsConnected = true; - SetConnectStatusEvent("连接成功"); - - BufferSize = ClientTcp.ReceiveBufferSize; - FixedBuffer = new byte[BufferSize]; - - RaskThreadIsStart = true; - } - - ConnectMonitoringThread = new Thread(MonitorConnecting); - ConnectMonitoringThread.Name = "TCP客户端连接状态监测" + ClientPort.ToString(); - ConnectMonitoringThread.Start(); - - DataMonitoringThread = new Thread(MonitorRecevingData); - DataMonitoringThread.Name = "TCP客户端数据接收监测" + ClientPort.ToString(); - DataMonitoringThread.Start(); - } - catch (Exception ex) - { - SetConnectStatusEvent("连接失败" + ex.ToString()); - } - } - - - /// - /// 设置连接状态字符串 - /// - /// 连接状态字符串。比如:“连接成功” - private void SetConnectStatusEvent(string status) - { - string strClient = ""; - if (ClientTcp != null && ClientTcp.Client.LocalEndPoint != null) - { - strClient = ClientTcp.Client.LocalEndPoint.ToString(); - } - string strTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " "; - string strConnectLog = strTime + "客户端" + strClient + "与服务端" + ClientIP.ToString() + ":" + ClientPort.ToString() + " " + status + "!"; - - EventHandler ConnectedHandler; - ConnectedHandler = ConnectedStatusChanged; - if (ConnectedHandler != null) - { - ConnectedHandler.Invoke(this, new ViewLogEventArgs() { ConnectedStatus = IsConnected, IsContent = strConnectLog }); - } - } - - - /// - /// 是否连接 - /// - public bool Connected - { - get - { - bool state = ClientTcp.Connected; - - if (state == false) - { - TerminateThreadsTCPStream(); - } - if (state != IsConnected) - { - IsConnected = state; - } - return state; - } - - private set - { - if (value == IsConnected) return; - IsConnected = value; - } - } - - /// - /// 断开连接 - /// - public virtual void Disconnect() - { - TerminateThreadsTCPStream(); - Connected = false; - - ClientTcp.Close(); - ClientTcp = new System.Net.Sockets.TcpClient(); - } - - /// - /// 结束线程与数据流 - /// - private void TerminateThreadsTCPStream() - { - RaskThreadIsStart = false; - DataMonitoringThread = null; - ConnectMonitoringThread = null; - - ClientStream?.Close(); - ClientStream = null; - } - - /// - /// 获取客户端连接状态 - /// - /// - private bool GetConnectedStatus() - { - return !((ClientTcp.Client.Poll(1000, SelectMode.SelectRead) && (ClientTcp.Client.Available == 0)) || !ClientTcp.Client.Connected); - } - - /// - /// 监测接收数据字符串 - /// - - private async void MonitorRecevingData() - { - await Task.Run(() => - { - try - { - EventHandler DataReceivedHandler; - while (RaskThreadIsStart) - { - if (!Connected) ClientConnect(); - else - { - DataReceivedHandler = DataReceived; - if (DataReceivedHandler != null) - { - if (ClientStream != null) - { - if (ClientStream.DataAvailable) - { - lock (LockHandler) - { - List datas = ReadOrigBytes(); - if (datas != null) - { - if (datas.Count > 0) - { - for (int i = 0; i < datas.Count; i++) - { - if (datas[i].Length > 0) - { - DataReceivedHandler.Invoke(this, new TcpDataReceivedEventArgs() { Data = datas[i] }); - } - else - { - Thread.Sleep(20); - continue; - } - } - } - else - { - Thread.Sleep(20); - continue; - } - } - else - { - Thread.Sleep(20); - continue; - } - } - } - else - { - Thread.Sleep(20); - continue; - } - } - else - { - Thread.Sleep(20); - continue; - } - } - else - { - Thread.Sleep(20); - continue; - } - } - } - } - catch (Exception ex) - { - ex.ToString(); - } - }); - } - - - /// - /// 读原始数据字节数组 - /// - /// - private List ReadOrigBytes() - { - List bytesResult = new List(); - if (ClientStream != null) - { - ClientStream.ReadTimeout = ReadTimeout; - while (true) - { - int readByte = 0; - try - { - readByte = ClientStream.Read(FixedBuffer, 0, BufferSize); - if (readByte == 0) break; - else if (readByte > 6) - { - bytesResult = GetReadResult(FixedBuffer, readByte); - } - - if (!ClientStream.DataAvailable) break; - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine("警告: ReadRawBytes()引发异常: " + ex); - return null; - } - } - } - return bytesResult; - } - - - /// - /// 监测客户端连接 - /// - private void MonitorConnecting() - { - while (RaskThreadIsStart) - { - bool state = Connected; - - if (state != IsConnected) - { - IsConnected = state; - if (state == false) - { - SetConnectStatusEvent("连接失败"); - TerminateThreadsTCPStream(); - } - else - { - SetConnectStatusEvent("连接成功"); - - BufferSize = ClientTcp.ReceiveBufferSize; - FixedBuffer = new byte[BufferSize]; - - RaskThreadIsStart = true; - } - } - - Thread.Sleep(20); - } - } - - private List GetReadResult(byte[] bytes, int readLen) - { - int indexValue = 0; - List lstResult = new List(); - List lstStartIndex = new List(); //搜索开始字节0x08的索引值 - int len = 0; - if (readLen >= 6) - { - for (int i = 0; i < readLen; i++) - { - if (bytes[i] == 0x88) - { - lstStartIndex.Add(i); - } - } - } - int indexNum = lstStartIndex.Count; - if (indexNum > 0) - { - for (int j = 0; j < indexNum; j++) - { - if (indexValue < bytes.Count()) - { - //len = ToUInt16(bytes, indexValue + 1); - len = 13; - if (j < indexNum - 1) - { - int datalen = lstStartIndex[j + 1] - lstStartIndex[j]; - if (len == datalen) - { - indexValue += len; - byte[] data = new byte[datalen]; - Array.Copy(bytes, lstStartIndex[j], data, 0, datalen); - lstResult.Add(data); - } - else - { - indexValue += len; - byte[] data = new byte[len]; - if (len <= bytes.Count()) - { - Array.Copy(bytes, lstStartIndex[j], data, 0, len); - lstResult.Add(data); - } - } - } - else - { - int datalen = readLen - lstStartIndex[j]; - if (len == datalen) - { - byte[] data = new byte[datalen]; - Array.Copy(bytes, lstStartIndex[j], data, 0, datalen); - lstResult.Add(data); - } - } - } - } - } - return lstResult; - } - - /// - /// 客户端读字节 - /// - /// 字节数组 - public List ReadBytes() - { - lock (LockHandler) - { - if (!Connected) ClientConnect(); - return ReadOrigBytes(); - } - } - - /// - /// 客户端写字节指令 - /// - /// - public void Write(byte[] dataBytes) - { - if (ClientTcp != null) - { - if (ClientTcp.Connected) - { - try - { - EventHandler DataSendHandler; - DataSendHandler = DataSended; - DataSendHandler.Invoke(this, new TcpDataSendEventArgs() { Data = dataBytes }); - - ClientStream.Write(dataBytes, 0, dataBytes.Length); - ClientStream.Flush(); - } - catch (Exception ex) - { - ex.ToString(); - } - } - } - } - - private bool disposedValue = false; - - protected virtual void Dispose(bool disposing) - { - if (!disposedValue) - { - if (disposing) - { - TerminateThreadsTCPStream(); - ClientTcp.Close(); - ClientTcp = null; - } - - disposedValue = true; - } - } - - - public void Dispose() - { - Dispose(true); - } - - private ushort ToUInt16(byte[] value, int offset) - { - return (ushort)(value[offset] + (value[offset + 1] << 8)); - } - - } -} diff --git a/Module.Socket.Tool/TcpClientChargerTool.cs b/Module.Socket.Tool/TcpClientChargerTool.cs deleted file mode 100644 index a69abf0..0000000 --- a/Module.Socket.Tool/TcpClientChargerTool.cs +++ /dev/null @@ -1,474 +0,0 @@ -using DotNetty.Buffers; -using DotNetty.Codecs; -using DotNetty.Codecs.Protobuf; -using DotNetty.Common.Concurrency; -using DotNetty.Handlers.Timeout; -using DotNetty.Transport.Bootstrapping; -using DotNetty.Transport.Channels; -using DotNetty.Transport.Channels.Sockets; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Threading; -using System.Threading.Channels; -using System.Threading.Tasks; - -namespace Module.Socket.Tool -{ - public class TcpClientChargerTool - { - #region 定义锁 - - private object lockObj = new object(); //线程同步锁 - - #endregion 定义锁 - - #region 字段属性 - - private string _client_ip; - - /// - /// 客户端IP地址 - /// - public string F_ClientIP - { - get { return _client_ip; } - set - { - lock (lockObj) - { - _client_ip = value; - } - } - } - - private int _client_port; - - /// - /// 客户端端口号 - /// - public int F_ClientPort - { - get { return _client_port; } - set - { - lock (lockObj) - { - _client_port = value; - } - } - } - - public event EventHandler ConnectedStatusChanged; - - public event EventHandler DataSended; - - public event EventHandler ConnectLogEvent; - - #endregion - - private AutoResetEvent ChannelInitilizedEvent = new AutoResetEvent(false); - private Bootstrap SocketBootstrap = new Bootstrap(); - private MultithreadEventLoopGroup WorkGroup = new MultithreadEventLoopGroup(); - public volatile bool Connected = false; - public volatile IChannel NettyChannel; - - public Channel messageQueue; - - #region 类结构体 - - public TcpClientChargerTool() - { - UnboundedChannelOptions options = new UnboundedChannelOptions(); - options.SingleReader = true; - messageQueue = Channel.CreateUnbounded(options); - } - - public TcpClientChargerTool(string ipAddr, int port) - { - UnboundedChannelOptions options = new UnboundedChannelOptions(); - options.SingleReader = true; - messageQueue = Channel.CreateUnbounded(options); - _client_ip = ipAddr; - _client_port = port; - } - - #endregion 类结构体 - - private void InitBootstrap() - { - IByteBuffer delimiter = Unpooled.CopiedBuffer(new byte[] { 0x68 ,0xEE}); - - - SocketBootstrap = new Bootstrap(); - - SocketBootstrap.Group(WorkGroup) - .Channel() - .Option(ChannelOption.TcpNodelay, true) - .Option(ChannelOption.SoKeepalive, true) - .Handler(new ActionChannelInitializer(channel => - { - IChannelPipeline pipeline = channel.Pipeline; - // 在管道中添加 DelimiterBasedFrameDecoder,指定分隔符 - //pipeline.AddLast(new DelimiterBasedFrameDecoder(2048, delimiter)); - - //pipeline.AddLast(new CustomFrameDecoder1()); - //pipeline.AddLast(new CustomFrameDecoder2(new IByteBuffer[]{ delimiter }, false,false ));//效果不好 - //pipeline.AddLast(new CustomFrameDecoder3()); - pipeline.AddLast(new CustomFrameDecoder4(new IByteBuffer[] { delimiter }, false, false));//效果不好 - - - - pipeline.AddLast("idleStateHandler", new IdleStateHandler(30, 0, 0)); // 触发读取超时 - pipeline.AddLast(new ReconnectHandler(this)); - pipeline.AddLast(new ClientHandler(this)); - })); - } - - - public async Task Connect() - { - await DoConnect(); - } - - public void Disconnect() - { - WorkGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1)); - } - - public async Task Write(byte[] message) - { - try - { - await NettyChannel.WriteAndFlushAsync(Unpooled.WrappedBuffer(message)); - } - catch (Exception e) - { - Console.WriteLine($"{_client_ip} Error writing message: {e.Message}"); - } - } - - private async Task DoConnect() - { - Connected = false; - SetConnectStatusEvent("连接初始化"); - - do - { - try - { - InitBootstrap(); - var clientChannel = - await SocketBootstrap.ConnectAsync(new IPEndPoint(IPAddress.Parse(_client_ip), _client_port)); - NettyChannel = clientChannel; - if (clientChannel.Open) - { - Connected = true; - SetConnectStatusEvent("连接成功"); - } - else - { - Connected = false; - SetConnectStatusEvent("连接失败"); - await Task.Delay(5 * 1000); - } - - - //ChannelInitilizedEvent.Set(); - - await Task.Delay(200); - } - catch (Exception ce) - { - SetConnectStatusEvent(ce.StackTrace); - ConnectLogEventHandle( ce.StackTrace); - Debug.Print("连接失败:" + ce.StackTrace); - Debug.Print("connect fail ,reconnect after 5 seconds..." + _client_ip); - await Task.Delay(5 * 1000); - } - } while (!Connected); - } - - - /// - /// 设置连接状态字符串 - /// - /// 连接状态字符串。比如:“连接成功” - private void SetConnectStatusEvent(string status) - { - string strClient = ""; - if (NettyChannel != null && NettyChannel.RemoteAddress != null) - { - strClient = NettyChannel.RemoteAddress.ToString(); - } - - string strTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " "; - string strConnectLog = strTime + "客户端" + strClient + "与服务端" + _client_ip.ToString() + ":" + - _client_port.ToString() + " " + status + "!"; - - EventHandler ConnectedHandler; - ConnectedHandler = ConnectedStatusChanged; - if (ConnectedHandler != null) - { - ConnectedHandler.Invoke(this, - new ViewLogEventArgs() { ConnectedStatus = Connected, IsContent = strConnectLog }); - } - } - - - internal void ConnectLogEventHandle(string message) - { - if (ConnectLogEvent != null) - { - ConnectLogEvent.Invoke(this, new ViewLogEventArgs() { IsContent = message }); - } - } - } - - - public class CustomFrameDecoder : ByteToMessageDecoder - { - - - - - protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List output) - { - // 寻找消息头的位置 - int headerIndex = IndexOf(input, 0x68); - - if (headerIndex == -1) - { - // 没有找到消息头 等待消息头 - - return; - } - - // 跳过 消息头之前的数据 - if (headerIndex > 0) - { - input.SkipBytes(headerIndex); - - } - - //if (input.GetByte(0) != 0x68) - //{ - // input.SkipBytes(1); - // return; - //} - - //if (input.GetByte(1) != 0xEE) - //{ - // input.SkipBytes(1); - // return; - //} - - // 如果长度不足 继续等待 - if (input.ReadableBytes < 3) - { - // 数据不足,等待更多数据 - return; - } - - int length = (input.GetUnsignedShortLE(headerIndex + 2)) + 4; - - - // 检查剩余可读字节数是否足够构成完整的帧 - if (input.ReadableBytes < length) - { - // 数据不足,等待更多数据 - return; - } - byte[] bytes = new byte[length]; - input.ReadBytes(bytes); - // 添加到输出列表 - output.Add(bytes); - } - - - private readonly PacketParser packetParser = new PacketParser(); - - - - //protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List output) { - // var outputBufferList = new List(); - // var resultByte = new byte[input.ReadableBytes]; - // input.ReadBytes(resultByte); - // packetParser.TryParsing(ref resultByte, ref outputBufferList); - // output.AddRange(outputBufferList); - // input.Clear(); - //} - private int IndexOf(IByteBuffer buffer, byte value) - { - int readerIndex = buffer.ReaderIndex; - int writerIndex = buffer.WriterIndex; - for (int i = readerIndex; i < writerIndex; i++) - { - if (buffer.GetByte(i) == value) - { - return i - readerIndex; - } - } - - return -1; - } - - public class PacketParser - { - private readonly List _bufferList = new List(); - - public void TryParsing(ref byte[] inBytes, ref List outBytes) - { - try - { - _bufferList.Add(inBytes); - var tempBuffer = new byte[_bufferList.Sum(item => item.Length)]; - - var size = 0; - foreach (var item in _bufferList) - { - item.CopyTo(tempBuffer, size); - size += item.Length; - } - - if (tempBuffer.Length < 4) return; - var packetLen = BitConverter.ToUInt16(tempBuffer, 2); - - if (tempBuffer.Length < (4 + packetLen)) - { - return; - } - - if (tempBuffer.Length == (4 + packetLen)) - { - _bufferList.Clear(); - outBytes.Add(tempBuffer); - } - - if (tempBuffer.Length > (4 + packetLen)) - { - var left = new byte[4 + packetLen]; - Array.Copy(tempBuffer, 0, left, 0, left.Length); - var right = new byte[tempBuffer.Length - left.Length]; - Array.Copy(tempBuffer, left.Length, right, 0, right.Length); - _bufferList.Clear(); - outBytes.Add(left); - TryParsing(ref right, ref outBytes); - } - } - catch (Exception ex) - { - Debug.Print(ex.ToString()); - } - } - } - - - } - - - public class ClientHandler : SimpleChannelInboundHandler - { - private readonly TcpClientChargerTool tcpClientChargerTool; - - public ClientHandler(TcpClientChargerTool tcpClientChargerTool) - { - this.tcpClientChargerTool = tcpClientChargerTool; - } - public static string BytesToHexStr(byte[] data) - { - StringBuilder sb = new StringBuilder(data.Length * 3); - foreach (byte b in data) - sb.Append(Convert.ToString(b, 16).PadLeft(2, '0') + " "); - return sb.ToString().ToUpper(); - } - - //protected override void ChannelRead0(IChannelHandlerContext context, IByteBuffer message) - //{ - // byte[] bytes = new byte[message.ReadableBytes ]; - // message.ReadBytes(bytes); - - // Log.WriteLog($"RECV:{BytesToHexStr(bytes)}", "ChargerC001" ); - - - // tcpClientChargerTool.messageQueue.Writer.WriteAsync(bytes.Skip(1).ToArray()).AsTask().Wait(); - - // //byte[] bytes = new byte[message.ReadableBytes]; - // //message.ReadBytes(bytes); - // //tcpClientChargerTool.messageQueue.Enqueue(bytes); - //} - - protected override void ChannelRead0(IChannelHandlerContext context, byte[] message) - { - //Log.WriteLog($"RECV:{BytesToHexStr(message)}", "ChargerC001"); - // byte[] bytes = new byte[message.ReadableBytes + 1]; - //bytes[0] = 0x68; - //message.ReadBytes(bytes, 1, message.ReadableBytes); - message = message.Skip(1).ToArray(); - tcpClientChargerTool.messageQueue.Writer.WriteAsync(message).AsTask().Wait(); - - //byte[] bytes = new byte[message.ReadableBytes]; - //message.ReadBytes(bytes); - //tcpClientChargerTool.messageQueue.Enqueue(bytes); - } - - - } - - class ReconnectHandler : ChannelHandlerAdapter - { - private readonly TcpClientChargerTool tcpClientChargerTool; - - public ReconnectHandler(TcpClientChargerTool tcpClientChargerTool) - { - this.tcpClientChargerTool = tcpClientChargerTool; - } - - public override void UserEventTriggered(IChannelHandlerContext context, object evt) - { - if (evt is IdleStateEvent) - { - // 处理超时事件 - tcpClientChargerTool.ConnectLogEventHandle("开始处理读写超时事件"); - if (tcpClientChargerTool.NettyChannel.Open) - { - // 如果存在有效连接,关闭之前的连接 - tcpClientChargerTool.NettyChannel.CloseAsync().Wait(); - tcpClientChargerTool.NettyChannel.CloseCompletion.Wait(); // 等待关闭完成 - tcpClientChargerTool.ConnectLogEventHandle("关闭之前的连接"); - } - } - } - - - public override async void ChannelInactive(IChannelHandlerContext context) - { - tcpClientChargerTool.ConnectLogEventHandle("Connection lost. Attempting to reconnect..."); - await ReconnectAsync(context); - } - - - private async Task ReconnectAsync(IChannelHandlerContext context) - { - try - { - tcpClientChargerTool.ConnectLogEventHandle("开始重连"); - await tcpClientChargerTool.Connect(); // 这里需要异步连接方法 - tcpClientChargerTool.ConnectLogEventHandle("Reconnected to server."); - } - catch (Exception ex) - { - tcpClientChargerTool.ConnectLogEventHandle($"Reconnection failed: {ex.Message}"); - System.Diagnostics.Debug.WriteLine($"Reconnection failed: {ex.Message}"); - context.Channel.EventLoop.Schedule(() => ReconnectAsync(context), TimeSpan.FromSeconds(5)); - } - } - } -} - - diff --git a/WebStarter/WebStarter.csproj b/WebStarter/WebStarter.csproj index 0224e9c..08c4b6a 100644 --- a/WebStarter/WebStarter.csproj +++ b/WebStarter/WebStarter.csproj @@ -15,7 +15,6 @@ - diff --git a/WebStarter/bin/Debug/net6.0/logs/WebApi.log b/WebStarter/bin/Debug/net6.0/logs/WebApi.log index 58a12f2..ee0e25e 100644 --- a/WebStarter/bin/Debug/net6.0/logs/WebApi.log +++ b/WebStarter/bin/Debug/net6.0/logs/WebApi.log @@ -1,12 +1,4 @@ -2024-04-02 09:30:46,687 INFO 1 Microsoft.Hosting.Lifetime - Now listening on: http://localhost:5034 -2024-04-02 09:30:46,776 INFO 1 Microsoft.Hosting.Lifetime - Application started. Press Ctrl+C to shut down. -2024-04-02 09:30:46,787 INFO 1 Microsoft.Hosting.Lifetime - Hosting environment: Development -2024-04-02 09:30:46,791 INFO 1 Microsoft.Hosting.Lifetime - Content root path: D:\lxw\work\pro\c#\hybird_framework\WebStarter\ -2024-04-02 09:32:11,957 INFO 1 Microsoft.Hosting.Lifetime - Now listening on: http://localhost:5034 -2024-04-02 09:32:12,026 INFO 1 Microsoft.Hosting.Lifetime - Application started. Press Ctrl+C to shut down. -2024-04-02 09:32:12,036 INFO 1 Microsoft.Hosting.Lifetime - Hosting environment: Development -2024-04-02 09:32:12,045 INFO 1 Microsoft.Hosting.Lifetime - Content root path: D:\lxw\work\pro\c#\hybird_framework\WebStarter\ -2024-04-02 13:21:51,544 INFO 1 Microsoft.Hosting.Lifetime - Now listening on: http://localhost:5034 -2024-04-02 13:21:51,595 INFO 1 Microsoft.Hosting.Lifetime - Application started. Press Ctrl+C to shut down. -2024-04-02 13:21:51,599 INFO 1 Microsoft.Hosting.Lifetime - Hosting environment: Development -2024-04-02 13:21:51,601 INFO 1 Microsoft.Hosting.Lifetime - Content root path: D:\Desktop\MyFrame\Frame\hybirdMyFrame\WebStarter\ +2024-04-07 11:50:38,204 INFO 1 Microsoft.Hosting.Lifetime - Now listening on: http://localhost:5034 +2024-04-07 11:50:38,281 INFO 1 Microsoft.Hosting.Lifetime - Application started. Press Ctrl+C to shut down. +2024-04-07 11:50:38,286 INFO 1 Microsoft.Hosting.Lifetime - Hosting environment: Development +2024-04-07 11:50:38,288 INFO 1 Microsoft.Hosting.Lifetime - Content root path: D:\桌面\hybird_framework\hybird_framework\WebStarter\ diff --git a/WinFormStarter/Form1.Designer.cs b/WinFormStarter/Form1.Designer.cs index 936c45e..598acb2 100644 --- a/WinFormStarter/Form1.Designer.cs +++ b/WinFormStarter/Form1.Designer.cs @@ -34,7 +34,6 @@ partial class Form1 private void InitializeComponent() { button1 = new Button(); - groupBox10 = new GroupBox(); btnCmd113 = new Button(); lstRecvFrameInfo = new ListBox(); groupBox16 = new GroupBox(); @@ -77,7 +76,6 @@ partial class Form1 txtChargePort = new TextBox(); BtnCloseConnect = new Button(); BtnChrg01Connect = new Button(); - groupBox1 = new GroupBox(); groupBox5 = new GroupBox(); lstSendFrameInfo = new ListBox(); groupBox8 = new GroupBox(); @@ -86,7 +84,17 @@ partial class Form1 btnCmd1 = new Button(); btnCmd5 = new Button(); groupBox2 = new GroupBox(); - groupBox10.SuspendLayout(); + groupBox11 = new GroupBox(); + btnCmd111 = new Button(); + btnCmd109 = new Button(); + btnCmd107 = new Button(); + btnCmd105 = new Button(); + btnCmd103 = new Button(); + btnCmd101 = new Button(); + groupBox10 = new GroupBox(); + btnCmd1506 = new Button(); + btnCmd1504 = new Button(); + btnCmd1502 = new Button(); groupBox16.SuspendLayout(); groupBox15.SuspendLayout(); groupBox14.SuspendLayout(); @@ -98,6 +106,9 @@ partial class Form1 groupBox3.SuspendLayout(); groupBox5.SuspendLayout(); groupBox8.SuspendLayout(); + groupBox2.SuspendLayout(); + groupBox11.SuspendLayout(); + groupBox10.SuspendLayout(); SuspendLayout(); // // button1 @@ -111,23 +122,13 @@ partial class Form1 button1.UseVisualStyleBackColor = true; button1.Click += button1_Click; // - // groupBox10 - // - groupBox10.Controls.Add(btnCmd113); - groupBox10.Location = new Point(589, 130); - groupBox10.Name = "groupBox10"; - groupBox10.Size = new Size(136, 65); - groupBox10.TabIndex = 157; - groupBox10.TabStop = false; - groupBox10.Text = "答充电桩上报充电"; - // // btnCmd113 // - btnCmd113.Location = new Point(6, 17); + btnCmd113.Location = new Point(870, 26); btnCmd113.Name = "btnCmd113"; btnCmd113.Size = new Size(115, 37); btnCmd113.TabIndex = 136; - btnCmd113.Text = "113"; + btnCmd113.Text = "113-查充电时段"; btnCmd113.UseVisualStyleBackColor = true; btnCmd113.Click += btnCmd113_Click; // @@ -136,10 +137,10 @@ partial class Form1 lstRecvFrameInfo.Anchor = AnchorStyles.None; lstRecvFrameInfo.FormattingEnabled = true; lstRecvFrameInfo.ItemHeight = 20; - lstRecvFrameInfo.Location = new Point(2, 695); + lstRecvFrameInfo.Location = new Point(8, 28); lstRecvFrameInfo.Margin = new Padding(5); lstRecvFrameInfo.Name = "lstRecvFrameInfo"; - lstRecvFrameInfo.Size = new Size(1130, 124); + lstRecvFrameInfo.Size = new Size(1115, 124); lstRecvFrameInfo.TabIndex = 145; // // groupBox16 @@ -151,7 +152,7 @@ partial class Form1 groupBox16.Controls.Add(btnCmd1001); groupBox16.Controls.Add(btnCmd1003); groupBox16.Controls.Add(btnCmd1007); - groupBox16.Location = new Point(7, 307); + groupBox16.Location = new Point(9, 351); groupBox16.Name = "groupBox16"; groupBox16.Size = new Size(1007, 75); groupBox16.TabIndex = 154; @@ -164,7 +165,7 @@ partial class Form1 btnCmd1021.Name = "btnCmd1021"; btnCmd1021.Size = new Size(115, 37); btnCmd1021.TabIndex = 124; - btnCmd1021.Text = "1021"; + btnCmd1021.Text = "1021-升级命令"; btnCmd1021.UseVisualStyleBackColor = true; btnCmd1021.Click += btnCmd1021_Click; // @@ -174,7 +175,7 @@ partial class Form1 btnCmd1011.Name = "btnCmd1011"; btnCmd1011.Size = new Size(115, 37); btnCmd1011.TabIndex = 123; - btnCmd1011.Text = "1011"; + btnCmd1011.Text = "1011-重启指令"; btnCmd1011.UseVisualStyleBackColor = true; btnCmd1011.Click += btnCmd1011_Click; // @@ -184,7 +185,7 @@ partial class Form1 btnCmd1009.Name = "btnCmd1009"; btnCmd1009.Size = new Size(115, 37); btnCmd1009.TabIndex = 122; - btnCmd1009.Text = "1009"; + btnCmd1009.Text = "1009-数据结束"; btnCmd1009.UseVisualStyleBackColor = true; btnCmd1009.Click += btnCmd1009_Click; // @@ -194,7 +195,7 @@ partial class Form1 btnCmd1005.Name = "btnCmd1005"; btnCmd1005.Size = new Size(115, 37); btnCmd1005.TabIndex = 120; - btnCmd1005.Text = "1005"; + btnCmd1005.Text = "1005-文件大小"; btnCmd1005.UseVisualStyleBackColor = true; btnCmd1005.Click += btnCmd1005_Click; // @@ -204,7 +205,7 @@ partial class Form1 btnCmd1001.Name = "btnCmd1001"; btnCmd1001.Size = new Size(115, 37); btnCmd1001.TabIndex = 118; - btnCmd1001.Text = "1001"; + btnCmd1001.Text = "1001-擦除指令"; btnCmd1001.UseVisualStyleBackColor = true; btnCmd1001.Click += btnCmd1001_Click; // @@ -214,7 +215,7 @@ partial class Form1 btnCmd1003.Name = "btnCmd1003"; btnCmd1003.Size = new Size(115, 37); btnCmd1003.TabIndex = 119; - btnCmd1003.Text = "1003"; + btnCmd1003.Text = "1003-升级文件"; btnCmd1003.UseVisualStyleBackColor = true; btnCmd1003.Click += btnCmd1003_Click; // @@ -224,7 +225,7 @@ partial class Form1 btnCmd1007.Name = "btnCmd1007"; btnCmd1007.Size = new Size(115, 37); btnCmd1007.TabIndex = 121; - btnCmd1007.Text = "1007"; + btnCmd1007.Text = "1007-文件数据"; btnCmd1007.UseVisualStyleBackColor = true; btnCmd1007.Click += btnCmd1007_Click; // @@ -232,7 +233,7 @@ partial class Form1 // groupBox15.Controls.Add(btnCmd421); groupBox15.Controls.Add(btnCmd401); - groupBox15.Location = new Point(876, 130); + groupBox15.Location = new Point(588, 98); groupBox15.Name = "groupBox15"; groupBox15.Size = new Size(271, 75); groupBox15.TabIndex = 155; @@ -245,7 +246,7 @@ partial class Form1 btnCmd421.Name = "btnCmd421"; btnCmd421.Size = new Size(115, 37); btnCmd421.TabIndex = 123; - btnCmd421.Text = "421"; + btnCmd421.Text = "421-历史充电"; btnCmd421.UseVisualStyleBackColor = true; btnCmd421.Click += btnCmd421_Click; // @@ -255,7 +256,7 @@ partial class Form1 btnCmd401.Name = "btnCmd401"; btnCmd401.Size = new Size(115, 37); btnCmd401.TabIndex = 122; - btnCmd401.Text = "401"; + btnCmd401.Text = "401-历史充电"; btnCmd401.UseVisualStyleBackColor = true; btnCmd401.Click += btnCmd401_Click; // @@ -263,7 +264,7 @@ partial class Form1 // groupBox14.Controls.Add(btnCmd301); groupBox14.Controls.Add(btnCmd303); - groupBox14.Location = new Point(876, 226); + groupBox14.Location = new Point(878, 270); groupBox14.Name = "groupBox14"; groupBox14.Size = new Size(273, 75); groupBox14.TabIndex = 156; @@ -276,7 +277,7 @@ partial class Form1 btnCmd301.Name = "btnCmd301"; btnCmd301.Size = new Size(115, 37); btnCmd301.TabIndex = 118; - btnCmd301.Text = "301"; + btnCmd301.Text = "301-上报BMS"; btnCmd301.UseVisualStyleBackColor = true; btnCmd301.Click += btnCmd301_Click; // @@ -286,7 +287,7 @@ partial class Form1 btnCmd303.Name = "btnCmd303"; btnCmd303.Size = new Size(115, 37); btnCmd303.TabIndex = 119; - btnCmd303.Text = "303"; + btnCmd303.Text = "303-上报BMS"; btnCmd303.UseVisualStyleBackColor = true; btnCmd303.Click += btnCmd303_Click; // @@ -298,7 +299,7 @@ partial class Form1 groupBox13.Controls.Add(btnCmd201); groupBox13.Controls.Add(btnCmd203); groupBox13.Controls.Add(btnCmd207); - groupBox13.Location = new Point(7, 226); + groupBox13.Location = new Point(9, 270); groupBox13.Name = "groupBox13"; groupBox13.Size = new Size(858, 75); groupBox13.TabIndex = 151; @@ -311,7 +312,7 @@ partial class Form1 btnCmd221.Name = "btnCmd221"; btnCmd221.Size = new Size(115, 37); btnCmd221.TabIndex = 123; - btnCmd221.Text = "221"; + btnCmd221.Text = "221-充电信息"; btnCmd221.UseVisualStyleBackColor = true; btnCmd221.Click += btnCmd221_Click; // @@ -321,7 +322,7 @@ partial class Form1 btnCmd209.Name = "btnCmd209"; btnCmd209.Size = new Size(115, 37); btnCmd209.TabIndex = 122; - btnCmd209.Text = "209"; + btnCmd209.Text = "209-充电结果"; btnCmd209.UseVisualStyleBackColor = true; btnCmd209.Click += btnCmd209_Click; // @@ -331,7 +332,7 @@ partial class Form1 btnCmd205.Name = "btnCmd205"; btnCmd205.Size = new Size(115, 37); btnCmd205.TabIndex = 120; - btnCmd205.Text = "205"; + btnCmd205.Text = "205-电密码验证"; btnCmd205.UseVisualStyleBackColor = true; btnCmd205.Click += btnCmd205_Click; // @@ -341,7 +342,7 @@ partial class Form1 btnCmd201.Name = "btnCmd201"; btnCmd201.Size = new Size(115, 37); btnCmd201.TabIndex = 118; - btnCmd201.Text = "201"; + btnCmd201.Text = "201-充电信息"; btnCmd201.UseVisualStyleBackColor = true; btnCmd201.Click += btnCmd201_Click; // @@ -351,7 +352,7 @@ partial class Form1 btnCmd203.Name = "btnCmd203"; btnCmd203.Size = new Size(115, 37); btnCmd203.TabIndex = 119; - btnCmd203.Text = "203"; + btnCmd203.Text = "203-应答账户查询"; btnCmd203.UseVisualStyleBackColor = true; btnCmd203.Click += btnCmd203_Click; // @@ -361,7 +362,7 @@ partial class Form1 btnCmd207.Name = "btnCmd207"; btnCmd207.Size = new Size(115, 37); btnCmd207.TabIndex = 121; - btnCmd207.Text = "207"; + btnCmd207.Text = "207-请求充电"; btnCmd207.UseVisualStyleBackColor = true; btnCmd207.Click += btnCmd207_Click; // @@ -369,7 +370,7 @@ partial class Form1 // groupBox7.Controls.Add(btnCmd1401); groupBox7.Controls.Add(btnCmd1406); - groupBox7.Location = new Point(733, 395); + groupBox7.Location = new Point(735, 439); groupBox7.Name = "groupBox7"; groupBox7.Size = new Size(281, 75); groupBox7.TabIndex = 152; @@ -382,7 +383,7 @@ partial class Form1 btnCmd1401.Name = "btnCmd1401"; btnCmd1401.Size = new Size(115, 37); btnCmd1401.TabIndex = 123; - btnCmd1401.Text = "1401"; + btnCmd1401.Text = "1401-远程升级"; btnCmd1401.UseVisualStyleBackColor = true; btnCmd1401.Click += btnCmd1401_Click; // @@ -392,14 +393,14 @@ partial class Form1 btnCmd1406.Name = "btnCmd1406"; btnCmd1406.Size = new Size(115, 37); btnCmd1406.TabIndex = 124; - btnCmd1406.Text = "1406"; + btnCmd1406.Text = "1406-日志信息"; btnCmd1406.UseVisualStyleBackColor = true; btnCmd1406.Click += btnCmd1406_Click; // // groupBox6 // groupBox6.Controls.Add(btnCmd1301); - groupBox6.Location = new Point(580, 395); + groupBox6.Location = new Point(584, 439); groupBox6.Name = "groupBox6"; groupBox6.Size = new Size(130, 75); groupBox6.TabIndex = 153; @@ -412,7 +413,7 @@ partial class Form1 btnCmd1301.Name = "btnCmd1301"; btnCmd1301.Size = new Size(115, 37); btnCmd1301.TabIndex = 122; - btnCmd1301.Text = "1301"; + btnCmd1301.Text = "1301-白名单"; btnCmd1301.UseVisualStyleBackColor = true; btnCmd1301.Click += btnCmd1301_Click; // @@ -422,7 +423,7 @@ partial class Form1 groupBox4.Controls.Add(btnCmd1101); groupBox4.Controls.Add(btnCmd1103); groupBox4.Controls.Add(btnCmd1107); - groupBox4.Location = new Point(5, 395); + groupBox4.Location = new Point(7, 439); groupBox4.Name = "groupBox4"; groupBox4.Size = new Size(562, 75); groupBox4.TabIndex = 150; @@ -435,7 +436,7 @@ partial class Form1 btnCmd1105.Name = "btnCmd1105"; btnCmd1105.Size = new Size(115, 37); btnCmd1105.TabIndex = 120; - btnCmd1105.Text = "1105"; + btnCmd1105.Text = "1105-设置分时"; btnCmd1105.UseVisualStyleBackColor = true; btnCmd1105.Click += btnCmd1105_Click; // @@ -445,7 +446,7 @@ partial class Form1 btnCmd1101.Name = "btnCmd1101"; btnCmd1101.Size = new Size(115, 37); btnCmd1101.TabIndex = 118; - btnCmd1101.Text = "1101"; + btnCmd1101.Text = "1101-查询计价"; btnCmd1101.UseVisualStyleBackColor = true; btnCmd1101.Click += btnCmd1101_Click; // @@ -455,7 +456,7 @@ partial class Form1 btnCmd1103.Name = "btnCmd1103"; btnCmd1103.Size = new Size(115, 37); btnCmd1103.TabIndex = 119; - btnCmd1103.Text = "1103"; + btnCmd1103.Text = "1103-设置计价"; btnCmd1103.UseVisualStyleBackColor = true; btnCmd1103.Click += btnCmd1103_Click; // @@ -465,17 +466,17 @@ partial class Form1 btnCmd1107.Name = "btnCmd1107"; btnCmd1107.Size = new Size(115, 37); btnCmd1107.TabIndex = 121; - btnCmd1107.Text = "1107"; + btnCmd1107.Text = "1107-查询分时"; btnCmd1107.UseVisualStyleBackColor = true; btnCmd1107.Click += btnCmd1107_Click; // // groupBox9 // groupBox9.Controls.Add(groupBox3); - groupBox9.Controls.Add(groupBox1); - groupBox9.Location = new Point(4, 26); + groupBox9.Controls.Add(groupBox15); + groupBox9.Location = new Point(5, 12); groupBox9.Name = "groupBox9"; - groupBox9.Size = new Size(1161, 98); + groupBox9.Size = new Size(1076, 98); groupBox9.TabIndex = 149; groupBox9.TabStop = false; groupBox9.Text = "站控发送指令"; @@ -495,7 +496,7 @@ partial class Form1 groupBox3.Margin = new Padding(5); groupBox3.Name = "groupBox3"; groupBox3.Padding = new Padding(5); - groupBox3.Size = new Size(1041, 63); + groupBox3.Size = new Size(1056, 63); groupBox3.TabIndex = 80; groupBox3.TabStop = false; groupBox3.Text = "充电机连接"; @@ -508,7 +509,7 @@ partial class Form1 lstBoxConnect.Location = new Point(707, 24); lstBoxConnect.Margin = new Padding(5); lstBoxConnect.Name = "lstBoxConnect"; - lstBoxConnect.Size = new Size(324, 24); + lstBoxConnect.Size = new Size(339, 24); lstBoxConnect.TabIndex = 71; // // label3 @@ -567,23 +568,11 @@ partial class Form1 BtnChrg01Connect.UseVisualStyleBackColor = true; BtnChrg01Connect.Click += BtnChrg01Connect_Click; // - // groupBox1 - // - groupBox1.Font = new Font("微软雅黑", 9F, FontStyle.Regular, GraphicsUnit.Point); - groupBox1.Location = new Point(879, 33); - groupBox1.Margin = new Padding(5); - groupBox1.Name = "groupBox1"; - groupBox1.Padding = new Padding(5); - groupBox1.Size = new Size(274, 57); - groupBox1.TabIndex = 79; - groupBox1.TabStop = false; - groupBox1.Text = "充电机连接状态"; - // // groupBox5 // groupBox5.Controls.Add(lstSendFrameInfo); groupBox5.Font = new Font("微软雅黑", 9F, FontStyle.Regular, GraphicsUnit.Point); - groupBox5.Location = new Point(2, 491); + groupBox5.Location = new Point(9, 595); groupBox5.Margin = new Padding(5); groupBox5.Name = "groupBox5"; groupBox5.Padding = new Padding(5); @@ -609,9 +598,9 @@ partial class Form1 groupBox8.Controls.Add(btnCmd3); groupBox8.Controls.Add(btnCmd1); groupBox8.Controls.Add(btnCmd5); - groupBox8.Location = new Point(5, 130); + groupBox8.Location = new Point(7, 116); groupBox8.Name = "groupBox8"; - groupBox8.Size = new Size(555, 70); + groupBox8.Size = new Size(580, 70); groupBox8.TabIndex = 148; groupBox8.TabStop = false; groupBox8.Text = "设置/查询工作参数和命令"; @@ -622,68 +611,186 @@ partial class Form1 btnCmd7.Name = "btnCmd7"; btnCmd7.Size = new Size(115, 37); btnCmd7.TabIndex = 123; - btnCmd7.Text = "7"; + btnCmd7.Text = "7-开启充电"; btnCmd7.UseVisualStyleBackColor = true; btnCmd7.Click += btnCmd7_Click; // // btnCmd3 // - btnCmd3.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + btnCmd3.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point); btnCmd3.Location = new Point(149, 17); btnCmd3.Margin = new Padding(5); btnCmd3.Name = "btnCmd3"; btnCmd3.Size = new Size(115, 37); btnCmd3.TabIndex = 91; - btnCmd3.Text = "3"; + btnCmd3.Text = "3-字符型"; btnCmd3.UseVisualStyleBackColor = true; btnCmd3.Click += btnCmd3_Click; // // btnCmd1 // - btnCmd1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + btnCmd1.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point); btnCmd1.Location = new Point(8, 17); btnCmd1.Margin = new Padding(5); btnCmd1.Name = "btnCmd1"; btnCmd1.Size = new Size(115, 37); btnCmd1.TabIndex = 90; - btnCmd1.Text = "1"; + btnCmd1.Text = "1-整形工作"; btnCmd1.UseVisualStyleBackColor = true; btnCmd1.Click += btnCmd1_Click; // // btnCmd5 // - btnCmd5.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + btnCmd5.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point); btnCmd5.Location = new Point(296, 17); btnCmd5.Margin = new Padding(5); btnCmd5.Name = "btnCmd5"; btnCmd5.Size = new Size(115, 37); btnCmd5.TabIndex = 92; - btnCmd5.Text = "5"; + btnCmd5.Text = "5-控制命令"; btnCmd5.UseVisualStyleBackColor = true; btnCmd5.Click += btnCmd5_Click; // // groupBox2 // groupBox2.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; + groupBox2.Controls.Add(lstRecvFrameInfo); groupBox2.Font = new Font("微软雅黑", 9F, FontStyle.Regular, GraphicsUnit.Point); - groupBox2.Location = new Point(2, 767); + groupBox2.Location = new Point(9, 767); groupBox2.Margin = new Padding(5); groupBox2.Name = "groupBox2"; groupBox2.Padding = new Padding(5); - groupBox2.Size = new Size(1545, 0); + groupBox2.Size = new Size(1148, 162); groupBox2.TabIndex = 146; groupBox2.TabStop = false; groupBox2.Text = "接收数据帧信息"; // + // groupBox11 + // + groupBox11.Controls.Add(btnCmd113); + groupBox11.Controls.Add(btnCmd111); + groupBox11.Controls.Add(btnCmd109); + groupBox11.Controls.Add(btnCmd107); + groupBox11.Controls.Add(btnCmd105); + groupBox11.Controls.Add(btnCmd103); + groupBox11.Controls.Add(btnCmd101); + groupBox11.Location = new Point(9, 191); + groupBox11.Name = "groupBox11"; + groupBox11.Size = new Size(992, 73); + groupBox11.TabIndex = 158; + groupBox11.TabStop = false; + groupBox11.Text = "主动上传数据"; + // + // btnCmd111 + // + btnCmd111.Location = new Point(726, 26); + btnCmd111.Name = "btnCmd111"; + btnCmd111.Size = new Size(115, 37); + btnCmd111.TabIndex = 142; + btnCmd111.Text = "111-答充上报"; + btnCmd111.UseVisualStyleBackColor = true; + btnCmd111.Click += btnCmd111_Click; + // + // btnCmd109 + // + btnCmd109.Location = new Point(588, 26); + btnCmd109.Name = "btnCmd109"; + btnCmd109.Size = new Size(115, 37); + btnCmd109.TabIndex = 141; + btnCmd109.Text = "109-答充启动"; + btnCmd109.UseVisualStyleBackColor = true; + btnCmd109.Click += btnCmd109_Click; + // + // btnCmd107 + // + btnCmd107.Location = new Point(440, 26); + btnCmd107.Name = "btnCmd107"; + btnCmd107.Size = new Size(115, 37); + btnCmd107.TabIndex = 140; + btnCmd107.Text = "107-答充告警"; + btnCmd107.UseVisualStyleBackColor = true; + btnCmd107.Click += btnCmd107_Click; + // + // btnCmd105 + // + btnCmd105.Location = new Point(296, 26); + btnCmd105.Name = "btnCmd105"; + btnCmd105.Size = new Size(115, 37); + btnCmd105.TabIndex = 139; + btnCmd105.Text = "105-答充签到"; + btnCmd105.UseVisualStyleBackColor = true; + btnCmd105.Click += btnCmd105_Click; + // + // btnCmd103 + // + btnCmd103.Location = new Point(149, 26); + btnCmd103.Name = "btnCmd103"; + btnCmd103.Size = new Size(115, 37); + btnCmd103.TabIndex = 138; + btnCmd103.Text = "103-应答状态"; + btnCmd103.UseVisualStyleBackColor = true; + btnCmd103.Click += btnCmd103_Click; + // + // btnCmd101 + // + btnCmd101.Location = new Point(11, 26); + btnCmd101.Name = "btnCmd101"; + btnCmd101.Size = new Size(115, 37); + btnCmd101.TabIndex = 137; + btnCmd101.Text = "101-应答心跳"; + btnCmd101.UseVisualStyleBackColor = true; + btnCmd101.Click += btnCmd101_Click; + // + // groupBox10 + // + groupBox10.Controls.Add(btnCmd1506); + groupBox10.Controls.Add(btnCmd1504); + groupBox10.Controls.Add(btnCmd1502); + groupBox10.Location = new Point(9, 522); + groupBox10.Name = "groupBox10"; + groupBox10.Size = new Size(426, 65); + groupBox10.TabIndex = 159; + groupBox10.TabStop = false; + groupBox10.Text = "协议方式日志上传"; + // + // btnCmd1506 + // + btnCmd1506.Location = new Point(292, 22); + btnCmd1506.Name = "btnCmd1506"; + btnCmd1506.Size = new Size(115, 37); + btnCmd1506.TabIndex = 124; + btnCmd1506.Text = "1506-接收完成"; + btnCmd1506.UseVisualStyleBackColor = true; + btnCmd1506.Click += btnCmd1506_Click; + // + // btnCmd1504 + // + btnCmd1504.Location = new Point(147, 22); + btnCmd1504.Name = "btnCmd1504"; + btnCmd1504.Size = new Size(115, 37); + btnCmd1504.TabIndex = 123; + btnCmd1504.Text = "1504-应答上传"; + btnCmd1504.UseVisualStyleBackColor = true; + btnCmd1504.Click += btnCmd1504_Click; + // + // btnCmd1502 + // + btnCmd1502.Location = new Point(6, 22); + btnCmd1502.Name = "btnCmd1502"; + btnCmd1502.Size = new Size(115, 37); + btnCmd1502.TabIndex = 122; + btnCmd1502.Text = "1502-允许上传"; + btnCmd1502.UseVisualStyleBackColor = true; + btnCmd1502.Click += btnCmd1502_Click; + // // Form1 // AutoScaleDimensions = new SizeF(9F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1186, 863); + ClientSize = new Size(1186, 943); Controls.Add(groupBox10); - Controls.Add(lstRecvFrameInfo); + Controls.Add(groupBox11); Controls.Add(groupBox16); - Controls.Add(groupBox15); Controls.Add(groupBox14); Controls.Add(groupBox13); Controls.Add(groupBox7); @@ -698,7 +805,6 @@ partial class Form1 Name = "Form1"; Text = "换电平台"; Load += FrmChargeResult_Load; - groupBox10.ResumeLayout(false); groupBox16.ResumeLayout(false); groupBox15.ResumeLayout(false); groupBox14.ResumeLayout(false); @@ -711,6 +817,9 @@ partial class Form1 groupBox3.PerformLayout(); groupBox5.ResumeLayout(false); groupBox8.ResumeLayout(false); + groupBox2.ResumeLayout(false); + groupBox11.ResumeLayout(false); + groupBox10.ResumeLayout(false); ResumeLayout(false); } @@ -718,7 +827,6 @@ partial class Form1 #endregion private Button button1; - private GroupBox groupBox10; private Button btnCmd113; private ListBox lstRecvFrameInfo; private GroupBox groupBox16; @@ -760,7 +868,6 @@ partial class Form1 private TextBox txtChargePort; private Button BtnCloseConnect; private Button BtnChrg01Connect; - private GroupBox groupBox1; private ListBox lstBoxConnect; private GroupBox groupBox5; private ListBox lstSendFrameInfo; @@ -770,4 +877,15 @@ partial class Form1 private Button btnCmd1; private Button btnCmd5; private GroupBox groupBox2; + private GroupBox groupBox11; + private Button btnCmd111; + private Button btnCmd109; + private Button btnCmd107; + private Button btnCmd105; + private Button btnCmd103; + private Button btnCmd101; + private GroupBox groupBox10; + private Button btnCmd1506; + private Button btnCmd1504; + private Button btnCmd1502; } diff --git a/WinFormStarter/Form1.cs b/WinFormStarter/Form1.cs index ff99cc5..b54bfb3 100644 --- a/WinFormStarter/Form1.cs +++ b/WinFormStarter/Form1.cs @@ -1,5 +1,6 @@ using Autofac; using HybirdFrameworkEntity; +using HybirdFrameworkServices; using HybirdFrameworkServices.Netty; using HybirdFrameworkServices.System; using log4net; @@ -11,7 +12,7 @@ public partial class Form1 : Form private ILog _log = LogManager.GetLogger(typeof(Form1)); private SysUserServices _sysUserServices; - Encode encode = new Encode(); + ChargerMgrTool encode = new ChargerMgrTool(); private Server Server; @@ -26,7 +27,9 @@ public partial class Form1 : Form private void button1_Click(object sender, EventArgs e) { //_log.Info("this is a test"); - //MessageBox.Show(_sysUserServices.Query().Count.ToString()); + //var lstSysUserServices = _sysUserServices.Query(); + + MessageBox.Show(_sysUserServices.Query().Count.ToString()); } private void FrmChargeResult_Load(object sender, EventArgs e) @@ -40,7 +43,8 @@ public partial class Form1 : Form private void BtnChrg01Connect_Click(object sender, EventArgs e) { int port = Convert.ToInt32(txtChargePort.Text); - Server = new Server(port); + Server = new Server(); + Server.connect(port); } #region @@ -424,4 +428,102 @@ public partial class Form1 : Form { Server.Dispose(); } + + private void btnCmd101_Click(object sender, EventArgs e) + { + ushort heartbeatNum = 0; + byte[] bytes = encode.Send101(heartbeatNum); + + if (Server != null) + { + Server.Send(bytes); + } + } + + private void btnCmd103_Click(object sender, EventArgs e) + { + byte chargeNum = 0; + bool reportMessage = false; + byte[] bytes = encode.Send103(chargeNum, reportMessage); + + if (Server != null) + { + Server.Send(bytes); + } + } + + private void btnCmd105_Click(object sender, EventArgs e) + { + CMD105 CMD = new CMD105(); + byte[] bytes = encode.Send105(CMD); + + if (Server != null) + { + Server.Send(bytes); + } + } + + private void btnCmd107_Click(object sender, EventArgs e) + { + byte[] bytes = encode.Send107(); + + if (Server != null) + { + Server.Send(bytes); + } + } + + private void btnCmd109_Click(object sender, EventArgs e) + { + byte[] bytes = encode.Send109(); + + if (Server != null) + { + Server.Send(bytes); + } + } + + private void btnCmd111_Click(object sender, EventArgs e) + { + byte messageType = 0; + byte[] bytes = encode.Send111(messageType); + + if (Server != null) + { + Server.Send(bytes); + } + } + + private void btnCmd1502_Click(object sender, EventArgs e) + { + uint responseCode = 0; + byte[] bytes = encode.Send1502(responseCode); + + if (Server != null) + { + Server.Send(bytes); + } + } + + private void btnCmd1504_Click(object sender, EventArgs e) + { + uint logo = 0; + uint successReservedMessageNum = 0; + byte[] bytes = encode.Send1504(logo, successReservedMessageNum); + + if (Server != null) + { + Server.Send(bytes); + } + } + + private void btnCmd1506_Click(object sender, EventArgs e) + { + byte[] bytes = encode.Send1506(); + + if (Server != null) + { + Server.Send(bytes); + } + } } \ No newline at end of file diff --git a/WinFormStarter/obj/Debug/net6.0-windows/WinFormStarter.designer.deps.json b/WinFormStarter/obj/Debug/net6.0-windows/WinFormStarter.designer.deps.json index 5c4e154..44914b5 100644 --- a/WinFormStarter/obj/Debug/net6.0-windows/WinFormStarter.designer.deps.json +++ b/WinFormStarter/obj/Debug/net6.0-windows/WinFormStarter.designer.deps.json @@ -55,6 +55,20 @@ } } }, + "DotNetty.Codecs.Mqtt/0.7.5": { + "dependencies": { + "DotNetty.Buffers": "0.7.5", + "DotNetty.Codecs": "0.7.5", + "DotNetty.Common": "0.7.5", + "DotNetty.Transport": "0.7.5" + }, + "runtime": { + "lib/net6.0/DotNetty.Codecs.Mqtt.dll": { + "assemblyVersion": "0.7.5.0", + "fileVersion": "0.7.5.0" + } + } + }, "DotNetty.Common/0.7.5": { "dependencies": { "Microsoft.Extensions.Logging": "5.0.0", @@ -93,18 +107,6 @@ } } }, - "HslCommunication/11.2.1": { - "dependencies": { - "Newtonsoft.Json": "13.0.3", - "System.IO.Ports": "6.0.0" - }, - "runtime": { - "lib/netstandard2.1/HslCommunication.dll": { - "assemblyVersion": "11.2.1.0", - "fileVersion": "11.2.1.0" - } - } - }, "log4net/2.0.15": { "dependencies": { "System.Configuration.ConfigurationManager": "6.0.0" @@ -489,60 +491,6 @@ } } }, - "runtime.linux-arm.runtime.native.System.IO.Ports/6.0.0": { - "runtimeTargets": { - "runtimes/linux-arm/native/libSystem.IO.Ports.Native.so": { - "rid": "linux-arm", - "assetType": "native", - "fileVersion": "0.0.0.0" - } - } - }, - "runtime.linux-arm64.runtime.native.System.IO.Ports/6.0.0": { - "runtimeTargets": { - "runtimes/linux-arm64/native/libSystem.IO.Ports.Native.so": { - "rid": "linux-arm64", - "assetType": "native", - "fileVersion": "0.0.0.0" - } - } - }, - "runtime.linux-x64.runtime.native.System.IO.Ports/6.0.0": { - "runtimeTargets": { - "runtimes/linux-x64/native/libSystem.IO.Ports.Native.so": { - "rid": "linux-x64", - "assetType": "native", - "fileVersion": "0.0.0.0" - } - } - }, - "runtime.native.System.IO.Ports/6.0.0": { - "dependencies": { - "runtime.linux-arm.runtime.native.System.IO.Ports": "6.0.0", - "runtime.linux-arm64.runtime.native.System.IO.Ports": "6.0.0", - "runtime.linux-x64.runtime.native.System.IO.Ports": "6.0.0", - "runtime.osx-arm64.runtime.native.System.IO.Ports": "6.0.0", - "runtime.osx-x64.runtime.native.System.IO.Ports": "6.0.0" - } - }, - "runtime.osx-arm64.runtime.native.System.IO.Ports/6.0.0": { - "runtimeTargets": { - "runtimes/osx-arm64/native/libSystem.IO.Ports.Native.dylib": { - "rid": "osx-arm64", - "assetType": "native", - "fileVersion": "0.0.0.0" - } - } - }, - "runtime.osx-x64.runtime.native.System.IO.Ports/6.0.0": { - "runtimeTargets": { - "runtimes/osx-x64/native/libSystem.IO.Ports.Native.dylib": { - "rid": "osx-x64", - "assetType": "native", - "fileVersion": "0.0.0.0" - } - } - }, "SQLitePCLRaw.bundle_e_sqlite3/2.1.4": { "dependencies": { "SQLitePCLRaw.lib.e_sqlite3": "2.1.4", @@ -920,31 +868,6 @@ "System.Threading.Tasks": "4.3.0" } }, - "System.IO.Ports/6.0.0": { - "dependencies": { - "runtime.native.System.IO.Ports": "6.0.0" - }, - "runtime": { - "lib/net6.0/System.IO.Ports.dll": { - "assemblyVersion": "6.0.0.0", - "fileVersion": "6.0.21.52210" - } - }, - "runtimeTargets": { - "runtimes/unix/lib/net6.0/System.IO.Ports.dll": { - "rid": "unix", - "assetType": "runtime", - "assemblyVersion": "6.0.0.0", - "fileVersion": "6.0.21.52210" - }, - "runtimes/win/lib/net6.0/System.IO.Ports.dll": { - "rid": "win", - "assetType": "runtime", - "assemblyVersion": "6.0.0.0", - "fileVersion": "6.0.21.52210" - } - } - }, "System.Memory/4.5.3": {}, "System.Reflection/4.3.0": { "dependencies": { @@ -1258,6 +1181,13 @@ "path": "dotnetty.codecs/0.7.5", "hashPath": "dotnetty.codecs.0.7.5.nupkg.sha512" }, + "DotNetty.Codecs.Mqtt/0.7.5": { + "type": "package", + "serviceable": true, + "sha512": "sha512-14rSl+h6gvErT60FraR6Aplpu6FCnrF8zbgi3XIBgE7MorwbHJuaCcBqOjEDVB8/w8QZSJLIFWMgYANCZjNcJQ==", + "path": "dotnetty.codecs.mqtt/0.7.5", + "hashPath": "dotnetty.codecs.mqtt.0.7.5.nupkg.sha512" + }, "DotNetty.Common/0.7.5": { "type": "package", "serviceable": true, @@ -1279,13 +1209,6 @@ "path": "dotnetty.transport/0.7.5", "hashPath": "dotnetty.transport.0.7.5.nupkg.sha512" }, - "HslCommunication/11.2.1": { - "type": "package", - "serviceable": true, - "sha512": "sha512-j1Dw8iKx+cDO7TrpZ+ethoF114pP13kyW7NeiIlE54QXLA8lAVAzQy5twYbo3DnXJj7NizqBUUhOLDN4uNIh1g==", - "path": "hslcommunication/11.2.1", - "hashPath": "hslcommunication.11.2.1.nupkg.sha512" - }, "log4net/2.0.15": { "type": "package", "serviceable": true, @@ -1517,48 +1440,6 @@ "path": "oracle.manageddataaccess.core/3.21.100", "hashPath": "oracle.manageddataaccess.core.3.21.100.nupkg.sha512" }, - "runtime.linux-arm.runtime.native.System.IO.Ports/6.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-75q52H7CSpgIoIDwXb9o833EvBZIXJ0mdPhz1E6jSisEXUBlSCPalC29cj3EXsjpuDwr0dj1LRXZepIQH/oL4Q==", - "path": "runtime.linux-arm.runtime.native.system.io.ports/6.0.0", - "hashPath": "runtime.linux-arm.runtime.native.system.io.ports.6.0.0.nupkg.sha512" - }, - "runtime.linux-arm64.runtime.native.System.IO.Ports/6.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-xn2bMThmXr3CsvOYmS8ex2Yz1xo+kcnhVg2iVhS9PlmqjZPAkrEo/I40wjrBZH/tU4kvH0s1AE8opAvQ3KIS8g==", - "path": "runtime.linux-arm64.runtime.native.system.io.ports/6.0.0", - "hashPath": "runtime.linux-arm64.runtime.native.system.io.ports.6.0.0.nupkg.sha512" - }, - "runtime.linux-x64.runtime.native.System.IO.Ports/6.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-16nbNXwv0sC+gLGIuecri0skjuh6R1maIJggsaNP7MQBcbVcEfWFUOkEnsnvoLEjy0XerfibuRptfQ8AmdIcWA==", - "path": "runtime.linux-x64.runtime.native.system.io.ports/6.0.0", - "hashPath": "runtime.linux-x64.runtime.native.system.io.ports.6.0.0.nupkg.sha512" - }, - "runtime.native.System.IO.Ports/6.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-KaaXlpOcuZjMdmyF5wzzx3b+PRKIzt6A5Ax9dKenPDQbVJAFpev+casD0BIig1pBcbs3zx7CqWemzUJKAeHdSQ==", - "path": "runtime.native.system.io.ports/6.0.0", - "hashPath": "runtime.native.system.io.ports.6.0.0.nupkg.sha512" - }, - "runtime.osx-arm64.runtime.native.System.IO.Ports/6.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-fXG12NodG1QrCdoaeSQ1gVnk/koi4WYY4jZtarMkZeQMyReBm1nZlSRoPnUjLr2ZR36TiMjpcGnQfxymieUe7w==", - "path": "runtime.osx-arm64.runtime.native.system.io.ports/6.0.0", - "hashPath": "runtime.osx-arm64.runtime.native.system.io.ports.6.0.0.nupkg.sha512" - }, - "runtime.osx-x64.runtime.native.System.IO.Ports/6.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-/As+zPY49+dSUXkh+fTUbyPhqrdGN//evLxo4Vue88pfh1BHZgF7q4kMblTkxYvwR6Vi03zSYxysSFktO8/SDQ==", - "path": "runtime.osx-x64.runtime.native.system.io.ports/6.0.0", - "hashPath": "runtime.osx-x64.runtime.native.system.io.ports.6.0.0.nupkg.sha512" - }, "SQLitePCLRaw.bundle_e_sqlite3/2.1.4": { "type": "package", "serviceable": true, @@ -1699,13 +1580,6 @@ "path": "system.io/4.3.0", "hashPath": "system.io.4.3.0.nupkg.sha512" }, - "System.IO.Ports/6.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-dRyGI7fUESar5ZLIpiBOaaNLW7YyOBGftjj5Of+xcduC/Rjl7RjhEnWDvvNBmHuF3d0tdXoqdVI/yrVA8f00XA==", - "path": "system.io.ports/6.0.0", - "hashPath": "system.io.ports.6.0.0.nupkg.sha512" - }, "System.Memory/4.5.3": { "type": "package", "serviceable": true, diff --git a/hybirdMyFrame.sln b/hybirdMyFrame.sln index 678ddb6..0b62e60 100644 --- a/hybirdMyFrame.sln +++ b/hybirdMyFrame.sln @@ -19,15 +19,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebStarter", "WebStarter\We EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HybirdFrameworkCore", "HybirdFrameworkCore\HybirdFrameworkCore.csproj", "{5F1D9B39-E50F-4B7C-B1C6-E60B64C4CA1A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HybirdFrameworkEntity", "HybirdFrameworkEntity\HybirdFrameworkEntity.csproj", "{0180C7F7-AFCE-451E-B98E-8061FCEAF37D}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HybirdFrameworkRepository", "HybirdFrameworkRepository\HybirdFrameworkRepository.csproj", "{01D2CC15-F1FD-4E22-845A-2D2473662860}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HybirdFrameworkServices", "HybirdFrameworkServices\HybirdFrameworkServices.csproj", "{A6C2AA7F-B2A2-4AE0-AE84-49BE36B990EC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormStarter", "WinFormStarter\WinFormStarter.csproj", "{A6757DAD-EF5A-41FD-9323-F3FCF05ED777}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Module.Socket.Tool", "Module.Socket.Tool\Module.Socket.Tool.csproj", "{D8870B31-70B0-4520-98FB-799CD4BFA624}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HybirdFrameworkEntity", "HybirdFrameworkEntity\HybirdFrameworkEntity.csproj", "{C2380814-15D4-491D-ADF2-ADC68617C3FA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -43,10 +41,6 @@ Global {5F1D9B39-E50F-4B7C-B1C6-E60B64C4CA1A}.Debug|Any CPU.Build.0 = Debug|Any CPU {5F1D9B39-E50F-4B7C-B1C6-E60B64C4CA1A}.Release|Any CPU.ActiveCfg = Release|Any CPU {5F1D9B39-E50F-4B7C-B1C6-E60B64C4CA1A}.Release|Any CPU.Build.0 = Release|Any CPU - {0180C7F7-AFCE-451E-B98E-8061FCEAF37D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0180C7F7-AFCE-451E-B98E-8061FCEAF37D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0180C7F7-AFCE-451E-B98E-8061FCEAF37D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0180C7F7-AFCE-451E-B98E-8061FCEAF37D}.Release|Any CPU.Build.0 = Release|Any CPU {01D2CC15-F1FD-4E22-845A-2D2473662860}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {01D2CC15-F1FD-4E22-845A-2D2473662860}.Debug|Any CPU.Build.0 = Debug|Any CPU {01D2CC15-F1FD-4E22-845A-2D2473662860}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -59,10 +53,10 @@ Global {A6757DAD-EF5A-41FD-9323-F3FCF05ED777}.Debug|Any CPU.Build.0 = Debug|Any CPU {A6757DAD-EF5A-41FD-9323-F3FCF05ED777}.Release|Any CPU.ActiveCfg = Release|Any CPU {A6757DAD-EF5A-41FD-9323-F3FCF05ED777}.Release|Any CPU.Build.0 = Release|Any CPU - {D8870B31-70B0-4520-98FB-799CD4BFA624}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D8870B31-70B0-4520-98FB-799CD4BFA624}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D8870B31-70B0-4520-98FB-799CD4BFA624}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D8870B31-70B0-4520-98FB-799CD4BFA624}.Release|Any CPU.Build.0 = Release|Any CPU + {C2380814-15D4-491D-ADF2-ADC68617C3FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C2380814-15D4-491D-ADF2-ADC68617C3FA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C2380814-15D4-491D-ADF2-ADC68617C3FA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C2380814-15D4-491D-ADF2-ADC68617C3FA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -70,10 +64,10 @@ Global GlobalSection(NestedProjects) = preSolution {61B1609B-97EE-48E4-ADA6-4F1A832B8D33} = {DEE625EC-B6DC-4381-B78C-D89F09C00E7C} {5F1D9B39-E50F-4B7C-B1C6-E60B64C4CA1A} = {0E784680-8280-4C47-8D2D-6405AC892164} - {0180C7F7-AFCE-451E-B98E-8061FCEAF37D} = {6203689E-8261-4814-BFC2-013188AED6A1} {01D2CC15-F1FD-4E22-845A-2D2473662860} = {348F9459-2A59-47EB-B801-0CF907DFD8EC} {A6C2AA7F-B2A2-4AE0-AE84-49BE36B990EC} = {5F67ED42-6437-4FC6-86D2-0495DE990BC4} {A6757DAD-EF5A-41FD-9323-F3FCF05ED777} = {A0BA21DB-6630-41AB-A0FD-594DBB197E0E} + {C2380814-15D4-491D-ADF2-ADC68617C3FA} = {6203689E-8261-4814-BFC2-013188AED6A1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3E10BF3D-9914-44B1-A6AA-FCF013C3F155}