添加断线,心跳和鉴权

master
CZ 8 months ago
commit a01fa6028a

Binary file not shown.

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.Charger.BatCharging.Manager
{
/// <summary>
/// 管理充电机信息
/// </summary>
public class ChargerEqmManager
{
public Channel<byte[]> messageQueue;
/// <summary>
/// 充电机通讯连接线程
/// </summary>
public void ChargerNetConnectThread()
{
Thread chrgConnectThread = new Thread(ChargerNetConnectFunc);
chrgConnectThread.IsBackground = true;
chrgConnectThread.Start();
}
/// <summary>
/// 充电机通讯连接
/// </summary>
private void ChargerNetConnectFunc()
{
UnboundedChannelOptions options = new UnboundedChannelOptions();
options.SingleReader = true;
messageQueue = Channel.CreateUnbounded<byte[]>(options);
ChargerConnect();
}
public void ChargerConnect()
{
Task.Run(() => ConsumeMessagesThread());
while (true)
{
//if(messageQueue.)
}
}
public async Task ConsumeMessagesThread()
{
while (await messageQueue.Reader.WaitToReadAsync())
{
while (messageQueue.Reader.TryRead(out var message))
{
//Client_DataReceived(message);
}
}
}
}
}

@ -28,6 +28,8 @@ namespace HybirdFrameworkServices
public byte LoginVerify { get; set; }
/// <summary>
/// 加密标识
/// <code>0-不加密</code>
/// <code>1-ASE 加密</code>
/// </summary>
public byte EncryptionFlag { get; set; }
/// <summary>

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.Charger.BatCharging.Service
{
public static class BcdTimeConverter
{
public static long ConvertToBcdTime(DateTime dateTime)
{
// 将DateTime的各个部分分离出来
int year = dateTime.Year;
int month = dateTime.Month;
int day = dateTime.Day;
int hour = dateTime.Hour;
int minute = dateTime.Minute;
int second = dateTime.Second;
int millisecond = dateTime.Millisecond;
// BCD编码转换函数
byte BcdEncode(int value)
{
return (byte)((value / 10 * 16) + (value % 10));
}
// 构造BCD时间
// 注意:这里假设毫秒只取前两位(十位和个位),忽略剩余的毫秒数
byte secondTens = BcdEncode(second / 10);
byte secondUnits = BcdEncode(second % 10);
byte minuteTens = BcdEncode(minute / 10);
byte minuteUnits = BcdEncode(minute % 10);
byte hourTens = BcdEncode(hour / 10);
byte hourUnits = BcdEncode(hour % 10);
byte dayTens = BcdEncode(day / 10);
byte dayUnits = BcdEncode(day % 10);
byte monthTens = BcdEncode(month / 10);
byte monthUnits = BcdEncode(month % 10);
byte yearTens = BcdEncode(year / 10);
byte yearUnits = BcdEncode(year % 10);
// 组合成一个8字节的数
long bcdTime = (long)secondTens << 56 | (long)secondUnits << 52 |
(long)minuteTens << 48 | (long)minuteUnits << 44 |
(long)hourTens << 40 | (long)hourUnits << 36 |
(long)dayTens << 32 | (long)dayUnits << 28 |
(long)monthTens << 24 | (long)monthUnits << 20 |
(long)yearTens << 16 | (long)yearUnits;
return bcdTime;
}
public static byte[] ConvertToBcdTimeByte(DateTime dateTime)
{
// 将DateTime的各个部分分离出来
int year = dateTime.Year;
int month = dateTime.Month;
int day = dateTime.Day;
int hour = dateTime.Hour;
int minute = dateTime.Minute;
int second = dateTime.Second;
int millisecond = dateTime.Millisecond;
byte[] bytes= new byte[8];
bytes[0]= (byte)year;
bytes[1]= (byte)month;
bytes[2]= (byte)day;
bytes[3]= (byte)hour;
bytes[4]= (byte)minute;
bytes[5]= (byte)second;
bytes[6]= (byte)0;
bytes[7]= (byte)0;
return bytes;
}
}
}

