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