diff --git a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusTcpMaster.cs b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusTcpMaster.cs index e4ad4aa..380d03d 100644 --- a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusTcpMaster.cs +++ b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusTcpMaster.cs @@ -118,6 +118,7 @@ public class ModbusTcpMaster if (result.IsSuccess) return result.Content; return null; + } public bool WriteValue(ModbusProperty property) diff --git a/Service/Cloud/Client/CloudClient.cs b/Service/Cloud/Client/CloudClient.cs index 3a6f906..efb7b77 100644 --- a/Service/Cloud/Client/CloudClient.cs +++ b/Service/Cloud/Client/CloudClient.cs @@ -18,6 +18,7 @@ using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Service.Cloud.Handler; using Service.Cloud.Msg; +using Service.Cloud.Msg.Cloud.Req; using Service.Cloud.Msg.Host.Req; namespace Service.Cloud.Client; @@ -55,9 +56,16 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR public int Encrypt { get; set; } public string? AesKey { get; set; } + + public bool Authed { get; set; } #endregion + #region Cmd + + public CarCanStart? CarCanStart { get; set; } + + #endregion private IMqttClient? MqttClient; diff --git a/Service/Cloud/Handler/CarCanStartHandler.cs b/Service/Cloud/Handler/CarCanStartHandler.cs new file mode 100644 index 0000000..d07833d --- /dev/null +++ b/Service/Cloud/Handler/CarCanStartHandler.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; +using Service.Cloud.Client; +using Service.Cloud.Common; +using Service.Cloud.Msg.Cloud.Req; + +namespace Service.Cloud.Handler; + +public class CarCanStartHandler : IBaseHandler +{ + public bool CanHandle(string cmd) + { + return CloudConst.carCanStart == cmd; + } + + public void Handle(string t) + { + CarCanStart? carCanStart = JsonConvert.DeserializeObject(t); + CloudClientMgr.CloudClient.CarCanStart = carCanStart; + } +} \ No newline at end of file diff --git a/Service/Cloud/Handler/SignInRespHandler.cs b/Service/Cloud/Handler/SignInRespHandler.cs index 2b4569a..218b52a 100644 --- a/Service/Cloud/Handler/SignInRespHandler.cs +++ b/Service/Cloud/Handler/SignInRespHandler.cs @@ -1,7 +1,7 @@ using HybirdFrameworkCore.Autofac.Attribute; using Newtonsoft.Json; +using Service.Cloud.Client; using Service.Cloud.Common; -using Service.Cloud.Msg; using Service.Cloud.Msg.Cloud.Resp; namespace Service.Cloud.Handler; @@ -13,6 +13,10 @@ public class SignInRespHandler : IBaseHandler public void Handle(string t) { SignInResp? signInResp = JsonConvert.DeserializeObject(t); + if (signInResp != null) + { + CloudClientMgr.CloudClient.Authed = signInResp.re == 0; + } } public bool CanHandle(string cmd) diff --git a/Service/Cloud/Msg/Cloud/Req/PowerChangeCommand.cs b/Service/Cloud/Msg/Cloud/Req/CarCanStart.cs similarity index 95% rename from Service/Cloud/Msg/Cloud/Req/PowerChangeCommand.cs rename to Service/Cloud/Msg/Cloud/Req/CarCanStart.cs index dad7d68..a5fe31b 100644 --- a/Service/Cloud/Msg/Cloud/Req/PowerChangeCommand.cs +++ b/Service/Cloud/Msg/Cloud/Req/CarCanStart.cs @@ -10,7 +10,7 @@ namespace Service.Cloud.Msg.Cloud.Req /// /// 1 云平台下发车辆开始换电指令 /// - public class PowerChangeCommand + public class CarCanStart { /// /// 订单号