mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-27 05:37:10 +08:00
OPCUA插件afterStop方法重写时需执行父类方法
This commit is contained in:
@@ -43,14 +43,16 @@ public abstract class CollectBase : DriverBase
|
||||
|
||||
public override async Task AfterStopAsync()
|
||||
{
|
||||
await base.AfterStopAsync();
|
||||
//去除全局设备变量
|
||||
lock (_globalDeviceData.CollectDevices)
|
||||
{
|
||||
_globalDeviceData.CollectDevices.RemoveWhere(it => it.Id == DeviceId);
|
||||
}
|
||||
await base.AfterStopAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void Init(DeviceRunTime device)
|
||||
{
|
||||
base.Init(device);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ThingsGateway.Gateway.Application;
|
||||
/// </summary>
|
||||
public class CollectDeviceWorker : DeviceWorker
|
||||
{
|
||||
|
||||
private GlobalDeviceData _globalDeviceData;
|
||||
public CollectDeviceWorker(IServiceScopeFactory serviceScopeFactory, IHostApplicationLifetime appLifetime) : base(serviceScopeFactory, appLifetime)
|
||||
{
|
||||
_logger = _serviceScope.ServiceProvider.GetService<ILoggerFactory>().CreateLogger("南向设备服务");
|
||||
@@ -49,6 +49,10 @@ public class CollectDeviceWorker : DeviceWorker
|
||||
await StopOtherHostService();
|
||||
//停止全部采集线程
|
||||
await RemoveAllDeviceThreadAsync();
|
||||
|
||||
//清空内存列表
|
||||
_globalDeviceData.CollectDevices.Clear();
|
||||
|
||||
//创建全部采集线程
|
||||
await CreatAllDeviceThreadsAsync();
|
||||
//开始其他后台服务
|
||||
@@ -197,6 +201,7 @@ public class CollectDeviceWorker : DeviceWorker
|
||||
{
|
||||
await _easyLock?.WaitAsync();
|
||||
_driverPluginService = _serviceScope.ServiceProvider.GetService<DriverPluginService>();
|
||||
_globalDeviceData = _serviceScope.ServiceProvider.GetService<GlobalDeviceData>();
|
||||
//重启采集线程,会启动其他后台服务
|
||||
await RestartDeviceThreadAsync();
|
||||
await WhileExecuteAsync(stoppingToken);
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class DeviceWorker : BackgroundService
|
||||
/// </summary>
|
||||
public List<DriverBase> DriverBases => _deviceThreads
|
||||
.Where(a => a.DriverBases.Any(b => b.CurrentDevice != null))
|
||||
.SelectMany(a => a.DriverBases).ToList();
|
||||
.SelectMany(a => a.DriverBases).OrderByDescending(a => a.CurrentDevice.DeviceStatus).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// 设备子线程列表
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\admin\ThingsGateway.Admin.Blazor\ThingsGateway.Admin.Blazor.csproj" />
|
||||
<ProjectReference Include="..\..\admin\ThingsGateway.Components\ThingsGateway.Components.csproj" />
|
||||
<ProjectReference Include="..\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
||||
@@ -48,7 +48,7 @@ public class OPCUAClient : CollectBase
|
||||
public override Task AfterStopAsync()
|
||||
{
|
||||
_plc?.Disconnect();
|
||||
return Task.CompletedTask;
|
||||
return base.AfterStopAsync();
|
||||
}
|
||||
protected override string GetAddressDescription()
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
||||
Reference in New Issue
Block a user