@ -10,6 +10,7 @@ using Newtonsoft.Json;
using System.Linq;
using DotNetty.Transport.Channels;
using HybirdFrameworkServices.Netty;
using HybirdFrameworkServices.Charger.BatCharging.Service;
namespace HybirdFrameworkServices
{
@ -100,6 +101,24 @@ namespace HybirdFrameworkServices
}
}
}
/// <summary>
/// 线程是否启动
/// </summary>
private bool _thread_start;
/// <summary>
/// 线程是否启动
/// </summary>
public bool F_ThreadStart
{
get { return _thread_start; }
set
{
lock (lockObj)
{
_thread_start = value;
}
}
}
/// <summary>
/// 是否与充电机已经鉴权
@ -573,16 +592,7 @@ namespace HybirdFrameworkServices
#region 通讯线程
/// <summary>
/// 充电机心跳线程和断线线程
/// </summary>
public void ChargerNetHeartBeatThread()
{
Thread chrgConnectedThread = new Thread(ChargerHeartBeatFunc);
chrgConnectedThread.IsBackground = true;
chrgConnectedThread.Start();
}
/// <summary>
/// 充电机判断是否断线线程
/// 充电机线程启动
/// </summary>
public void ChargerNetCheckThread()
{
@ -590,39 +600,31 @@ namespace HybirdFrameworkServices
chargerThread.IsBackground = true;
chargerThread.Start();
}
/// <summary>
/// 充电机的心跳方法
/// </summary>
public void ChargerHeartBeatFunc()
{
while (F_IsAuthed)
{
Thread.Sleep(2000);
byte[] bytes = Send101(F_Accumulation);
if (Server != null)
{
Server.Send(bytes);
}
}
}
/// <summary>
/// 充电机判断是否断线线程.充电机在连接情况下30秒未收到信息则认为断线需要重新连接
/// 读取发送到此充电机的报文
/// </summary>
private void ChargerNetCheckFunc()
{
while (F_IsAuthed)
while (F_ThreadStart)
{
Thread.Sleep(2000);
DateTime recvTime = DateTime.Now;
int seconds = Convert.ToInt32(recvTime.Subtract(F_RecvingDataTime).TotalSeconds);
if (seconds >= _net_check_time_out)
//if (F_IsAuthed)//是否鉴权
// if (F_NetConnected)//是否连接
if (F_NetConnected)//是否连接
{
//ChargerDisConnect();
Thread.Sleep(2000);
DateTime recvTime = DateTime.Now;
int seconds = Convert.ToInt32(recvTime.Subtract(F_RecvingDataTime).TotalSeconds);
if (seconds >= _net_check_time_out)
{
//ChargerDisConnect();
Server.Disconnect(F_IPAddr);
}
}
}
}
#endregion 通讯线程
@ -630,395 +632,422 @@ namespace HybirdFrameworkServices
#region 数据接收
public void decode(string IP, string port, byte[] data)
public void decode(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 设置/查询工作参数和命令
if (func == 106 || F_IsAuthed)
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" + "充电机编码");
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 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 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 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;
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
}
break;
#endregion
#region 充电桩主动上传数据
#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)
case 102:
{
Server.Send(bytes);
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)
{
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 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)
}
break;
case 106:
//106签到鉴权
{
F_EqmCode = CMD106.ASCIINum;
F_Sign = CMD106.Sign == 1 ? true : false;
F_IsAuthed = true;
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)
{
//回复106签到报文
{
F_EqmCode = CMD106.ASCIINum;
F_Sign = CMD106.Sign == 1 ? true : false;
F_IsAuthed = true;
CMD105 CMD = new CMD105();
CMD.NumResponse = (uint)new Random().Next();
CMD.LoginVerify = 0;
CMD.EncryptionFlag = 0;
CMD.RSAComModule = "";
CMD.RSAComSecret = 0;
CMD.RSAComSecret = 0;
CMD.StSign = 0;
CMD.BCDTime = (ulong)BcdTimeConverter.ConvertToBcdTime(DateTime.Now);
CMD.MessageUpload = 0;
CMD.AESSecretKey = "";
byte[] bytes = Send105(CMD);
if (Server != null)
{
Server.Send(bytes);
}
}
//CMD3对时报文
{
byte type = 1;//0-查询 1-设置
uint startAddress = 2;//设置/查询参数启始地址
byte[] setData = new byte[8];//设置数据
setData = BcdTimeConverter.ConvertToBcdTimeByte(DateTime.Now);
byte[] bytes = Send3(type, startAddress, setData);
if (Server != null)
{
Server.Send(bytes);
}
}
}
}
}
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 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 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
}
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 充电信息数据
#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" + "充电机编码");
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
}
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 直流充电桩 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" + "充电机编码");
#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
}
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 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 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 白名单报文
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 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" + "充电机编码");
#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
}
}
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 数据发送
public void Send(byte[] bytes)
{
Server.Send(bytes, ID);
}
#region 服务器向充电桩设置/查询工作参数和命令
/// <summary>

