Compare commits

...

4 Commits

Author SHA1 Message Date
Diego
9ee638c2f1 更新依赖包 2025-07-08 23:59:24 +08:00
Diego
d90fdbaf35 补充更新nuget包 2025-07-08 18:15:50 +08:00
Diego
b55e3db736 10.9.29 2025-07-08 17:55:37 +08:00
Diego
dbee8496cb opcuaServer支持decimal类型 2025-07-08 16:53:28 +08:00
14 changed files with 40 additions and 110 deletions

View File

@@ -38,7 +38,7 @@
<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" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">

View File

@@ -106,58 +106,6 @@ public static class DictionaryExtensions
}
/// <summary>
/// 批量出队
/// </summary>
public static IEnumerable<T> ToIEnumerableWithDequeue<TKEY, T>(this ConcurrentDictionary<TKEY, T> values, int maxCount = 0)
{
if (values.IsEmpty) yield break;
if (maxCount <= 0)
{
maxCount = values.Count;
}
else
{
maxCount = Math.Min(maxCount, values.Count);
}
var keys = values.Keys;
foreach (var key in keys)
{
if (maxCount-- <= 0) break;
if (values.TryRemove(key, out var result))
{
yield return result;
}
}
}
/// <summary>
/// 批量出队
/// </summary>
public static IEnumerable<TKEY> ToIEnumerableWithDequeue<TKEY>(this ConcurrentHashSet<TKEY> values, int maxCount = 0)
{
if (values.IsEmpty) yield break;
if (maxCount <= 0)
{
maxCount = values.Count;
}
else
{
maxCount = Math.Min(maxCount, values.Count);
}
var keys = values.Keys;
foreach (var key in keys)
{
if (maxCount-- <= 0) break;
if (values.TryRemove(key))
{
yield return key;
}
}
}
/// <summary>
/// 批量出队
@@ -216,35 +164,9 @@ public static class DictionaryExtensions
}
}
/// <summary>
/// 批量出队
/// </summary>
public static List<TKEY> ToListWithDequeue<TKEY>(this ConcurrentHashSet<TKEY> values, int maxCount = 0)
{
List<TKEY> result = new();
if (values.IsEmpty) return result;
if (maxCount <= 0)
{
maxCount = values.Count;
}
else
{
maxCount = Math.Min(maxCount, values.Count);
}
var keys = values.Keys;
foreach (var key in keys)
{
if (maxCount-- <= 0) break;
if (values.TryRemove(key))
{
result.Add(key);
}
}
return result;
}
}

View File

@@ -1,11 +1,11 @@
<Project>
<PropertyGroup>
<PluginVersion>10.9.27</PluginVersion>
<ProPluginVersion>10.9.26</ProPluginVersion>
<DefaultVersion>10.9.27</DefaultVersion>
<AuthenticationVersion>2.9.13</AuthenticationVersion>
<SourceGeneratorVersion>10.9.13</SourceGeneratorVersion>
<PluginVersion>10.9.33</PluginVersion>
<ProPluginVersion>10.9.33</ProPluginVersion>
<DefaultVersion>10.9.33</DefaultVersion>
<AuthenticationVersion>2.9.16</AuthenticationVersion>
<SourceGeneratorVersion>10.9.15</SourceGeneratorVersion>
<NET8Version>8.0.17</NET8Version>
<NET9Version>9.0.6</NET9Version>
<SatelliteResourceLanguages>zh-Hans;en-US</SatelliteResourceLanguages>

View File

@@ -10,8 +10,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(NET9Version)" />
<PackageReference Include="TouchSocket" Version="3.1.11" />
<PackageReference Include="TouchSocket.SerialPorts" Version="3.1.11" />
<PackageReference Include="TouchSocket" Version="3.1.12" />
<PackageReference Include="TouchSocket.SerialPorts" Version="3.1.12" />
</ItemGroup>
<ItemGroup>

View File

@@ -10,8 +10,8 @@
<PackageReference Include="Riok.Mapperly" Version="4.2.1" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Rougamo.Fody" Version="5.0.1" />
<PackageReference Include="System.Linq.Async" Version="6.0.3" />
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.11" />
<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.1.11" />
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.12" />
<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.1.12" />
<PackageReference Include="ThingsGateway.Authentication" Version="$(AuthenticationVersion)" />
<!--<ProjectReference Include="..\..\PluginPro\ThingsGateway.Authentication\ThingsGateway.Authentication.csproj" />-->

View File

