From dc7dd818a31e547547947416dff9dfaab6f76bd1 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期三, 25 九月 2024 09:45:04 +0800
Subject: [PATCH] 修改问题

---
 Admin.NET/WCS.Application/Hub/PlcHub.cs |   36 +++++++++++++++++++++++++++++++++---
 1 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/Admin.NET/WCS.Application/Hub/PlcHub.cs b/Admin.NET/WCS.Application/Hub/PlcHub.cs
index ba57a75..cf77858 100644
--- a/Admin.NET/WCS.Application/Hub/PlcHub.cs
+++ b/Admin.NET/WCS.Application/Hub/PlcHub.cs
@@ -10,10 +10,11 @@
 public class PlcHub : Hub<IPlcHub>
 {
     private readonly IHubContext<PlcHub, IPlcHub> _plcHubContext;
-
-    public PlcHub(IHubContext<PlcHub, IPlcHub> plcHubContext)
+    private readonly SysConfigService _sysConfigService;
+    public PlcHub(IHubContext<PlcHub, IPlcHub> plcHubContext, SysConfigService sysConfigService)
     {
         _plcHubContext = plcHubContext;
+        _sysConfigService = sysConfigService;
     }
     /// <summary>
     /// 涓嬪彂PLC杩炴帴鐘舵��
@@ -42,14 +43,39 @@
     {
         //杩愯鐘舵��
         if (context.BoRunningState.HasValue)
+        {
             PLCTaskAction.boRunningState = context.BoRunningState.Value;
+            if (context.BoRunningState.Value)
+                PLCTaskAction.Init();
+            else
+                PLCTaskAction.Stop();
+            await _sysConfigService.UpdateConfigValue("sys_RunningState", context.BoRunningState.Value);
+        }
         //鑴辨満妯″紡
         if (context.BoOffline.HasValue)
+        {
             PLCTaskAction.boOffline = context.BoOffline.Value;
+            await _sysConfigService.UpdateConfigValue("sys_Offline", context.BoOffline.Value);
+        }
         //鑷埛鏂�
         if (context.BoRefresh.HasValue)
+        {
             PLCTaskAction.boRefresh = context.BoRefresh.Value;
-        await _plcHubContext.Clients.All.UpdateService(context);
+            await _sysConfigService.UpdateConfigValue("sys_Refresh", context.BoRefresh.Value);
+        }
+        //婕旂ず妯″紡
+        if (context.BoDemo.HasValue)
+        {
+            PLCTaskAction.boDemo = context.BoDemo.Value;
+            await _sysConfigService.UpdateConfigValue("sys_demo", context.BoDemo.Value);
+        }
+        //婊氱瓛鍙嶈浆
+        if (context.BoDrumReversal.HasValue)
+        {
+            PLCTaskAction.boDrumReversal = context.BoDrumReversal.Value;
+            await _sysConfigService.UpdateConfigValue("sys_DrumReversal", context.BoDrumReversal.Value);
+        }
+        await _plcHubContext.Clients.All.UpdateService(new PLCServiceModel() { BoRunningState = PLCTaskAction.boRunningState, BoRefresh = PLCTaskAction.boRefresh, BoOffline = PLCTaskAction.boOffline, BoDemo = PLCTaskAction.boDemo, BoDrumReversal = PLCTaskAction.boDrumReversal });
     }
 }
 public class PLCServiceModel
@@ -61,4 +87,8 @@
 
 
     public bool? BoRefresh { get; set; }
+
+    public bool? BoDemo { get; set; }
+
+    public bool? BoDrumReversal { get; set; }
 }
\ No newline at end of file

--
Gitblit v1.8.0