mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-20 10:50:48 +08:00
10.11.57
This commit is contained in:
@@ -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.1" />
|
||||
<PackageReference Include="BootstrapBlazor" Version="9.10.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<PluginVersion>10.11.56</PluginVersion>
|
||||
<ProPluginVersion>10.11.56</ProPluginVersion>
|
||||
<DefaultVersion>10.11.56</DefaultVersion>
|
||||
<PluginVersion>10.11.57</PluginVersion>
|
||||
<ProPluginVersion>10.11.57</ProPluginVersion>
|
||||
<DefaultVersion>10.11.57</DefaultVersion>
|
||||
<AuthenticationVersion>10.11.5</AuthenticationVersion>
|
||||
<SourceGeneratorVersion>10.11.4</SourceGeneratorVersion>
|
||||
<NET8Version>8.0.20</NET8Version>
|
||||
|
@@ -1,53 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人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
|
||||
}
|
@@ -37,6 +37,8 @@ public abstract class DriverBase : AsyncDisposableObject, IDriver
|
||||
|
||||
#region 属性
|
||||
|
||||
public virtual bool RefreshRuntimeAlways { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 调试UI Type,如果不存在,返回null
|
||||
/// </summary>
|
||||
|
@@ -64,26 +64,36 @@ public static class DynamicModelExtension
|
||||
|
||||
if (GlobalData.IdDevices.TryGetValue(businessId, out var deviceRuntime))
|
||||
{
|
||||
if (deviceRuntime.Driver is BusinessBase businessBase && businessBase.DriverProperties is IBusinessPropertyAllVariableBase property)
|
||||
if (deviceRuntime.Driver is BusinessBase businessBase)
|
||||
{
|
||||
if (property.IsAllVariable)
|
||||
if (businessBase.DriverProperties is IBusinessPropertyAllVariableBase property && property.IsAllVariable)
|
||||
{
|
||||
// 检查是否存在对应的业务设备Id
|
||||
if (variableRuntime.VariablePropertys?.ContainsKey(businessId) == true)
|
||||
{
|
||||
variableRuntime.VariablePropertys[businessId].TryGetValue(propertyName, out var value);
|
||||
return value; // 返回属性值
|
||||
}
|
||||
else
|
||||
{
|
||||
return ThingsGatewayStringConverter.Default.Serialize(null, businessBase.VariablePropertys.GetValue(propertyName, false));
|
||||
}
|
||||
return GetVariableProperty(variableRuntime, businessId, propertyName, businessBase);
|
||||
}
|
||||
else if (businessBase.RefreshRuntimeAlways)
|
||||
{
|
||||
return GetVariableProperty(variableRuntime, businessId, propertyName, businessBase);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null; // 未找到对应的业务设备Id,返回null
|
||||
|
||||
static string? GetVariableProperty(VariableRuntime variableRuntime, long businessId, string propertyName, BusinessBase businessBase)
|
||||
{
|
||||
// 检查是否存在对应的业务设备Id
|
||||
if (variableRuntime.VariablePropertys?.ContainsKey(businessId) == true)
|
||||
{
|
||||
variableRuntime.VariablePropertys[businessId].TryGetValue(propertyName, out var value);
|
||||
return value; // 返回属性值
|
||||
}
|
||||
else
|
||||
{
|
||||
return ThingsGatewayStringConverter.Default.Serialize(null, businessBase.VariablePropertys.GetValue(propertyName, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -43,6 +43,7 @@ namespace ThingsGateway.Gateway.Application
|
||||
string PluginDirectory { get; }
|
||||
Dictionary<long, VariableRuntime> IdVariableRuntimes { get; }
|
||||
IDeviceThreadManage DeviceThreadManage { get; }
|
||||
bool RefreshRuntimeAlways { get; set; }
|
||||
|
||||
bool IsConnected();
|
||||
void PauseThread(bool pause);
|
||||
|
@@ -125,9 +125,14 @@ public static class GlobalData
|
||||
{
|
||||
if (GlobalData.IdDevices.TryGetValue(businessDeviceId, out var deviceRuntime))
|
||||
{
|
||||
if (deviceRuntime.Driver?.DriverProperties is IBusinessPropertyAllVariableBase property)
|
||||
|
||||
if (deviceRuntime.Driver is BusinessBase businessBase)
|
||||
{
|
||||
if (property.IsAllVariable)
|
||||
if (businessBase.DriverProperties is IBusinessPropertyAllVariableBase property && property.IsAllVariable)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (businessBase.RefreshRuntimeAlways)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -141,7 +146,46 @@ public static class GlobalData
|
||||
|
||||
return a.VariablePropertys?.ContainsKey(businessDeviceId) == true;
|
||||
}
|
||||
public static DeviceRuntime[] GetAllVariableBusinessDeviceRuntime()
|
||||
{
|
||||
var channelDevice = GlobalData.IdDevices.Where(a =>
|
||||
{
|
||||
if (a.Value.Driver is BusinessBase businessBase)
|
||||
{
|
||||
if (businessBase.DriverProperties is IBusinessPropertyAllVariableBase property && property.IsAllVariable)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (businessBase.RefreshRuntimeAlways)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}).Select(a => a.Value).ToArray();
|
||||
return channelDevice;
|
||||
}
|
||||
public static IDriver[] GetAllVariableBusinessDriver()
|
||||
{
|
||||
var channelDevice = GlobalData.IdDevices.Where(a =>
|
||||
{
|
||||
if (a.Value.Driver is BusinessBase businessBase)
|
||||
{
|
||||
if (businessBase.DriverProperties is IBusinessPropertyAllVariableBase property && property.IsAllVariable)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (businessBase.RefreshRuntimeAlways)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}).Select(a => a.Value.Driver).ToArray();
|
||||
return channelDevice;
|
||||
}
|
||||
/// <summary>
|
||||
/// 只读的通道字典,提供对通道的只读访问
|
||||
/// </summary>
|
||||
|
@@ -240,6 +240,11 @@ internal static class RuntimeServiceHelper
|
||||
if (group.Key != null)
|
||||
await group.Key.RestartDeviceAsync(group.Value, false).ConfigureAwait(false);
|
||||
}
|
||||
foreach (var group in GlobalData.GetAllVariableBusinessDeviceRuntime().Where(a => a.Driver?.DeviceThreadManage != null).GroupBy(a => a.Driver.DeviceThreadManage))
|
||||
{
|
||||
if (group.Key != null)
|
||||
await group.Key.RestartDeviceAsync(group.ToArray(), false).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
public static async Task RemoveDeviceAsync(HashSet<long> newDeciceIds)
|
||||
{
|
||||
@@ -255,11 +260,18 @@ internal static class RuntimeServiceHelper
|
||||
if (group.Key != null)
|
||||
await group.Key.RemoveDeviceAsync(group.Value.Select(a => a.Id).ToArray()).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
foreach (var group in GlobalData.GetAllVariableBusinessDeviceRuntime().Where(a => a.Driver?.DeviceThreadManage != null).GroupBy(a => a.Driver.DeviceThreadManage))
|
||||
{
|
||||
if (group.Key != null)
|
||||
await group.Key.RestartDeviceAsync(group.ToArray(), false).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static async Task ChangedDriverAsync(ILogger logger)
|
||||
{
|
||||
var channelDevice = GlobalData.IdDevices.Where(a => a.Value.Driver?.DriverProperties is IBusinessPropertyAllVariableBase property && property.IsAllVariable).Select(a => a.Value).ToArray();
|
||||
var channelDevice = GlobalData.GetAllVariableBusinessDeviceRuntime();
|
||||
|
||||
await channelDevice.ParallelForEachAsync(async (item, token) =>
|
||||
{
|
||||
@@ -275,7 +287,7 @@ internal static class RuntimeServiceHelper
|
||||
}
|
||||
public static async Task ChangedDriverAsync(ConcurrentHashSet<IDriver> changedDriver, ILogger logger)
|
||||
{
|
||||
var drivers = GlobalData.IdDevices.Where(a => a.Value.Driver?.DriverProperties is IBusinessPropertyAllVariableBase property && property.IsAllVariable).Select(a => a.Value.Driver);
|
||||
var drivers = GlobalData.GetAllVariableBusinessDriver();
|
||||
|
||||
var changedDrivers = drivers.Concat(changedDriver).Where(a => a.DisposedValue == false).Distinct().ToArray();
|
||||
await changedDrivers.ParallelForEachAsync(async (driver, token) =>
|
||||
|
@@ -30,7 +30,7 @@ public partial class SqlHistoryAlarm : BusinessBaseWithCacheAlarm
|
||||
{
|
||||
internal readonly SqlHistoryAlarmProperty _driverPropertys = new();
|
||||
private readonly SqlHistoryAlarmVariableProperty _variablePropertys = new();
|
||||
|
||||
public override bool RefreshRuntimeAlways { get; set; } = true;
|
||||
/// <inheritdoc/>
|
||||
public override Type DriverUIType
|
||||
{
|
||||
|
Reference in New Issue
Block a user