diff --git a/.vs/hybirdMyFrame/DesignTimeBuild/.dtbcache.v2 b/.vs/hybirdMyFrame/DesignTimeBuild/.dtbcache.v2
index 775c3cd..14686b0 100644
Binary files a/.vs/hybirdMyFrame/DesignTimeBuild/.dtbcache.v2 and b/.vs/hybirdMyFrame/DesignTimeBuild/.dtbcache.v2 differ
diff --git a/.vs/hybirdMyFrame/v17/.suo b/.vs/hybirdMyFrame/v17/.suo
index c5e13fd..05ea547 100644
Binary files a/.vs/hybirdMyFrame/v17/.suo and b/.vs/hybirdMyFrame/v17/.suo differ
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Manager/ChargerEqmManager.cs b/HybirdFrameworkServices/Charger/BatCharging.Manager/ChargerEqmManager.cs
new file mode 100644
index 0000000..66f17b1
--- /dev/null
+++ b/HybirdFrameworkServices/Charger/BatCharging.Manager/ChargerEqmManager.cs
@@ -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
+{
+ ///
+ /// 管理充电机信息
+ ///
+ public class ChargerEqmManager
+ {
+ public Channel messageQueue;
+ ///
+ /// 充电机通讯连接线程
+ ///
+ public void ChargerNetConnectThread()
+ {
+ Thread chrgConnectThread = new Thread(ChargerNetConnectFunc);
+ chrgConnectThread.IsBackground = true;
+ chrgConnectThread.Start();
+ }
+ ///
+ /// 充电机通讯连接
+ ///
+ private void ChargerNetConnectFunc()
+ {
+ UnboundedChannelOptions options = new UnboundedChannelOptions();
+ options.SingleReader = true;
+ messageQueue = Channel.CreateUnbounded(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);
+
+
+
+ }
+ }
+
+ }
+ }
+}
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD10.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD10.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD10.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD10.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1002.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1002.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1002.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1002.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1004.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1004.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1004.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1004.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1006.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1006.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1006.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1006.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1008.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1008.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1008.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1008.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1010.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1010.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1010.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1010.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1012.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1012.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1012.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1012.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD102.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD102.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD102.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD102.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1022.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1022.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1022.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1022.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD104.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD104.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD104.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD104.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD106.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD106.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD106.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD106.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD108.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD108.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD108.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD108.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD110.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD110.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD110.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD110.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1102.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1102.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1102.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1102.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1104.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1104.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1104.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1104.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1106.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1106.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1106.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1106.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1108.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1108.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1108.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1108.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD112.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD112.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD112.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD112.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD114.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD114.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD114.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD114.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1302.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1302.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1302.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1302.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1402.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1402.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1402.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1402.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1403.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1403.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1403.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1403.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1407.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1407.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1407.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1407.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1501.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1501.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1501.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1501.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1503.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1503.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1503.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1503.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1505.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1505.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1505.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1505.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1506.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1506.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD1506.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD1506.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD2.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD2.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD2.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD2.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD202.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD202.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD202.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD202.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD204.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD204.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD204.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD204.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD206.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD206.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD206.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD206.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD208.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD208.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD208.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD208.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD210.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD210.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD210.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD210.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD221.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD221.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD221.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD221.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD222.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD222.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD222.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD222.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD302.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD302.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD302.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD302.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD304.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD304.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD304.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD304.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD4.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD4.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD4.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD4.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD402.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD402.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD402.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD402.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD6.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD6.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD6.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD6.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD8.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD8.cs
similarity index 100%
rename from HybirdFrameworkServices/Charger/BatCharging.Model/RecpCMD/CMD8.cs
rename to HybirdFrameworkServices/Charger/BatCharging.Model/ReceiveCMD/CMD8.cs
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD105.cs b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD105.cs
index 3e5ed8c..de8f977 100644
--- a/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD105.cs
+++ b/HybirdFrameworkServices/Charger/BatCharging.Model/SendCMD/CMD105.cs
@@ -28,6 +28,8 @@ namespace HybirdFrameworkServices
public byte LoginVerify { get; set; }
///
/// 加密标识
+ /// 0-不加密
+ /// 1-ASE 加密
///
public byte EncryptionFlag { get; set; }
///
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Service/BcdTimeConverter.cs b/HybirdFrameworkServices/Charger/BatCharging.Service/BcdTimeConverter.cs
new file mode 100644
index 0000000..35a01ea
--- /dev/null
+++ b/HybirdFrameworkServices/Charger/BatCharging.Service/BcdTimeConverter.cs
@@ -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;
+ }
+ }
+}
diff --git a/HybirdFrameworkServices/Charger/BatCharging.Service/ChargerMgrTool.cs b/HybirdFrameworkServices/Charger/BatCharging.Service/ChargerMgrTool.cs
index 556a48d..6d200a3 100644
--- a/HybirdFrameworkServices/Charger/BatCharging.Service/ChargerMgrTool.cs
+++ b/HybirdFrameworkServices/Charger/BatCharging.Service/ChargerMgrTool.cs
@@ -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
}
}
}
+ ///
+ /// ߳Ƿ
+ ///
+ private bool _thread_start;
+ ///
+ /// ߳Ƿ
+ ///
+ public bool F_ThreadStart
+ {
+ get { return _thread_start; }
+ set
+ {
+ lock (lockObj)
+ {
+ _thread_start = value;
+ }
+ }
+ }
///
/// ǷѾȨ
@@ -573,16 +592,7 @@ namespace HybirdFrameworkServices
#region ͨѶ߳
///
- /// ̺߳Ͷ߳
- ///
- public void ChargerNetHeartBeatThread()
- {
- Thread chrgConnectedThread = new Thread(ChargerHeartBeatFunc);
- chrgConnectedThread.IsBackground = true;
- chrgConnectedThread.Start();
- }
- ///
- /// жǷ߳
+ /// ߳
///
public void ChargerNetCheckThread()
{
@@ -590,39 +600,31 @@ namespace HybirdFrameworkServices
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)
+ 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) Ժ̨·ijӦ - ֽݣ" + ByteUtils.BytesToHexStr(data) + "";
- result += "\r\n" + "(CMD=8) Ժ̨·ijӦ" + JsonConvert.SerializeObject(CMD8);
- //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;
+ 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 = "ϱʷij¼ - ֽݣ" + ByteUtils.BytesToHexStr(data) + "";
- result += "\r\n" + "ϱʷij¼" + JsonConvert.SerializeObject(CMD402);
- //Log.LogInstance.WriteLog(result, LogType.Information, "Charger" + "");
+ #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
+ }
+ 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 /ѯ
///
diff --git a/HybirdFrameworkServices/Netty/Server.cs b/HybirdFrameworkServices/Netty/Server.cs
index d9f4751..e4ddb0f 100644
--- a/HybirdFrameworkServices/Netty/Server.cs
+++ b/HybirdFrameworkServices/Netty/Server.cs
@@ -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);
}
///
diff --git a/HybirdFrameworkServices/Tool/ClientConnectionMonitorHandler.cs b/HybirdFrameworkServices/Tool/ClientConnectionMonitorHandler.cs
index 7f863ec..ae75d34 100644
--- a/HybirdFrameworkServices/Tool/ClientConnectionMonitorHandler.cs
+++ b/HybirdFrameworkServices/Tool/ClientConnectionMonitorHandler.cs
@@ -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;
diff --git a/HybirdFrameworkServices/Tool/CustomFrameDecoder.cs b/HybirdFrameworkServices/Tool/CustomFrameDecoder.cs
index 9e99cf4..d76f759 100644
--- a/HybirdFrameworkServices/Tool/CustomFrameDecoder.cs
+++ b/HybirdFrameworkServices/Tool/CustomFrameDecoder.cs
@@ -28,7 +28,6 @@ namespace HybirdFrameworkServices
protected override void Decode(IChannelHandlerContext ctx, IByteBuffer buffer, List