diff --git a/src/Admin/ThingsGateway.NewLife.X/Common/TimeTick.cs b/src/Admin/ThingsGateway.NewLife.X/Common/TimeTick.cs index 8d10a5da7..037efc4b2 100644 --- a/src/Admin/ThingsGateway.NewLife.X/Common/TimeTick.cs +++ b/src/Admin/ThingsGateway.NewLife.X/Common/TimeTick.cs @@ -32,7 +32,7 @@ public class TimeTick /// /// 上次触发时间 /// - public DateTime LastTime { get; private set; } = DateTime.Now; + public DateTime LastTime { get; private set; } = DateTime.UtcNow; /// /// 是否触发时间刻度 @@ -62,7 +62,7 @@ public class TimeTick return result; } - public DateTime GetNextTime(DateTime currentTime, bool setLastTime = true) + public DateTime GetNextTime(DateTime currentTime, bool setLastTime = false) { // 在没有 Cron 表达式的情况下,使用固定间隔 if (cron == null) @@ -86,7 +86,7 @@ public class TimeTick } - public DateTime GetNextTime(bool setLastTime = true) => GetNextTime(DateTime.UtcNow, setLastTime); + public DateTime GetNextTime(bool setLastTime = false) => GetNextTime(DateTime.UtcNow, setLastTime); /// /// 是否到达设置的时间间隔 diff --git a/src/Admin/ThingsGateway.Razor/ThingsGateway.Razor.csproj b/src/Admin/ThingsGateway.Razor/ThingsGateway.Razor.csproj index 71e0f2d9c..daf284cba 100644 --- a/src/Admin/ThingsGateway.Razor/ThingsGateway.Razor.csproj +++ b/src/Admin/ThingsGateway.Razor/ThingsGateway.Razor.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 61080da01..616903b75 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,8 +1,8 @@ - 10.5.6 - 10.5.6 + 10.5.7 + 10.5.7 2.1.7 diff --git a/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalAlarmModel.cs b/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalAlarmModel.cs index a3f05af5f..d8a73e9f5 100644 --- a/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalAlarmModel.cs +++ b/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalAlarmModel.cs @@ -87,12 +87,12 @@ public abstract class BusinessBaseWithCacheIntervalAlarmModel { - if (a.Value.DeviceStatus == DeviceStatusEnum.OnLine) + if (a.Value.DeviceStatus == DeviceStatusEnum.OnLine && _businessPropertyWithCacheInterval.BusinessUpdateEnum != BusinessUpdateEnum.Interval) DeviceStatusChange(a.Value, a.Value.Adapt()); }); IdVariableRuntimes.ForEach(a => { - if (a.Value.IsOnline) + if (a.Value.IsOnline && _businessPropertyWithCacheInterval.BusinessUpdateEnum != BusinessUpdateEnum.Interval) VariableValueChange(a.Value, a.Value.Adapt()); }); } diff --git a/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalDeviceModel.cs b/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalDeviceModel.cs index ce9f76b36..d0dd70670 100644 --- a/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalDeviceModel.cs +++ b/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalDeviceModel.cs @@ -85,12 +85,12 @@ public abstract class BusinessBaseWithCacheIntervalDeviceModel { - if (a.Value.DeviceStatus == DeviceStatusEnum.OnLine) + if (a.Value.DeviceStatus == DeviceStatusEnum.OnLine && _businessPropertyWithCacheInterval.BusinessUpdateEnum != BusinessUpdateEnum.Interval) DeviceStatusChange(a.Value, a.Value.Adapt()); }); IdVariableRuntimes.ForEach(a => { - if (a.Value.IsOnline) + if (a.Value.IsOnline && _businessPropertyWithCacheInterval.BusinessUpdateEnum != BusinessUpdateEnum.Interval) VariableValueChange(a.Value, a.Value.Adapt()); }); } diff --git a/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalVariableModel.cs b/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalVariableModel.cs index 0ec229f60..41c316468 100644 --- a/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalVariableModel.cs +++ b/src/Gateway/ThingsGateway.Gateway.Application/Driver/Business/Cache/Interval/BusinessBaseWithCacheIntervalVariableModel.cs @@ -73,7 +73,7 @@ public abstract class BusinessBaseWithCacheIntervalVariableModel : BusinessBa // 触发一次变量值变化事件 IdVariableRuntimes.ForEach(a => { - if (a.Value.IsOnline) + if (a.Value.IsOnline && _businessPropertyWithCacheInterval.BusinessUpdateEnum != BusinessUpdateEnum.Interval) VariableValueChange(a.Value, a.Value.Adapt()); }); } diff --git a/src/Gateway/ThingsGateway.Gateway.Razor/Pages/GatewayMonitorPage/ChannelDeviceTree.razor.cs b/src/Gateway/ThingsGateway.Gateway.Razor/Pages/GatewayMonitorPage/ChannelDeviceTree.razor.cs index 4a8a159b4..a4002e82b 100644 --- a/src/Gateway/ThingsGateway.Gateway.Razor/Pages/GatewayMonitorPage/ChannelDeviceTree.razor.cs +++ b/src/Gateway/ThingsGateway.Gateway.Razor/Pages/GatewayMonitorPage/ChannelDeviceTree.razor.cs @@ -1299,7 +1299,7 @@ EventCallback.Factory.Create(this, async e => try { if (Disposed) return; - await Task.Delay(2000); + await Task.Delay(1000); await OnClickSearch(SearchText); Value = GetValue(Value); diff --git a/src/Plugin/ThingsGateway.Foundation.OpcUa/OpcUaMaster/OpcUaMaster.cs b/src/Plugin/ThingsGateway.Foundation.OpcUa/OpcUaMaster/OpcUaMaster.cs index 42ce24434..3558eaeed 100644 --- a/src/Plugin/ThingsGateway.Foundation.OpcUa/OpcUaMaster/OpcUaMaster.cs +++ b/src/Plugin/ThingsGateway.Foundation.OpcUa/OpcUaMaster/OpcUaMaster.cs @@ -251,7 +251,7 @@ public class OpcUaMaster : IDisposable DisplayName = subscriptionName }; List monitoredItems = new(); - var variableNodes = loadType ? await ReadNodesAsync(items, cancellationToken).ConfigureAwait(false) : null; + var variableNodes = loadType ? await ReadNodesAsync(items, false, cancellationToken).ConfigureAwait(false) : null; for (int i = 0; i < items.Length; i++) { try @@ -743,7 +743,7 @@ public class OpcUaMaster : IDisposable NodeId = new NodeId(item.Key), AttributeId = Attributes.Value, }; - var variableNode = await ReadNodeAsync(item.Key, false, cancellationToken).ConfigureAwait(false); + var variableNode = await ReadNodeAsync(item.Key, false, false, cancellationToken).ConfigureAwait(false); var dataValue = JsonUtils.Decode( m_session.MessageContext, variableNode.DataType, @@ -793,9 +793,10 @@ public class OpcUaMaster : IDisposable { if (m_session != null) { - var variableNode = ReadNode(monitoreditem.StartNodeId.ToString(), false); foreach (var value in monitoreditem.DequeueValues()) { + var variableNode = ReadNode(monitoreditem.StartNodeId.ToString(), false, StatusCode.IsGood(value.StatusCode)); + if (value.Value != null) { var data = JsonUtils.Encode(m_session.MessageContext, TypeInfo.GetBuiltInType(variableNode.DataType, m_session.SystemContext.TypeTable), value.Value); @@ -974,7 +975,7 @@ public class OpcUaMaster : IDisposable List<(string, DataValue, JToken)> jTokens = new(); for (int i = 0; i < results.Count; i++) { - var variableNode = await ReadNodeAsync(nodeIds[i].ToString(), false, cancellationToken).ConfigureAwait(false); + var variableNode = await ReadNodeAsync(nodeIds[i].ToString(), false, StatusCode.IsGood(results[i].StatusCode), cancellationToken).ConfigureAwait(false); var type = TypeInfo.GetBuiltInType(variableNode.DataType, m_session.SystemContext.TypeTable); var jToken = JsonUtils.Encode(m_session.MessageContext, type, results[i].Value); jTokens.Add((variableNode.NodeId.ToString(), results[i], jToken)); @@ -985,7 +986,7 @@ public class OpcUaMaster : IDisposable /// /// 从服务器或缓存读取节点 /// - private VariableNode ReadNode(string nodeIdStr, bool isOnlyServer = true) + private VariableNode ReadNode(string nodeIdStr, bool isOnlyServer = true, bool cache = true) { if (!isOnlyServer) { @@ -1025,14 +1026,15 @@ public class OpcUaMaster : IDisposable VariableNode variableNode = GetVariableNodes(itemsToRead, values, diagnosticInfos, responseHeader).FirstOrDefault(); - _variableDicts.AddOrUpdate(nodeIdStr, a => variableNode, (a, b) => variableNode); + if (cache) + _variableDicts.AddOrUpdate(nodeIdStr, a => variableNode, (a, b) => variableNode); return variableNode; } /// /// 从服务器或缓存读取节点 /// - private async Task ReadNodeAsync(string nodeIdStr, bool isOnlyServer = true, CancellationToken cancellationToken = default) + private async Task ReadNodeAsync(string nodeIdStr, bool isOnlyServer = true, bool cache = true, CancellationToken cancellationToken = default) { if (!isOnlyServer) { @@ -1073,7 +1075,9 @@ public class OpcUaMaster : IDisposable if (OpcUaProperty.LoadType && variableNode.DataType != NodeId.Null && TypeInfo.GetBuiltInType(variableNode.DataType, m_session.SystemContext.TypeTable) == BuiltInType.ExtensionObject) await typeSystem.LoadType(variableNode.DataType, ct: cancellationToken).ConfigureAwait(false); - _variableDicts.AddOrUpdate(nodeIdStr, a => variableNode, (a, b) => variableNode); + + if (cache) + _variableDicts.AddOrUpdate(nodeIdStr, a => variableNode, (a, b) => variableNode); return variableNode; } @@ -1127,7 +1131,7 @@ public class OpcUaMaster : IDisposable /// /// 从服务器读取节点 /// - private async Task> ReadNodesAsync(string[] nodeIdStrs, CancellationToken cancellationToken = default) + private async Task> ReadNodesAsync(string[] nodeIdStrs, bool cache = false, CancellationToken cancellationToken = default) { List result = new(nodeIdStrs.Length); foreach (var items in nodeIdStrs.ChunkBetter(OpcUaProperty.GroupSize)) @@ -1171,7 +1175,8 @@ public class OpcUaMaster : IDisposable } else { - _variableDicts.AddOrUpdate(nodeIdStrs[i], a => node, (a, b) => node); + if (cache) + _variableDicts.AddOrUpdate(nodeIdStrs[i], a => node, (a, b) => node); if (node.DataType != NodeId.Null && TypeInfo.GetBuiltInType(node.DataType, m_session.SystemContext.TypeTable) == BuiltInType.ExtensionObject) { await typeSystem.LoadType(node.DataType, ct: cancellationToken).ConfigureAwait(false); diff --git a/src/Upgrade/ThingsGateway.Upgrade/Services/FileHostService.cs b/src/Upgrade/ThingsGateway.Upgrade/Services/FileHostService.cs index cdbb8cb04..a0f9ff436 100644 --- a/src/Upgrade/ThingsGateway.Upgrade/Services/FileHostService.cs +++ b/src/Upgrade/ThingsGateway.Upgrade/Services/FileHostService.cs @@ -162,7 +162,7 @@ public class FileHostService : BackgroundService, IFileHostService _log.Exception(ex); try { - await TcpDmtpService.StopAsync().ConfigureAwait(false); + await TcpDmtpService.StopAsync(default).ConfigureAwait(false); } catch { diff --git a/src/Version.props b/src/Version.props index 0c0931338..3a22ad198 100644 --- a/src/Version.props +++ b/src/Version.props @@ -1,6 +1,6 @@ - 10.5.6 + 10.5.7