@@ -1419,7 +1419,7 @@ EventCallback.Factory.Create<MouseEventArgs>(this, async e =>
{
if (item.PluginType == PluginTypeEnum.Collect)
collectChannelDevices.Add(item, new());
else if (item.PluginType == PluginTypeEnum.Collect)
else if (item.PluginType == PluginTypeEnum.Business)
businessChannelDevices.Add(item, new());
else
otherChannelDevices.Add(item, new());

View File

@@ -116,7 +116,8 @@ public static class JsonUtils
case BuiltInType.Int64: { return decoder.ReadInt64(fieldName); }
case BuiltInType.UInt64: { return decoder.ReadUInt64(fieldName); }
case BuiltInType.Float: { return decoder.ReadFloat(fieldName); }
case BuiltInType.Double: { return decoder.ReadDouble(fieldName); }
case BuiltInType.Double:
case BuiltInType.Number: { return decoder.ReadDouble(fieldName); }
case BuiltInType.String:
{
if (decoder.ReadField(fieldName, out var value))
@@ -288,7 +289,7 @@ public static class JsonUtils
}
case BuiltInType.Number:
{
encoder.WriteInt64(fieldName, Convert.ToInt64(value));
encoder.WriteDouble(fieldName, Convert.ToInt64(value));
return;
}
case BuiltInType.UInteger:

View File

@@ -147,9 +147,10 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariable, IDBH
{
if (_driverPropertys.IsReadDB)
{
var list = RealTimeVariables.ToListWithDequeue();
try
{
var varLists = RealTimeVariables.ToIEnumerableWithDequeue().Batch(100000);
var varLists = list.Batch(100000);
foreach (var varList in varLists)
{
var result = await UpdateAsync(varList, cancellationToken).ConfigureAwait(false);
@@ -166,6 +167,11 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariable, IDBH
if (success)
LogMessage?.LogWarning(ex);
success = false;
list.ForEach(variable =>
{
RealTimeVariables.AddOrUpdate(variable.Id, variable, (key, oldValue) => variable);
});
}
}

View File

@@ -172,7 +172,7 @@ public class ModbusSlave : BusinessBase
await Task.Delay(10000, cancellationToken).ConfigureAwait(false);
}
}
var list = ModbusVariableQueue.ToIEnumerableKVWithDequeue();
var list = ModbusVariableQueue.ToDictWithDequeue();
foreach (var item in list)
{
if (cancellationToken.IsCancellationRequested)

View File

@@ -226,7 +226,7 @@ public class ThingsGatewayNodeManager : CustomNodeManager2
/// 更新变量
/// </summary>
/// <param name="variable"></param>
public void UpVariable(VariableRuntime variable)
public void UpVariable(VariableBasicData variable)
{
if (!NodeIdTags.TryGetValue($"{variable.DeviceName}.{variable.Name}", out var uaTag))
return;
@@ -287,6 +287,8 @@ public class ThingsGatewayNodeManager : CustomNodeManager2
return DataTypeIds.String;
if (tp == typeof(DateTime))
return DataTypeIds.DateTime;
if (tp == typeof(decimal))
return DataTypeIds.Decimal;
return DataTypeIds.String;
}

View File

@@ -14,9 +14,10 @@ using Microsoft.Extensions.Logging;
using Opc.Ua;
using Opc.Ua.Configuration;
using System.Collections.Concurrent;
using ThingsGateway.Extension.Generic;
using ThingsGateway.Gateway.Application;
using ThingsGateway.NewLife.Collections;
using ThingsGateway.NewLife.DictionaryExtensions;
using TouchSocket.Core;
@@ -43,7 +44,7 @@ public partial class OpcUaServer : BusinessBase
protected override BusinessPropertyBase _businessPropertyBase => _driverPropertys;
protected IStringLocalizer Localizer { get; private set; }
private ConcurrentHashSet<long> CollectVariableRuntimes { get; set; } = new();
private ConcurrentDictionary<long, VariableBasicData> CollectVariableRuntimes { get; set; } = new();
private static readonly string[] separator = new string[] { ";" };
@@ -167,10 +168,11 @@ public partial class OpcUaServer : BusinessBase
{
try
{
await Task.Delay(3000, cancellationToken).ConfigureAwait(false);
await Task.Delay(2000, cancellationToken).ConfigureAwait(false);
await m_application.CheckApplicationInstanceCertificates(true, 1200, cancellationToken).ConfigureAwait(false);
await m_application.Start(m_server).ConfigureAwait(false);
connect_success = true;
await Task.Delay(2000, cancellationToken).ConfigureAwait(false);
IdVariableRuntimes.ForEach(a =>
{
VariableValueChange(a.Value, a.Value.AdaptVariableBasicData());
@@ -191,10 +193,7 @@ public partial class OpcUaServer : BusinessBase
{
if (!cancellationToken.IsCancellationRequested)
{
if (IdVariableRuntimes.TryGetValue(item, out var variableRuntime) && variableRuntime != null)
{
m_server?.NodeManager?.UpVariable(variableRuntime);
}
m_server?.NodeManager?.UpVariable(item);
}
else
{
@@ -407,12 +406,12 @@ public partial class OpcUaServer : BusinessBase
}
private void VariableValueChange(VariableRuntime variableRuntime, VariableBasicData variableData)
{
if (CurrentDevice.Pause)
return;
//if (CurrentDevice.Pause)
// return;
if (TaskSchedulerLoop?.Stoped == true) return;
if (DisposedValue) return;
if (IdVariableRuntimes.ContainsKey(variableData.Id))
CollectVariableRuntimes.TryAdd(variableData.Id);
CollectVariableRuntimes.AddOrUpdate(variableData.Id, variableData, (a, b) => variableData);
else
{

View File

@@ -1,7 +1,7 @@
<Project>
<ItemGroup>
<PackageReference Include="ThingsGateway.Plugin.Synchronization" Version="$(ProPluginVersion)" GeneratePathProperty="true">
<PackageReference Include="ThingsGateway.Plugin.SyncBridge" Version="$(ProPluginVersion)" GeneratePathProperty="true">
<Private>false</Private>
<IncludeAssets> native;</IncludeAssets>
</PackageReference>
@@ -64,7 +64,7 @@
<PkgThingsGateway_Plugin_SECSPackageFiles Include="$(PkgThingsGateway_Plugin_SECS)\Content\$(PluginTargetFramework)\**\*.*" />
<PkgThingsGateway_Plugin_TS550PackageFiles Include="$(PkgThingsGateway_Plugin_TS550)\Content\$(PluginTargetFramework)\**\*.*" />
<PkgThingsGateway_Plugin_VigorPackageFiles Include="$(PkgThingsGateway_Plugin_Vigor)\Content\$(PluginTargetFramework)\**\*.*" />
<PkgThingsGateway_Plugin_SynchronizationPackageFiles Include="$(PkgThingsGateway_Plugin_Synchronization)\Content\$(PluginTargetFramework)\**\*.*" />
<PkgThingsGateway_Plugin_SyncBridgePackageFiles Include="$(PkgThingsGateway_Plugin_SyncBridge)\Content\$(PluginTargetFramework)\**\*.*" />
</ItemGroup>
<PropertyGroup>
@@ -91,7 +91,7 @@
<Copy SourceFiles="@(PkgThingsGateway_Plugin_TS550PackageFiles)" DestinationFolder="$(PluginFolder)ThingsGateway.Plugin.TS550%(RecursiveDir)" />
<Copy SourceFiles="@(PkgThingsGateway_Plugin_VigorPackageFiles)" DestinationFolder="$(PluginFolder)ThingsGateway.Plugin.Vigor%(RecursiveDir)" />
<Copy SourceFiles="@(PkgThingsGateway_Plugin_VigorPackageFiles)" DestinationFolder="$(PluginFolder)ThingsGateway.Plugin.Synchronization%(RecursiveDir)" />
<Copy SourceFiles="@(PkgThingsGateway_Plugin_SyncBridgePackageFiles)" DestinationFolder="$(PluginFolder)ThingsGateway.Plugin.SyncBridge%(RecursiveDir)" />
</Target>
</Project>

View File

@@ -1,7 +1,7 @@
<Project>
<ItemGroup>
<ProjectReference Include="..\PluginPro\ThingsGateway.Plugin.Synchronization\ThingsGateway.Plugin.Synchronization.csproj" />
<ProjectReference Include="..\PluginPro\ThingsGateway.Plugin.SyncBridge\ThingsGateway.Plugin.SyncBridge.csproj" />
<ProjectReference Include="..\PluginPro\ThingsGateway.Plugin.AllenBradleyCip\ThingsGateway.Plugin.AllenBradleyCip.csproj" />
<ProjectReference Include="..\PluginPro\ThingsGateway.Plugin.BACnet\ThingsGateway.Plugin.BACnet.csproj" />

View File

@@ -16,7 +16,7 @@
<ItemGroup>
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.11" />
<PackageReference Include="TouchSocket.Dmtp" Version="3.1.12" />
<PackageReference Include="Riok.Mapperly" Version="4.2.1" ExcludeAssets="runtime" PrivateAssets="all" />
</ItemGroup>