From 10e7f202aad783bc9184247ffc0ba615baad88e9 Mon Sep 17 00:00:00 2001 From: "2248356998 qq.com" <2248356998@qq.com> Date: Sun, 2 Jul 2023 19:50:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8F=92=E4=BB=B6=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Wokers/Collect/CollectDeviceCore.cs | 6 +++++- .../Wokers/Plugin/DriverBase.cs | 4 ++++ .../Wokers/Plugin/PluginSingletonService.cs | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ThingsGateway.Web.Foundation/Wokers/Collect/CollectDeviceCore.cs b/src/ThingsGateway.Web.Foundation/Wokers/Collect/CollectDeviceCore.cs index 05e704299..0dedc5779 100644 --- a/src/ThingsGateway.Web.Foundation/Wokers/Collect/CollectDeviceCore.cs +++ b/src/ThingsGateway.Web.Foundation/Wokers/Collect/CollectDeviceCore.cs @@ -451,7 +451,11 @@ public class CollectDeviceCore : DisposableObject } else { - + var oper = _driver.IsConnected(); + if (oper.IsSuccess) + { + Device.DeviceStatus = DeviceStatusEnum.OnLine; + } } if (StoppingToken.Token.IsCancellationRequested) return ThreadRunReturn.Break; diff --git a/src/ThingsGateway.Web.Foundation/Wokers/Plugin/DriverBase.cs b/src/ThingsGateway.Web.Foundation/Wokers/Plugin/DriverBase.cs index 57523aebe..426998056 100644 --- a/src/ThingsGateway.Web.Foundation/Wokers/Plugin/DriverBase.cs +++ b/src/ThingsGateway.Web.Foundation/Wokers/Plugin/DriverBase.cs @@ -41,6 +41,10 @@ public abstract class DriverBase : DisposableObject TouchSocketConfig.ConfigureContainer(a => a.RegisterSingleton(logMessage)); } /// + /// 当前插件描述 + /// + public DriverPlugin DriverPlugin { get; set; } + /// /// 日志 /// protected ILogger _logger; diff --git a/src/ThingsGateway.Web.Foundation/Wokers/Plugin/PluginSingletonService.cs b/src/ThingsGateway.Web.Foundation/Wokers/Plugin/PluginSingletonService.cs index feff555f3..155cc187d 100644 --- a/src/ThingsGateway.Web.Foundation/Wokers/Plugin/PluginSingletonService.cs +++ b/src/ThingsGateway.Web.Foundation/Wokers/Plugin/PluginSingletonService.cs @@ -77,6 +77,7 @@ public class PluginSingletonService : ISingleton { object driver = Activator.CreateInstance(DriverPluginDict[plugin.Id], _scopeFactory); DeviceOnDriverPluginDict[plugin.Id].AddRangeIfNotContains(devId); + ((DriverBase)driver).DriverPlugin = plugin; return driver; } Assembly assembly = null; @@ -114,6 +115,7 @@ public class PluginSingletonService : ISingleton _logger?.LogInformation($"加载插件 {driverFilePath}-{plugin.AssembleName} 成功"); DriverPluginDict.TryAdd(plugin.Id, driverBase); DeviceOnDriverPluginDict.TryAdd(plugin.Id, new() { devId }); + ((DriverBase)driver).DriverPlugin = plugin; return driver; } else @@ -129,6 +131,7 @@ public class PluginSingletonService : ISingleton _logger?.LogInformation($"加载插件 {driverFilePath}-{plugin.AssembleName} 成功"); DriverPluginDict.TryAdd(plugin.Id, upLoadBase); DeviceOnDriverPluginDict.TryAdd(plugin.Id, new() { devId }); + ((DriverBase)driver).DriverPlugin = plugin; return driver; } else