Compare commits

...

6 Commits

Author SHA1 Message Date
2248356998 qq.com
901aa2d59f 10.11.52 2025-09-17 11:07:45 +08:00
2248356998 qq.com
764957c014 10.11.51 2025-09-16 22:19:01 +08:00
Diego
0e3898218b 10.11.44 2025-09-16 19:13:19 +08:00
Diego
61f13cef3c 10.11.43 2025-09-15 17:35:49 +08:00
2248356998 qq.com
0b663d9e01 fix: modbusRtu 0x10 2025-09-14 11:18:41 +08:00
2248356998 qq.com
6c95c6209f 10.11.41 2025-09-13 14:22:13 +08:00
36 changed files with 170 additions and 94 deletions

View File

@@ -4,7 +4,7 @@
<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" 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

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;

View File

@@ -15,23 +15,19 @@ public class ExpiringDictionary<TKey, TValue> : IDisposable
public void TryAdd(TKey key, TValue value)
{
if (_cleanupTimer.Disposed) throw new ObjectDisposedException(nameof(ExpiringDictionary<TKey, TValue>));
_dict.TryAdd(key, value);
}
public bool TryGetValue(TKey key, out TValue value)
{
if (_cleanupTimer.Disposed) throw new ObjectDisposedException(nameof(ExpiringDictionary<TKey, TValue>));
return _dict.TryGetValue(key, out value);
}
public TValue GetOrAdd(TKey key, Func<TKey, TValue> func)
{
if (_cleanupTimer.Disposed) throw new ObjectDisposedException(nameof(ExpiringDictionary<TKey, TValue>));
return _dict.GetOrAdd(key, func);
}
public TValue GetOrAdd(TKey key, TValue value)
{
if (_cleanupTimer.Disposed) throw new ObjectDisposedException(nameof(ExpiringDictionary<TKey, TValue>));
return _dict.GetOrAdd(key, value);
}

View File

@@ -106,6 +106,17 @@ public static class Runtime
#if NET6_0_OR_GREATER
public static Boolean IsSystemd
{
get
{
var id = Environment.GetEnvironmentVariable("INVOCATION_ID");
return !string.IsNullOrEmpty(id);
}
}
public static Boolean? isLegacyWindows;
/// <summary>

View File

@@ -21,6 +21,7 @@ public class Setting : Config<Setting>
#region
/// <summary>是否启用全局调试。默认启用</summary>
[Description("全局调试。XTrace.Debug")]
[XmlIgnore, IgnoreDataMember]
public Boolean Debug { get; set; } = true;
/// <summary>日志等级只输出大于等于该级别的日志All/Debug/Info/Warn/Error/Fatal默认Info</summary>
@@ -30,6 +31,7 @@ public class Setting : Config<Setting>
/// <summary>文件日志目录。默认Log子目录</summary>
[Description("文件日志目录。默认Log子目录")]
[XmlIgnore, IgnoreDataMember]
public String LogPath { get; set; } = "Logs/XLog";
/// <summary>日志文件上限。超过上限后拆分新日志文件默认5MB0表示不限制大小</summary>
@@ -42,6 +44,7 @@ public class Setting : Config<Setting>
/// <summary>日志文件格式。默认{0:yyyy_MM_dd}.log支持日志等级如 {1}_{0:yyyy_MM_dd}.log</summary>
[Description("日志文件格式。默认{0:yyyy_MM_dd}.log支持日志等级如 {1}_{0:yyyy_MM_dd}.log")]
[XmlIgnore, IgnoreDataMember]
public String LogFileFormat { get; set; } = "{0:yyyy_MM_dd}.log";
/// <summary>日志行格式。默认Time|ThreadId|Kind|Name|Message还支持Level</summary>

View File

@@ -52,7 +52,7 @@
<ItemGroup>
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>

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

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;

View File

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

View File

