fix: opcua插件订阅检查失效

This commit is contained in:
Diego
2025-06-19 10:42:54 +08:00
parent 52b3097f04
commit 59241b8faa
3 changed files with 12 additions and 7 deletions

View File

@@ -1,8 +1,8 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<PluginVersion>10.8.7</PluginVersion> <PluginVersion>10.8.8</PluginVersion>
<ProPluginVersion>10.8.7</ProPluginVersion> <ProPluginVersion>10.8.8</ProPluginVersion>
<AuthenticationVersion>2.8.0</AuthenticationVersion> <AuthenticationVersion>2.8.0</AuthenticationVersion>
<SourceGeneratorVersion>10.8.2</SourceGeneratorVersion> <SourceGeneratorVersion>10.8.2</SourceGeneratorVersion>
<NET8Version>8.0.17</NET8Version> <NET8Version>8.0.17</NET8Version>

View File

@@ -108,17 +108,23 @@ public class OpcUaMaster : CollectBase
var check = ScheduledTaskHelper.GetTask("3000", CheckAsync, null, LogMessage, cancellationToken); var check = ScheduledTaskHelper.GetTask("3000", CheckAsync, null, LogMessage, cancellationToken);
list.Add(check); list.Add(check);
var checkConnec = ScheduledTaskHelper.GetTask("3000", CheckConnectAsync, null, LogMessage, cancellationToken); var checkConnec = ScheduledTaskHelper.GetTask("10000", CheckConnectAsync, null, LogMessage, cancellationToken);
list.Add(checkConnec); list.Add(checkConnec);
return list; return list;
} }
protected override async Task ProtectedStartAsync(CancellationToken cancellationToken)
{
await CheckConnectAsync(null, cancellationToken).ConfigureAwait(false);
await base.ProtectedStartAsync(cancellationToken).ConfigureAwait(false);
}
private async Task CheckConnectAsync(object? state, CancellationToken cancellationToken) private async Task CheckConnectAsync(object? state, CancellationToken cancellationToken)
{ {
if (_plc.Session == null) if (_plc.Session == null)
{ {
try try
{ {
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
if (_plc.Session == null) if (_plc.Session == null)
await _plc.ConnectAsync(cancellationToken).ConfigureAwait(false); await _plc.ConnectAsync(cancellationToken).ConfigureAwait(false);
} }
@@ -129,13 +135,12 @@ public class OpcUaMaster : CollectBase
connectFirstFailLoged = true; connectFirstFailLoged = true;
CurrentDevice.SetDeviceStatus(TimerX.Now, true, ex.Message); CurrentDevice.SetDeviceStatus(TimerX.Now, true, ex.Message);
await Task.Delay(10000, cancellationToken).ConfigureAwait(false);
} }
} }
} }
private async Task CheckAsync(object? state, CancellationToken cancellationToken) private async Task CheckAsync(object? state, CancellationToken cancellationToken)
{ {
if (_plc.Session == null) if (_plc.Session != null)
{ {
if (_driverProperties.ActiveSubscribe) if (_driverProperties.ActiveSubscribe)
{ {

View File

@@ -1,6 +1,6 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<Version>10.8.7</Version> <Version>10.8.8</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>