Compare commits

...

7 Commits

Author SHA1 Message Date
2248356998 qq.com
6c95c6209f 10.11.41 2025-09-13 14:22:13 +08:00
2248356998 qq.com
4d223d2622 10.11.40 2025-09-13 13:00:52 +08:00
yunqi
e8d7e91b64 !74 modify dlt645_2007 buildcmd
* modify dlt645_2007 buildcmd
2025-09-13 04:59:10 +00:00
2248356998 qq.com
8175f541ec 更新基准测试 2025-09-12 23:53:36 +08:00
2248356998 qq.com
0adbdb926b 更新基准测试 2025-09-12 23:49:18 +08:00
Diego
42adee9980 更新依赖 2025-09-11 22:22:39 +08:00
2248356998 qq.com
427a7404bc 更新UI 2025-09-11 19:05:14 +08:00
28 changed files with 223 additions and 94 deletions

View File

@@ -4,9 +4,9 @@
<div class="tg-table h-100">
<Table TItem="TItem" IsBordered="true" IsStriped="true" TableSize="TableSize.Compact" IsMultipleSelect="IsMultipleSelect" @ref="Instance" SearchTemplate="SearchTemplate"
<Table TItem="TItem" IsBordered="true" IsStriped="true" TableSize="TableSize.Compact" SelectedRows=SelectedRows SelectedRowsChanged=privateSelectedRowsChanged IsMultipleSelect="IsMultipleSelect" @ref="Instance" SearchTemplate="SearchTemplate"
DataService="DataService" CreateItemCallback="CreateItemCallback!"
IsPagination="IsPagination" PageItemsSource="PageItemsSource" IsFixedHeader="IsFixedHeader" IndentSize=24 RowHeight=RowHeight ShowSearchText="ShowSearchText" ShowSearchButton="ShowSearchButton" BeforeShowEditDialogCallback="BeforeShowEditDialogCallback!"
IsPagination="IsPagination" PageItemsSource="PageItemsSource" IsFixedHeader="IsFixedHeader" IndentSize=24 RowHeight=RowHeight ShowSearchText="ShowSearchText" ShowSearchButton="ShowSearchButton" DisableEditButtonCallback="DisableEditButtonCallback" DisableDeleteButtonCallback="DisableDeleteButtonCallback" BeforeShowEditDialogCallback=" BeforeShowEditDialogCallback!"
IsTree="IsTree" OnTreeExpand="OnTreeExpand!" TreeNodeConverter="TreeNodeConverter!" TreeIcon="fa-solid fa-circle-chevron-right" TreeExpandIcon="fa-solid fa-circle-chevron-right fa-rotate-90" IsAutoQueryFirstRender=IsAutoQueryFirstRender
ShowDefaultButtons="ShowDefaultButtons" ShowAdvancedSearch="ShowAdvancedSearch" ShowResetButton=ShowResetButton
ShowEmpty="ShowEmpty" EmptyText="@EmptyText" EmptyImage="@($"{WebsiteConst.DefaultResourceUrl}images/empty.svg")" SortString="@SortString" EditDialogSize="EditDialogSize"
@@ -14,7 +14,7 @@
ShowSkeleton="true" ShowLoading="ShowLoading" ShowSearch="ShowSearch" SearchModel=@SearchModel ShowLineNo
SearchMode=SearchMode ShowExportPdfButton=ShowExportPdfButton ExportButtonText=@ExportButtonText
ShowExportButton=@ShowExportButton Items=Items ClickToSelect=ClickToSelect ScrollMode=ScrollMode
ShowExportCsvButton=@ShowExportCsvButton SelectedRowsChanged=SelectedRowsChanged ShowCardView=ShowCardView
ShowExportCsvButton=@ShowExportCsvButton ShowCardView=ShowCardView
FixedExtendButtonsColumn=FixedExtendButtonsColumn FixedMultipleColumn=FixedMultipleColumn FixedDetailRowHeaderColumn=FixedDetailRowHeaderColumn FixedLineNoColumn=FixedLineNoColumn
IsAutoRefresh=IsAutoRefresh AutoRefreshInterval=AutoRefreshInterval
AllowDragColumn=@AllowDragColumn Height=@Height ShowRefresh=ShowRefresh
@@ -29,7 +29,7 @@
ShowMultiFilterHeader=ShowMultiFilterHeader
ShowFilterHeader=ShowFilterHeader
ShowColumnList=ShowColumnList ExtendButtonColumnWidth="@ExtendButtonColumnWidth"
CustomerSearchModel="CustomerSearchModel" SelectedRows="SelectedRows" ModelEqualityComparer="ModelEqualityComparer!"
CustomerSearchModel="CustomerSearchModel" ModelEqualityComparer="ModelEqualityComparer!"
ShowExtendEditButtonCallback="ShowExtendEditButtonCallback!" ShowExtendDeleteButtonCallback="ShowExtendDeleteButtonCallback!"
DisableExtendEditButton="DisableExtendEditButton!" DisableExtendDeleteButton="DisableExtendDeleteButton!"
DisableExtendEditButtonCallback="DisableExtendEditButtonCallback!" DisableExtendDeleteButtonCallback="DisableExtendDeleteButtonCallback!"

