From 681e418798696baae1f31b4627db82a48b859ff1 Mon Sep 17 00:00:00 2001 From: CZ Date: Tue, 18 Jun 2024 09:38:46 +0800 Subject: [PATCH] =?UTF-8?q?handler=E4=B8=AD=E9=94=99=E8=AF=AF=E4=BF=AE?= =?UTF-8?q?=E8=AE=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/TBox/Handler/BatteryFourSnHandler.cs | 7 +++++-- Service/TBox/Handler/BatteryInfo1Handler.cs | 7 +++++-- Service/TBox/Handler/BatteryOneSnHandler.cs | 7 +++++-- Service/TBox/Handler/BatteryThreeSnHandler.cs | 7 +++++-- Service/TBox/Handler/BatteryTwoSnHandler.cs | 7 +++++-- Service/TBox/Handler/LockMsgHandler.cs | 8 ++++++-- Service/TBox/Handler/LockStatusMsgHandler.cs | 7 +++++-- Service/TBox/Handler/RestartMsgHandler.cs | 8 ++++++-- Service/TBox/Handler/SohMsgHandler.cs | 7 +++++-- Service/TBox/Handler/StatusMsgHandler.cs | 7 +++++-- Service/TBox/Handler/SubMileMsgHandler.cs | 7 +++++-- Service/TBox/Handler/TotalMileMsgHandler.cs | 7 +++++-- Service/TBox/Handler/VersionMsgHandler.cs | 7 +++++-- WinFormStarter/Form2.cs | 2 +- 14 files changed, 68 insertions(+), 27 deletions(-) diff --git a/Service/TBox/Handler/BatteryFourSnHandler.cs b/Service/TBox/Handler/BatteryFourSnHandler.cs index 5dd3a5b..37e842f 100644 --- a/Service/TBox/Handler/BatteryFourSnHandler.cs +++ b/Service/TBox/Handler/BatteryFourSnHandler.cs @@ -2,17 +2,20 @@ using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class BatteryFourSnHandler : SimpleChannelInboundHandler, IBaseHandler +public class BatteryFourSnHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryFourSnHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryFourSn msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.BatteryFourSn = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/BatteryInfo1Handler.cs b/Service/TBox/Handler/BatteryInfo1Handler.cs index 239b902..0d3130a 100644 --- a/Service/TBox/Handler/BatteryInfo1Handler.cs +++ b/Service/TBox/Handler/BatteryInfo1Handler.cs @@ -2,17 +2,20 @@ using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class BatteryInfo1Handler : SimpleChannelInboundHandler, IBaseHandler +public class BatteryInfo1Handler : SimpleChannelInboundHandler< BatteryInfo1>, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryInfo1Handler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryInfo1 msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.BatteryInfo1 = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/BatteryOneSnHandler.cs b/Service/TBox/Handler/BatteryOneSnHandler.cs index 257c60a..5db4793 100644 --- a/Service/TBox/Handler/BatteryOneSnHandler.cs +++ b/Service/TBox/Handler/BatteryOneSnHandler.cs @@ -2,17 +2,20 @@ using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class BatteryOneSnHandler : SimpleChannelInboundHandler, IBaseHandler +public class BatteryOneSnHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryOneSnHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryOneSn msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.BatteryOneSn = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/BatteryThreeSnHandler.cs b/Service/TBox/Handler/BatteryThreeSnHandler.cs index 9486252..048c6a0 100644 --- a/Service/TBox/Handler/BatteryThreeSnHandler.cs +++ b/Service/TBox/Handler/BatteryThreeSnHandler.cs @@ -2,17 +2,20 @@ using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class BatteryThreeSnHandler : SimpleChannelInboundHandler, IBaseHandler +public class BatteryThreeSnHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryThreeSnHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryThreeSn msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.BatteryThreeSn = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/BatteryTwoSnHandler.cs b/Service/TBox/Handler/BatteryTwoSnHandler.cs index 3946e7b..4a0213e 100644 --- a/Service/TBox/Handler/BatteryTwoSnHandler.cs +++ b/Service/TBox/Handler/BatteryTwoSnHandler.cs @@ -2,17 +2,20 @@ using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class BatteryTwoSnHandler : SimpleChannelInboundHandler, IBaseHandler +public class BatteryTwoSnHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryTwoSnHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryTwoSn msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.BatteryTwoSn = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/LockMsgHandler.cs b/Service/TBox/Handler/LockMsgHandler.cs index 3d89bb3..2f893f3 100644 --- a/Service/TBox/Handler/LockMsgHandler.cs +++ b/Service/TBox/Handler/LockMsgHandler.cs @@ -1,18 +1,22 @@ using DotNetty.Transport.Channels; using HybirdFrameworkCore.Autofac.Attribute; using log4net; +using Service.TBox.Msg.Host; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class LockMsgHandler : SimpleChannelInboundHandler, IBaseHandler +public class LockMsgHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(LockMsgHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, LockMsg msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.LockMsg = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/LockStatusMsgHandler.cs b/Service/TBox/Handler/LockStatusMsgHandler.cs index bccca84..80c2cea 100644 --- a/Service/TBox/Handler/LockStatusMsgHandler.cs +++ b/Service/TBox/Handler/LockStatusMsgHandler.cs @@ -2,17 +2,20 @@ using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class LockStatusMsgHandler : SimpleChannelInboundHandler, IBaseHandler +public class LockStatusMsgHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(LockStatusMsgHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, LockStatusMsg msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.LockStatusMsg = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/RestartMsgHandler.cs b/Service/TBox/Handler/RestartMsgHandler.cs index 3ceb8a7..8b8fc5e 100644 --- a/Service/TBox/Handler/RestartMsgHandler.cs +++ b/Service/TBox/Handler/RestartMsgHandler.cs @@ -1,18 +1,22 @@ using DotNetty.Transport.Channels; using HybirdFrameworkCore.Autofac.Attribute; using log4net; +using Service.TBox.Msg.Host; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class RestartMsgHandler : SimpleChannelInboundHandler, IBaseHandler +public class RestartMsgHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(RestartMsgHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, RestartMsg msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.RestartMsg = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/SohMsgHandler.cs b/Service/TBox/Handler/SohMsgHandler.cs index d7aa8b4..5fc7643 100644 --- a/Service/TBox/Handler/SohMsgHandler.cs +++ b/Service/TBox/Handler/SohMsgHandler.cs @@ -2,17 +2,20 @@ using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class SohMsgHandler : SimpleChannelInboundHandler, IBaseHandler +public class SohMsgHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(SohMsgHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, SohMsg msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.SohMsg = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/StatusMsgHandler.cs b/Service/TBox/Handler/StatusMsgHandler.cs index 3b88fea..dd79583 100644 --- a/Service/TBox/Handler/StatusMsgHandler.cs +++ b/Service/TBox/Handler/StatusMsgHandler.cs @@ -2,17 +2,20 @@ using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class StatusMsgHandler : SimpleChannelInboundHandler, IBaseHandler +public class StatusMsgHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(StatusMsgHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, StatusMsg msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.StatusMsg = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/SubMileMsgHandler.cs b/Service/TBox/Handler/SubMileMsgHandler.cs index 679cd2b..a4a5560 100644 --- a/Service/TBox/Handler/SubMileMsgHandler.cs +++ b/Service/TBox/Handler/SubMileMsgHandler.cs @@ -2,17 +2,20 @@ using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class SubMileMsgHandler : SimpleChannelInboundHandler, IBaseHandler +public class SubMileMsgHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(SubMileMsgHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, SubMileMsg msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.SubMileMsg = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/TotalMileMsgHandler.cs b/Service/TBox/Handler/TotalMileMsgHandler.cs index 6a56bcd..1d270ee 100644 --- a/Service/TBox/Handler/TotalMileMsgHandler.cs +++ b/Service/TBox/Handler/TotalMileMsgHandler.cs @@ -2,17 +2,20 @@ using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class TotalMileMsgHandler : SimpleChannelInboundHandler, IBaseHandler +public class TotalMileMsgHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(TotalMileMsgHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, TotalMileMsg msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.TotalMileMsg = msg; } } \ No newline at end of file diff --git a/Service/TBox/Handler/VersionMsgHandler.cs b/Service/TBox/Handler/VersionMsgHandler.cs index 370f172..0e8a7d4 100644 --- a/Service/TBox/Handler/VersionMsgHandler.cs +++ b/Service/TBox/Handler/VersionMsgHandler.cs @@ -2,17 +2,20 @@ using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.TBox.Msg.TBox; +using Service.TBox.Server; namespace Service.TBox.Handler; [Order(8)] [Scope("InstancePerDependency")] -public class VersionMsgHandler : SimpleChannelInboundHandler, IBaseHandler +public class VersionMsgHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(VersionMsgHandler)); - protected override void ChannelRead0(IChannelHandlerContext ctx, OtherMsg msg) + protected override void ChannelRead0(IChannelHandlerContext ctx, VersionMsg msg) { Log.Info($"receive OtherMsg={msg}"); + var server = TBoxServerMgr.Server; + if (server != null) server.VersionMsg = msg; } } \ No newline at end of file diff --git a/WinFormStarter/Form2.cs b/WinFormStarter/Form2.cs index 0d0ae6f..817263a 100644 --- a/WinFormStarter/Form2.cs +++ b/WinFormStarter/Form2.cs @@ -21,7 +21,7 @@ public partial class Form2 : Form public Form2() { InitializeComponent(); - this.txtPort.Text = "9000"; + this.txtPort.Text = "9999"; Task.Run(() => { while (true)