using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using BatCharging.Model; using Monitor.LogService; using Module.Socket.Tool; using BatCharging.Service.Encoder.New; using BatCharging.Service.Decoder.New; using Module.TBox.Can.Tool; using System.Net.Http; using Newtonsoft.Json; using System.Security.AccessControl; using BatCharging.Service.DataRlt; //using HslCommunication.Enthernet.Redis; namespace BatCharging.Service { /// /// 1号充电机管理工具 /// public class ChargerMgrTool { #region 定义锁 private object lockObj = new object(); //线程同步锁 #endregion 定义锁 #region 字段属性 /// /// 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 _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; } } } /// /// TCP客户端 /// private TcpClientChargerTool _chr_client; /// /// 充电机连接客户端 /// public TcpClientChargerTool F_ChrClient { get { return _chr_client; } set { lock (lockObj) { _chr_client = 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; } } } /// /// 充电机的目的地址 /// private byte[] _dest_addr = new byte[] { 0x13, 0, 0, 0x10 }; /// /// 充电机的目的地址(外部设定). /// public byte[] F_DestAddr { get { return _dest_addr; } set { lock (lockObj) { _dest_addr = 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 ChgResult _result; /// /// 充电机发送与接收的结果. /// public ChgResult F_Result { get { return _result; } set { lock (lockObj) { _result = value; } } } /// /// 充电机编码 /// private string _eqmcode; /// /// 充电机编码 /// public string F_EqmCode { get { return _eqmcode; } set { lock (lockObj) { _eqmcode = value; } } } /// /// 充电机工作状态-从遥信数据包中得到。0:待机;1:工作;2:工作完成;3:充/放电暂停 /// private byte _workstate; /// /// 充电机工作状态-从遥信数据包中得到。0:待机;1:工作;2:工作完成;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_code = 0; /// /// 故障码 /// public int F_FaultCode { get { return _fault_code; } set { lock (lockObj) { _fault_code = 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 RemoteData _remote_data = new RemoteData(); /// /// 充电机遥信数据 /// public RemoteData F_RemoteData { get { return _remote_data; } set { lock (lockObj) { _remote_data = value; } } } /// ///充电机遥测数据 /// private TelemetryData _telem_data = new TelemetryData(); /// /// 充电机遥测数据 /// public TelemetryData F_TelemData { get { return _telem_data; } set { lock (lockObj) { _telem_data = 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 SBMUCanRecvMsg _msg_recv = new SBMUCanRecvMsg(); /// /// 接收到的消息 /// public SBMUCanRecvMsg F_Msg_Recv { get { return _msg_recv; } set { lock (lockObj) { _msg_recv = value; } } } #endregion 字段属性 #region 类结构体 public ChargerMgrTool() { } /// /// 类结构体 /// /// 充电机目的地址字节数组 public ChargerMgrTool(byte[] dest_addr) { _dest_addr = dest_addr; } /// /// 类结构体 /// /// IP地址 /// 网络端口号 public ChargerMgrTool(string ipAddr, int port) { _ip_addr = ipAddr; _ip_port = port; } /// /// /// /// IP地址 /// 网络端口号 /// 充电机目的地址字节数组 public ChargerMgrTool(string ipAddr, int port, byte[] dest_addr) { _ip_addr = ipAddr; _ip_port = port; _dest_addr = dest_addr; } #endregion 类结构体 #region 事件定义 public event EventHandler ConnectedStatusChanged; public event EventHandler DataReceived; public event EventHandler DataSended; #endregion 事件定义 #region 事件处理 /// /// 接收到的数据信息事件方法 /// /// private void ConnectedStatusEventFunc(bool isConnected, string msg) { if (!String.IsNullOrEmpty(msg)) { EventHandler ConnectedHandler; ConnectedHandler = ConnectedStatusChanged; if (ConnectedHandler != null) { ConnectedHandler.Invoke(null, new LogEventArgs() { ConnectedStatus = isConnected, IsContent = msg }); } string strConnected = "Connected Failure"; if (isConnected) { strConnected = "Connected Success"; } string result = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "]" + "CONNECT STATUS:" + strConnected; result += "\r\n" + msg; Log.LogInstance.WriteLog(result, LogType.Information, _eqmcode + "ConnectedLog"); } } /// /// 接收到的数据事件方法 /// /// private void DataReceivedEventFunc(byte[] msg) { if (msg != null) { EventHandler DataReceivedHandler; DataReceivedHandler = DataReceived; if (DataReceivedHandler != null) { DataReceivedHandler.Invoke(null, new DataRecvedEventArgs() { Data = msg }); } string result = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "]" + "RECV HEX:"; result += ByteUtils.BytesToHexStr(msg); Log.LogInstance.WriteLog(result, LogType.Information, _eqmcode + "RecvedLog"); } } /// /// 发送的数据事件方法 /// /// private void DataSendedEventFunc(byte[] msg) { if (msg != null) { EventHandler DataSendedHandler; DataSendedHandler = DataSended; if (DataSendedHandler != null) { DataSendedHandler.Invoke(null, new DataSendedEventArgs() { Data = msg }); } string result = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "]" + "SEND HEX:"; result += ByteUtils.BytesToHexStr(msg); //var log = LogManager.GetLogger(typeof(ChargerMgrTool)); //log.Info(result); Log.LogInstance.WriteLog(result, LogType.Run, "chargerProtocolTestLog"); Log.LogInstance.WriteLog(result, LogType.Information, _eqmcode + "SendedLog"); } } #endregion 事件处理 #region 通讯连接 ///// ///// 充电机连接线程 ///// //public void ChargerNetConnectThread() //{ // Thread chrgConnectedThread = new Thread(ChargerConnectFunc); // chrgConnectedThread.IsBackground = true; // chrgConnectedThread.Start(); //} ///// ///// 充电机通讯连接 ///// //private void ChargerConnectFunc() //{ // while (_net_connect_enabled) // { // if (!_net_connected) // { // ChargerConnect(); // } // Thread.Sleep(30 * 1000); // } //} ///// ///// 充电机连接 ///// //public void ChargerConnect() //{ // if (!string.IsNullOrEmpty(_ip_addr)) // { // _chr_client = new TcpClientChargerTool(_ip_addr, _ip_port); // _chr_client.ConnectedStatusChanged += Client_ConnectedStatusChanged; // _chr_client.ClientConnect(); // if (_chr_client.Connected) // { // if (_result == null) // { // _result = new ChgResult(); // } // _chr_client.DataReceived += Client_DataReceived; // _chr_client.DataSended += Client_DataSended; // Thread.Sleep(100); // SendCharingSignIn(); // Thread.Sleep(100); // _recving_data_time = DateTime.Now; // Thread.Sleep(100); // //充电机判断是否断线线程 // ChargerNetCheckThread(); // } // } //} /// /// 充电机连接 /// /// ip /// ip /// 站号 public void ChargerConnect(string ipAddr, int port, int destAddr) { _ip_addr = ipAddr; _ip_port = port; _dest_addr = new byte[] { Convert.ToByte(destAddr), 0, 0, 0x10 }; _chr_client = new Module.Socket.Tool.TcpClientChargerTool(ipAddr, port); _chr_client.ConnectedStatusChanged += Client_ConnectedStatusChanged; _chr_client.ClientConnect(); if (_chr_client.Connected) { string result = ipAddr + ":" + port + "连接成功"; Log.LogInstance.WriteLog(result, LogType.Information, _eqmcode + "ConnectedLog"); if (_result == null) { _result = new ChgResult(); } Thread.Sleep(100); //充电鉴权 SendCharingSignIn(); _recving_data_time = DateTime.Now; _chr_client.DataReceived += Client_DataReceived; _chr_client.DataSended += Client_DataSended; Thread.Sleep(100); //充电机判断是否断线线程 ChargerNetCheckThread(); } } /// /// 充电机断开连接 /// public void ChargerDisConnect() { if (_chr_client != null) { if (_chr_client.Connected) { _chr_client.Disconnect(); } } } /// /// 连接事件 /// /// /// /// private void Client_ConnectedStatusChanged(object sender, Module.Socket.Tool.ViewLogEventArgs e) { _net_connected = e.ConnectedStatus; ConnectedStatusEventFunc(e.ConnectedStatus, e.IsContent); } #endregion 通讯连接 #region 数据接收 /// /// 充电机判断是否断线线程 /// public void ChargerNetCheckThread() { Thread chargerThread = new Thread(ChargerNetCheckFunc); chargerThread.IsBackground = true; chargerThread.Start(); } /// /// 充电机判断是否断线线程.充电机在连接情况下,30秒未收到信息,则认为断线,需要重新连接 /// private void ChargerNetCheckFunc() { while (_net_connect_enabled) { if (_net_connected) { DateTime recvTime = DateTime.Now; int seconds = Convert.ToInt32(recvTime.Subtract(F_RecvingDataTime).TotalSeconds); if (seconds >= _net_check_time_out) { ChargerDisConnect(); } } Thread.Sleep(10000); } } /// /// 接收事件 /// /// /// /// private void Client_DataReceived(object sender, Module.Socket.Tool.TcpDataReceivedEventArgs e) { byte[] data = e.Data; if (data != null) { _recving_data_time = DateTime.Now; //记录接收到的消息日志 DataReceivedEventFunc(data);//解析显示到窗体 ProcDataRecved(data);//解析数据 } } private ushort ToUInt16(byte[] value, int offset) { return (ushort)(value[offset] + (value[offset + 1] << 8)); } /// /// 处理接收到的数值 /// /// 接收到的字节数组 private void ProcDataRecved(byte[] data) { if (data != null) { if (data.Length >= 9) { { UInt16 func = ToUInt16(data, 6); switch (func) { #region 协议格式 case 2: { CMD2 CMD2 = new MsgReceiveCMDCom().ConCMD2(data); string result = "(CMD=2)充电桩参数整形设置/查询应答 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=2)充电桩参数整形设置/查询应答对象:" + JsonConvert.SerializeObject(CMD2); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD2 != null) { //byte type = 0; //uint startAddress = 0; //byte num = 0; //byte[] setData = null; ////(CMD=1)后台服务器下发充电桩整形工作参数 //CmnChargerParam._CHR00TCPCLIENT.Send1(type, startAddress, num, setData); } } break; case 4: { CMD4 CMD4 = new MsgReceiveCMDCom().ConCMD4(data); string result = "(CMD=4)充电桩参数字符形设置/查询应答 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=4)充电桩参数字符形设置/查询应答对象:" + JsonConvert.SerializeObject(CMD4); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD4 != null) { //byte type = 0; //uint startAddress = 1; //byte[] setData = new byte[4]; ////(CMD=3)后台服务器下发充电桩字符型参数 //CmnChargerParam._CHR00TCPCLIENT.Send3(type, startAddress, setData); } } break; case 6: { CMD6 CMD6 = new MsgReceiveCMDCom().ConCMD6(data); string result = "(CMD=6)充电桩对后台控制命令应答- 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=6)充电桩对后台控制命令应答对象:" + JsonConvert.SerializeObject(CMD6); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD6 != null) { //byte type = 0; //uint startAddress = 0; //byte num = 0; //byte[] setData = new byte[4]; ////(CMD=5)后台服务器下发充电桩控制命令 //CmnChargerParam._CHR00TCPCLIENT.Send5(type, startAddress, num, setData); } } break; case 8: { CMD8 CMD8 = new MsgReceiveCMDCom().ConCMD8(data); string result = "(CMD=8) 充电桩对后台下发的充电桩开启充电控制应答 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=8) 充电桩对后台下发的充电桩开启充电控制应答对象:" + JsonConvert.SerializeObject(CMD8); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD8 != null) { //CMD7 CMD = new CMD7(); //CMD.value13 = "1234567890"; ////(CMD=1)后台服务器下发充电桩整形工作参数 //CmnChargerParam._CHR00TCPCLIENT.Send7(CMD); } } break; case 10: { CMD10 CMD10 = new MsgReceiveCMDCom().ConCMD10(data); string result = "(CMD=10)充电桩上传命令请求(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=10)充电桩上传命令请求(预留)对象:" + JsonConvert.SerializeObject(CMD10); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD10 != null) { byte chargeMuzzle = 0; uint executeResult = 0; uint address = 0; byte[] setData = null; //(CMD=9)后台服务器应答桩上传命令请求(预留) CmnChargerParam._CHR00TCPCLIENT.Send9(chargeMuzzle, executeResult, address, setData); } } break; #endregion #region 充电桩主动上传数据 case 102: { CMD102 CMD102 = new MsgReceiveCMDCom().ConCMD102(data); string result = "(CMD=10)充电桩上传心跳包信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=10)充电桩上传心跳包信息对象:" + JsonConvert.SerializeObject(CMD102); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD102 != null) { ushort heartbeatNum = 0; //(CMD=9)后台服务器应答桩上传命令请求(预留) CmnChargerParam._CHR00TCPCLIENT.Send101(heartbeatNum); } } break; case 104: { CMD104 CMD104 = new MsgReceiveCMDCom().ConCMD104(data); string result = "(CMD=10)充电桩状态信息包上报 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=10)充电桩状态信息包上报对象:" + JsonConvert.SerializeObject(CMD104); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD104 != null) { byte chargeNum = 0; bool reportMessage = true; //(CMD=9)后台服务器应答桩上传命令请求(预留) CmnChargerParam._CHR00TCPCLIENT.Send103(chargeNum, reportMessage); } } break; case 106: { CMD106 CMD106 = new MsgReceiveCMDCom().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) { CMD105 CMD = new CMD105(); //(CMD=9)后台服务器应答桩上传命令请求(预留) CmnChargerParam._CHR00TCPCLIENT.Send105(CMD); } } break; case 108: { CMD108 CMD108 = new MsgReceiveCMDCom().ConCMD108(data); string result = "(CMD=10)充电桩告警信息上报(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=10)充电桩告警信息上报(预留)对象:" + JsonConvert.SerializeObject(CMD108); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD108 != null) { //(CMD=9)后台服务器应答桩上传命令请求(预留) //CmnChargerParam._CHR00TCPCLIENT.Send107(); } } break; case 110: { CMD110 CMD110 = new MsgReceiveCMDCom().ConCMD110(data); string result = "(CMD=10)充电桩上报充电启动完成命令(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=10)充电桩上报充电启动完成命令(预留)对象:" + JsonConvert.SerializeObject(CMD110); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD110 != null) { //(CMD=9)后台服务器应答桩上传命令请求(预留) CmnChargerParam._CHR00TCPCLIENT.Send109(); } } break; case 112: { CMD112 CMD112 = new MsgReceiveCMDCom().ConCMD112(data); string result = "(CMD=10)充电桩模块信息上报(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=10)充电桩模块信息上报对象:" + JsonConvert.SerializeObject(CMD112); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD112 != null) { byte messageType = 0; //(CMD=9)后台服务器应答桩上传命令请求(预留) CmnChargerParam._CHR00TCPCLIENT.Send111(messageType); } } break; case 114: { CMD114 CMD114 = new MsgReceiveCMDCom().ConCMD114(data); string result = "(CMD=10)充电桩应答服务器查询最近一次充电各时段信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=10)充电桩应答服务器查询最近一次充电各时段信息对象:" + JsonConvert.SerializeObject(CMD114); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD114 != null) { //todo } } break; #endregion #region 充电信息数据 case 202: case 222: { CMD202 CMD202 = new MsgReceiveCMDCom().ConCMD202(func, data); string result = "充电桩上报充电记录信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "上报充电记录信息对象:" + JsonConvert.SerializeObject(CMD202); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD202 != null) { //todo 实例化CMD201对象 CMD201 cMD201 = new CMD201(); cMD201.value04 = "0"; //201中其他字段如何赋值 cMD201.value05 = CMD202.value17; CmnChargerParam._CHR00TCPCLIENT.Send201(cMD201, func); } } break; case 204: { CMD204 CMD204 = new MsgReceiveCMDCom().ConCMD204(data); string result = "充电桩充电上传用户账户查询报文 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩充电上传用户账户查询报文对象:" + JsonConvert.SerializeObject(CMD204); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD204 != null) { uint value03 = 0; uint value04 = 0; ushort value05 = 0; ushort value06 = 0; byte value07 = 0; byte value08 = 0; byte value09 = 0; byte value10 = 0; string value11 = "123"; string value12 = "456"; CmnChargerParam._CHR00TCPCLIENT.Send203(CMD204, value03, value04, value05, value06, value07, value08, value09, value10, value11, value12); } } break; case 206: { CMD206 CMD206 = new MsgReceiveCMDCom().ConCMD206(data); string result = "充电桩充电上传用户密码验证报文 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩充电上传用户密码验证报文对象:" + JsonConvert.SerializeObject(CMD206); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD206 != null) { uint value03 = 0; uint value04 = 0; CmnChargerParam._CHR00TCPCLIENT.Send205(value03, value04); } } break; case 208: { CMD208 CMD208 = new MsgReceiveCMDCom().ConCMD208(data); string result = "充电桩上报“即插即充”启动充电请求 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩上报“即插即充”启动充电请求对象:" + JsonConvert.SerializeObject(CMD208); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD208 != null) { CmnChargerParam._CHR00TCPCLIENT.Send207(CMD208, "", "", 0, 0, 0, 0); } } break; case 210: { CMD210 CMD210 = new MsgReceiveCMDCom().ConCMD210(data); string result = "充电桩上报“即插即充”启动充电结果 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩上报“即插即充”启动充电结果:" + JsonConvert.SerializeObject(CMD210); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD210 != null) { //(CMD=9)后台服务器应答桩上传命令请求(预留) string value05 = ""; CmnChargerParam._CHR00TCPCLIENT.Send209(CMD210, value05); } } break; #endregion #region 直流充电桩 BMS 信息数据(预留) case 302: { CMD302 CMD302 = new MsgReceiveCMDCom().ConCMD302(data); string result = "充电桩上报BMS信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩上报BMS信息对象:" + JsonConvert.SerializeObject(CMD302); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD302 != null) { //(CMD=9)后台服务器应答桩上传命令请求(预留) CmnChargerParam._CHR00TCPCLIENT.Send301(); } } break; case 304: { CMD304 CMD304 = new MsgReceiveCMDCom().ConCMD304(data); string result = "充电桩上报BMS信息(预留-暂时不用) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩上报BMS信息(预留-暂时不用)对象:" + JsonConvert.SerializeObject(CMD304); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD304 != null) { //(CMD=9)后台服务器应答桩上传命令请求(预留) CmnChargerParam._CHR00TCPCLIENT.Send303(); } } break; #endregion #region 历史记录 case 402: case 422: { CMD402 CMD402 = new MsgReceiveCMDCom().ConCMD402(func, data); string result = "充电桩上报历史的充电记录 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩上报历史的充电记录:" + JsonConvert.SerializeObject(CMD402); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD402 != null) { //todo } } break; #endregion #region 升级命令 case 1002: { CMD1002 CMD1002 = new MsgReceiveCMDCom().ConCMD1002(data); string result = "充电桩回复服务器下发擦除指令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩回复服务器下发擦除指令对象:" + JsonConvert.SerializeObject(CMD1002); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1002 != null) { //todo } } break; case 1004: { CMD1004 CMD1004 = new MsgReceiveCMDCom().ConCMD1004(data); string result = "充电桩应答服务器下发升级文件名指令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答服务器下发升级文件名指令对象:" + JsonConvert.SerializeObject(CMD1004); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1004 != null) { //todo } } break; case 1006: { CMD1006 CMD1006 = new MsgReceiveCMDCom().ConCMD1006(data); string result = "充电桩应答服务器下发升级文件大小指令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答服务器下发升级文件大小指令对象:" + JsonConvert.SerializeObject(CMD1006); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1006 != null) { //todo } } break; case 1008: { CMD1008 CMD1008 = new MsgReceiveCMDCom().ConCMD1008(data); string result = "充电桩应答服务器下发升级文件数据指令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答服务器下发升级文件数据指令对象:" + JsonConvert.SerializeObject(CMD1008); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1008 != null) { //todo } } break; case 1010: { CMD1010 CMD1010 = new MsgReceiveCMDCom().ConCMD1010(data); string result = "充电桩应答服务器下发升级文件数据结束指令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答服务器下发升级文件数据结束指令对象:" + JsonConvert.SerializeObject(CMD1010); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1010 != null) { //todo } } break; case 1012: { CMD1012 CMD1012 = new MsgReceiveCMDCom().ConCMD1012(data); string result = "充电桩应答服务器下发重启指令- 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答服务器下发重启指令对象:" + JsonConvert.SerializeObject(CMD1012); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1012 != null) { //todo } } break; case 1022: { CMD1022 CMD1022 = new MsgReceiveCMDCom().ConCMD1022(data); string result = "充电桩主动请求升级命令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩主动请求升级命令对象:" + JsonConvert.SerializeObject(CMD1022); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1022 != null) { uint results = 0; string description = ""; //服务器回复充电桩主动请求升级命令 CmnChargerParam._CHR00TCPCLIENT.Send1021(results, description); } } break; #endregion #region 与计费策略相关的指令 case 1102: { CMD1102 CMD1102 = new MsgReceiveCMDCom().ConCMD1102(data); string result = "充电桩应答后台服务器查询24时电费计价策略信息- 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答后台服务器查询24时电费计价策略信息对象:" + JsonConvert.SerializeObject(CMD1102); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1102 != null) { //todo } } break; case 1104: { CMD1104 CMD1104 = new MsgReceiveCMDCom().ConCMD1104(data); string result = "充电桩应答后台服务器设置24时电费计价策略信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答后台服务器设置24时电费计价策略信息对象:" + JsonConvert.SerializeObject(CMD1104); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1104 != null) { //todo } } break; case 1106: { CMD1106 CMD1106 = new MsgReceiveCMDCom().ConCMD1106(data); string result = "充电桩应答后台服务器设置分时段计价策略信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答后台服务器设置分时段计价策略信息对象:" + JsonConvert.SerializeObject(CMD1106); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1106 != null) { //todo } } break; case 1108: { CMD1108 CMD1108 = new MsgReceiveCMDCom().ConCMD1108(data); string result = "充电桩回复分时电费计价策略信息 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩回复分时电费计价策略信息对象:" + JsonConvert.SerializeObject(CMD1108); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1108 != null) { //todo } } break; #endregion #region 白名单报文 case 1302: { CMD1302 CMD1302 = new MsgReceiveCMDCom().ConCMD1302(data); string result = "充电桩应答白名单操作日志数据包 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答白名单操作日志数据包对象:" + JsonConvert.SerializeObject(CMD1302); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1302 != null) { //todo } } break; #endregion #region FTP远程升级和FTP方式日志上传 case 1402: { CMD1402 CMD1402 = new MsgReceiveCMDCom().ConCMD1402(data); string result = "充电桩应答服务器下发FTP远程升级命令- 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答服务器下发FTP远程升级命令对象:" + JsonConvert.SerializeObject(CMD1402); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1402 != null) { //todo } } break; case 1403: { CMD1403 CMD1403 = new MsgReceiveCMDCom().ConCMD1403(data); string result = "充电桩应答FTP升级包下载进度 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答FTP升级包下载进度对象:" + JsonConvert.SerializeObject(CMD1403); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1403 != null) { //todo } } break; case 1407: { CMD1407 CMD1407 = new MsgReceiveCMDCom().ConCMD1407(data); string result = "充电桩应答服务器下发获取充电桩日志命令 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "充电桩应答服务器下发获取充电桩日志命令对象:" + JsonConvert.SerializeObject(CMD1407); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1407 != null) { //todo } } break; #endregion #region 协议方式日志上传 case 1501: { CMD1501 CMD1501 = new MsgReceiveCMDCom().ConCMD1501(data); string result = "(CMD=1501)申请上传文件 - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=1501)申请上传文件对象:" + JsonConvert.SerializeObject(CMD1501); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1501 != null) { //判断是否允许上传 todo //应答码responseCode 0-允许发送,其他-不支持日志上传 uint responseCode = 0; //服务器允许上传 CmnChargerParam._CHR00TCPCLIENT.Send1502(responseCode); PublicProgram.failName01 = CMD1501.value03 + "/" + CMD1501.value04 + "/" + DateTime.Now.ToString("yyyyMMddHHmmss"); //获取桌面路径 string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); // 检查文件夹是否已经存在 if (!Directory.Exists(folderPath)) { // 如果文件夹不存在,则创建它 Directory.CreateDirectory(folderPath); } } } break; case 1503: { CMD1503 CMD1503 = new MsgReceiveCMDCom().ConCMD1503(data); string result = "(CMD=10)充电桩上传命令请求(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=10)充电桩上传命令请求(预留)对象:" + JsonConvert.SerializeObject(CMD1503); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1503 != null) { //要加防止重复(未加) //要判断是否接收成功 logo=0-成功接收、logo=1-接收出错 UInt32 logo = 0; // CmnChargerParam._CHR00TCPCLIENT.Send1504(logo, CMD1503.value04); Log.LogInstance.WriteLog(CMD1503.value05, LogType.Information, PublicProgram.failName01); } } break; case 1505://接收完成,要保存关闭 { CMD1505 CMD1505 = new MsgReceiveCMDCom().ConCMD1505(data); string result = "(CMD=10)充电桩上传命令请求(预留) - 接收字节内容:" + ByteUtils.BytesToHexStr(data) + ";"; result += "\r\n" + "(CMD=10)充电桩上传命令请求(预留)对象:" + JsonConvert.SerializeObject(CMD1505); Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "充电机编码"); if (CMD1505 != null) { // CmnChargerParam._CHR00TCPCLIENT.Send1506(); } } break; #endregion } } } } } /// /// 故障记录处理 /// /// 故障报警记录值 /// 故障报警码 private void ProcFaultResult(byte faultVal, int faultCode) { if (faultVal == 1) { if (!_fault_alaram_no_list.Contains(faultCode)) { _fault_code = faultCode; _fault_alaram_no_list.Add(faultCode); //将故障报警记录存入数据库 } } else { if (_fault_alaram_no_list.Contains(faultCode)) { _fault_alaram_no_list.Remove(faultCode); //将故障报警消除的信息存入数据库 } } } #endregion 数据接收 #region 数据发送 /// /// 发送事件 /// /// /// /// private void Client_DataSended(object sender, Module.Socket.Tool.TcpDataSendEventArgs e) { DataSendedEventFunc(e.Data); } #region 充电机发送指令方法 #region 充放电启动指令 /// /// 充电鉴权 /// /// 是否写成功 public void SendCharingSignIn() { if (_chr_client != null) { if (_chr_client.Connected) { Auth auth = new ChargerSendMsgUtils().SendCharingSignIn(_chr_client, _dest_addr); if (auth != null) { if (_result._auth_rlt == null) { _result._auth_rlt = new AuthResult(); } //将发送结果保持到公共变量结果中 _result._auth_rlt.F_ID = auth.ConnSeq; _result._auth_rlt.F_HaveRes = false; _result._auth_rlt.F_Auth = auth; _result._auth_rlt.F_AuthRes = null; } } } } /// /// 监控平台应答充电设备登录签到 /// /// 是否写成功 public void SendCharingLoginRes() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendCharingLoginRes(_chr_client, _dest_addr); } } } /// /// 监控平台心跳应答 /// /// 是否写成功 public void SendCharingHeartRes() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendCharingHeartRes(_chr_client, _dest_addr); } } } /// /// 监控平台发送远程开始充电指令 /// /// SOC限制.百分比 /// 功率调节指令类型.默认1 绝对功率值 /// 0.1kw/位,默认3600 /// 是否写成功 public void SendRemoteStartCharing(byte socLimit, byte changePowerCmdType, UInt16 changePower, byte startModel) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendRemoteStartCharing(_chr_client, _dest_addr, socLimit, changePowerCmdType, changePower, startModel); } } } #region 远程停止充电指令发送 /// /// 停止充电-一直发送直到收到充电机响应为止,调用此方法时,需要将F_StopReason赋值,判断F_IsCanSendStopCmd是否为False,如果是,则赋值为True,否则不可重复发送 /// public void SendRemoteStopCmdThread() { //发送停止充电指令线程 Thread sendRemoteStopThread = new Thread(SendRemoteStopChargingCmd); sendRemoteStopThread.IsBackground = true; sendRemoteStopThread.Start(); } /// /// 发送停止充电指令线程 /// private void SendRemoteStopChargingCmd() { while (_is_can_send_stop_cmd) { SendRemoteStopCharing(_stop_reason); Thread.Sleep(2000); } } /// /// 监控平台发送远程停止充电指令 /// /// 停止原因.0正常停机 1服务器发现桩异常,强制停机 private void SendRemoteStopCharing(byte stopReason) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendRemoteStopCharing(_chr_client, _dest_addr, stopReason); } } } #endregion 远程停止充电指令发送 /// /// 监控平台应答充电启动完成帧 /// /// 成功标识.0:成功;1:失败 /// 失败原因.0:成功 1:交易流水号数据异常 2:充电方式数据异常 public void SendStartChargingFinishedRes(byte resResult, byte failReason) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendStartChargingFinishedRes(_chr_client, _dest_addr, resResult, failReason); } } } /// /// 监控平台应答充电停止完成帧 /// /// 成功标识.0:成功;1:失败 public void SendStopChargingFinishedRes(byte resResult) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendStopChargingFinishedRes(_chr_client, _dest_addr, resResult); } } } #endregion 充放电启动指令 /// /// 监控平台下发版本号查询 /// /// public void SendVersionNumber() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendVersionNumber(_chr_client, _dest_addr); } } } /// /// 站控设置尖峰平谷时间段标识 /// /// public void SendPeakTimePeriod(SharpPeakTimeRangeIde timeRng) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendPeakTimePeriod(_chr_client, _dest_addr, timeRng); } } } /// /// 3.5.7 主动上送充电记录响应 /// /// public void SendRecordChargResp(byte reserve1, byte reserve2) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendRecordChargResp(_chr_client, _dest_addr, reserve1, reserve2); } } } /// /// 3.4.1 监控平台发送功率调节指令 帧类型45 记录类型 5 /// /// public void SendPowerRegulate(ushort expectePower) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendPowerRegulate(_chr_client, _dest_addr, expectePower); } } } /// /// 监控平台下发辅源控制指令 /// /// public void SendAuxiliaryPowerControl(byte onAuxiliaryFlag) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendAuxiliaryPowerControl(_chr_client, _dest_addr, onAuxiliaryFlag); } } } /// /// 监控平台下发掉线停止充电 /// /// /// public void SendDisconnectStopCharge(byte responseResults, ushort reserve) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendDisconnectStopCharge(_chr_client, _dest_addr, responseResults, reserve); } } } /// /// 监控平台下发站外允许充电SOC /// /// public void SendOutsideAllowChargeSOC(byte SOCLimitValue) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendOutsideAllowChargeSOC(_chr_client, _dest_addr, SOCLimitValue); } } } public void SendQueryPeakTime(byte reserve) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendQueryPeakTime(_chr_client, _dest_addr, reserve); } } } #region New /// /// 3.4.1 监控平台发送功率调节指令 帧类型45 记录类型 5 /// public void SendPowerRegulateCmd(ushort expectePower) { SendPowerRegulate(expectePower); } public void SendAuxiliaryPowerControlCmd(byte onAuxiliaryFlag) { SendAuxiliaryPowerControl(onAuxiliaryFlag); } public void SendDisconnectStopChargeCmd(byte responseResults, ushort reserve) { SendDisconnectStopCharge(responseResults, reserve); } public void SendOutsideAllowChargeSOCCmd(byte SOCLimitValue) { SendOutsideAllowChargeSOC(SOCLimitValue); } public void SendVersionNumberCmd() { SendVersionNumber(); } public void SendQueryPeakTimeCmd(byte reserve) { SendQueryPeakTime(reserve); } /// /// 3.5.11 站控响应充放电机上报模块状态 /// /// public void SendUpModelStationResp(byte respResult) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().SendUpModelStationResp(_chr_client, _dest_addr, respResult); } } } #endregion New #endregion 充电机发送指令方法 #endregion 数据发送 #region 协议格式 /// /// (CMD=1)后台服务器下发充电桩整形工作参数 /// /// 类型 0-查询/1-设置 /// 设置/查询参数起始地址 /// 设置/查询个数 /// 设置数据 public void Send1(byte type, uint startAddress, byte num, byte[] setData) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1(_chr_client, type, startAddress, num, setData); } } } /// /// 后台服务器下发充电桩字符型参数 /// /// 类型 0-查询 1-设置 /// 设置/查询参数起始地址 /// 设置数据 public void Send3(byte type, uint startAddress, byte[] setData) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send3(_chr_client, type, startAddress, setData); } } } public void Send5(byte type, uint startAddress, byte num, byte[] setData) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send5(_chr_client, type, startAddress, num, setData); } } } public void Send7(CMD7 CMD) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send7(_chr_client, CMD); } } } public void Send9(byte chargeMuzzle, uint executeResult, uint address, byte[] setData) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send9(_chr_client, chargeMuzzle, executeResult, address, setData); } } } #endregion 协议格式 #region 充电桩主动上传数据 public void Send101(ushort heartbeatNum) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send101(_chr_client, heartbeatNum); } } } public void Send103(byte chargeNum, bool reportMessage) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send103(_chr_client, chargeNum, reportMessage); } } } public void Send105(CMD105 CMD) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send105(_chr_client, CMD); } } } public void Send107() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send107(_chr_client); } } } public void Send109() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send109(_chr_client); } } } public void Send111(byte messageType) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send111(_chr_client, messageType); } } } public void Send113(byte chargeNum, byte sign) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send113(_chr_client, chargeNum, sign); } } } #endregion #region 充电信息数据 public void Send201(CMD201 CMD201, uint func) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send201(_chr_client, CMD201, func); } } } public void Send203(CMD204 CMD204, uint value03, uint value04, ushort value05, ushort value06, byte value07, byte value08, byte value09, byte value10, string value11, string value12) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send203(_chr_client, CMD204, value03, value04, value05, value06, value07, value08, value09, value10, value11, value12); } } } public void Send205(uint value03, uint value04) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send205(_chr_client, value03, value04); } } } public void Send207(CMD208 CMD208, string value06, string value07, byte value08, byte value09, uint value10, ulong value11) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send207(_chr_client, CMD208, value06, value07, value08, value09, value10, value11); } } } public void Send209(CMD210 CMD210, string value05) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send209(_chr_client, CMD210, value05); } } } public void Send221(CMD221 CMD221, uint value05) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send221(_chr_client, CMD221, value05); } } } #endregion #region- 直流充电桩 BMS 信息数据(预留) public void Send301() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send301(_chr_client); } } } public void Send303() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send303(_chr_client); } } } #endregion #region 历史记录 public void Send401(string chargingSerialNum, uint startIndex) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send401(_chr_client, chargingSerialNum, startIndex); } } } #endregion #region 升级命令 public void Send1001(uint instruct) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1001(_chr_client, instruct); } } } public void Send1003(string fileName) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1003(_chr_client, fileName); } } } public void Send1005(uint fileLength) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1005(_chr_client, fileLength); } } } public void Send1007(string updata) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1007(_chr_client, updata); } } } public void Send1009() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1009(_chr_client); } } } public void Send1011() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1011(_chr_client); } } } public void Send1021(uint results, string description) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1021(_chr_client, results, description); } } } #endregion #region 与计费策略相关的指令 public void Send1101() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1101(_chr_client); } } } public void Send1103(CMD1103 CMD) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1103(_chr_client, CMD); } } } public void Send1105(CMD1105 CMD) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1105(_chr_client, CMD); } } } public void Send1107() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1107(_chr_client); } } } #endregion #region 白名单报文 public void Send1301(CMD1301 CMD) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1301(_chr_client, CMD); } } } #endregion #region FTP 远程升级和 FTP 方式日志上传 public void Send1401(CMD1401 CMD) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1401(_chr_client, CMD); } } } public void Send1406(CMD1406 CMD) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1406(_chr_client, CMD); } } } #endregion #region 协议方式日志上传 public void Send1502(uint responseCode) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1502(_chr_client, responseCode); } } } public void Send1504(uint logo, uint successReservedMessageNum) { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1504(_chr_client, logo, successReservedMessageNum); } } } public void Send1506() { if (_chr_client != null) { if (_chr_client.Connected) { new ChargerSendMsgUtils().Send1506(_chr_client); } } } #endregion } }