View File

@@ -13,6 +13,24 @@ namespace ThingsGateway.Admin.Razor;
[CascadingTypeParameter(nameof(TItem))]
public partial class AdminTable<TItem> where TItem : class, new()
{
/// <inheritdoc cref="Table{TItem}.SelectedRowsChanged"/>
[Parameter]
public EventCallback<List<TItem>> SelectedRowsChanged { get; set; }
/// <inheritdoc cref="Table{TItem}.SelectedRows"/>
[Parameter]
public List<TItem> SelectedRows { get; set; } = new();
private async Task privateSelectedRowsChanged(List<TItem> items)
{
SelectedRows = items;
if (SelectedRowsChanged.HasDelegate)
await SelectedRowsChanged.InvokeAsync(items);
}
/// <inheritdoc cref="Table{TItem}.DoubleClickToEdit"/>
[Parameter]
public bool DoubleClickToEdit { get; set; } = false;
@@ -210,14 +228,6 @@ public partial class AdminTable<TItem> where TItem : class, new()
[Parameter]
public RenderFragment<TItem>? SearchTemplate { get; set; }
/// <inheritdoc cref="Table{TItem}.SelectedRows"/>
[Parameter]
public List<TItem>? SelectedRows { get; set; } = new List<TItem>();
/// <inheritdoc cref="Table{TItem}.SelectedRowsChanged"/>
[Parameter]
public EventCallback<List<TItem>> SelectedRowsChanged { get; set; }
/// <inheritdoc cref="Table{TItem}.SetRowClassFormatter"/>
[Parameter]
public Func<TItem, string?>? SetRowClassFormatter { get; set; }
@@ -266,6 +276,15 @@ public partial class AdminTable<TItem> where TItem : class, new()
[Parameter]
public bool ShowExportButton { get; set; } = false;
/// <inheritdoc cref="Table{TItem}.DisableEditButtonCallback"/>
public Func<List<TItem>, bool> DisableEditButtonCallback { get; set; } = (list) =>
list.Count != 1;
/// <inheritdoc cref="Table{TItem}.DisableDeleteButtonCallback"/>
[Parameter]
public Func<List<TItem>, bool> DisableDeleteButtonCallback { get; set; } = (list) =>
list.Count <= 0;
/// <inheritdoc cref="Table{TItem}.ShowExportCsvButton"/>
[Parameter]
public bool ShowExportCsvButton { get; set; } = false;

View File

@@ -1,7 +1,7 @@
@namespace ThingsGateway.Razor
@typeparam TItem
<Table TItem="TItem" IsBordered="true" IsStriped="true" IsMultipleSelect="IsMultipleSelect" @ref="Instance" TableSize=TableSize SearchTemplate=SearchTemplate
<Table TItem="TItem" IsBordered="true" IsStriped="true" IsMultipleSelect="IsMultipleSelect" @ref="Instance" TableSize=TableSize SearchTemplate=SearchTemplate SelectedRows=SelectedRows SelectedRowsChanged=privateSelectedRowsChanged
IsPagination="IsPagination" PageItemsSource="PageItemsSource" IsFixedHeader="IsFixedHeader" IndentSize=24 RowHeight=RowHeight ShowSearchText="ShowSearchText"
IsTree="IsTree" OnTreeExpand="OnTreeExpand!" TreeNodeConverter="TreeNodeConverter!" TreeIcon="fa-solid fa-circle-chevron-right" TreeExpandIcon="fa-solid fa-circle-chevron-right fa-rotate-90" IsAutoQueryFirstRender=IsAutoQueryFirstRender
ShowDefaultButtons="ShowDefaultButtons" ShowAdvancedSearch="ShowAdvancedSearch" ShowResetButton=ShowResetButton
@@ -10,7 +10,7 @@
ShowSkeleton="true" ShowLoading="ShowLoading" ShowSearch="ShowSearch" SearchModel=@SearchModel ShowLineNo
SearchMode=SearchMode ShowExportPdfButton=ShowExportPdfButton
ShowExportButton=@ShowExportButton Items=Items ClickToSelect=ClickToSelect ScrollMode=ScrollMode
ShowExportCsvButton=@ShowExportCsvButton SelectedRowsChanged=SelectedRowsChanged ShowCardView=ShowCardView
ShowExportCsvButton=@ShowExportCsvButton ShowCardView=ShowCardView
FixedExtendButtonsColumn IsAutoRefresh=IsAutoRefresh AutoRefreshInterval=AutoRefreshInterval
AllowDragColumn=@AllowDragColumn Height=@Height ShowRefresh=ShowRefresh
AllowResizing=@AllowResizing ExportButtonDropdownTemplate=ExportButtonDropdownTemplate
@@ -24,7 +24,7 @@
ShowMultiFilterHeader=ShowMultiFilterHeader
ShowFilterHeader=ShowFilterHeader
ShowColumnList=ShowColumnList ExtendButtonColumnWidth="@ExtendButtonColumnWidth"
CustomerSearchModel="CustomerSearchModel" SelectedRows="SelectedRows" ModelEqualityComparer="ModelEqualityComparer!"
CustomerSearchModel="CustomerSearchModel" ModelEqualityComparer="ModelEqualityComparer!"
ShowExtendEditButtonCallback="ShowExtendEditButtonCallback!" ShowExtendDeleteButtonCallback="ShowExtendDeleteButtonCallback!"
DisableExtendEditButton="DisableExtendEditButton!" DisableExtendDeleteButton="DisableExtendDeleteButton!"
DisableExtendEditButtonCallback="DisableExtendEditButtonCallback!" DisableExtendDeleteButtonCallback="DisableExtendDeleteButtonCallback!"

View File

@@ -13,6 +13,23 @@ namespace ThingsGateway.Razor;
[CascadingTypeParameter(nameof(TItem))]
public partial class DefaultTable<TItem> where TItem : class, new()
{
/// <inheritdoc cref="Table{TItem}.SelectedRowsChanged"/>
[Parameter]
public EventCallback<List<TItem>> SelectedRowsChanged { get; set; }
/// <inheritdoc cref="Table{TItem}.SelectedRows"/>
[Parameter]
public List<TItem> SelectedRows { get; set; } = new();
private async Task privateSelectedRowsChanged(List<TItem> items)
{
SelectedRows = items;
if (SelectedRowsChanged.HasDelegate)
await SelectedRowsChanged.InvokeAsync(items);
}
/// <inheritdoc cref="Table{TItem}.AllowDragColumn"/>
[Parameter]
public bool AllowDragColumn { get; set; } = false;
@@ -186,14 +203,6 @@ public partial class DefaultTable<TItem> where TItem : class, new()
[Parameter]
public RenderFragment<TItem>? SearchTemplate { get; set; }
/// <inheritdoc cref="Table{TItem}.SelectedRows"/>
[Parameter]
public List<TItem>? SelectedRows { get; set; } = new List<TItem>();
/// <inheritdoc cref="Table{TItem}.SelectedRowsChanged"/>
[Parameter]
public EventCallback<List<TItem>> SelectedRowsChanged { get; set; }
/// <inheritdoc cref="Table{TItem}.SetRowClassFormatter"/>
[Parameter]
public Func<TItem, string?>? SetRowClassFormatter { get; set; }

View File

@@ -1,9 +1,9 @@
<Project>
<PropertyGroup>
<PluginVersion>10.11.37</PluginVersion>
<ProPluginVersion>10.11.37</ProPluginVersion>
<DefaultVersion>10.11.37</DefaultVersion>
<PluginVersion>10.11.40</PluginVersion>
<ProPluginVersion>10.11.40</ProPluginVersion>
<DefaultVersion>10.11.41</DefaultVersion>
<AuthenticationVersion>10.11.5</AuthenticationVersion>
<SourceGeneratorVersion>10.11.4</SourceGeneratorVersion>
<NET8Version>8.0.20</NET8Version>

View File

@@ -37,6 +37,7 @@ public static class ChannelOptionsExtensions
for (int i = 0; i < funcs.Count; i++)
{
var func = funcs[i];
if (func == null) continue;
await func.Invoke(clientChannel, e, i == funcs.Count - 1).ConfigureAwait(false);
if (e.Handled)
{
@@ -65,6 +66,7 @@ public static class ChannelOptionsExtensions
for (int i = 0; i < funcs.Count; i++)
{
var func = funcs[i];
if (func == null) continue;
var handled = await func.Invoke(clientChannel, i == funcs.Count - 1).ConfigureAwait(false);
if (handled)
{
@@ -99,16 +101,16 @@ public static class ChannelOptionsExtensions
switch (channelType)
{
case ChannelTypeEnum.TcpClient:
return config.GetTcpClientWithIPHost(channelOptions);
return config.GetTcpClient(channelOptions);
case ChannelTypeEnum.TcpService:
return config.GetTcpServiceWithBindIPHost(channelOptions);
return config.GetTcpService(channelOptions);
case ChannelTypeEnum.SerialPort:
return config.GetSerialPortWithOption(channelOptions);
return config.GetSerialPort(channelOptions);
case ChannelTypeEnum.UdpSession:
return config.GetUdpSessionWithIPHost(channelOptions);
return config.GetUdpSession(channelOptions);
case ChannelTypeEnum.Other:
channelOptions.Config = config;
OtherChannel otherChannel = new OtherChannel(channelOptions);
@@ -123,13 +125,12 @@ public static class ChannelOptionsExtensions
/// <param name="config">配置</param>
/// <param name="channelOptions">串口配置</param>
/// <returns></returns>
public static SerialPortChannel GetSerialPortWithOption(this TouchSocketConfig config, IChannelOptions channelOptions)
public static SerialPortChannel GetSerialPort(this TouchSocketConfig config, IChannelOptions channelOptions)
{
var serialPortOption = channelOptions.Map<SerialPortOption>();
serialPortOption.ThrowIfNull(nameof(SerialPortOption));
channelOptions.Config = config;
config.SetSerialPortOption(serialPortOption);
//载入配置
SerialPortChannel serialPortChannel = new SerialPortChannel(channelOptions);
return serialPortChannel;
@@ -142,7 +143,7 @@ public static class ChannelOptionsExtensions
/// <param name="channelOptions">通道配置</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static TcpClientChannel GetTcpClientWithIPHost(this TouchSocketConfig config, IChannelOptions channelOptions)
public static TcpClientChannel GetTcpClient(this TouchSocketConfig config, IChannelOptions channelOptions)
{
var remoteUrl = channelOptions.RemoteUrl;
var bindUrl = channelOptions.BindUrl;
@@ -164,7 +165,7 @@ public static class ChannelOptionsExtensions
/// <param name="channelOptions">通道配置</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IChannel GetTcpServiceWithBindIPHost(this TouchSocketConfig config, IChannelOptions channelOptions)
public static IChannel GetTcpService(this TouchSocketConfig config, IChannelOptions channelOptions)
{
var bindUrl = channelOptions.BindUrl;
bindUrl.ThrowIfNull(nameof(bindUrl));
@@ -192,7 +193,7 @@ public static class ChannelOptionsExtensions
/// <param name="channelOptions">通道配置</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static UdpSessionChannel GetUdpSessionWithIPHost(this TouchSocketConfig config, IChannelOptions channelOptions)
public static UdpSessionChannel GetUdpSession(this TouchSocketConfig config, IChannelOptions channelOptions)
{
var remoteUrl = channelOptions.RemoteUrl;
var bindUrl = channelOptions.BindUrl;

View File

@@ -19,6 +19,11 @@ namespace ThingsGateway.Foundation;
/// </summary>
public class OtherChannel : SetupConfigObject, IClientChannel
{
~OtherChannel()
{
this.SafeDispose();
}
private SingleStreamDataHandlingAdapter m_dataHandlingAdapter;
public DataHandlingAdapter ReadOnlyDataHandlingAdapter => m_dataHandlingAdapter;

View File

@@ -19,6 +19,10 @@ namespace ThingsGateway.Foundation;
/// </summary>
public class SerialPortChannel : SerialPortClient, IClientChannel
{
~SerialPortChannel()
{
this.SafeDispose();
}
public SerialPortChannel(IChannelOptions channelOptions)
{
ChannelOptions = channelOptions;

View File

@@ -17,6 +17,10 @@ namespace ThingsGateway.Foundation;
/// </summary>
public class TcpClientChannel : TcpClient, IClientChannel
{
~TcpClientChannel()
{
this.SafeDispose();
}
/// <inheritdoc/>
public TcpClientChannel(IChannelOptions channelOptions)
{

View File

@@ -18,6 +18,11 @@ namespace ThingsGateway.Foundation;
/// <typeparam name="TClient"></typeparam>
public abstract class TcpServiceChannelBase<TClient> : TcpService<TClient>, ITcpService<TClient> where TClient : TcpSessionClientChannel, new()
{
~TcpServiceChannelBase()
{
this.SafeDispose();
}
/// <inheritdoc/>
public ConcurrentList<IDevice> Collects { get; } = new();

View File

@@ -17,6 +17,10 @@ namespace ThingsGateway.Foundation;
/// </summary>
public class TcpSessionClientChannel : TcpSessionClient, IClientChannel
{
~TcpSessionClientChannel()
{
this.SafeDispose();
}
/// <inheritdoc/>
public TcpSessionClientChannel()
{

View File

@@ -17,6 +17,10 @@ namespace ThingsGateway.Foundation;
/// </summary>
public class UdpSessionChannel : UdpSession, IClientChannel
{
~UdpSessionChannel()
{
this.SafeDispose();
}
private readonly WaitLock _connectLock = new WaitLock(nameof(UdpSessionChannel));
/// <inheritdoc/>

View File

@@ -629,7 +629,7 @@ public abstract class DeviceBase : AsyncAndSyncDisposableObject, IDevice
DataTypeEnum.UInt32 => await ReadUInt32Async(address, length, cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.Int64 => await ReadInt64Async(address, length, cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.UInt64 => await ReadUInt64Async(address, length, cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.Single => await ReadSingleAsync(address, length, cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.Float => await ReadSingleAsync(address, length, cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.Double => await ReadDoubleAsync(address, length, cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.Decimal => await ReadDecimalAsync(address, length, cancellationToken: cancellationToken).ConfigureAwait(false),
_ => new OperResult<Array>(string.Format(AppResource.DataTypeNotSupported, dataType)),
@@ -655,7 +655,7 @@ public abstract class DeviceBase : AsyncAndSyncDisposableObject, IDevice
DataTypeEnum.UInt32 => await WriteAsync(address, jArray.ToObject<UInt32[]>().AsMemory(), cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.Int64 => await WriteAsync(address, jArray.ToObject<Int64[]>().AsMemory(), cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.UInt64 => await WriteAsync(address, jArray.ToObject<UInt64[]>().AsMemory(), cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.Single => await WriteAsync(address, jArray.ToObject<Single[]>().AsMemory(), cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.Float => await WriteAsync(address, jArray.ToObject<Single[]>().AsMemory(), cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.Double => await WriteAsync(address, jArray.ToObject<Double[]>().AsMemory(), cancellationToken: cancellationToken).ConfigureAwait(false),
DataTypeEnum.Decimal => await WriteAsync(address, jArray.ToObject<Decimal[]>().AsMemory(), cancellationToken: cancellationToken).ConfigureAwait(false),
_ => new OperResult(string.Format(AppResource.DataTypeNotSupported, dataType)),
@@ -674,7 +674,7 @@ public abstract class DeviceBase : AsyncAndSyncDisposableObject, IDevice
DataTypeEnum.UInt32 => await WriteAsync(address, value.ToObject<UInt32>(), bitConverter, cancellationToken).ConfigureAwait(false),
DataTypeEnum.Int64 => await WriteAsync(address, value.ToObject<Int64>(), bitConverter, cancellationToken).ConfigureAwait(false),
DataTypeEnum.UInt64 => await WriteAsync(address, value.ToObject<UInt64>(), bitConverter, cancellationToken).ConfigureAwait(false),
DataTypeEnum.Single => await WriteAsync(address, value.ToObject<Single>(), bitConverter, cancellationToken).ConfigureAwait(false),
DataTypeEnum.Float => await WriteAsync(address, value.ToObject<Single>(), bitConverter, cancellationToken).ConfigureAwait(false),
DataTypeEnum.Double => await WriteAsync(address, value.ToObject<Double>(), bitConverter, cancellationToken).ConfigureAwait(false),
DataTypeEnum.Decimal => await WriteAsync(address, value.ToObject<Decimal>(), bitConverter, cancellationToken).ConfigureAwait(false),
_ => new OperResult(string.Format(AppResource.DataTypeNotSupported, dataType)),
@@ -864,7 +864,7 @@ public abstract class DeviceBase : AsyncAndSyncDisposableObject, IDevice
public virtual ValueTask<OperResult> WriteAsync(string address, float value, IThingsGatewayBitConverter bitConverter = null, CancellationToken cancellationToken = default)
{
bitConverter ??= ThingsGatewayBitConverter.GetTransByAddress(address);
return WriteAsync(address, bitConverter.GetBytes(value), DataTypeEnum.Single, cancellationToken);
return WriteAsync(address, bitConverter.GetBytes(value), DataTypeEnum.Float, cancellationToken);
}
/// <inheritdoc/>
@@ -937,7 +937,7 @@ public abstract class DeviceBase : AsyncAndSyncDisposableObject, IDevice
public virtual ValueTask<OperResult> WriteAsync(string address, ReadOnlyMemory<float> value, IThingsGatewayBitConverter bitConverter = null, CancellationToken cancellationToken = default)
{
bitConverter ??= ThingsGatewayBitConverter.GetTransByAddress(address);
return WriteAsync(address, bitConverter.GetBytes(value.Span), DataTypeEnum.Single, cancellationToken);
return WriteAsync(address, bitConverter.GetBytes(value.Span), DataTypeEnum.Float, cancellationToken);
}
/// <inheritdoc/>

View File

@@ -45,12 +45,16 @@ public enum DataTypeEnum
/// <inheritdoc/>
UInt64,
/// <inheritdoc/>
Single,
/// <summary>
/// 大部分人并不认识Single但都认识Float
/// </summary>
Float,
/// <inheritdoc/>
Double,
/// <inheritdoc/>
Decimal,
}

View File

@@ -32,7 +32,7 @@ public static class DataTypeExtensions
DataTypeEnum.UInt32 => 4,
DataTypeEnum.Int64 => 8,
DataTypeEnum.UInt64 => 8,
DataTypeEnum.Single => 4,
DataTypeEnum.Float => 4,
DataTypeEnum.Double => 8,
DataTypeEnum.Decimal => 16,
_ => 0,
@@ -57,7 +57,7 @@ public static class DataTypeExtensions
TypeCode.UInt32 => DataTypeEnum.UInt32,
TypeCode.Int64 => DataTypeEnum.Int64,
TypeCode.UInt64 => DataTypeEnum.UInt64,
TypeCode.Single => DataTypeEnum.Single,
TypeCode.Single => DataTypeEnum.Float,
TypeCode.Double => DataTypeEnum.Double,
TypeCode.Decimal => DataTypeEnum.Decimal,
_ => DataTypeEnum.Object,
@@ -82,7 +82,7 @@ public static class DataTypeExtensions
DataTypeEnum.UInt32 => typeof(uint),
DataTypeEnum.Int64 => typeof(long),
DataTypeEnum.UInt64 => typeof(ulong),
DataTypeEnum.Single => typeof(float),
DataTypeEnum.Float => typeof(float),
DataTypeEnum.Double => typeof(double),
DataTypeEnum.Decimal => typeof(decimal),
_ => typeof(object),

View File

@@ -11,8 +11,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(NET9Version)" />
<PackageReference Include="TouchSocket" Version="4.0.0-beta.25" />
<PackageReference Include="TouchSocket.SerialPorts" Version="4.0.0-beta.25" />
<PackageReference Include="TouchSocket" Version="4.0.0-beta.27" />
<PackageReference Include="TouchSocket.SerialPorts" Version="4.0.0-beta.27" />
</ItemGroup>
<ItemGroup>

View File

@@ -56,7 +56,7 @@ public static class ThingsGatewayBitConverterExtension
case DataTypeEnum.UInt64:
return byteConverter.GetBytes(value.ToObject<UInt64[]>());
case DataTypeEnum.Single:
case DataTypeEnum.Float:
return byteConverter.GetBytes(value.ToObject<Single[]>());
case DataTypeEnum.Double:
@@ -107,7 +107,7 @@ public static class ThingsGatewayBitConverterExtension
case DataTypeEnum.UInt64:
return byteConverter.GetBytes(value.ToObject<UInt64>());
case DataTypeEnum.Single:
case DataTypeEnum.Float:
return byteConverter.GetBytes(value.ToObject<Single>());
case DataTypeEnum.Double:
@@ -333,7 +333,7 @@ public static class ThingsGatewayBitConverterExtension
return true;
}
case DataTypeEnum.Single:
case DataTypeEnum.Float:
if (arrayLength > 1)
{
var newVal = byteConverter.ToSingle(buffer, index, arrayLength);

View File

@@ -12,7 +12,6 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Concurrent;
using ThingsGateway.Common.Extension;

View File

@@ -11,9 +11,9 @@
<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="4.0.0-beta.25" />
<!--<PackageReference Include="TouchSocket.WebApi.Swagger" Version="4.0.0-beta.25" />-->
<PackageReference Include="TouchSocket.WebApi" Version="4.0.0-beta.25" />
<PackageReference Include="TouchSocket.Dmtp" Version="4.0.0-beta.27" />
<!--<PackageReference Include="TouchSocket.WebApi.Swagger" Version="4.0.0-beta.27" />-->
<PackageReference Include="TouchSocket.WebApi" Version="4.0.0-beta.27" />
<PackageReference Include="ThingsGateway.Authentication" Version="$(AuthenticationVersion)" />
<!--<ProjectReference Include="..\..\PluginPro\ThingsGateway.Authentication\ThingsGateway.Authentication.csproj" />-->

View File

@@ -48,7 +48,7 @@
}
/*切换高度*/
.quickactions-list.is-open {
height: 300px;
height: 200px;
}
.quickactions-header {

View File

@@ -76,18 +76,34 @@ public partial class DeviceRuntimeInfo1 : IDisposable
{
return;
}
await DialogService.Show(new DialogOption()
{
IsScrolling = false,
ShowMaximizeButton = true,
Size = Size.ExtraExtraLarge,
Title = DeviceRuntime.Name,
Component = BootstrapDynamicComponent.CreateComponent(driver, new Dictionary<string, object?>()
var renderFragment = BootstrapDynamicComponent.CreateComponent(driver, new Dictionary<string, object?>()
{
{nameof(IDriverUIBase.Driver),DeviceRuntime.Driver},
})
});
}).Render();
if (renderFragment != null)
{
var option = new WinBoxOption()
{
Title = DeviceRuntime.Name,
ContentTemplate = renderFragment,
Max = false,
Width = "80%",
Height = "80%",
Top = "0%",
Left = "10%",
Background = "var(--bb-primary-color)",
Overflow = true
};
await WinBoxService.Show(option);
}
}
[Inject]
[NotNull]
private WinBoxService? WinBoxService { get; set; }
#endif
[Inject]

View File

@@ -48,8 +48,22 @@ public partial class GatewayMonitorPage
}
else
{
VariableRuntimes = deviceRuntime.Driver?.IdVariableRuntimes?.Where(a => a.Value != null)
if (deviceRuntime.Driver == null)
{
_ = Task.Run(async () =>
{
await Task.Delay(2000);
VariableRuntimes = deviceRuntime.Driver?.IdVariableRuntimes?.Where(a => a.Value != null)
.Select(a => a.Value) ?? Enumerable.Empty<VariableRuntime>();
await InvokeAsync(StateHasChanged);
});
}
else
{
VariableRuntimes = deviceRuntime.Driver?.IdVariableRuntimes?.Where(a => a.Value != null)
.Select(a => a.Value) ?? Enumerable.Empty<VariableRuntime>();
}
}
ChannelRuntimes = Enumerable.Repeat(deviceRuntime.ChannelRuntime, 1);
DeviceRuntimes = Enumerable.Repeat(deviceRuntime, 1);

View File

@@ -28,15 +28,7 @@ public partial class VariableRuntimeInfo : IDisposable
[Parameter]
public IEnumerable<VariableRuntime>? Items { get; set; } = Enumerable.Empty<VariableRuntime>();
private IEnumerable<VariableRuntime>? _previousItemsRef;
protected override async Task OnParametersSetAsync()
{
if (!ReferenceEquals(_previousItemsRef, Items))
{
_previousItemsRef = Items;
await Refresh(null);
}
}
#endif
private static void BeforeShowEditDialogCallback(ITableEditDialogOption<VariableRuntime> tableEditDialogOption)

View File

@@ -13,7 +13,11 @@ using BenchmarkConsoleApp;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;
using HslCommunication.ModBus;
using Longbow.Modbus;
using Longbow.TcpSocket;
using Microsoft.Extensions.DependencyInjection;
using System.IO.Pipelines;
using System.Net.Sockets;
@@ -31,9 +35,10 @@ namespace ThingsGateway.Foundation;
[MemoryDiagnoser]
public class ModbusBenchmark : IDisposable
{
private readonly List<IModbusClient> _lgbModbusClients = [];
private List<ModbusMaster> thingsgatewaymodbuss = new();
private List<IModbusMaster> nmodbuss = new();
private List<ModbusTcpNet> modbusTcpNets = new();
//private List<ModbusTcpNet> modbusTcpNets = new();
private List<ModbusTcpMaster> modbusTcpMasters = new();
private PipeOptions GetNoDelayPipeOptions()
{
@@ -54,7 +59,7 @@ public class ModbusBenchmark : IDisposable
// ReceivePipeOptions = GetNoDelayPipeOptions(),
// SendPipeOptions = GetNoDelayPipeOptions(),
//}).SetNoDelay(true);
var clientChannel = clientConfig.GetTcpClientWithIPHost(new ChannelOptions() { RemoteUrl = "127.0.0.1:502", MaxConcurrentCount = 10 });
var clientChannel = clientConfig.GetTcpClient(new ChannelOptions() { RemoteUrl = "127.0.0.1:502", MaxConcurrentCount = 10 });
var thingsgatewaymodbus = new ModbusMaster()
{
//modbus协议格式
@@ -77,15 +82,15 @@ public class ModbusBenchmark : IDisposable
nmodbus.ReadHoldingRegistersAsync(1, 0, 100).GetFalseAwaitResult();
nmodbuss.Add(nmodbus);
}
for (int i = 0; i < Program.ClientCount; i++)
{
ModbusTcpNet modbusTcpNet = new();
modbusTcpNet.IpAddress = "127.0.0.1";
modbusTcpNet.Port = 502;
modbusTcpNet.ConnectServer();
modbusTcpNet.ReadAsync("0", 100).GetFalseAwaitResult();
modbusTcpNets.Add(modbusTcpNet);
}
//for (int i = 0; i < Program.ClientCount; i++)
//{
// ModbusTcpNet modbusTcpNet = new();
// modbusTcpNet.IpAddress = "127.0.0.1";
// modbusTcpNet.Port = 502;
// modbusTcpNet.ConnectServer();
// modbusTcpNet.ReadAsync("0", 100).GetFalseAwaitResult();
// modbusTcpNets.Add(modbusTcpNet);
//}
for (int i = 0; i < Program.ClientCount; i++)
{
@@ -96,12 +101,50 @@ public class ModbusBenchmark : IDisposable
client.ReadHoldingRegistersAsync(0, 100).GetFalseAwaitResult();
modbusTcpMasters.Add(client);
}
}
{
var sc = new ServiceCollection();
sc.AddTcpSocketFactory();
sc.AddModbusFactory();
var provider = sc.BuildServiceProvider();
var factory = provider.GetRequiredService<IModbusFactory>();
for (int i = 0; i < Program.ClientCount; i++)
{
var client = factory.GetOrCreateTcpMaster();
client.ConnectAsync("127.0.0.1", 502).GetAwaiter().GetResult();
client.ReadHoldingRegistersAsync(0x01, 0x00, 10).GetAwaiter().GetResult();
_lgbModbusClients.Add(client);
}
}
}
[Benchmark]
public async Task LongbowModbus()
{
List<Task> tasks = new List<Task>();
foreach (var _lgbModbusClient in _lgbModbusClients)
{
for (int i = 0; i < Program.TaskNumberOfItems; i++)
{
tasks.Add(Task.Run(async () =>
{
for (int i = 0; i < Program.NumberOfItems; i++)
{
var task = await _lgbModbusClient.ReadHoldingRegistersAsync(1, 0, 100);
}
}));
}
}
await Task.WhenAll(tasks);
}
[Benchmark]
public async Task ThingsGateway()
{
ModbusAddress addr = new ModbusAddress() { FunctionCode = 3, StartAddress = 0, Length = 100 };
//ModbusAddress addr = new ModbusAddress() { FunctionCode = 3, StartAddress = 0, Length = 100 };
List<Task> tasks = new List<Task>();
foreach (var thingsgatewaymodbus in thingsgatewaymodbuss)
{
@@ -112,11 +155,12 @@ public class ModbusBenchmark : IDisposable
{
for (int i = 0; i < Program.NumberOfItems; i++)
{
var result = await thingsgatewaymodbus.ModbusReadAsync(addr);
var result = await thingsgatewaymodbus.ModbusReadAsync(new ModbusAddress() { FunctionCode = 3, StartAddress = 0, Length = 100 });
if (!result.IsSuccess)
{
throw new Exception(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ffff") + result.ToString());
}
var data = TouchSocketBitConverter.ConvertValues<byte, ushort>(result.Content.Span, EndianType.Little);
}
}));
}
@@ -139,6 +183,7 @@ public class ModbusBenchmark : IDisposable
for (int i = 0; i < Program.NumberOfItems; i++)
{
var result = await modbusTcpMaster.ReadHoldingRegistersAsync(0, 100);
var data = TouchSocketBitConverter.ConvertValues<byte, ushort>(result.Data.Span, EndianType.Little);
if (!result.IsSuccess)
{
throw new Exception(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ffff") + result.ToString());
@@ -199,9 +244,12 @@ public class ModbusBenchmark : IDisposable
public void Dispose()
{
thingsgatewaymodbuss?.ForEach(a => a.Channel.SafeDispose());
thingsgatewaymodbuss?.ForEach(a => a.SafeDispose());
nmodbuss?.ForEach(a => a.SafeDispose());
modbusTcpNets?.ForEach(a => a.SafeDispose());
//modbusTcpNets?.ForEach(a => a.SafeDispose());
_lgbModbusClients?.ForEach(a => a.DisposeAsync().GetAwaiter().GetResult());
}
}

View File

@@ -51,7 +51,7 @@ public class S7Benchmark : IDisposable
ReceivePipeOptions = GetNoDelayPipeOptions(),
SendPipeOptions = GetNoDelayPipeOptions(),
}).SetNoDelay(true);
var clientChannel = clientConfig.GetTcpClientWithIPHost(new ChannelOptions() { RemoteUrl = "127.0.0.1:102" });
var clientChannel = clientConfig.GetTcpClient(new ChannelOptions() { RemoteUrl = "127.0.0.1:102" });
var siemensS7 = new SiemensS7Master()
{
//modbus协议格式

View File

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

View File

@@ -186,7 +186,7 @@ public class Dlt645_2007Send : ISendMessage
}
var lenSpan = writerLenAnchor.Rewind(ref byteBlock, out var length);
lenSpan.WriteValue<byte>((byte)(length - 1));//数据域长度
lenSpan.WriteValue<byte>((byte)(length));//数据域长度
int num = 0;
for (int index = 0; index < byteBlock.WrittenCount - SendHeadCodeIndex; ++index)

View File

@@ -126,7 +126,7 @@ public partial class MainLayout : IDisposable
if (context is TabItem tabItem)
{
await WinboxRender(tabItem.ChildContent, tabItem.Text);
await _tab.RemoveTab(tabItem);
//await _tab.RemoveTab(tabItem);
}
}
[Inject]