添加 double 类型的变量值

This commit is contained in:
2025-09-13 08:24:06 +08:00
parent c173ab08d3
commit 5a39796f0e
5 changed files with 120 additions and 0 deletions

View File

@@ -81,6 +81,30 @@ namespace DMS.Infrastructure.Services
{
if (_session != null)
{
// 取消所有订阅
if (_subscription != null)
{
try
{
// 删除服务器上的订阅
_subscription.Delete(true);
// 从会话中移除订阅
_session.RemoveSubscription(_subscription);
// 释放订阅资源
_subscription.Dispose();
_subscription = null;
}
catch (Exception ex)
{
Console.WriteLine($"取消订阅时发生错误: {ex.Message}");
// 即使取消订阅失败,也继续关闭会话
}
}
// 清理订阅节点跟踪字典
_subscribedNodes.Clear();
// 关闭会话
await _session.CloseAsync();
_session = null;
}

View File

@@ -336,6 +336,7 @@ namespace DMS.Infrastructure.Services
// 更新变量值
variable.DataValue = newValue;
variable.DisplayValue = newValue;
variable.UpdateNumericValue(); // 更新数值属性
variable.UpdatedAt = DateTime.Now;
_logger.LogDebug($"节点:{variable.OpcUaNodeId}值发生了变化:{newValue}");