@ -58,7 +58,7 @@ namespace HybirdFrameworkServices.Netty
pipeline.AddLast(new CustomFrameDecoder(new IByteBuffer[] { delimiter }, false, false));
pipeline.AddLast(new CustomFrameEncoder());
//// 添加客户端连接监控Handler
//pipeline.AddLast(new ClientConnectionMonitorHandler());
pipeline.AddLast(new ClientConnectionMonitorHandler());
//pipeline.AddLast("idleStateHandler", new IdleStateHandler(30, 0, 0)); // 触发读取超时
//pipeline.AddLast(new ReconnectHandler(this));
//pipeline.AddLast(new ClientHandler(this));
@ -82,12 +82,15 @@ namespace HybirdFrameworkServices.Netty
channel.WriteAndFlushAsync(bytes);
}
}
public void Send(byte[] bytes,string id)
public void Send(byte[] bytes, IChannelId id)
{
foreach (IChannel channel in _container.Values)
{
channel.WriteAndFlushAsync(bytes);
}
//foreach (IChannel channel in _container.Values)
//{
// channel.WriteAndFlushAsync(bytes);
//}
if (_container.ContainsKey(id))
_container[id].WriteAndFlushAsync(bytes);
}
/// <summary>

@ -1,4 +1,5 @@
using DotNetty.Transport.Channels;
using DotNetty.Buffers;
using DotNetty.Transport.Channels;
using System;
using System.Collections.Generic;
using System.Linq;
@ -19,7 +20,6 @@ namespace HybirdFrameworkServices
public override void HandlerAdded(IChannelHandlerContext ctx)
{
Console.WriteLine("Client connected: " + ctx.Channel.RemoteAddress);
string input = ctx.Channel.RemoteAddress.ToString();
// 正则表达式匹配IPv4地址和端口号
@ -31,10 +31,12 @@ namespace HybirdFrameworkServices
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();
CmnChargingsEqmInfo._CHR01.F_ThreadStart = true;
CmnChargingsEqmInfo._CHR01.F_NetConnected = true;
CmnChargingsEqmInfo._CHR01.F_IPAddr = ipAddress;
CmnChargingsEqmInfo._CHR01.F_Port = Convert.ToInt32(match.Groups[3].Value);
CmnChargingsEqmInfo._CHR01.F_RecvingDataTime = DateTime.Now;
CmnChargingsEqmInfo._CHR01.ChargerNetCheckThread();
break;
case "127.0.0.2":
break;
@ -70,7 +72,9 @@ namespace HybirdFrameworkServices
switch (ipAddress)
{
case "127.0.0.1":
CmnChargingsEqmInfo._CHR01 = null;
CmnChargingsEqmInfo._CHR01.F_ThreadStart = false;
CmnChargingsEqmInfo._CHR01.F_NetConnected = false;
CmnChargingsEqmInfo._CHR01.F_IsAuthed = false;
break;
case "127.0.0.2":
break;

@ -28,7 +28,6 @@ namespace HybirdFrameworkServices
protected override void Decode(IChannelHandlerContext ctx, IByteBuffer buffer, List<object> output)
{
// 查找分隔符
IByteBuffer delimiter = FindDelimiter(buffer);
if (delimiter != null)
@ -62,18 +61,6 @@ namespace HybirdFrameworkServices
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++)//这里有校验域所以减一
{
@ -94,11 +81,45 @@ namespace HybirdFrameworkServices
byteList.Remove(8);//移除前面两个长度
bytes = byteList.ToArray();
new ChargerMgrTool().decode(ipAddress, port, bytes);
CmnChargingsEqmInfo._CHR01.decode(bytes);
}
else //不加密
{
new ChargerMgrTool().decode(ipAddress, port, bytes);
//CmnChargingsEqmInfo._CHR01.decode(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;
switch (ipAddress)
{
case "127.0.0.1":
CmnChargingsEqmInfo._CHR01.ID = ctx.Channel.Id;
CmnChargingsEqmInfo._CHR01.decode(bytes);
break;
case "127.0.0.2":
CmnChargingsEqmInfo._CHR02.ID = ctx.Channel.Id;
CmnChargingsEqmInfo._CHR02.decode(bytes);
break;
case "127.0.0.3":
CmnChargingsEqmInfo._CHR03.ID = ctx.Channel.Id;
CmnChargingsEqmInfo._CHR03.decode(bytes);
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;
}
}
}
//ctx.Channel.WriteAndFlushAsync(bytes);

@ -1,6 +1,7 @@
using Autofac;
using HybirdFrameworkEntity;
using HybirdFrameworkServices;
using HybirdFrameworkServices.Charger.BatCharging.Manager;
using HybirdFrameworkServices.Netty;
using HybirdFrameworkServices.System;
using log4net;
@ -47,7 +48,7 @@ public partial class Form1 : Form
Server.connect(port);
}
#region
#region 按钮方法
private void btnCmd1_Click(object sender, EventArgs e)
{
byte type = 1;//ÀàÐÍ 0-²éѯ/1-ÉèÖÃ
@ -327,8 +328,6 @@ public partial class Form1 : Form
Server.Send(bytes);
}
}
#endregion
private void btnCmd205_Click(object sender, EventArgs e)
{
uint value03 = 0;
@ -526,4 +525,5 @@ public partial class Form1 : Form
Server.Send(bytes);
}
}
#endregion
}
Loading…
Cancel
Save