更新依赖

This commit is contained in:
Diego
2025-09-11 18:12:40 +08:00
parent 6a18fc3e06
commit 82eedee50a
6 changed files with 74 additions and 19 deletions

View File

@@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="BootstrapBlazor.TableExport" Version="9.2.6" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
<PackageReference Include="BootstrapBlazor" Version="9.10.0" />
<PackageReference Include="BootstrapBlazor" Version="9.10.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -32,7 +32,7 @@
<PackageReference Include="CsvHelper" Version="33.1.0" />
<PackageReference Include="TDengine.Connector" Version="3.1.9" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.9.1" />
<PackageReference Include="Oscar.Data.SqlClient" Version="4.2.23" />
<PackageReference Include="Oscar.Data.SqlClient" Version="4.2.25" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.1.1" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />

View File

@@ -12,6 +12,7 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Concurrent;
using ThingsGateway.Common.Extension;
@@ -55,7 +56,15 @@ public abstract partial class CollectBase : DriverBase
/// 特殊方法
/// </summary>
public List<DriverMethodInfo>? DriverMethodInfos { get; private set; }
protected virtual bool IsRuntimeSourceValid(VariableRuntime a)
{
//筛选特殊变量地址
//1、DeviceStatus
return !a.RegisterAddress.Equals(nameof(DeviceRuntime.DeviceStatus), StringComparison.OrdinalIgnoreCase) &&
!a.RegisterAddress.Equals("Script", StringComparison.OrdinalIgnoreCase) &&
!a.RegisterAddress.Equals("ScriptRead", StringComparison.OrdinalIgnoreCase)
;
}
public override async Task AfterVariablesChangedAsync(CancellationToken cancellationToken)
{
LogMessage?.LogInformation("Refresh variable");
@@ -84,21 +93,13 @@ public abstract partial class CollectBase : DriverBase
&& string.IsNullOrEmpty(it.OtherMethod)
&& !string.IsNullOrEmpty(it.RegisterAddress));
//筛选特殊变量地址
//1、DeviceStatus
Func<VariableRuntime, bool> source = (a =>
{
return !a.RegisterAddress.Equals(nameof(DeviceRuntime.DeviceStatus), StringComparison.OrdinalIgnoreCase) &&
!a.RegisterAddress.Equals("Script", StringComparison.OrdinalIgnoreCase) &&
!a.RegisterAddress.Equals("ScriptRead", StringComparison.OrdinalIgnoreCase)
;
});
var now = DateTime.Now;
#pragma warning disable CA1851
try
{
currentDevice.VariableScriptReads = tags.Where(a => !source(a)).Select(a =>
currentDevice.VariableScriptReads = tags.Where(a => !IsRuntimeSourceValid(a)).Select(a =>
{
var data = new VariableScriptRead();
data.VariableRuntime = a;
@@ -111,9 +112,9 @@ public abstract partial class CollectBase : DriverBase
// 如果出现异常,记录日志并初始化 VariableSourceReads 属性为新实例
currentDevice.VariableScriptReads = new();
LogMessage?.LogWarning(ex, string.Format(AppResource.VariablePackError, ex.Message));
tags.Where(a => !source(a)).ForEach(a => a.SetValue(null, now, isOnline: false));
tags.Where(a => !IsRuntimeSourceValid(a)).ForEach(a => a.SetValue(null, now, isOnline: false));
}
var variableReads = tags.Where(source).ToList();
var variableReads = tags.Where(IsRuntimeSourceValid).ToList();
try
{
// 将打包后的结果存储在当前设备的 VariableSourceReads 属性中
@@ -482,6 +483,7 @@ public abstract partial class CollectBase : DriverBase
protected virtual Task TestOnline(object? state, CancellationToken cancellationToken)
{
CurrentDevice.SetDeviceStatus(TimerX.Now, false, null);
return Task.CompletedTask;
}

View File

@@ -0,0 +1,53 @@
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://thingsgateway.cn/
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Gateway.Application;
/// <summary>
/// 插件配置项
/// <br></br>
/// 使用<see cref="DynamicPropertyAttribute"/> 标识所需的配置属性
/// </summary>
public class MempryDevicePropertyBase : CollectPropertyBase
{
}
/// <summary>
/// <para></para>
/// 采集插件继承实现不同PLC通讯
/// <para></para>
/// </summary>
public class MempryDevice : CollectBase
{
private MempryDevicePropertyBase _driverPropertyBase = new MempryDevicePropertyBase();
public override CollectPropertyBase CollectProperties => _driverPropertyBase;
#if !Management
/// <summary>
/// 是否连接成功
/// </summary>
public override bool IsConnected()
{
return true;
}
protected override Task<List<VariableSourceRead>> ProtectedLoadSourceReadAsync(List<VariableRuntime> deviceVariables)
{
return Task.FromResult(new List<VariableSourceRead>());
}
protected override bool IsRuntimeSourceValid(VariableRuntime a)
{
return false;
}
#endif
}

View File

@@ -409,7 +409,7 @@ internal sealed class DeviceThreadManage : IAsyncDisposable, IDeviceThreadManage
// 查找具有指定设备ID的驱动程序对象
if (Drivers.TryRemove(deviceId, out var driver))
{
driver.CurrentDevice.SetDeviceStatus(now, false, "Communication connection has been removed");
driver.CurrentDevice.SetDeviceStatus(now, true, "Communication connection has been removed");
if (IsCollectChannel == true)
{
foreach (var a in driver.IdVariableRuntimes)

View File

@@ -42,12 +42,12 @@
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
<PackageReference Include="HslCommunication" Version="12.3.3" />
<PackageReference Include="HslCommunication" Version="12.5.0" />
<PackageReference Include="NModbus" Version="3.0.81" />
<PackageReference Include="NModbus.Serial" Version="3.0.81" />
<PackageReference Include="S7netplus" Version="0.20.0" />
<PackageReference Include="ThingsGateway.Foundation.Modbus" Version="10.11.33" />
<PackageReference Include="ThingsGateway.Foundation.SiemensS7" Version="10.11.33" />
<PackageReference Include="ThingsGateway.Foundation.Modbus" Version="$(DefaultVersion)" />
<PackageReference Include="ThingsGateway.Foundation.SiemensS7" Version="$(DefaultVersion)" />
<PackageReference Include="TouchSocket.Modbus" Version="4.0.0-beta.25" />
</ItemGroup>