mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-22 03:24:29 +08:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6510c3e289 | ||
![]() |
920e407d05 | ||
![]() |
7314c8901d | ||
![]() |
4e9f02b48c | ||
![]() |
9ae7602cb4 | ||
![]() |
aa8aa36aef | ||
![]() |
0174f7c6f2 | ||
![]() |
df9e7d6ff1 | ||
![]() |
b40ca920d3 | ||
![]() |
5a4b0a0e93 |
@@ -1,5 +1,5 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
|
||||
<Version>$(SourceGeneratorVersion)</Version>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
namespace BlazorSetParametersAsyncGenerator;
|
||||
namespace Microsoft.AspNetCore.Components;
|
||||
|
||||
[Generator]
|
||||
public partial class SetParametersAsyncGenerator : ISourceGenerator
|
||||
@@ -11,7 +11,7 @@ public partial class SetParametersAsyncGenerator : ISourceGenerator
|
||||
private string m_DoNotGenerateSetParametersAsyncAttribute = """
|
||||
|
||||
using System;
|
||||
namespace BlazorSetParametersAsyncGenerator
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
|
||||
internal sealed class DoNotGenerateSetParametersAsyncAttribute : Attribute
|
||||
@@ -25,7 +25,7 @@ public partial class SetParametersAsyncGenerator : ISourceGenerator
|
||||
private string m_GenerateSetParametersAsyncAttribute = """
|
||||
|
||||
using System;
|
||||
namespace BlazorSetParametersAsyncGenerator
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
|
||||
internal sealed class GenerateSetParametersAsyncAttribute : Attribute
|
||||
@@ -40,7 +40,7 @@ public partial class SetParametersAsyncGenerator : ISourceGenerator
|
||||
private string m_GlobalGenerateSetParametersAsyncAttribute = """
|
||||
|
||||
using System;
|
||||
namespace BlazorSetParametersAsyncGenerator
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
|
||||
internal sealed class GlobalGenerateSetParametersAsyncAttribute : Attribute
|
||||
@@ -445,8 +445,8 @@ namespace {namespaceName}
|
||||
private static IEnumerable<INamedTypeSymbol> GetCandidateClasses(SyntaxReceiver receiver, GeneratorExecutionContext context)
|
||||
{
|
||||
var compilation = context.Compilation;
|
||||
var positiveAttributeSymbol = compilation.GetTypeByMetadataName("BlazorSetParametersAsyncGenerator.GenerateSetParametersAsyncAttribute");
|
||||
var negativeAttributeSymbol = compilation.GetTypeByMetadataName("BlazorSetParametersAsyncGenerator.DoNotGenerateSetParametersAsyncAttribute");
|
||||
var positiveAttributeSymbol = compilation.GetTypeByMetadataName("Microsoft.AspNetCore.Components.GenerateSetParametersAsyncAttribute");
|
||||
var negativeAttributeSymbol = compilation.GetTypeByMetadataName("Microsoft.AspNetCore.Components.DoNotGenerateSetParametersAsyncAttribute");
|
||||
|
||||
// loop over the candidate methods, and keep the ones that are actually annotated
|
||||
|
||||
@@ -454,7 +454,7 @@ namespace {namespaceName}
|
||||
var assemblyAttributes = compilation.Assembly.GetAttributes();
|
||||
|
||||
var enableAttr = assemblyAttributes.FirstOrDefault(attr =>
|
||||
attr.AttributeClass?.ToDisplayString() == "BlazorSetParametersAsyncGenerator.GlobalGenerateSetParametersAsyncAttribute");
|
||||
attr.AttributeClass?.ToDisplayString() == "Microsoft.AspNetCore.Components.GlobalGenerateSetParametersAsyncAttribute");
|
||||
|
||||
var globalEnable = false;
|
||||
if (enableAttr != null)
|
||||
|
@@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace BlazorSetParametersAsyncGenerator
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
internal static class SourceGeneratorContextExtension
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
|
||||
namespace BlazorSetParametersAsyncGenerator
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
internal static class StringExtension
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace BlazorSetParametersAsyncGenerator
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
public static class TypeSymbolExtension
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
@@ -18,7 +18,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Rougamo.Fody" Version="5.0.0" />
|
||||
<PackageReference Include="Rougamo.Fody" Version="5.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
|
||||
@@ -41,12 +41,20 @@
|
||||
<ItemGroup>
|
||||
<None Include="..\README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="..\README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ThingsGateway.DB\ThingsGateway.DB.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<!--<Target Name="Mapster" AfterTargets="AfterBuild">
|
||||
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet tool restore" />
|
||||
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster extension -o MapsterGenerator -a "$(TargetDir)$(ProjectName).dll"" />
|
||||
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster mapper -o MapsterGenerator -a "$(TargetDir)$(ProjectName).dll"" />
|
||||
</Target>-->
|
||||
|
||||
|
||||
</Project>
|
||||
|
@@ -19,4 +19,4 @@ global using System.Diagnostics.CodeAnalysis;
|
||||
global using ThingsGateway.Razor;
|
||||
|
||||
[assembly: SuppressMessage("Reliability", "CA2007", Justification = "<挂起>", Scope = "module")]
|
||||
[assembly: BlazorSetParametersAsyncGenerator.GlobalGenerateSetParametersAsync(true)]
|
||||
[assembly: GlobalGenerateSetParametersAsync(true)]
|
@@ -39,6 +39,7 @@ public partial class SysUserEdit
|
||||
var items = await SysPositionService.SelectorAsync(new PositionSelectorInput() { });
|
||||
Items = PositionUtil.BuildCascaderItemList(items);
|
||||
ModuleSelectedItems = ResourceUtil.BuildModuleSelectList((await SysResourceService.GetAllAsync())).ToList();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ThingsGateway.Admin.Application\ThingsGateway.Admin.Application.csproj" />
|
||||
@@ -30,8 +30,8 @@
|
||||
<ItemGroup>
|
||||
<None Include="..\README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="..\README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
@@ -11,14 +11,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BootstrapBlazor.TableExport" Version="9.2.5" />
|
||||
<PackageReference Include="BootstrapBlazor.TableExport" Version="9.2.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="..\README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -15,6 +15,7 @@ using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
using ThingsGateway.NewLife.Caching;
|
||||
using ThingsGateway.NewLife.Log;
|
||||
|
||||
namespace ThingsGateway.Logging;
|
||||
|
||||
@@ -33,7 +34,7 @@ public sealed class DatabaseLoggerProvider : ILoggerProvider, ISupportExternalSc
|
||||
/// <summary>
|
||||
/// 日志消息队列(线程安全)
|
||||
/// </summary>
|
||||
private readonly BlockingCollection<LogMessage> _logMessageQueue = new(12000);
|
||||
private readonly BlockingCollection<LogMessage> _logMessageQueue = new(20000);
|
||||
|
||||
/// <summary>
|
||||
/// 日志作用域提供器
|
||||
@@ -135,7 +136,10 @@ public sealed class DatabaseLoggerProvider : ILoggerProvider, ISupportExternalSc
|
||||
{
|
||||
try
|
||||
{
|
||||
_logMessageQueue.Add(logMsg);
|
||||
if (!_logMessageQueue.TryAdd(logMsg, 5000))
|
||||
{
|
||||
XTrace.Log.Warn($"{nameof(DatabaseLoggerProvider)} queue add fail");
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (InvalidOperationException) { }
|
||||
|
@@ -14,6 +14,7 @@ using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
using ThingsGateway.NewLife.Caching;
|
||||
using ThingsGateway.NewLife.Log;
|
||||
|
||||
namespace ThingsGateway.Logging;
|
||||
|
||||
@@ -32,7 +33,7 @@ public sealed class FileLoggerProvider : ILoggerProvider, ISupportExternalScope
|
||||
/// <summary>
|
||||
/// 日志消息队列(线程安全)
|
||||
/// </summary>
|
||||
private readonly BlockingCollection<LogMessage> _logMessageQueue = new(12000);
|
||||
private readonly BlockingCollection<LogMessage> _logMessageQueue = new(20000);
|
||||
|
||||
/// <summary>
|
||||
/// 日志作用域提供器
|
||||
@@ -170,8 +171,10 @@ public sealed class FileLoggerProvider : ILoggerProvider, ISupportExternalScope
|
||||
{
|
||||
try
|
||||
{
|
||||
_logMessageQueue.Add(logMsg);
|
||||
return;
|
||||
if (!_logMessageQueue.TryAdd(logMsg, 5000))
|
||||
{
|
||||
XTrace.Log.Warn($"{nameof(DatabaseLoggerProvider)} queue add fail");
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException) { }
|
||||
catch { }
|
||||
|
@@ -46,6 +46,8 @@ public static class ObjectMapperServiceCollectionExtensions
|
||||
// 获取全局映射配置
|
||||
var config = TypeAdapterConfig.GlobalSettings;
|
||||
|
||||
//config.Compiler = exp => exp.CompileFast();
|
||||
|
||||
// 扫描所有继承 IRegister 接口的对象映射配置
|
||||
if (assemblies?.Length > 0) config.Scan(assemblies);
|
||||
|
||||
|
@@ -76,7 +76,7 @@ internal sealed partial class SchedulerFactory : ISchedulerFactory
|
||||
/// <summary>
|
||||
/// 作业持久化记录消息队列(线程安全)
|
||||
/// </summary>
|
||||
private readonly BlockingCollection<PersistenceContext> _persistenceMessageQueue = new(12000);
|
||||
private readonly BlockingCollection<PersistenceContext> _persistenceMessageQueue = new(20000);
|
||||
|
||||
/// <summary>
|
||||
/// 不受控的作业 Id 集合
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net9.0;</TargetFrameworks>
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Ben.Demystifier" Version="0.4.1" />
|
||||
<!--<PackageReference Include="FastExpressionCompiler" Version="5.3.0" />-->
|
||||
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
|
||||
<PackageReference Include="Mapster" Version="7.4.0" />
|
||||
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.5.4" />
|
||||
@@ -61,8 +62,8 @@
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net462;netstandard2.0;net6.0;net6.0-windows;net8.0;net8.0-windows;</TargetFrameworks>
|
||||
@@ -16,8 +16,8 @@
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'=='net462' or '$(TargetFramework)'=='net5.0-windows' or '$(TargetFramework)'=='net6.0-windows' or '$(TargetFramework)'=='net7.0-windows' or '$(TargetFramework)'=='net8.0-windows'">
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net9.0;</TargetFrameworks>
|
||||
|
@@ -13,7 +13,7 @@ namespace ThingsGateway.Razor;
|
||||
/// <summary>
|
||||
/// 母版页基类
|
||||
/// </summary>
|
||||
[BlazorSetParametersAsyncGenerator.DoNotGenerateSetParametersAsync]
|
||||
[DoNotGenerateSetParametersAsync]
|
||||
public partial class BaseLayout
|
||||
{
|
||||
}
|
||||
|
@@ -18,8 +18,6 @@ namespace ThingsGateway.Extension.Generic;
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public static class GenericExtensions
|
||||
{
|
||||
private static MemoryCache Instance { get; set; } = new MemoryCache();
|
||||
|
||||
/// <summary>
|
||||
/// 把已修改的属性赋值到列表中,并返回字典
|
||||
/// </summary>
|
||||
|
@@ -21,4 +21,4 @@ global using System.Globalization;
|
||||
|
||||
|
||||
[assembly: SuppressMessage("Reliability", "CA2007", Justification = "<挂起>", Scope = "module")]
|
||||
[assembly: BlazorSetParametersAsyncGenerator.GlobalGenerateSetParametersAsync(true)]
|
||||
[assembly: GlobalGenerateSetParametersAsync(true)]
|
@@ -1,12 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BootstrapBlazor.FontAwesome" Version="9.0.2" />
|
||||
<PackageReference Include="BootstrapBlazor" Version="9.7.4-beta09" />
|
||||
<PackageReference Include="BootstrapBlazor" Version="9.7.4" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
<ItemGroup>
|
||||
<None Include="..\README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="..\README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
@@ -13,8 +13,8 @@
|
||||
<ItemGroup>
|
||||
<None Include="..\README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="..\README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="$(SolutionDir)..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.md" Pack="false" PackagePath="\" />
|
||||
<None Remove="..\..\..\README.zh-CN.md" Pack="false" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -1,12 +1,13 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<PluginVersion>10.8.12</PluginVersion>
|
||||
<ProPluginVersion>10.8.12</ProPluginVersion>
|
||||
<AuthenticationVersion>2.8.0</AuthenticationVersion>
|
||||
<SourceGeneratorVersion>10.8.2</SourceGeneratorVersion>
|
||||
<PluginVersion>10.8.23</PluginVersion>
|
||||
<ProPluginVersion>10.8.23</ProPluginVersion>
|
||||
<AuthenticationVersion>2.8.4</AuthenticationVersion>
|
||||
<SourceGeneratorVersion>10.8.6</SourceGeneratorVersion>
|
||||
<NET8Version>8.0.17</NET8Version>
|
||||
<NET9Version>9.0.6</NET9Version>
|
||||
<SatelliteResourceLanguages>zh-Hans;en-US</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
@@ -41,7 +42,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(SolutionDir)Directory.Build.props" Pack="true" PackagePath="\" />
|
||||
<None Include="$(MSBuildThisFileDirectory)Directory.Build.props" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
@@ -4,6 +4,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(SolutionDir)Foundation.props" Pack="true" PackagePath="\" />
|
||||
<None Include="$(MSBuildThisFileDirectory)Foundation.props" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
|
||||
|
@@ -19,4 +19,4 @@ global using ThingsGateway.Razor;
|
||||
|
||||
[assembly: SuppressMessage("Reliability", "CA2007", Justification = "<挂起>", Scope = "module")]
|
||||
|
||||
[assembly: BlazorSetParametersAsyncGenerator.GlobalGenerateSetParametersAsync(true)]
|
||||
[assembly: GlobalGenerateSetParametersAsync(true)]
|
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
<!--<UseRazorSourceGenerator>false</UseRazorSourceGenerator>-->
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
|
||||
|
@@ -85,6 +85,7 @@ public static class ChannelOptionsExtensions
|
||||
channelOptions.ThrowIfNull(nameof(IChannelOptions));
|
||||
var channelType = channelOptions.ChannelType;
|
||||
channelType.ThrowIfNull(nameof(ChannelTypeEnum));
|
||||
config.SetMaxCount(channelOptions.MaxClientCount);
|
||||
switch (channelType)
|
||||
{
|
||||
case ChannelTypeEnum.TcpClient:
|
||||
|
@@ -509,18 +509,11 @@ public abstract class DeviceBase : DisposableObject, IDevice
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected virtual async ValueTask<MessageBase> SendThenReturnMessageBaseAsync(ISendMessage command, IClientChannel clientChannel = default, CancellationToken cancellationToken = default)
|
||||
protected virtual ValueTask<MessageBase> SendThenReturnMessageBaseAsync(ISendMessage command, IClientChannel clientChannel = default, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
return await GetResponsedDataAsync(command, clientChannel, Timeout, cancellationToken).ConfigureAwait(false);
|
||||
return GetResponsedDataAsync(command, clientChannel, Timeout, cancellationToken);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$(SolutionDir)Foundation.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="..\..\Foundation.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>工业设备通讯协议-基础类库</Description>
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(NET9Version)" />
|
||||
<PackageReference Include="TouchSocket" Version="3.1.8" />
|
||||
<PackageReference Include="TouchSocket.SerialPorts" Version="3.1.8" />
|
||||
<PackageReference Include="TouchSocket" Version="3.1.10" />
|
||||
<PackageReference Include="TouchSocket.SerialPorts" Version="3.1.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<None Remove="$(SolutionDir)..\README.md" />
|
||||
<None Remove="$(SolutionDir)..\README.zh-CN.md" />
|
||||
<None Remove="..\..\..\README.md" />
|
||||
<None Remove="..\..\..\README.zh-CN.md" />
|
||||
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
|
@@ -11,4 +11,4 @@
|
||||
|
||||
global using Microsoft.AspNetCore.Components;
|
||||
|
||||
[assembly: BlazorSetParametersAsyncGenerator.GlobalGenerateSetParametersAsync(true)]
|
||||
[assembly: GlobalGenerateSetParametersAsync(true)]
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<None Remove="$(SolutionDir)..\README.md" />
|
||||
<None Remove="$(SolutionDir)..\README.zh-CN.md" />
|
||||
<None Remove="..\..\..\README.md" />
|
||||
<None Remove="..\..\..\README.zh-CN.md" />
|
||||
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
|
@@ -29,4 +29,13 @@ public class TaskSchedulerLoop
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(IScheduledTask task)
|
||||
{
|
||||
Tasks.Add(task);
|
||||
}
|
||||
public void Remove(IScheduledTask task)
|
||||
{
|
||||
Tasks.Remove(task);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -435,8 +435,10 @@ public abstract class BusinessBaseWithCacheVariableModel<VarModel> : BusinessBas
|
||||
|
||||
try
|
||||
{
|
||||
if (_memoryVarModelsQueue.TryDequeue(out var cacheDBItem))
|
||||
while (_memoryVarModelsQueue.TryDequeue(out var cacheDBItem))
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
break;
|
||||
var list = cacheDBItem.Value;
|
||||
var data = list.ChunkBetter(_businessPropertyWithCache.SplitSize);
|
||||
foreach (var item in data)
|
||||
|
@@ -127,6 +127,24 @@ public abstract class CollectBase : DriverBase, IRpcDriver
|
||||
LogMessage?.LogWarning(ex, string.Format(AppResource.GetMethodError, ex.Message));
|
||||
}
|
||||
|
||||
|
||||
if (VariableTasks.Count > 0)
|
||||
{
|
||||
foreach (var item in VariableTasks)
|
||||
{
|
||||
item.Stop();
|
||||
TaskSchedulerLoop.Remove(item);
|
||||
}
|
||||
|
||||
VariableTasks = AddVariableTask(cancellationToken);
|
||||
|
||||
foreach (var item in VariableTasks)
|
||||
{
|
||||
TaskSchedulerLoop.Add(item);
|
||||
item.Start();
|
||||
}
|
||||
}
|
||||
|
||||
// 根据标签获取方法信息的局部函数
|
||||
List<VariableMethod> GetMethod(IEnumerable<VariableRuntime> tag)
|
||||
{
|
||||
@@ -165,16 +183,28 @@ public abstract class CollectBase : DriverBase, IRpcDriver
|
||||
return string.Empty;
|
||||
}
|
||||
protected virtual bool VariableSourceReadsEnable => true;
|
||||
|
||||
protected List<IScheduledTask> VariableTasks = new List<IScheduledTask>();
|
||||
protected override List<IScheduledTask> ProtectedGetTasks(CancellationToken cancellationToken)
|
||||
{
|
||||
var tasks = new List<IScheduledTask>();
|
||||
|
||||
var setDeviceStatusTask = new ScheduledSyncTask(3000, SetDeviceStatus, null, LogMessage, cancellationToken);
|
||||
var setDeviceStatusTask = new ScheduledSyncTask(10000, SetDeviceStatus, null, LogMessage, cancellationToken);
|
||||
tasks.Add(setDeviceStatusTask);
|
||||
|
||||
var testOnline = new ScheduledAsyncTask(30000, TestOnline, null, LogMessage, cancellationToken);
|
||||
tasks.Add(testOnline);
|
||||
|
||||
VariableTasks = AddVariableTask(cancellationToken);
|
||||
|
||||
tasks.AddRange(VariableTasks);
|
||||
return tasks;
|
||||
|
||||
}
|
||||
|
||||
protected List<IScheduledTask> AddVariableTask(CancellationToken cancellationToken)
|
||||
{
|
||||
List<IScheduledTask> variableTasks = new();
|
||||
if (VariableSourceReadsEnable)
|
||||
{
|
||||
for (int i = 0; i < CurrentDevice.VariableSourceReads.Count; i++)
|
||||
@@ -182,7 +212,7 @@ public abstract class CollectBase : DriverBase, IRpcDriver
|
||||
var variableSourceRead = CurrentDevice.VariableSourceReads[i];
|
||||
|
||||
var executeTask = ScheduledTaskHelper.GetTask(variableSourceRead.IntervalTime, ReadVariableSource, variableSourceRead, LogMessage, cancellationToken);
|
||||
tasks.Add(executeTask);
|
||||
variableTasks.Add(executeTask);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -192,7 +222,7 @@ public abstract class CollectBase : DriverBase, IRpcDriver
|
||||
var variableMethod = CurrentDevice.ReadVariableMethods[i];
|
||||
|
||||
var executeTask = ScheduledTaskHelper.GetTask(variableMethod.IntervalTime, ReadVariableMed, variableMethod, LogMessage, cancellationToken);
|
||||
tasks.Add(executeTask);
|
||||
variableTasks.Add(executeTask);
|
||||
|
||||
}
|
||||
|
||||
@@ -201,12 +231,11 @@ public abstract class CollectBase : DriverBase, IRpcDriver
|
||||
var variableScriptRead = CurrentDevice.VariableScriptReads[i];
|
||||
|
||||
var executeTask = ScheduledTaskHelper.GetTask(variableScriptRead.IntervalTime, ScriptVariableRun, variableScriptRead, LogMessage, cancellationToken);
|
||||
tasks.Add(executeTask);
|
||||
variableTasks.Add(executeTask);
|
||||
|
||||
}
|
||||
|
||||
return tasks;
|
||||
|
||||
return variableTasks;
|
||||
}
|
||||
|
||||
private void SetDeviceStatus(object? state, CancellationToken cancellationToken)
|
||||
@@ -220,7 +249,8 @@ public abstract class CollectBase : DriverBase, IRpcDriver
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentDevice.SetDeviceStatus(TimerX.Now);
|
||||
if (IdVariableRuntimes.All(a => !a.Value.IsOnline))
|
||||
CurrentDevice.SetDeviceStatus(TimerX.Now, true);
|
||||
}
|
||||
}
|
||||
else if (IsStarted)
|
||||
@@ -314,6 +344,8 @@ public abstract class CollectBase : DriverBase, IRpcDriver
|
||||
|
||||
var readErrorCount = 0;
|
||||
|
||||
await ReadWriteLock.ReaderLockAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
//if (LogMessage?.LogLevel <= TouchSocket.Core.LogLevel.Trace)
|
||||
// LogMessage?.Trace(string.Format("{0} - Collecting [{1} - {2}]", DeviceName, variableSourceRead?.RegisterAddress, variableSourceRead?.Length));
|
||||
var readResult = await ReadSourceAsync(variableSourceRead, cancellationToken).ConfigureAwait(false);
|
||||
@@ -430,7 +462,40 @@ public abstract class CollectBase : DriverBase, IRpcDriver
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
protected async Task Check(Dictionary<VariableRuntime, JToken> writeInfoLists, ConcurrentDictionary<string, OperResult> operResults, CancellationToken cancellationToken)
|
||||
{
|
||||
if (VariableSourceReadsEnable)
|
||||
{
|
||||
// 如果成功,每个变量都读取一次最新值,再次比较写入值
|
||||
var successfulWriteNames = operResults.Where(a => a.Value.IsSuccess).Select(a => a.Key).ToHashSet();
|
||||
|
||||
var groups = writeInfoLists.Select(a => a.Key).Where(a => a.RpcWriteCheck && a.ProtectType != ProtectTypeEnum.WriteOnly && successfulWriteNames.Contains(a.Name) && a.VariableSource != null).GroupBy(a => a.VariableSource as VariableSourceRead).Where(a => a.Key != null).ToList();
|
||||
|
||||
await groups.ParallelForEachAsync(async (varRead, token) =>
|
||||
{
|
||||
var result = await ReadSourceAsync(varRead.Key, token).ConfigureAwait(false);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
foreach (var item in varRead)
|
||||
{
|
||||
if (!item.Value.Equals(writeInfoLists[item].ToObject(item.Value?.GetType())))
|
||||
{
|
||||
// 如果写入值与读取值不同,则更新操作结果为失败
|
||||
operResults[item.Name] = new OperResult($"The write value is inconsistent with the read value, Write value: {writeInfoLists[item].ToObject(item.Value?.GetType())}, read value: {item.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in varRead)
|
||||
{
|
||||
// 如果写入值与读取值不同,则更新操作结果为失败
|
||||
operResults[item.Name] = new OperResult($"Reading and rechecking resulted in an error: {result.ErrorMessage}", result.Exception);
|
||||
}
|
||||
}
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
#region 写入方法
|
||||
|
||||
|
@@ -133,7 +133,6 @@ public abstract class CollectFoundationBase : CollectBase
|
||||
{
|
||||
try
|
||||
{
|
||||
await ReadWriteLock.ReaderLockAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return new(new OperationCanceledException());
|
||||
@@ -202,6 +201,8 @@ public abstract class CollectFoundationBase : CollectBase
|
||||
}
|
||||
}, CollectProperties.MaxConcurrentCount, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
await Check(writeInfoLists, operResults, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// 返回包含操作结果的字典
|
||||
return new Dictionary<string, OperResult>(operResults);
|
||||
}
|
||||
@@ -210,4 +211,5 @@ public abstract class CollectFoundationBase : CollectBase
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -399,6 +399,7 @@ public abstract class DriverBase : DisposableObject, IDriver
|
||||
stringBuilder.Append(" ");
|
||||
if (expireTime.HasValue && (DateTime.Now - expireTime.Value).TotalHours > -72)
|
||||
{
|
||||
stringBuilder.Append(',');
|
||||
stringBuilder.Append(Localizer["ExpireTime", expireTime.Value.ToString("yyyy-MM-dd HH")]);
|
||||
}
|
||||
|
||||
|
@@ -30,9 +30,6 @@ namespace ThingsGateway.Gateway.Application;
|
||||
[SugarIndex("unique_deviceid_variable_name", nameof(Variable.Name), OrderByType.Asc, nameof(Variable.DeviceId), OrderByType.Asc, true)]
|
||||
public class Variable : BaseDataEntity, IValidatableObject
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导入验证专用
|
||||
/// </summary>
|
||||
@@ -68,6 +65,8 @@ public class Variable : BaseDataEntity, IValidatableObject
|
||||
private bool lLAlarmEnable;
|
||||
private bool lAlarmEnable;
|
||||
private bool customAlarmEnable;
|
||||
private bool businessGroupUpdateTrigger = true;
|
||||
private bool rpcWriteCheck;
|
||||
|
||||
private object _value;
|
||||
private string name;
|
||||
@@ -143,6 +142,20 @@ public class Variable : BaseDataEntity, IValidatableObject
|
||||
[AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true, Order = 1)]
|
||||
public virtual string BusinessGroup { get => businessGroup; set => businessGroup = value; }
|
||||
|
||||
/// <summary>
|
||||
/// 分组上传触发变量
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "分组上传触发变量", IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true, Order = 1)]
|
||||
public virtual bool BusinessGroupUpdateTrigger { get => businessGroupUpdateTrigger; set => businessGroupUpdateTrigger = value; }
|
||||
|
||||
/// <summary>
|
||||
/// 写入后再次读取检查值是否一致
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "写入后再次读取检查值是否一致", IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true, Order = 1)]
|
||||
public virtual bool RpcWriteCheck { get => rpcWriteCheck; set => rpcWriteCheck = value; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
|
@@ -52,17 +52,7 @@
|
||||
"RulesId": "Name"
|
||||
},
|
||||
|
||||
"ThingsGateway.Management.Authentication": {
|
||||
"AuthName": "AuthName",
|
||||
"Authorized": "Authorized",
|
||||
"ExpireTime": "ExpireTime",
|
||||
"Password": "Password",
|
||||
"Register": "Register",
|
||||
"RegisterStatus": "RegisterStatus",
|
||||
"Unauthorized": "Unauthorized",
|
||||
"Unregister": "Unregister",
|
||||
"UUID": "UUID"
|
||||
},
|
||||
|
||||
"ThingsGateway.Management.AutoUpdateController": {
|
||||
"AutoUpdateController": "AutoUpdate",
|
||||
"Update": "Update"
|
||||
@@ -373,7 +363,7 @@
|
||||
|
||||
"ThingsGateway.Gateway.Application.DriverBase": {
|
||||
"Authorized": "Authorized",
|
||||
"ExpireTime": "ExpireTime",
|
||||
"ExpireTime": "ExpireTime {0}",
|
||||
"Unauthorized": "Unauthorized"
|
||||
},
|
||||
"ThingsGateway.Gateway.Application.ExportString": {
|
||||
@@ -448,6 +438,8 @@
|
||||
"BoolOpenAlarmText": "BoolOpenAlarmText",
|
||||
"BoolOpenRestrainExpressions": "BoolOpenRestrainExpressions",
|
||||
"BusinessGroup": "BusinessGroup",
|
||||
"BusinessGroupUpdateTrigger": "BusinessGroupUpdateTrigger",
|
||||
"RpcWriteCheck": "RpcWriteCheck",
|
||||
"ClearVariable": "Clear Variable",
|
||||
"CollectGroup": "CollectGroup",
|
||||
"CopyVariable": "Copy Variable",
|
||||
@@ -456,7 +448,7 @@
|
||||
"CustomAlarmText": "CustomAlarmText",
|
||||
"CustomRestrainExpressions": "CustomRestrainExpressions",
|
||||
"DataType": "DataType",
|
||||
"DeleteVariable": "Copy Variable",
|
||||
"DeleteVariable": "Delete Variable",
|
||||
"Description": "Description",
|
||||
"DeviceId": "CollectionDevice",
|
||||
"DeviceId.MinValue": "{0} cannot be empty",
|
||||
|
@@ -50,17 +50,7 @@
|
||||
"LogConsole": "日志",
|
||||
"RulesId": "名称"
|
||||
},
|
||||
"ThingsGateway.Management.Authentication": {
|
||||
"AuthName": "公司名称",
|
||||
"Authorized": "已授权",
|
||||
"ExpireTime": "过期时间",
|
||||
"Password": "注册码",
|
||||
"Register": "注册",
|
||||
"RegisterStatus": "注册状态",
|
||||
"Unauthorized": "未授权",
|
||||
"Unregister": "取消注册",
|
||||
"UUID": "唯一编码"
|
||||
},
|
||||
|
||||
"ThingsGateway.Management.AutoUpdateController": {
|
||||
"AutoUpdateController": "程序更新",
|
||||
"Update": "更新"
|
||||
@@ -374,7 +364,7 @@
|
||||
|
||||
"ThingsGateway.Gateway.Application.DriverBase": {
|
||||
"Authorized": "已授权",
|
||||
"ExpireTime": "过期时间",
|
||||
"ExpireTime": "过期时间 {0}",
|
||||
"Unauthorized": "未授权"
|
||||
},
|
||||
"ThingsGateway.Gateway.Application.ExportString": {
|
||||
@@ -449,6 +439,8 @@
|
||||
"BoolOpenAlarmText": "布尔开报警文本",
|
||||
"BoolOpenRestrainExpressions": "布尔开报警约束",
|
||||
"BusinessGroup": "业务组",
|
||||
"BusinessGroupUpdateTrigger": "分组上传触发",
|
||||
"RpcWriteCheck": "写入后再次读取检查值是否一致",
|
||||
"ClearVariable": "清空变量",
|
||||
"CollectGroup": "采集组",
|
||||
"CopyVariable": "复制变量",
|
||||
|
@@ -101,6 +101,9 @@ public class VariableBasicData
|
||||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string BusinessGroup => VariableRuntime.BusinessGroup;
|
||||
|
||||
/// <inheritdoc cref="Variable.BusinessGroupUpdateTrigger"/>
|
||||
public bool BusinessGroupUpdateTrigger => VariableRuntime.BusinessGroupUpdateTrigger;
|
||||
|
||||
/// <inheritdoc cref="VariableRuntime.DeviceName"/>
|
||||
public string DeviceName => VariableRuntime.DeviceName;
|
||||
|
||||
|
@@ -414,6 +414,12 @@ internal sealed class DeviceThreadManage : IAsyncDisposable, IDeviceThreadManage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (DriverTasks.TryRemove(deviceId, out var task))
|
||||
{
|
||||
task.Stop();
|
||||
}
|
||||
|
||||
// 取消驱动程序的操作
|
||||
if (CancellationTokenSources.TryRemove(deviceId, out var token))
|
||||
{
|
||||
@@ -424,10 +430,6 @@ internal sealed class DeviceThreadManage : IAsyncDisposable, IDeviceThreadManage
|
||||
}
|
||||
}
|
||||
|
||||
if (DriverTasks.TryRemove(deviceId, out var task))
|
||||
{
|
||||
task.Stop();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
@@ -104,12 +104,22 @@ public class ExecuteScriptNode : TextNode, IActuatorNode, IExexcuteExpressionsBa
|
||||
}
|
||||
}
|
||||
|
||||
Task<NodeOutput> IActuatorNode.ExecuteAsync(NodeInput input, CancellationToken cancellationToken)
|
||||
async Task<OperResult<NodeOutput>> IActuatorNode.ExecuteAsync(NodeInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
Logger?.Trace($"Execute script");
|
||||
var exexcuteExpressions = CSharpScriptEngineExtension.Do<IExexcuteExpressions>(Text);
|
||||
exexcuteExpressions.Logger = Logger;
|
||||
return exexcuteExpressions.ExecuteAsync(input, cancellationToken);
|
||||
try
|
||||
{
|
||||
Logger?.Trace($"Execute script");
|
||||
var exexcuteExpressions = CSharpScriptEngineExtension.Do<IExexcuteExpressions>(Text);
|
||||
exexcuteExpressions.Logger = Logger;
|
||||
var data = await exexcuteExpressions.ExecuteAsync(input, cancellationToken).ConfigureAwait(false);
|
||||
return new OperResult<NodeOutput>() { Content = data };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogWarning(ex);
|
||||
return new OperResult<NodeOutput>(ex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -12,22 +12,32 @@ public class VariableRpcNode : VariableNode, IActuatorNode
|
||||
public VariableRpcNode(string id, Point? position = null) : base(id, position)
|
||||
{ Title = "VariableRpcNode"; }
|
||||
|
||||
async Task<NodeOutput> IActuatorNode.ExecuteAsync(NodeInput input, CancellationToken cancellationToken)
|
||||
async Task<OperResult<NodeOutput>> IActuatorNode.ExecuteAsync(NodeInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
if ((!DeviceText.IsNullOrWhiteSpace()) && GlobalData.ReadOnlyDevices.TryGetValue(DeviceText, out var device))
|
||||
try
|
||||
{
|
||||
if (device.ReadOnlyVariableRuntimes.TryGetValue(Text, out var value))
|
||||
|
||||
if ((!DeviceText.IsNullOrWhiteSpace()) && GlobalData.ReadOnlyDevices.TryGetValue(DeviceText, out var device))
|
||||
{
|
||||
var data = await value.RpcAsync(input.JToken.ToString(), $"RulesEngine: {RulesEngineName}", cancellationToken).ConfigureAwait(false);
|
||||
if (data.IsSuccess)
|
||||
Logger?.Trace($" VariableRpcNode - VariableName {Text} : execute success");
|
||||
else
|
||||
Logger?.Warning($" VariableRpcNode - VariableName {Text} : {data.ErrorMessage}");
|
||||
return new NodeOutput() { Value = data };
|
||||
if (device.ReadOnlyVariableRuntimes.TryGetValue(Text, out var value))
|
||||
{
|
||||
var data = await value.RpcAsync(input.JToken.ToString(), $"RulesEngine: {RulesEngineName}", cancellationToken).ConfigureAwait(false);
|
||||
if (data.IsSuccess)
|
||||
Logger?.Trace($" VariableRpcNode - VariableName {Text} : execute success");
|
||||
else
|
||||
Logger?.Warning($" VariableRpcNode - VariableName {Text} : {data.ErrorMessage}");
|
||||
return new OperResult<NodeOutput>() { Content = new NodeOutput() { Value = data } };
|
||||
}
|
||||
}
|
||||
Logger?.Warning($" VariableRpcNode - VariableName {Text} : not found");
|
||||
|
||||
return new OperResult<NodeOutput>() { Content = new NodeOutput() { } };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogWarning(ex);
|
||||
return new OperResult<NodeOutput>(ex);
|
||||
}
|
||||
Logger?.Warning($" VariableRpcNode - VariableName {Text} : not found");
|
||||
return new NodeOutput() { };
|
||||
}
|
||||
|
||||
|
||||
|
@@ -16,12 +16,21 @@ public class DataNode : TextNode, IExpressionNode
|
||||
|
||||
}
|
||||
|
||||
Task<NodeOutput> IExpressionNode.ExecuteAsync(NodeInput input, CancellationToken cancellationToken)
|
||||
Task<OperResult<NodeOutput>> IExpressionNode.ExecuteAsync(NodeInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
var value = Text.GetExpressionsResult(input.Value, Logger);
|
||||
NodeOutput nodeOutput = new();
|
||||
nodeOutput.Value = value;
|
||||
Logger?.Trace($"Data result: {nodeOutput.JToken?.ToString(Newtonsoft.Json.Formatting.Indented)}");
|
||||
return Task.FromResult(nodeOutput);
|
||||
try
|
||||
{
|
||||
var value = Text.GetExpressionsResult(input.Value, Logger);
|
||||
NodeOutput nodeOutput = new();
|
||||
nodeOutput.Value = value;
|
||||
Logger?.Trace($"Data result: {nodeOutput.JToken?.ToString(Newtonsoft.Json.Formatting.Indented)}");
|
||||
return Task.FromResult(new OperResult<NodeOutput>() { Content = nodeOutput });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogWarning(ex);
|
||||
return Task.FromResult(new OperResult<NodeOutput>(ex));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -10,11 +10,20 @@ public class DelayNode : NumberNode, IExpressionNode
|
||||
{
|
||||
public DelayNode(string id, Point? position = null) : base(id, position) { Title = "DelayNode"; Placeholder = "DelayNode.Placeholder"; }
|
||||
|
||||
async Task<NodeOutput> IExpressionNode.ExecuteAsync(NodeInput input, CancellationToken cancellationToken)
|
||||
async Task<OperResult<NodeOutput>> IExpressionNode.ExecuteAsync(NodeInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
Logger?.Trace($"Delay {Number} ms");
|
||||
await Task.Delay(Number ?? 0, cancellationToken).ConfigureAwait(false);
|
||||
return new NodeOutput();
|
||||
try
|
||||
{
|
||||
Logger?.Trace($"Delay {Number} ms");
|
||||
await Task.Delay(Number ?? 0, cancellationToken).ConfigureAwait(false);
|
||||
return new OperResult<NodeOutput>() { Content = new NodeOutput() };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogWarning(ex);
|
||||
return new OperResult<NodeOutput>(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,11 +13,11 @@ public interface IConditionNode : INode
|
||||
|
||||
public interface IExpressionNode : INode
|
||||
{
|
||||
public Task<NodeOutput> ExecuteAsync(NodeInput input, CancellationToken cancellationToken);
|
||||
public Task<OperResult<NodeOutput>> ExecuteAsync(NodeInput input, CancellationToken cancellationToken);
|
||||
}
|
||||
public interface IActuatorNode : INode
|
||||
{
|
||||
public Task<NodeOutput> ExecuteAsync(NodeInput input, CancellationToken cancellationToken);
|
||||
public Task<OperResult<NodeOutput>> ExecuteAsync(NodeInput input, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
public interface ITriggerNode : INode
|
||||
|
@@ -65,7 +65,7 @@ internal sealed class RulesEngineHostedService : BackgroundService, IRulesEngine
|
||||
if (rules.Status)
|
||||
{
|
||||
var data = Init(rules);
|
||||
await Start(data.rulesLog, data.blazorDiagram, TokenSource.Token).ConfigureAwait(false);
|
||||
Start(data.rulesLog, data.blazorDiagram, TokenSource.Token);
|
||||
dispatchService.Dispatch(null);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ internal sealed class RulesEngineHostedService : BackgroundService, IRulesEngine
|
||||
|
||||
return result;
|
||||
}
|
||||
private static Task Start(RulesLog rulesLog, DefaultDiagram item, CancellationToken cancellationToken)
|
||||
private static void Start(RulesLog rulesLog, DefaultDiagram item, CancellationToken cancellationToken)
|
||||
{
|
||||
rulesLog.Log.Trace("Start");
|
||||
var startNodes = item.Nodes.Where(a => a is IStartNode);
|
||||
@@ -123,7 +123,6 @@ internal sealed class RulesEngineHostedService : BackgroundService, IRulesEngine
|
||||
{
|
||||
_ = Analysis((link.Target.Model as PortModel)?.Parent, new NodeInput(), rulesLog, cancellationToken);
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private static async Task Analysis(NodeModel targetNode, NodeInput input, RulesLog rulesLog, CancellationToken cancellationToken)
|
||||
@@ -152,17 +151,24 @@ internal sealed class RulesEngineHostedService : BackgroundService, IRulesEngine
|
||||
else if (targetNode is IExpressionNode expressionNode)
|
||||
{
|
||||
var nodeOutput = await expressionNode.ExecuteAsync(input, cancellationToken).ConfigureAwait(false);
|
||||
foreach (var link in targetNode.PortLinks.Where(a => ((a.Target.Model as PortModel)?.Parent) != targetNode))
|
||||
if (nodeOutput.IsSuccess)
|
||||
{
|
||||
await Analysis((link.Target.Model as PortModel)?.Parent, new NodeInput() { Value = nodeOutput.Value, }, rulesLog, cancellationToken).ConfigureAwait(false);
|
||||
foreach (var link in targetNode.PortLinks.Where(a => ((a.Target.Model as PortModel)?.Parent) != targetNode))
|
||||
{
|
||||
await Analysis((link.Target.Model as PortModel)?.Parent, new NodeInput() { Value = nodeOutput.Content.Value, }, rulesLog, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (targetNode is IActuatorNode actuatorNode)
|
||||
{
|
||||
var nodeOutput = await actuatorNode.ExecuteAsync(input, cancellationToken).ConfigureAwait(false);
|
||||
foreach (var link in targetNode.PortLinks.Where(a => ((a.Target.Model as PortModel)?.Parent) != targetNode))
|
||||
if (nodeOutput.IsSuccess)
|
||||
{
|
||||
await Analysis((link.Target.Model as PortModel)?.Parent, new NodeInput() { Value = nodeOutput.Value }, rulesLog, cancellationToken).ConfigureAwait(false);
|
||||
foreach (var link in targetNode.PortLinks.Where(a => ((a.Target.Model as PortModel)?.Parent) != targetNode))
|
||||
{
|
||||
await Analysis((link.Target.Model as PortModel)?.Parent, new NodeInput() { Value = nodeOutput.Content.Value }, rulesLog, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (targetNode is ITriggerNode triggerNode)
|
||||
@@ -200,11 +206,10 @@ internal sealed class RulesEngineHostedService : BackgroundService, IRulesEngine
|
||||
foreach (var rules in Rules.Where(a => a.Status))
|
||||
{
|
||||
var item = Init(rules);
|
||||
await Start(item.rulesLog, item.blazorDiagram, cancellationToken).ConfigureAwait(false);
|
||||
Start(item.rulesLog, item.blazorDiagram, cancellationToken);
|
||||
}
|
||||
dispatchService.Dispatch(null);
|
||||
|
||||
|
||||
_ = Task.Factory.StartNew(async (state) =>
|
||||
{
|
||||
if (state is not Dictionary<RulesLog, Diagram> diagrams)
|
||||
|
@@ -176,20 +176,20 @@ public class VariableRuntimeService : IVariableRuntimeService
|
||||
var datas = await GlobalData.VariableService.InsertTestDataAsync(testVariableCount, testDeviceCount, slaveUrl, businessEnable).ConfigureAwait(false);
|
||||
|
||||
{
|
||||
var newChannelRuntimes = (datas.Item1).Adapt<List<ChannelRuntime>>();
|
||||
var newChannelRuntimes = datas.Item1.Adapt<List<ChannelRuntime>>();
|
||||
|
||||
//批量修改之后,需要重新加载通道
|
||||
RuntimeServiceHelper.Init(newChannelRuntimes);
|
||||
|
||||
{
|
||||
|
||||
var newDeviceRuntimes = (datas.Item2).Adapt<List<DeviceRuntime>>();
|
||||
var newDeviceRuntimes = datas.Item2.Adapt<List<DeviceRuntime>>();
|
||||
|
||||
RuntimeServiceHelper.Init(newDeviceRuntimes);
|
||||
|
||||
}
|
||||
{
|
||||
var newVariableRuntimes = (datas.Item3).Adapt<List<VariableRuntime>>();
|
||||
var newVariableRuntimes = datas.Item3.Adapt<List<VariableRuntime>>();
|
||||
RuntimeServiceHelper.Init(newVariableRuntimes);
|
||||
|
||||
}
|
||||
|
@@ -1,15 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
|
||||
<PackageReference Include="Rougamo.Fody" Version="5.0.0" />
|
||||
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.8" />
|
||||
<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.1.8" />
|
||||
<PackageReference Include="Rougamo.Fody" Version="5.0.1" />
|
||||
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.10" />
|
||||
<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.1.10" />
|
||||
<PackageReference Include="ThingsGateway.Authentication" Version="$(AuthenticationVersion)" />
|
||||
<!--<ProjectReference Include="..\..\PluginPro\ThingsGateway.Authentication\ThingsGateway.Authentication.csproj" />-->
|
||||
|
||||
|
@@ -20,4 +20,4 @@ global using ThingsGateway.Razor;
|
||||
|
||||
[assembly: SuppressMessage("Reliability", "CA2007", Justification = "<挂起>", Scope = "module")]
|
||||
|
||||
[assembly: BlazorSetParametersAsyncGenerator.GlobalGenerateSetParametersAsync(true)]
|
||||
[assembly: GlobalGenerateSetParametersAsync(true)]
|
@@ -1,4 +1,34 @@
|
||||
{
|
||||
"ThingsGateway.Gateway.Razor.ValueTransformType": {
|
||||
"None": "None",
|
||||
"Linear": "Linear",
|
||||
"Sqrt": "Sqrt"
|
||||
},
|
||||
|
||||
"ThingsGateway.Gateway.Razor.ValueTransformConfig": {
|
||||
"TransformType": "TransformType",
|
||||
"MinMax": "MinMax",
|
||||
"ClampToRawRange": "ClampToRawRange",
|
||||
"DecimalPlaces": "DecimalPlaces",
|
||||
"RawMin": "RawMin",
|
||||
"RawMax": "RawMax",
|
||||
"ActualMin": "ActualMin",
|
||||
"ActualMax": "ActualMax"
|
||||
},
|
||||
|
||||
|
||||
"ThingsGateway.Management.Authentication": {
|
||||
"AuthName": "AuthName",
|
||||
"Authorized": "Authorized",
|
||||
"ExpireTime": "ExpireTime",
|
||||
"Password": "Password",
|
||||
"Register": "Register",
|
||||
"RegisterStatus": "RegisterStatus",
|
||||
"Unauthorized": "Unauthorized",
|
||||
"Unregister": "Unregister",
|
||||
"UUID": "UUID"
|
||||
},
|
||||
|
||||
"ThingsGateway.Gateway.Razor._Imports": {
|
||||
|
||||
"Actuator": "Actuator",
|
||||
|
@@ -1,4 +1,32 @@
|
||||
{
|
||||
"ThingsGateway.Gateway.Razor.ValueTransformType": {
|
||||
"None": "无",
|
||||
"Linear": "线性",
|
||||
"Sqrt": "开方"
|
||||
},
|
||||
"ThingsGateway.Gateway.Razor.ValueTransformConfig": {
|
||||
"TransformType": "转换方式",
|
||||
"MinMax": "最小最大值",
|
||||
"ClampToRawRange": "限制范围",
|
||||
"DecimalPlaces": "保留小数位",
|
||||
"RawMin": "原始最小值",
|
||||
"RawMax": "原始最大值",
|
||||
"ActualMin": "实际最小值",
|
||||
"ActualMax": "实际最大值"
|
||||
},
|
||||
|
||||
"ThingsGateway.Management.Authentication": {
|
||||
"AuthName": "公司名称",
|
||||
"Authorized": "已授权",
|
||||
"ExpireTime": "过期时间",
|
||||
"Password": "注册码",
|
||||
"Register": "注册",
|
||||
"RegisterStatus": "注册状态",
|
||||
"Unauthorized": "未授权",
|
||||
"Unregister": "取消注册",
|
||||
"UUID": "唯一编码"
|
||||
},
|
||||
|
||||
"ThingsGateway.Gateway.Razor._Imports": {
|
||||
|
||||
"Actuator": "执行",
|
||||
|
@@ -0,0 +1,62 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Gateway.Razor;
|
||||
|
||||
public class ValueTransformConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 保留小数位
|
||||
/// </summary>
|
||||
public int DecimalPlaces { get; set; } = 2;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 限制范围
|
||||
/// </summary>
|
||||
public bool ClampToRawRange { get; set; }
|
||||
|
||||
public ValueTransformType TransformType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原始低
|
||||
/// </summary>
|
||||
public decimal RawMin { get; set; }
|
||||
/// <summary>
|
||||
/// 原始高
|
||||
/// </summary>
|
||||
public decimal RawMax { get; set; }
|
||||
/// <summary>
|
||||
/// 实际低
|
||||
/// </summary>
|
||||
public decimal ActualMin { get; set; }
|
||||
/// <summary>
|
||||
/// 实际高
|
||||
/// </summary>
|
||||
public decimal ActualMax { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public enum ValueTransformType
|
||||
{
|
||||
/// <summary>
|
||||
/// 不转换,仅保留小数位
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// 线性转换
|
||||
/// </summary>
|
||||
Linear,
|
||||
/// <summary>
|
||||
/// 开方转换
|
||||
/// </summary>
|
||||
Sqrt
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
@namespace ThingsGateway.Gateway.Razor
|
||||
@using ThingsGateway.Admin.Application
|
||||
@using ThingsGateway.Admin.Razor
|
||||
@using ThingsGateway.Foundation
|
||||
@using ThingsGateway.Gateway.Application
|
||||
@inherits ComponentDefault
|
||||
|
||||
<ValidateForm class="p-4 h-100" Model="@ValueTransformConfig" OnValidSubmit="OnSave">
|
||||
<EditorForm AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=1 LabelWidth=150 Model="ValueTransformConfig">
|
||||
|
||||
<FieldItems>
|
||||
|
||||
<EditorItem @bind-Field="@context.TransformType" GroupName=@(ValueTransformConfigLocalizer["TransformType"]) Cols="4" />
|
||||
<EditorItem @bind-Field="@context.ClampToRawRange" GroupName=@(ValueTransformConfigLocalizer["TransformType"]) Cols="4" />
|
||||
<EditorItem @bind-Field="@context.DecimalPlaces" GroupName=@(ValueTransformConfigLocalizer["TransformType"]) Cols="4" />
|
||||
|
||||
|
||||
<EditorItem @bind-Field="@context.RawMin" GroupName=@(ValueTransformConfigLocalizer["MinMax"]) GroupOrder=2 Cols="6" />
|
||||
<EditorItem @bind-Field="@context.RawMax" GroupName=@(ValueTransformConfigLocalizer["MinMax"]) GroupOrder=2 Cols="6" />
|
||||
<EditorItem @bind-Field="@context.ActualMin" GroupName=@(ValueTransformConfigLocalizer["MinMax"]) GroupOrder=2 Cols="6" />
|
||||
<EditorItem @bind-Field="@context.ActualMax" GroupName=@(ValueTransformConfigLocalizer["MinMax"]) GroupOrder=2 Cols="6" />
|
||||
|
||||
|
||||
</FieldItems>
|
||||
<Buttons>
|
||||
<Button ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" IsAsync Text=@RazorLocalizer["Save"] />
|
||||
</Buttons>
|
||||
</EditorForm>
|
||||
|
||||
</ValidateForm>
|
||||
|
@@ -0,0 +1,215 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using ThingsGateway.NewLife.Extension;
|
||||
|
||||
namespace ThingsGateway.Gateway.Razor;
|
||||
|
||||
public partial class ValueTransformConfigPage
|
||||
{
|
||||
private ValueTransformConfig ValueTransformConfig = new();
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IStringLocalizer<ValueTransformConfig>? ValueTransformConfigLocalizer { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Expressions { get; set; }
|
||||
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> ExpressionsChanged { get; set; }
|
||||
|
||||
public static bool TryParseLinearFormula(string formula, out ValueTransformConfig config)
|
||||
{
|
||||
config = new ValueTransformConfig();
|
||||
var dec = @"[\d]+(?:\.[\d]+)?";
|
||||
|
||||
try
|
||||
{
|
||||
// None + clamp actual
|
||||
var m = Regex.Match(formula, $@"^Math\.Round\(\s*
|
||||
Math\.Min\(\s*
|
||||
Math\.Max\(\s*
|
||||
raw\.ToDecimal\(\)\s*,\s*({dec})\s*\)\s*,\s*({dec})\s*\)\s*,\s*(\d+)\s*\)$", RegexOptions.IgnorePatternWhitespace);
|
||||
if (m.Success)
|
||||
{
|
||||
config.TransformType = ValueTransformType.None;
|
||||
config.ClampToRawRange = true;
|
||||
config.ActualMin = decimal.Parse(m.Groups[1].Value);
|
||||
config.ActualMax = decimal.Parse(m.Groups[2].Value);
|
||||
config.DecimalPlaces = int.Parse(m.Groups[3].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
// None pure
|
||||
m = Regex.Match(formula, $@"^Math\.Round\(\s*raw\.ToDecimal\(\)\s*,\s*(\d+)\s*\)$");
|
||||
if (m.Success)
|
||||
{
|
||||
config.TransformType = ValueTransformType.None;
|
||||
config.ClampToRawRange = false;
|
||||
config.DecimalPlaces = int.Parse(m.Groups[1].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Linear + clamp actual
|
||||
|
||||
m = Regex.Match(formula, $@"^Math\.Round\(\s*
|
||||
Math\.Min\(\s*
|
||||
Math\.Max\(\s*
|
||||
\(\(raw\.ToDecimal\(\)\s*-\s*({dec})\)\s*/\s*
|
||||
\(({dec})\s*-\s*({dec})\)\s*\*\s*
|
||||
\(({dec})\s*-\s*({dec})\)\s*\+\s*
|
||||
({dec})\)\s*,\s*({dec})\)\s*,\s*({dec})\)\s*,\s*(\d+)\s*\)$", RegexOptions.IgnorePatternWhitespace);
|
||||
if (m.Success)
|
||||
{
|
||||
config.TransformType = ValueTransformType.Linear;
|
||||
config.ClampToRawRange = true;
|
||||
config.RawMin = decimal.Parse(m.Groups[1].Value);
|
||||
config.RawMax = decimal.Parse(m.Groups[2].Value);
|
||||
config.ActualMax = decimal.Parse(m.Groups[4].Value);
|
||||
config.ActualMin = decimal.Parse(m.Groups[5].Value);
|
||||
config.DecimalPlaces = int.Parse(m.Groups[9].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Linear pure
|
||||
m = Regex.Match(formula, $@"^Math\.Round\(\s*
|
||||
\(\(raw\.ToDecimal\(\)\s*-\s*({dec})\)\s*/\s*
|
||||
\(({dec})\s*-\s*({dec})\)\s*\*\s*
|
||||
\(({dec})\s*-\s*({dec})\)\s*\+\s*({dec})\)\s*,\s*(\d+)\s*\)$", RegexOptions.IgnorePatternWhitespace);
|
||||
|
||||
if (m.Success)
|
||||
{
|
||||
config.TransformType = ValueTransformType.Linear;
|
||||
config.ClampToRawRange = false;
|
||||
config.RawMin = decimal.Parse(m.Groups[1].Value); // raw减数(0)
|
||||
config.RawMax = decimal.Parse(m.Groups[2].Value); // 分母第一个数(10)
|
||||
config.ActualMax = decimal.Parse(m.Groups[4].Value); // 乘数第一个数(1)
|
||||
config.ActualMin = decimal.Parse(m.Groups[6].Value); // 加数(0)
|
||||
config.DecimalPlaces = int.Parse(m.Groups[7].Value); // 小数位(2)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Sqrt + clamp actual
|
||||
m = Regex.Match(formula, $@"^Math\.Round\(\s*
|
||||
Math\.Min\(\s*
|
||||
Math\.Max\(\s*
|
||||
Math\.Sqrt\(Math\.Max\(raw\.ToDecimal\(\),\s*0\)\)\s*\*\s*({dec})\s*,\s*({dec})\)\s*,\s*({dec})\)\s*,\s*(\d+)\s*\)$", RegexOptions.IgnorePatternWhitespace);
|
||||
if (m.Success)
|
||||
{
|
||||
config.TransformType = ValueTransformType.Sqrt;
|
||||
config.ClampToRawRange = true;
|
||||
config.ActualMax = decimal.Parse(m.Groups[1].Value);
|
||||
config.ActualMin = decimal.Parse(m.Groups[2].Value);
|
||||
config.DecimalPlaces = int.Parse(m.Groups[4].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Sqrt pure
|
||||
m = Regex.Match(formula, $@"^Math\.Round\(\s*
|
||||
Math\.Sqrt\(Math\.Max\(raw\.ToDecimal\(\),\s*0\)\)\s*\*\s*({dec})\s*,\s*(\d+)\s*\)$", RegexOptions.IgnorePatternWhitespace);
|
||||
if (m.Success)
|
||||
{
|
||||
config.TransformType = ValueTransformType.Sqrt;
|
||||
config.ClampToRawRange = false;
|
||||
config.DecimalPlaces = int.Parse(m.Groups[2].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string GenerateFormula(ValueTransformConfig config)
|
||||
{
|
||||
// 只有 ClampToRawRange 为 true 时才包裹实际值范围限制
|
||||
string clampActual(string expr)
|
||||
{
|
||||
if (config.ClampToRawRange)
|
||||
return $"Math.Min(Math.Max({expr}, {config.ActualMin}), {config.ActualMax})";
|
||||
else
|
||||
return expr;
|
||||
}
|
||||
|
||||
string rawExpr = "raw.ToDecimal()"; // 这里不做 raw clamp
|
||||
|
||||
switch (config.TransformType)
|
||||
{
|
||||
case ValueTransformType.None:
|
||||
return $"Math.Round({clampActual(rawExpr)}, {config.DecimalPlaces})";
|
||||
|
||||
case ValueTransformType.Linear:
|
||||
var linearExpr = $"(({rawExpr} - {config.RawMin}) / ({config.RawMax} - {config.RawMin}) * ({config.ActualMax} - {config.ActualMin}) + {config.ActualMin})";
|
||||
return $"Math.Round({clampActual(linearExpr)}, {config.DecimalPlaces})";
|
||||
|
||||
case ValueTransformType.Sqrt:
|
||||
var sqrtExpr = $"Math.Sqrt(Math.Max({rawExpr}, 0)) * {config.ActualMax}";
|
||||
return $"Math.Round({clampActual(sqrtExpr)}, {config.DecimalPlaces})";
|
||||
|
||||
default:
|
||||
throw new NotSupportedException($"Unsupported transform type: {config.TransformType}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (!Expressions.IsNullOrWhiteSpace())
|
||||
{
|
||||
if (TryParseLinearFormula(Expressions, out var config))
|
||||
{
|
||||
ValueTransformConfig = config;
|
||||
}
|
||||
}
|
||||
base.OnParametersSet();
|
||||
}
|
||||
|
||||
#region 修改
|
||||
[CascadingParameter]
|
||||
private Func<Task>? OnCloseAsync { get; set; }
|
||||
|
||||
|
||||
|
||||
private async Task OnSave(EditContext editContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = GenerateFormula(ValueTransformConfig);
|
||||
Expressions = result;
|
||||
if (ExpressionsChanged.HasDelegate)
|
||||
{
|
||||
await ExpressionsChanged.InvokeAsync(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
Expressions = result;
|
||||
}
|
||||
if (OnCloseAsync != null)
|
||||
await OnCloseAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await ToastService.Warn(ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 修改
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
.appconfig ::deep .tabs-body-content {
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
.appconfig {
|
||||
height: 100% !important;
|
||||
}
|
@@ -28,225 +28,247 @@
|
||||
RenderFragment renderFragment =>
|
||||
@<Tab>
|
||||
|
||||
<TabItem Text=@GatewayLocalizer["VariableInformation"]>
|
||||
<TabItem Text=@GatewayLocalizer["VariableInformation"]>
|
||||
|
||||
<EditorForm class="p-2" AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=2 LabelWidth=200 Model="Model">
|
||||
<EditorForm class="p-2" AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=2 LabelWidth=200 Model="Model">
|
||||
|
||||
<FieldItems>
|
||||
<EditorItem TValue="string" TModel="Variable" @bind-Field="@context.Name">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12">
|
||||
<h6>@GatewayLocalizer["BasicInformation"]</h6>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
<FieldItems>
|
||||
<EditorItem TValue="string" TModel="Variable" @bind-Field="@context.Name">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12">
|
||||
<h6>@GatewayLocalizer["BasicInformation"]</h6>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
|
||||
<EditorItem @bind-Field="@context.Name" Readonly=BatchEditEnable />
|
||||
<EditorItem @bind-Field="@context.Name" Readonly=BatchEditEnable />
|
||||
|
||||
<EditorItem @bind-Field="@context.Description" />
|
||||
<EditorItem @bind-Field="@context.CollectGroup" />
|
||||
<EditorItem @bind-Field="@context.BusinessGroup" />
|
||||
<EditorItem @bind-Field="@context.Description" />
|
||||
<EditorItem @bind-Field="@context.CollectGroup" />
|
||||
<EditorItem @bind-Field="@context.BusinessGroup" />
|
||||
<EditorItem @bind-Field="@context.BusinessGroupUpdateTrigger" />
|
||||
<EditorItem @bind-Field="@context.RpcWriteCheck" />
|
||||
|
||||
<EditorItem @bind-Field="@context.Unit" />
|
||||
<EditorItem @bind-Field="@context.ProtectType" />
|
||||
<EditorItem @bind-Field="@context.Enable" />
|
||||
<EditorItem @bind-Field="@context.RpcWriteEnable" />
|
||||
<EditorItem @bind-Field="@context.Unit" />
|
||||
<EditorItem @bind-Field="@context.ProtectType" />
|
||||
<EditorItem @bind-Field="@context.Enable" />
|
||||
<EditorItem @bind-Field="@context.RpcWriteEnable" />
|
||||
|
||||
<EditorItem @bind-Field="@context.InitValue">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12 col-md-6 ">
|
||||
<BootstrapInput @bind-Value="@value.InitValue" DisplayText="@(context.Description(a=>a.InitValue))" ShowLabel="true" Formatter=@(JsonFormatter) />
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
<EditorItem @bind-Field="@context.InitValue">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12 col-md-6 ">
|
||||
<BootstrapInput @bind-Value="@value.InitValue" DisplayText="@(context.Description(a => a.InitValue))" ShowLabel="true" Formatter=@(JsonFormatter) />
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
|
||||
<EditorItem @bind-Field="@context.SaveValue" />
|
||||
<EditorItem @bind-Field="@context.SaveValue" />
|
||||
|
||||
<EditorItem TValue="string" TModel="Variable" @bind-Field="@context.Name">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12">
|
||||
<h6>@GatewayLocalizer["Connection"]</h6>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
<EditorItem TValue="string" TModel="Variable" @bind-Field="@context.Name">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12">
|
||||
<h6>@GatewayLocalizer["Connection"]</h6>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
|
||||
<EditorItem @bind-Field="@context.DeviceId">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12 col-md-6 ">
|
||||
<BootstrapInputGroup>
|
||||
<Select IsVirtualize @bind-Value="@value.DeviceId" DefaultVirtualizeItemText=@(GlobalData.ReadOnlyIdDevices.TryGetValue(value.DeviceId,out var deviceRuntime)?deviceRuntime.Name:string.Empty) IsDisabled=BatchEditEnable Items="@CollectDeviceItems" OnSelectedItemChanged=OnDeviceChanged ShowSearch="true" ShowLabel="true" />
|
||||
<Button class="text-end" Icon="fa-solid fa-plus" OnClick="AddDevice" IsDisabled=BatchEditEnable></Button>
|
||||
</BootstrapInputGroup>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
<EditorItem @bind-Field="@context.DeviceId">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12 col-md-6 ">
|
||||
<BootstrapInputGroup>
|
||||
<Select IsVirtualize @bind-Value="@value.DeviceId" DefaultVirtualizeItemText=@(GlobalData.ReadOnlyIdDevices.TryGetValue(value.DeviceId, out var deviceRuntime) ? deviceRuntime.Name : string.Empty) IsDisabled=BatchEditEnable Items="@CollectDeviceItems" OnSelectedItemChanged=OnDeviceChanged ShowSearch="true" ShowLabel="true" />
|
||||
<Button class="text-end" Icon="fa-solid fa-plus" OnClick="AddDevice" IsDisabled=BatchEditEnable></Button>
|
||||
</BootstrapInputGroup>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
|
||||
<EditorItem @bind-Field="@context.DataType" />
|
||||
<EditorItem @bind-Field="@context.IntervalTime" />
|
||||
<EditorItem @bind-Field="@context.DataType" />
|
||||
<EditorItem @bind-Field="@context.IntervalTime" />
|
||||
|
||||
<EditorItem @bind-Field="@context.OtherMethod">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12 col-md-6">
|
||||
<Select IsVirtualize DefaultVirtualizeItemText=@(OtherMethods.TryGetValue(value.OtherMethod??string.Empty,out var desc)?desc:value.OtherMethod) @bind-Value="@value.OtherMethod" Items="@OtherMethodSelectedItems" ShowSearch="true" />
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
<EditorItem @bind-Field="@context.OtherMethod">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12 col-md-6">
|
||||
<Select IsVirtualize DefaultVirtualizeItemText=@(OtherMethods.TryGetValue(value.OtherMethod ?? string.Empty, out var desc) ? desc : value.OtherMethod) @bind-Value="@value.OtherMethod" Items="@OtherMethodSelectedItems" ShowSearch="true" />
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
|
||||
<EditorItem @bind-Field="@context.RegisterAddress">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12">
|
||||
<BootstrapInputGroup>
|
||||
@if(GlobalData.ReadOnlyIdDevices.TryGetValue(value.DeviceId,out var device)&&device.Driver is CollectBase collectBase)
|
||||
{
|
||||
<Textarea rows="1" title=@collectBase.GetAddressDescription() @bind-Value="value.RegisterAddress" ShowLabel="true"></Textarea>
|
||||
}
|
||||
else
|
||||
<EditorItem @bind-Field="@context.RegisterAddress">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12">
|
||||
<BootstrapInputGroup>
|
||||
@if(GlobalData.ReadOnlyIdDevices.TryGetValue(value.DeviceId,out var device)&&device.Driver is CollectBase collectBase)
|
||||
{
|
||||
<Textarea rows="1" title=@collectBase.GetAddressDescription() @bind-Value="value.RegisterAddress" ShowLabel="true"></Textarea>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Textarea rows="1" @bind-Value="value.RegisterAddress" ShowLabel="true"></Textarea>
|
||||
}
|
||||
<Button IsDisabled=@(AddressUIType==null) Icon="fa-solid fa-bars" OnClick="ShowAddressUI"></Button>
|
||||
</BootstrapInputGroup>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
<EditorItem @bind-Field="@context.ArrayLength" />
|
||||
<Button IsDisabled=@(AddressUIType == null) Icon="fa-solid fa-bars" OnClick="ShowAddressUI"></Button>
|
||||
</BootstrapInputGroup>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
<EditorItem @bind-Field="@context.ArrayLength" />
|
||||
|
||||
<EditorItem @bind-Field="@context.ReadExpressions" Rows="1" />
|
||||
<EditorItem @bind-Field="@context.WriteExpressions" Rows="1" />
|
||||
<EditorItem @bind-Field="@context.ReadExpressions">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12">
|
||||
<BootstrapInputGroup>
|
||||
|
||||
<Textarea rows="1" @bind-Value="value.ReadExpressions" ShowLabel="true"></Textarea>
|
||||
<Button Icon="fa-solid fa-bars" OnClick="() => ShowExpressionsUI(true)"></Button>
|
||||
</BootstrapInputGroup>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
<EditorItem @bind-Field="@context.WriteExpressions">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12">
|
||||
<BootstrapInputGroup>
|
||||
|
||||
<Textarea rows="1" @bind-Value="value.WriteExpressions" ShowLabel="true"></Textarea>
|
||||
<Button Icon="fa-solid fa-bars" OnClick="() => ShowExpressionsUI(false)"></Button>
|
||||
</BootstrapInputGroup>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
|
||||
|
||||
<EditorItem TValue="string" TModel="Variable" @bind-Field="@context.Description">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12">
|
||||
<h6>@GatewayLocalizer["Remark"]</h6>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
<EditorItem @bind-Field="@context.Remark1" />
|
||||
<EditorItem @bind-Field="@context.Remark2" />
|
||||
<EditorItem @bind-Field="@context.Remark3" />
|
||||
<EditorItem @bind-Field="@context.Remark4" />
|
||||
<EditorItem @bind-Field="@context.Remark5" />
|
||||
<EditorItem TValue="string" TModel="Variable" @bind-Field="@context.Description">
|
||||
<EditTemplate Context="value">
|
||||
<div class="col-12">
|
||||
<h6>@GatewayLocalizer["Remark"]</h6>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditorItem>
|
||||
<EditorItem @bind-Field="@context.Remark1" />
|
||||
<EditorItem @bind-Field="@context.Remark2" />
|
||||
<EditorItem @bind-Field="@context.Remark3" />
|
||||
<EditorItem @bind-Field="@context.Remark4" />
|
||||
<EditorItem @bind-Field="@context.Remark5" />
|
||||
|
||||
</FieldItems>
|
||||
</FieldItems>
|
||||
|
||||
</EditorForm>
|
||||
</TabItem>
|
||||
</EditorForm>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Text=@GatewayLocalizer["AlarmInformation"]>
|
||||
<EditorForm class="p-2" AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=2 LabelWidth=250 Model="Model">
|
||||
<FieldItems>
|
||||
<TabItem Text=@GatewayLocalizer["AlarmInformation"]>
|
||||
<EditorForm class="p-2" AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=2 LabelWidth=250 Model="Model">
|
||||
<FieldItems>
|
||||
|
||||
<EditorItem @bind-Field="@context.BoolCloseAlarmText" />
|
||||
<EditorItem @bind-Field="@context.BoolCloseRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.BoolCloseAlarmEnable" Rows="1" />
|
||||
<EditorItem @bind-Field="@context.BoolOpenAlarmText" />
|
||||
<EditorItem @bind-Field="@context.BoolOpenRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.BoolOpenAlarmEnable" Rows="1" />
|
||||
<EditorItem @bind-Field="@context.HHAlarmText" />
|
||||
<EditorItem @bind-Field="@context.HHAlarmCode" />
|
||||
<EditorItem @bind-Field="@context.HHRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.HHAlarmEnable" />
|
||||
<EditorItem @bind-Field="@context.HAlarmText" />
|
||||
<EditorItem @bind-Field="@context.HAlarmCode" />
|
||||
<EditorItem @bind-Field="@context.HRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.HAlarmEnable" />
|
||||
<EditorItem @bind-Field="@context.LAlarmText" />
|
||||
<EditorItem @bind-Field="@context.LAlarmCode" />
|
||||
<EditorItem @bind-Field="@context.LRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.LAlarmEnable" />
|
||||
<EditorItem @bind-Field="@context.LLAlarmText" />
|
||||
<EditorItem @bind-Field="@context.LLAlarmCode" />
|
||||
<EditorItem @bind-Field="@context.LLRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.LLAlarmEnable" />
|
||||
<EditorItem @bind-Field="@context.CustomAlarmText" />
|
||||
<EditorItem @bind-Field="@context.CustomAlarmCode" />
|
||||
<EditorItem @bind-Field="@context.CustomRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.CustomAlarmEnable" />
|
||||
<EditorItem @bind-Field="@context.AlarmDelay" />
|
||||
</FieldItems>
|
||||
</EditorForm>
|
||||
</TabItem>
|
||||
@if(!BatchEditEnable)
|
||||
{
|
||||
<EditorItem @bind-Field="@context.BoolCloseAlarmText" />
|
||||
<EditorItem @bind-Field="@context.BoolCloseRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.BoolCloseAlarmEnable" Rows="1" />
|
||||
<EditorItem @bind-Field="@context.BoolOpenAlarmText" />
|
||||
<EditorItem @bind-Field="@context.BoolOpenRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.BoolOpenAlarmEnable" Rows="1" />
|
||||
<EditorItem @bind-Field="@context.HHAlarmText" />
|
||||
<EditorItem @bind-Field="@context.HHAlarmCode" />
|
||||
<EditorItem @bind-Field="@context.HHRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.HHAlarmEnable" />
|
||||
<EditorItem @bind-Field="@context.HAlarmText" />
|
||||
<EditorItem @bind-Field="@context.HAlarmCode" />
|
||||
<EditorItem @bind-Field="@context.HRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.HAlarmEnable" />
|
||||
<EditorItem @bind-Field="@context.LAlarmText" />
|
||||
<EditorItem @bind-Field="@context.LAlarmCode" />
|
||||
<EditorItem @bind-Field="@context.LRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.LAlarmEnable" />
|
||||
<EditorItem @bind-Field="@context.LLAlarmText" />
|
||||
<EditorItem @bind-Field="@context.LLAlarmCode" />
|
||||
<EditorItem @bind-Field="@context.LLRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.LLAlarmEnable" />
|
||||
<EditorItem @bind-Field="@context.CustomAlarmText" />
|
||||
<EditorItem @bind-Field="@context.CustomAlarmCode" />
|
||||
<EditorItem @bind-Field="@context.CustomRestrainExpressions" />
|
||||
<EditorItem @bind-Field="@context.CustomAlarmEnable" />
|
||||
<EditorItem @bind-Field="@context.AlarmDelay" />
|
||||
</FieldItems>
|
||||
</EditorForm>
|
||||
</TabItem>
|
||||
@if (!BatchEditEnable)
|
||||
{
|
||||
<TabItem Text=@GatewayLocalizer["PluginInformation"]>
|
||||
<div class="min-height-500 px-4">
|
||||
<div class="row g-2 mx-1 form-inline">
|
||||
|
||||
<div class="col-12 col-md-8">
|
||||
<Select SkipValidate IsVirtualize DefaultVirtualizeItemText=@(GlobalData.ReadOnlyIdDevices.TryGetValue(ChoiceBusinessDeviceId,out var deviceRuntime)?deviceRuntime.Name:string.Empty) @bind-Value="@ChoiceBusinessDeviceId" Items="@BusinessDeviceItems" ShowSearch="true" ShowLabel="true" />
|
||||
<Select SkipValidate IsVirtualize DefaultVirtualizeItemText=@(GlobalData.ReadOnlyIdDevices.TryGetValue(ChoiceBusinessDeviceId, out var deviceRuntime) ? deviceRuntime.Name : string.Empty) @bind-Value="@ChoiceBusinessDeviceId" Items="@BusinessDeviceItems" ShowSearch="true" ShowLabel="true" />
|
||||
</div>
|
||||
<div class="col-12 col-md-4">
|
||||
<Button OnClick="async() =>{
|
||||
|
||||
await RefreshBusinessPropertyClickAsync(ChoiceBusinessDeviceId);
|
||||
foreach (var item in Model.VariablePropertyModels)
|
||||
{
|
||||
if(item.Value!=null)
|
||||
{
|
||||
item.Value.ValidateForm=null;
|
||||
}
|
||||
}
|
||||
}">
|
||||
@GatewayLocalizer["RefreshBusinessProperty"]
|
||||
</Button>
|
||||
</div>
|
||||
await RefreshBusinessPropertyClickAsync(ChoiceBusinessDeviceId);
|
||||
foreach (var item in Model.VariablePropertyModels)
|
||||
{
|
||||
if (item.Value != null)
|
||||
{
|
||||
item.Value.ValidateForm = null;
|
||||
}
|
||||
}
|
||||
}">
|
||||
@GatewayLocalizer["RefreshBusinessProperty"]
|
||||
</Button>
|
||||
</div>
|
||||
@if (Model.VariablePropertyModels != null)
|
||||
</div>
|
||||
@if (Model.VariablePropertyModels != null)
|
||||
{
|
||||
@foreach (var a in Model.VariablePropertyModels)
|
||||
{
|
||||
{
|
||||
|
||||
var item = a;
|
||||
var item = a;
|
||||
|
||||
var custom = VariablePropertyRenderFragments.TryGetValue(item.Key, out var renderFragment);
|
||||
var custom = VariablePropertyRenderFragments.TryGetValue(item.Key, out var renderFragment);
|
||||
|
||||
if (!custom)
|
||||
{
|
||||
var has = VariablePropertyEditors.TryGetValue(item.Key, out var items);
|
||||
if (has)
|
||||
{
|
||||
if (!custom)
|
||||
{
|
||||
var has = VariablePropertyEditors.TryGetValue(item.Key, out var items);
|
||||
if (has)
|
||||
{
|
||||
|
||||
|
||||
<Card IsShadow=true class="m-2 flex-fill" Color="Color.Primary">
|
||||
<HeaderTemplate>
|
||||
@{
|
||||
GlobalData.ReadOnlyIdDevices.TryGetValue(item.Key, out var items);
|
||||
<Card IsShadow=true class="m-2 flex-fill" Color="Color.Primary">
|
||||
<HeaderTemplate>
|
||||
@{
|
||||
GlobalData.ReadOnlyIdDevices.TryGetValue(item.Key, out var items);
|
||||
}
|
||||
<div class="flex-fill">
|
||||
@($"{items.Name} - {PluginServiceUtil.GetFileNameAndTypeName(items?.PluginName).TypeName}")
|
||||
</div>
|
||||
|
||||
<Button OnClick=@((a)=>
|
||||
{
|
||||
Model.VariablePropertyModels.TryRemove(item.Key, out _);
|
||||
}) class="mx-2" Color="Color.None" style="color: var(--bs-card-titlecolor);" Icon=@("fas fa-delete-left") />
|
||||
|
||||
</HeaderTemplate>
|
||||
|
||||
<BodyTemplate>
|
||||
|
||||
<ValidateForm Model="item.Value.Value" @ref=item.Value.ValidateForm
|
||||
@key=@($"VariableEditValidateForm{item.Key}{Model.Id}{item.Value.Value.GetType().TypeHandle.Value}")
|
||||
Id=@($"VariableEditValidateForm{item.Key}{Model.Id}{item.Value.Value.GetType().TypeHandle.Value}")>
|
||||
|
||||
<EditorFormObject class="p-2" Items=items AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=2 ShowLabelTooltip=true LabelWidth=150 Model="item.Value.Value" @key=@($"VariableEditEditorFormObject{item.Key}{Model.Id}{item.Value.Value.GetType().TypeHandle.Value}")>
|
||||
|
||||
</EditorFormObject>
|
||||
</ValidateForm>
|
||||
</BodyTemplate>
|
||||
</Card>
|
||||
}
|
||||
<div class="flex-fill">
|
||||
@($"{items.Name} - {PluginServiceUtil.GetFileNameAndTypeName(items?.PluginName).TypeName}")
|
||||
</div>
|
||||
|
||||
<Button OnClick=@((a)=>
|
||||
{
|
||||
Model.VariablePropertyModels.TryRemove(item.Key,out _);
|
||||
}) class="mx-2" Color="Color.None" style="color: var(--bs-card-titlecolor);" Icon=@("fas fa-delete-left") />
|
||||
|
||||
</HeaderTemplate>
|
||||
|
||||
<BodyTemplate>
|
||||
|
||||
<ValidateForm Model="item.Value.Value" @ref=item.Value.ValidateForm
|
||||
@key=@($"VariableEditValidateForm{item.Key}{Model.Id}{item.Value.Value.GetType().TypeHandle.Value}")
|
||||
Id=@($"VariableEditValidateForm{item.Key}{Model.Id}{item.Value.Value.GetType().TypeHandle.Value}")>
|
||||
|
||||
<EditorFormObject class="p-2" Items=items AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=2 ShowLabelTooltip=true LabelWidth=150 Model="item.Value.Value" @key=@($"VariableEditEditorFormObject{item.Key}{Model.Id}{item.Value.Value.GetType().TypeHandle.Value}")>
|
||||
|
||||
</EditorFormObject>
|
||||
</ValidateForm>
|
||||
</BodyTemplate>
|
||||
</Card>
|
||||
}
|
||||
else
|
||||
{
|
||||
@renderFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@renderFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</TabItem>
|
||||
</TabItem>
|
||||
}
|
||||
</Tab>;
|
||||
</Tab>;
|
||||
}
|
@@ -163,7 +163,37 @@ public partial class VariableEditComponent
|
||||
op.Component = AddressDynamicComponent;
|
||||
await DialogService.Show(op);
|
||||
}
|
||||
|
||||
[Inject]
|
||||
IStringLocalizer<Variable> VariableLocalizer { get; set; }
|
||||
private async Task ShowExpressionsUI(bool read)
|
||||
{
|
||||
var op = new DialogOption()
|
||||
{
|
||||
IsScrolling = false,
|
||||
ShowMaximizeButton = true,
|
||||
Size = Size.Large,
|
||||
Title = $"{Model.Name} {(read ? VariableLocalizer[nameof(Variable.ReadExpressions)] : VariableLocalizer[nameof(Variable.WriteExpressions)])}",
|
||||
ShowFooter = false,
|
||||
ShowCloseButton = false,
|
||||
BodyTemplate = BootstrapDynamicComponent.CreateComponent<ValueTransformConfigPage>(new Dictionary<string, object?>
|
||||
{
|
||||
{nameof(ValueTransformConfigPage.ExpressionsChanged), EventCallback.Factory.Create<string>(this,a =>
|
||||
{
|
||||
if(read)
|
||||
{
|
||||
Model.ReadExpressions = a;
|
||||
}
|
||||
else
|
||||
{
|
||||
Model.WriteExpressions=a;
|
||||
}
|
||||
})
|
||||
},
|
||||
{nameof(ValueTransformConfigPage.Expressions),read?Model.ReadExpressions:Model.WriteExpressions },
|
||||
}).Render(),
|
||||
};
|
||||
await DialogService.Show(op);
|
||||
}
|
||||
|
||||
[Inject]
|
||||
private IStringLocalizer<Device> DeviceLocalizer { get; set; }
|
||||
|
@@ -35,6 +35,8 @@
|
||||
<TableColumn @bind-Field="@context.Name" ShowTips=true Filterable=true Sortable=true Visible=true />
|
||||
<TableColumn @bind-Field="@context.Description" ShowTips=true Filterable=true Sortable=true Visible=true />
|
||||
<TableColumn @bind-Field="@context.BusinessGroup" ShowTips=true Filterable=true Sortable=true Visible=true />
|
||||
<TableColumn @bind-Field="@context.BusinessGroupUpdateTrigger" ShowTips=true Filterable=true Sortable=true Visible=false />
|
||||
<TableColumn @bind-Field="@context.RpcWriteCheck" ShowTips=true Filterable=true Sortable=true Visible=false />
|
||||
|
||||
<TableColumn @bind-Field="@context.Enable" Filterable=true Sortable=true Visible="false" />
|
||||
<TableColumn Field="@context.ChangeTime" ShowTips=true FieldExpression=@(()=>context.ChangeTime) Filterable=true Sortable=true Visible=false />
|
||||
|
@@ -44,9 +44,17 @@ namespace ThingsGateway.Gateway.Razor
|
||||
if(Node is IConditionNode conditionNode)
|
||||
return (await conditionNode.ExecuteAsync(new NodeInput(){Value=a==null?a:JToken.Parse(a??string.Empty) },default).ConfigureAwait(false)).ToString();
|
||||
if(Node is IExpressionNode expressionNode)
|
||||
return (await expressionNode.ExecuteAsync(new NodeInput(){Value=a==null?a:JToken.Parse(a??string.Empty) },default).ConfigureAwait(false)).JToken?.ToString();
|
||||
{
|
||||
var data=await expressionNode.ExecuteAsync(new NodeInput(){Value=a==null?a:JToken.Parse(a??string.Empty) },default).ConfigureAwait(false);
|
||||
|
||||
return data.IsSuccess? data.Content.JToken?.ToString()??string.Empty: data.ToString();
|
||||
}
|
||||
if(Node is IActuatorNode actuatorNode)
|
||||
return (await actuatorNode.ExecuteAsync(new NodeInput(){Value=a==null?a:JToken.Parse(a??string.Empty) },default).ConfigureAwait(false)).JToken?.ToString();
|
||||
{
|
||||
var data=await actuatorNode.ExecuteAsync(new NodeInput(){Value=a==null?a:JToken.Parse(a??string.Empty) },default).ConfigureAwait(false);
|
||||
|
||||
return data.IsSuccess? data.Content.JToken?.ToString()??string.Empty: data.ToString();
|
||||
}
|
||||
return string.Empty;
|
||||
}) },
|
||||
{nameof(ScriptEdit.Script),Node.Text },
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<PackageOutputPath>$(SolutionDir)..\..\nupkgs</PackageOutputPath>
|
||||
<PackageOutputPath>$(MSBuildThisFileDirectory)..\..\nupkgs</PackageOutputPath>
|
||||
<PackageVersion>$(Version)</PackageVersion>
|
||||
<PackageTags>ThingsGateway;Diego;Blazor;IOT;设备采集;边缘网关;物联网</PackageTags>
|
||||
<PackageProjectUrl>https://gitee.com/diego2098/ThingsGateway</PackageProjectUrl>
|
||||
@@ -19,13 +19,13 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(SolutionDir)PackNuget.props" Pack="true" PackagePath="\" />
|
||||
<None Include="$(MSBuildThisFileDirectory)PackNuget.props" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(SolutionDir)..\README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="$(SolutionDir)..\README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
<None Include="$(SolutionDir)..\LICENSE" Pack="true" PackagePath="\" />
|
||||
<None Include="$(SolutionDir)..\icon.png" Pack="true" PackagePath="\" />
|
||||
<None Include="$(MSBuildThisFileDirectory)..\README.md" Pack="true" PackagePath="\" />
|
||||
<None Include="$(MSBuildThisFileDirectory)..\README.zh-CN.md" Pack="true" PackagePath="\" />
|
||||
<None Include="$(MSBuildThisFileDirectory)..\LICENSE" Pack="true" PackagePath="\" />
|
||||
<None Include="$(MSBuildThisFileDirectory)..\icon.png" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
|
@@ -12,4 +12,4 @@ global using Microsoft.AspNetCore.Components;
|
||||
|
||||
global using ThingsGateway.Razor;
|
||||
|
||||
[assembly: BlazorSetParametersAsyncGenerator.GlobalGenerateSetParametersAsync(true)]
|
||||
[assembly: GlobalGenerateSetParametersAsync(true)]
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
<!--<UseRazorSourceGenerator>false</UseRazorSourceGenerator>-->
|
||||
|
@@ -162,7 +162,7 @@ public class Dlt645_2007Master : DtuServiceDeviceBase
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("State must be of type Dlt645_2007Address", nameof(state));
|
||||
return EasyValueTask.FromResult(new OperResult<byte[]>(new ArgumentException("State must be of type Dlt645_2007Address", nameof(state))));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)Foundation.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="..\..\Foundation.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<PropertyGroup>
|
||||
<Description>工业设备通讯协议-Dlt645协议</Description>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
|
@@ -108,7 +108,7 @@ public partial class ModbusMaster : DtuServiceDeviceBase, IModbusAddress
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("State must be of type ModbusAddress", nameof(state));
|
||||
return EasyValueTask.FromResult(new OperResult<byte[]>(new ArgumentException("State must be of type ModbusAddress", nameof(state))));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@@ -329,7 +329,7 @@ public class ModbusSlave : DeviceBase, IModbusAddress
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("State must be of type ModbusAddress", nameof(state));
|
||||
return EasyValueTask.FromResult(new OperResult<byte[]>(new ArgumentException("State must be of type ModbusAddress", nameof(state))));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)Foundation.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="..\..\Foundation.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<PropertyGroup>
|
||||
<Description>工业设备通讯协议-Modbus协议</Description>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net462;netstandard2.0;net6.0;</TargetFrameworks>
|
||||
<Description>工业设备通讯协议-OpcDa协议</Description>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net48;netstandard2.1;net6.0;</TargetFrameworks>
|
||||
<Description>工业设备通讯协议-OpcUa协议</Description>
|
||||
|
@@ -139,27 +139,36 @@ public partial class SiemensS7Master : DeviceBase
|
||||
{
|
||||
int num = 0;
|
||||
var addressLen = sAddress.Length == 0 ? 1 : sAddress.Length;
|
||||
while (num < addressLen)
|
||||
var start = sAddress.AddressStart;
|
||||
try
|
||||
{
|
||||
//pdu长度,重复生成报文,直至全部生成
|
||||
int len = Math.Min(addressLen - num, PduLength);
|
||||
sAddress.Length = len;
|
||||
|
||||
var result = await SendThenReturnAsync(new S7Send([sAddress], true), cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return result;
|
||||
|
||||
byteBlock.Write(result.Content);
|
||||
num += len;
|
||||
|
||||
if (sAddress.DataCode == S7Area.TM || sAddress.DataCode == S7Area.CT)
|
||||
while (num < addressLen)
|
||||
{
|
||||
sAddress.AddressStart += len / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
sAddress.AddressStart += len * 8;
|
||||
//pdu长度,重复生成报文,直至全部生成
|
||||
int len = Math.Min(addressLen - num, PduLength);
|
||||
sAddress.Length = len;
|
||||
var result = await SendThenReturnAsync(new S7Send([sAddress], true), cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
if (!result.IsSuccess) return result;
|
||||
|
||||
byteBlock.Write(result.Content);
|
||||
num += len;
|
||||
|
||||
if (sAddress.DataCode == S7Area.TM || sAddress.DataCode == S7Area.CT)
|
||||
{
|
||||
sAddress.AddressStart += len / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
sAddress.AddressStart += len * 8;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
sAddress.AddressStart = start;
|
||||
}
|
||||
}
|
||||
|
||||
return new OperResult<byte[]>() { Content = byteBlock.ToArray() };
|
||||
@@ -308,7 +317,7 @@ public partial class SiemensS7Master : DeviceBase
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("State must be of type SiemensS7Address", nameof(state));
|
||||
return EasyValueTask.FromResult(new OperResult<byte[]>(new ArgumentException("State must be of type SiemensS7Address", nameof(state))));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -361,6 +370,7 @@ public partial class SiemensS7Master : DeviceBase
|
||||
{
|
||||
try
|
||||
{
|
||||
SetDataAdapter(channel);
|
||||
AutoConnect = false;
|
||||
var ISO_CR = SiemensHelper.ISO_CR;
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="$(SolutionDir)Foundation.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="..\..\Foundation.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<PropertyGroup>
|
||||
<Description>工业设备通讯协议-SiemensS7协议</Description>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
|
@@ -75,7 +75,7 @@ public partial class QuestDBProducer : BusinessBaseWithCacheIntervalVariableMode
|
||||
|
||||
private void UpdateVariable(VariableRuntime variableRuntime, VariableBasicData variable)
|
||||
{
|
||||
if (_driverPropertys.GroupUpdate && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
if (_driverPropertys.GroupUpdate && variable.BusinessGroupUpdateTrigger && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
{
|
||||
|
||||
AddQueueVarModel(new CacheDBItem<List<VariableBasicData>>(variableRuntimeGroup.Adapt<List<VariableBasicData>>(_config)));
|
||||
|
@@ -82,7 +82,7 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariableModel<
|
||||
{
|
||||
if (_driverPropertys.IsHistoryDB)
|
||||
{
|
||||
if (_driverPropertys.GroupUpdate && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
if (_driverPropertys.GroupUpdate && variable.BusinessGroupUpdateTrigger && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
{
|
||||
|
||||
AddQueueVarModel(new CacheDBItem<List<VariableBasicData>>(variableRuntimeGroup.Adapt<List<VariableBasicData>>(_config)));
|
||||
|
@@ -77,7 +77,7 @@ public partial class TDengineDBProducer : BusinessBaseWithCacheIntervalVariableM
|
||||
|
||||
private void UpdateVariable(VariableRuntime variableRuntime, VariableBasicData variable)
|
||||
{
|
||||
if (_driverPropertys.GroupUpdate && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
if (_driverPropertys.GroupUpdate && variable.BusinessGroupUpdateTrigger && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
{
|
||||
|
||||
AddQueueVarModel(new CacheDBItem<List<VariableBasicData>>(variableRuntimeGroup.Adapt<List<VariableBasicData>>(_config)));
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
@@ -1,13 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Foundation\ThingsGateway.Foundation.Razor\ThingsGateway.Foundation.Razor.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Gateway\ThingsGateway.Gateway.Razor\ThingsGateway.Gateway.Razor.csproj">
|
||||
<ProjectReference Include="..\..\Gateway\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj">
|
||||
</ProjectReference>
|
||||
|
||||
|
||||
|
@@ -118,7 +118,7 @@ public partial class Webhook : BusinessBaseWithCacheIntervalScript<VariableBasic
|
||||
{
|
||||
if (!_businessPropertyWithCacheIntervalScript.VariableTopic.IsNullOrWhiteSpace())
|
||||
{
|
||||
if (_driverPropertys.GroupUpdate && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
if (_driverPropertys.GroupUpdate && variable.BusinessGroupUpdateTrigger && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
{
|
||||
|
||||
AddQueueVarModel(new CacheDBItem<List<VariableBasicData>>(variableRuntimeGroup.Adapt<List<VariableBasicData>>()));
|
||||
|
@@ -112,7 +112,7 @@ public partial class KafkaProducer : BusinessBaseWithCacheIntervalScript<Variabl
|
||||
{
|
||||
if (!_businessPropertyWithCacheIntervalScript.VariableTopic.IsNullOrWhiteSpace())
|
||||
{
|
||||
if (_driverPropertys.GroupUpdate && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
if (_driverPropertys.GroupUpdate && variable.BusinessGroupUpdateTrigger && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
{
|
||||
|
||||
AddQueueVarModel(new CacheDBItem<List<VariableBasicData>>(variableRuntimeGroup.Adapt<List<VariableBasicData>>()));
|
||||
|
@@ -1,13 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Foundation\ThingsGateway.Foundation.Razor\ThingsGateway.Foundation.Razor.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Gateway\ThingsGateway.Gateway.Razor\ThingsGateway.Gateway.Razor.csproj">
|
||||
<ProjectReference Include="..\..\Gateway\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj">
|
||||
</ProjectReference>
|
||||
<PackageReference Include="Confluent.Kafka" Version="2.10.1" GeneratePathProperty="true">
|
||||
<PrivateAssets>contentFiles;compile;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
@@ -170,7 +170,7 @@ public partial class MqttClient : BusinessBaseWithCacheIntervalScript<VariableBa
|
||||
{
|
||||
if (!_businessPropertyWithCacheIntervalScript.VariableTopic.IsNullOrWhiteSpace())
|
||||
{
|
||||
if (_driverPropertys.GroupUpdate && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
if (_driverPropertys.GroupUpdate && variable.BusinessGroupUpdateTrigger && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
{
|
||||
//获取组内全部变量
|
||||
AddQueueVarModel(new CacheDBItem<List<VariableBasicData>>(variableRuntimeGroup.Adapt<List<VariableBasicData>>()));
|
||||
|
@@ -126,7 +126,7 @@ public partial class MqttServer : BusinessBaseWithCacheIntervalScript<VariableBa
|
||||
{
|
||||
if (!_businessPropertyWithCacheIntervalScript.VariableTopic.IsNullOrWhiteSpace())
|
||||
{
|
||||
if (_driverPropertys.GroupUpdate && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
if (_driverPropertys.GroupUpdate && variable.BusinessGroupUpdateTrigger && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
{
|
||||
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
@@ -10,6 +10,8 @@
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
using ThingsGateway.Foundation.OpcDa;
|
||||
using ThingsGateway.Foundation.OpcDa.Da;
|
||||
using ThingsGateway.Gateway.Application;
|
||||
@@ -159,7 +161,7 @@ public class OpcDaMaster : CollectBase
|
||||
try
|
||||
{
|
||||
var result = _plc.WriteItem(writeInfoLists.ToDictionary(a => a.Key.RegisterAddress!, a => a.Value.GetObjectFromJToken()!));
|
||||
return result.ToDictionary<KeyValuePair<string, Tuple<bool, string>>, string, OperResult>(a =>
|
||||
var results = new ConcurrentDictionary<string, OperResult>(result.ToDictionary<KeyValuePair<string, Tuple<bool, string>>, string, OperResult>(a =>
|
||||
{
|
||||
return writeInfoLists.Keys.FirstOrDefault(b => b.RegisterAddress == a.Key).Name;
|
||||
}, a =>
|
||||
@@ -169,7 +171,11 @@ public class OpcDaMaster : CollectBase
|
||||
else
|
||||
return OperResult.Success;
|
||||
}
|
||||
);
|
||||
));
|
||||
|
||||
await Check(writeInfoLists, results, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return new(results);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
@@ -13,6 +13,8 @@ using Newtonsoft.Json.Linq;
|
||||
using Opc.Ua;
|
||||
using Opc.Ua.Client;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
using ThingsGateway.Foundation.Extension.Generic;
|
||||
using ThingsGateway.Foundation.OpcUa;
|
||||
using ThingsGateway.Gateway.Application;
|
||||
@@ -281,7 +283,7 @@ public class OpcUaMaster : CollectBase
|
||||
try
|
||||
{
|
||||
var result = await _plc.WriteNodeAsync(writeInfoLists.ToDictionary(a => a.Key.RegisterAddress!, a => a.Value), cancellationToken).ConfigureAwait(false);
|
||||
return result.ToDictionary<KeyValuePair<string, Tuple<bool, string>>, string, OperResult>(a =>
|
||||
var results = new ConcurrentDictionary<string, OperResult>(result.ToDictionary<KeyValuePair<string, Tuple<bool, string>>, string, OperResult>(a =>
|
||||
{
|
||||
return writeInfoLists.Keys.FirstOrDefault(b => b.RegisterAddress == a.Key)?.Name!;
|
||||
}
|
||||
@@ -291,7 +293,12 @@ public class OpcUaMaster : CollectBase
|
||||
return new OperResult(a.Value.Item2);
|
||||
else
|
||||
return OperResult.Success;
|
||||
})!;
|
||||
}));
|
||||
|
||||
await Check(writeInfoLists, results, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return new(results);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
@@ -113,7 +113,7 @@ public partial class RabbitMQProducer : BusinessBaseWithCacheIntervalScript<Vari
|
||||
{
|
||||
if (!_businessPropertyWithCacheIntervalScript.VariableTopic.IsNullOrWhiteSpace())
|
||||
{
|
||||
if (_driverPropertys.GroupUpdate && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
if (_driverPropertys.GroupUpdate && variable.BusinessGroupUpdateTrigger && !variable.BusinessGroup.IsNullOrEmpty() && VariableRuntimeGroups.TryGetValue(variable.BusinessGroup, out var variableRuntimeGroup))
|
||||
|
||||
{
|
||||
//获取组内全部变量
|
||||
|
@@ -1,13 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Foundation\ThingsGateway.Foundation.Razor\ThingsGateway.Foundation.Razor.csproj">
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Gateway\ThingsGateway.Gateway.Razor\ThingsGateway.Gateway.Razor.csproj">
|
||||
<ProjectReference Include="..\..\Gateway\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj">
|
||||
</ProjectReference>
|
||||
|
||||
</ItemGroup>
|
||||
|
@@ -179,6 +179,7 @@ public class SiemensS7Master : CollectFoundationBase
|
||||
}
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
await Check(writeInfoLists, operResults, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// 返回包含操作结果的字典
|
||||
return new Dictionary<string, OperResult>(operResults);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Import Project="$(SolutionDir)Version.props" />
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user