@@ -68,6 +68,7 @@ public class ModbusMasterDemo
bytes = await device.ModbusReadAsync(new ModbusAddress()
{
Station = 1,
StartAddress = 0,
FunctionCode = 3,
Length = 10,
@@ -92,6 +93,7 @@ public class ModbusMasterDemo
write = await device.ModbusRequestAsync(new ModbusAddress()
{
Station = 1,
StartAddress = 0,
FunctionCode = 3,
MasterWriteDatas = device.ThingsGatewayBitConverter.GetBytes(new double[] { 123.456, 123.456 })

View File

@@ -98,6 +98,19 @@ public static class ChannelOptionsExtensions
if (channelOptions.MaxClientCount > 0)
config.SetMaxCount(channelOptions.MaxClientCount);
config.SetTransportOption(new TouchSocket.Sockets.TransportOption()
{
SendPipeOptions = new System.IO.Pipelines.PipeOptions(
minimumSegmentSize: 1024,
useSynchronizationContext: false),
ReceivePipeOptions = new System.IO.Pipelines.PipeOptions(
minimumSegmentSize: 1024,
pauseWriterThreshold: 1024 * 1024,
resumeWriterThreshold: 1024 * 512,
useSynchronizationContext: false)
});
switch (channelType)
{
case ChannelTypeEnum.TcpClient:
@@ -125,7 +138,7 @@ public static class ChannelOptionsExtensions
/// <param name="config">配置</param>
/// <param name="channelOptions">串口配置</param>
/// <returns></returns>
public static SerialPortChannel GetSerialPort(this TouchSocketConfig config, IChannelOptions channelOptions)
private static SerialPortChannel GetSerialPort(this TouchSocketConfig config, IChannelOptions channelOptions)
{
var serialPortOption = channelOptions.Map<SerialPortOption>();
serialPortOption.ThrowIfNull(nameof(SerialPortOption));
@@ -143,7 +156,7 @@ public static class ChannelOptionsExtensions
/// <param name="channelOptions">通道配置</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static TcpClientChannel GetTcpClient(this TouchSocketConfig config, IChannelOptions channelOptions)
private static TcpClientChannel GetTcpClient(this TouchSocketConfig config, IChannelOptions channelOptions)
{
var remoteUrl = channelOptions.RemoteUrl;
var bindUrl = channelOptions.BindUrl;
@@ -165,7 +178,7 @@ public static class ChannelOptionsExtensions
/// <param name="channelOptions">通道配置</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IChannel GetTcpService(this TouchSocketConfig config, IChannelOptions channelOptions)
private static IChannel GetTcpService(this TouchSocketConfig config, IChannelOptions channelOptions)
{
var bindUrl = channelOptions.BindUrl;
bindUrl.ThrowIfNull(nameof(bindUrl));
@@ -193,7 +206,7 @@ public static class ChannelOptionsExtensions
/// <param name="channelOptions">通道配置</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static UdpSessionChannel GetUdpSession(this TouchSocketConfig config, IChannelOptions channelOptions)
private static UdpSessionChannel GetUdpSession(this TouchSocketConfig config, IChannelOptions channelOptions)
{
var remoteUrl = channelOptions.RemoteUrl;
var bindUrl = channelOptions.BindUrl;

View File

@@ -105,6 +105,5 @@ public class BusinessPropertyWithCacheIntervalScript : BusinessPropertyWithCache
/// 报警实体脚本
/// </summary>
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptPluginEventDataModel { get; set; }
public virtual string? BigTextScriptPluginEventDataModel { get; set; }
}

View File

@@ -48,6 +48,14 @@
@Localizer["Check"]
</Button>
</div>
</div>
<div class="col-12 col-md-12 min-height-500">
<BootstrapLabel Value=@PropertyComponentLocalizer["BigTextScriptPluginEventDataModel"] ShowLabelTooltip="true" />
<CodeEditor IsReadonly=@(!CanWrite) ShowLineNo @bind-Value=@businessProperty.BigTextScriptPluginEventDataModel Language="csharp" Theme="vs-dark" />
</div>
</EditTemplate>

View File

@@ -40,13 +40,6 @@ public class ModbusBenchmark : IDisposable
private List<IModbusMaster> nmodbuss = new();
//private List<ModbusTcpNet> modbusTcpNets = new();
private List<ModbusTcpMaster> modbusTcpMasters = new();
private PipeOptions GetNoDelayPipeOptions()
{
return new PipeOptions(
readerScheduler: PipeScheduler.Inline,
writerScheduler: PipeScheduler.Inline,
useSynchronizationContext: false);
}
public ModbusBenchmark()
{
@@ -54,12 +47,8 @@ public class ModbusBenchmark : IDisposable
{
var clientConfig = new TouchSocket.Core.TouchSocketConfig();
//clientConfig.SetTransportOption(new TouchSocket.Sockets.TransportOption()
//{
// ReceivePipeOptions = GetNoDelayPipeOptions(),
// SendPipeOptions = GetNoDelayPipeOptions(),
//}).SetNoDelay(true);
var clientChannel = clientConfig.GetTcpClient(new ChannelOptions() { RemoteUrl = "127.0.0.1:502", MaxConcurrentCount = 10 });
var clientChannel = clientConfig.GetChannel(new ChannelOptions() { ChannelType = ChannelTypeEnum.TcpClient, RemoteUrl = "127.0.0.1:502", MaxConcurrentCount = 10 });
var thingsgatewaymodbus = new ModbusMaster()
{
//modbus协议格式
@@ -121,26 +110,7 @@ public class ModbusBenchmark : IDisposable
}
}
}
[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()
{
@@ -155,7 +125,7 @@ public class ModbusBenchmark : IDisposable
{
for (int i = 0; i < Program.NumberOfItems; i++)
{
var result = await thingsgatewaymodbus.ModbusReadAsync(new ModbusAddress() { FunctionCode = 3, StartAddress = 0, Length = 100 });
var result = await thingsgatewaymodbus.ModbusReadAsync(new ModbusAddress() { Station = 1, FunctionCode = 3, StartAddress = 0, Length = 100 }).ConfigureAwait(false);
if (!result.IsSuccess)
{
throw new Exception(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ffff") + result.ToString());
@@ -168,7 +138,27 @@ public class ModbusBenchmark : IDisposable
await Task.WhenAll(tasks);
}
[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++)
{
using var cts = new CancellationTokenSource(3000);
var task = await _lgbModbusClient.ReadHoldingRegistersAsync(1, 0, 100, cts.Token).ConfigureAwait(false);
}
}));
}
}
await Task.WhenAll(tasks);
}
[Benchmark]
public async Task TouchSocket()
@@ -182,7 +172,7 @@ public class ModbusBenchmark : IDisposable
{
for (int i = 0; i < Program.NumberOfItems; i++)
{
var result = await modbusTcpMaster.ReadHoldingRegistersAsync(0, 100);
var result = await modbusTcpMaster.ReadHoldingRegistersAsync(0, 100).ConfigureAwait(false);
var data = TouchSocketBitConverter.ConvertValues<byte, ushort>(result.Data.Span, EndianType.Little);
if (!result.IsSuccess)
{
@@ -208,7 +198,7 @@ public class ModbusBenchmark : IDisposable
{
for (int i = 0; i < Program.NumberOfItems; i++)
{
var result = await nmodbus.ReadHoldingRegistersAsync(1, 0, 100);
var result = await nmodbus.ReadHoldingRegistersAsync(1, 0, 100).ConfigureAwait(false);
}
}));
}

View File

@@ -32,13 +32,7 @@ public class S7Benchmark : IDisposable
private List<Plc> plcs = new();
private List<SiemensS7Net> siemensS7Nets = new();
private PipeOptions GetNoDelayPipeOptions()
{
return new PipeOptions(
readerScheduler: PipeScheduler.Inline,
writerScheduler: PipeScheduler.Inline,
useSynchronizationContext: false);
}
public S7Benchmark()
{
@@ -46,12 +40,8 @@ public class S7Benchmark : IDisposable
for (int i = 0; i < Program.ClientCount; i++)
{
var clientConfig = new TouchSocket.Core.TouchSocketConfig();
clientConfig.SetTransportOption(new TouchSocket.Sockets.TransportOption()
{
ReceivePipeOptions = GetNoDelayPipeOptions(),
SendPipeOptions = GetNoDelayPipeOptions(),
}).SetNoDelay(true);
var clientChannel = clientConfig.GetTcpClient(new ChannelOptions() { RemoteUrl = "127.0.0.1:102" });
var clientChannel = clientConfig.GetChannel(new ChannelOptions() { ChannelType = ChannelTypeEnum.TcpClient, RemoteUrl = "127.0.0.1:102" });
var siemensS7 = new SiemensS7Master()
{
//modbus协议格式

View File

@@ -20,9 +20,9 @@ namespace BenchmarkConsoleApp
{
internal class Program
{
public static int ClientCount = 30;
public static int TaskNumberOfItems = 10;
public static int NumberOfItems = 30;
public static int ClientCount = 50;
public static int TaskNumberOfItems = 1;
public static int NumberOfItems = 50;
private static async Task Main(string[] args)
{

View File

@@ -43,17 +43,17 @@
<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="Longbow.Modbus" Version="9.0.6" />
<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="ThingsGateway.Foundation.Modbus" Version="$(DefaultVersion)" />
<PackageReference Include="ThingsGateway.Foundation.SiemensS7" Version="$(DefaultVersion)" />-->
<PackageReference Include="TouchSocket.Modbus" Version="4.0.0-beta.27" />
</ItemGroup>
<ItemGroup>
<!--<ProjectReference Include="..\..\Plugin\ThingsGateway.Foundation.Modbus\ThingsGateway.Foundation.Modbus.csproj" />
<ProjectReference Include="..\..\Plugin\ThingsGateway.Foundation.SiemensS7\ThingsGateway.Foundation.SiemensS7.csproj" />-->
<ProjectReference Include="..\..\Plugin\ThingsGateway.Foundation.Modbus\ThingsGateway.Foundation.Modbus.csproj" />
<ProjectReference Include="..\..\Plugin\ThingsGateway.Foundation.SiemensS7\ThingsGateway.Foundation.SiemensS7.csproj" />
</ItemGroup>
</Project>

View File

@@ -52,7 +52,7 @@ public class ModbusRequest
/// <summary>
/// 站号
/// </summary>
public byte Station { get; set; }
public byte Station { get; set; } = 1;
#endregion Request
}

View File

@@ -69,7 +69,6 @@ public class ModbusRtuSend : ISendMessage
else if (wf == 15 || wf == 16)
{
var data = ModbusAddress.MasterWriteDatas.ArrayExpandToLengthEven().Span;
WriterExtension.WriteValue(ref byteBlock, (ushort)(data.Length + 7), EndianType.Big);
WriterExtension.WriteValue(ref byteBlock, (byte)ModbusAddress.Station);
WriterExtension.WriteValue(ref byteBlock, (byte)ModbusAddress.WriteFunctionCode);
WriterExtension.WriteValue(ref byteBlock, (ushort)ModbusAddress.StartAddress, EndianType.Big);

View File

@@ -97,7 +97,9 @@ public class ModbusSlave : DeviceBase, IModbusAddress
{
return $"{base.GetAddressDescription()}{Environment.NewLine}{ModbusHelper.GetAddressDescription()}";
}
protected override void SetChannel()
{
}
/// <inheritdoc/>
public override DataHandlingAdapter GetDataAdapter()
{

View File

@@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes" Version="1.5.376.244" />
</ItemGroup>

View File

@@ -39,7 +39,7 @@ public class RealDBProducerProperty : BusinessPropertyWithCacheInterval
/// <summary>
/// 历史表脚本
/// </summary>
[DynamicProperty(Remark = "必须为间隔上传,才生效")]
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptHistoryTable { get; set; }
}

View File

@@ -85,7 +85,6 @@ public partial class QuestDBProducer : BusinessBaseWithCacheIntervalVariable
{
_db.DbMaintenance.CreateDatabase();
//必须为间隔上传
if (!_driverPropertys.BigTextScriptHistoryTable.IsNullOrEmpty())
{
DynamicSQLBase? hisModel = CSharpScriptEngineExtension.Do<DynamicSQLBase>(_driverPropertys.BigTextScriptHistoryTable);

View File

@@ -112,7 +112,6 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariable
{
_db.DbMaintenance.CreateDatabase();
//必须为间隔上传
if (!_driverPropertys.BigTextScriptHistoryTable.IsNullOrEmpty())
{
var hisModel = CSharpScriptEngineExtension.Do<DynamicSQLBase>(_driverPropertys.BigTextScriptHistoryTable);

View File

@@ -69,13 +69,13 @@ public class SqlDBProducerProperty : BusinessPropertyWithCacheInterval
/// <summary>
/// 实时表脚本
/// </summary>
[DynamicProperty(Remark = "必须为间隔上传,才生效")]
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptRealTable { get; set; }
/// <summary>
/// 历史表脚本
/// </summary>
[DynamicProperty(Remark = "必须为间隔上传,才生效")]
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptHistoryTable { get; set; }
}

View File

@@ -102,7 +102,6 @@ public partial class TDengineDBProducer : BusinessBaseWithCacheIntervalVariable
{
_db.DbMaintenance.CreateDatabase();
//必须为间隔上传
if (!_driverPropertys.BigTextScriptHistoryTable.IsNullOrEmpty())
{
var hisModel = CSharpScriptEngineExtension.Do<DynamicSQLBase>(_driverPropertys.BigTextScriptHistoryTable);

View File

@@ -114,7 +114,8 @@ public class ModbusSlave : BusinessBase
try
{
await _plc.ConnectAsync(cancellationToken).ConfigureAwait(false);
if (channel.ChannelType == ChannelTypeEnum.TcpService)
await _plc.ConnectAsync(cancellationToken).ConfigureAwait(false);
}
catch
{

View File

@@ -1,5 +1,6 @@
{
"ThingsGateway.Plugin.Mqtt.MqttClientProperty": {
"BigTextScriptPluginEventDataModel": "BigTextScriptPluginEventDataModel",
"CAFile_BrowserFile": "CAFile",
"ClientCertificateFile_BrowserFile": "ClientCertificateFile",
"ClientKeyFile_BrowserFile": "ClientKeyFile",
@@ -40,6 +41,7 @@
"WebSocketUrl": "WebSocketUrl"
},
"ThingsGateway.Plugin.Mqtt.MqttServerProperty": {
"BigTextScriptPluginEventDataModel": "BigTextScriptPluginEventDataModel",
"AnonymousEnable": "AnonymousEnable",
"DeviceRpcEnable": "DeviceRpcEnable",
"IP": "IP",

View File

@@ -1,5 +1,6 @@
{
"ThingsGateway.Plugin.Mqtt.MqttClientProperty": {
"BigTextScriptPluginEventDataModel": "插件事件上传脚本",
"CAFile_BrowserFile": "CA文件",
"ClientCertificateFile_BrowserFile": "客户端证书",
"ClientKeyFile_BrowserFile": "客户端key文件",
@@ -40,6 +41,7 @@
"WebSocketUrl": "WebSocketUrl"
},
"ThingsGateway.Plugin.Mqtt.MqttServerProperty": {
"BigTextScriptPluginEventDataModel": "插件事件上传脚本",
"AnonymousEnable": "允许匿名登录",
"DeviceRpcEnable": "允许Rpc写入",
"IP": "IP",

View File

@@ -124,4 +124,8 @@ public class MqttClientProperty : BusinessPropertyWithCacheIntervalScript
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptRpc { get; set; }
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public override string? BigTextScriptPluginEventDataModel { get; set; }
}

View File

@@ -76,4 +76,8 @@ public class MqttServerProperty : BusinessPropertyWithCacheIntervalScript
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptRpc { get; set; }
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public override string? BigTextScriptPluginEventDataModel { get; set; }
}

View File

@@ -1,7 +1,4 @@
{
"Debug": "true",
"LogPath": "Logs/XLog",
"LogFileMaxBytes": "5", //5mb最大日志文件
"LogFileBackups": "50", //50个日志文件
"LogFileFormat": "{0:yyyy_MM_dd}.log"
"LogFileBackups": "50" //50个日志文件
}

View File

@@ -36,6 +36,7 @@ public class Program
ClaimConst.Scheme = $"{typeof(Program).Assembly.GetName().Name}{SchemeHelper.GetOrCreate()}";
Runtime.CreateConfigOnMissing = true;
#region Logo
Console.Write(Environment.NewLine);
@@ -72,8 +73,17 @@ public class Program
if (Runtime.IsLegacyWindows)
builder.Logging.ClearProviders(); //去除默认的事件日志提供者,某些情况下会日志输出异常,导致程序崩溃
}).ConfigureBuilder(builder =>
{
if (Runtime.IsSystemd)
{
builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Warning);
}
if (!builder.Environment.IsDevelopment())
{
builder.Services.AddResponseCompression(
@@ -108,6 +118,8 @@ public class Program
#endif
ReflectionInoHelper.RemoveAllCache();
InstanceFactory.RemoveCache();
})
@@ -136,6 +148,12 @@ public class Program
}).ConfigureBuilder(builder =>
{
if (Runtime.IsSystemd)
{
builder.ConfigureLogging(a => a.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Warning));
}
// 设置接口超时时间和上传大小-Kestrel
builder.ConfigureKestrel(u =>
{
@@ -144,11 +162,7 @@ public class Program
u.Limits.MaxRequestBodySize = null;
}).UseKestrel().Configure(app =>
{
// ✅ 最小中间件
app.Run(context =>
{
return context.Response.WriteAsync("web is disable");
});
app.Run(context => context.Response.WriteAsync("web is disable"));
});
})
.Configure(app =>

View File

@@ -73,7 +73,6 @@ public class Startup : AppStartup
services.AddRazorPages();
services.AddMvcFilter<RequestAuditFilter>();
services.AddControllers()

View File

@@ -1,5 +1,5 @@
#docker run -d --name tg --restart always -p 127.0.0.1:5000:5000 -e ASPNETCORE_ENVIRONMENT=Demo -v /thingsgateway/Keys:/app/Keys -v /thingsgateway/DB:/app/DB --memory="512m" registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway:latest
#docker run -d --log-driver json-file --log-opt max-size=50m --log-opt max-file=5 --name tg --restart always -p 127.0.0.1:5000:5000 -p 502:502 -e ASPNETCORE_ENVIRONMENT=Demo -v /thingsgateway/Keys:/app/Keys -v /thingsgateway/DB:/app/DB --memory="512m" registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway:latest
version: "latest" # Docker Compose 配置版本

View File

@@ -25,6 +25,14 @@ Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
# 文件配置
# [Journal]
# SystemMaxUse=200M # 日志最大占用200MB磁盘空间
# SystemMaxFileSize=50M # 单个日志文件最大50MB
# MaxRetentionSec=1month # 日志只保留1个月
# RuntimeMaxUse=100M # 内存中最多缓存100MB日志
# 加载服务配置文件
# systemctl daemon-reload