格式清理
This commit is contained in:
@@ -219,7 +219,7 @@ public class OPCUAClient : DisposableObject
|
||||
set { m_useSecurity = value; }
|
||||
}
|
||||
|
||||
private Dictionary<string, List<string>> _tagDicts=new();
|
||||
private Dictionary<string, List<string>> _tagDicts = new();
|
||||
public Dictionary<string, List<string>> SetTags(List<string> tags)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Furion.Pure.Xunit" Version="4.8.7.6" />
|
||||
<PackageReference Include="Furion.Pure.Xunit" Version="4.8.7.7" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace ThingsGateway.Modbus
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger?.LogError(ex,"自动分包方法获取Bit失败" );
|
||||
_logger?.LogError(ex, "自动分包方法获取Bit失败");
|
||||
}
|
||||
}
|
||||
item.Index = bitIndex;
|
||||
@@ -105,7 +105,7 @@ namespace ThingsGateway.Modbus
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger?.LogError( ex, "自动分包失败");
|
||||
_logger?.LogError(ex, "自动分包失败");
|
||||
}
|
||||
return OperResult.CreateSuccessResult(result);
|
||||
}
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.7.6" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.8.7.6" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.7.7" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.8.7.7" />
|
||||
<PackageReference Include="Magicodes.IE.Excel" Version="2.7.4.2" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.58" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.59" />
|
||||
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
|
||||
<PackageReference Include="NewLife.Core" Version="10.2.2023.301" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.7.6" />
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.7.7" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
public ushort TimeOut { get; set; } = 3000;
|
||||
public ushort RegisterByteLength { get; set; } = 1;
|
||||
|
||||
|
||||
public abstract void Connect();
|
||||
public abstract Task ConnectAsync();
|
||||
|
||||
public abstract void Disconnect();
|
||||
@@ -28,6 +30,7 @@
|
||||
public abstract Task<OperResult<byte[]>> ReadAsync(string address, int length, CancellationToken token = default);
|
||||
|
||||
public abstract Task<OperResult<byte[]>> SendThenResponseAsync(byte[] data, WaitingOptions waitingOptions = null, CancellationToken token = default);
|
||||
public abstract OperResult<byte[]> SendThenResponse(byte[] data, WaitingOptions waitingOptions = null, CancellationToken token = default);
|
||||
|
||||
public abstract void SetDataAdapter();
|
||||
|
||||
|
||||
@@ -29,7 +29,10 @@
|
||||
{
|
||||
return TcpClient.ConnectAsync(ConnectTimeOut);
|
||||
}
|
||||
|
||||
public override void Connect()
|
||||
{
|
||||
TcpClient.Connect(ConnectTimeOut);
|
||||
}
|
||||
public override void Disconnect()
|
||||
{
|
||||
TcpClient.Close();
|
||||
@@ -50,6 +53,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
public override OperResult<byte[]> SendThenResponse(byte[] data, WaitingOptions waitingOptions = null, CancellationToken token = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (waitingOptions == null) { waitingOptions = new WaitingOptions(); waitingOptions.ThrowBreakException = true; waitingOptions.AdapterFilter = AdapterFilter.NoneAll; }
|
||||
Connect();
|
||||
ResponsedData result = TcpClient.GetWaitingClient(waitingOptions).SendThenResponse(data, TimeOut, token);
|
||||
return OperResult.CreateSuccessResult(result.Data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new OperResult<byte[]>(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return TcpClient.RemoteIPHost.ToString();
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
{
|
||||
return Task.FromResult(UdpSession.Start());
|
||||
}
|
||||
|
||||
public override void Connect()
|
||||
{
|
||||
UdpSession.Start();
|
||||
}
|
||||
public override void Disconnect()
|
||||
{
|
||||
UdpSession.Stop();
|
||||
@@ -33,6 +36,19 @@
|
||||
return new OperResult<byte[]>(ex);
|
||||
}
|
||||
}
|
||||
public override OperResult<byte[]> SendThenResponse(byte[] data, WaitingOptions waitingOptions = null, CancellationToken token = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (waitingOptions == null) { waitingOptions = new WaitingOptions(); waitingOptions.ThrowBreakException = true; waitingOptions.AdapterFilter = AdapterFilter.NoneAll; }
|
||||
ResponsedData result = UdpSession.GetWaitingClient(waitingOptions).SendThenResponse(data, TimeOut, CancellationToken.None);
|
||||
return OperResult.CreateSuccessResult(result.Data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new OperResult<byte[]>(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
@@ -253,7 +253,7 @@ public class AlarmHostService : BackgroundService, ISingleton
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (LastIsSuccess)
|
||||
_logger?.LogError(ex, $"历史报警循环异常");
|
||||
_logger?.LogError($"历史报警循环异常:" + ex.Message);
|
||||
StatuString = new OperResult($"异常:请查看后台日志");
|
||||
LastIsSuccess = false;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ public class AlarmHostService : BackgroundService, ISingleton
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger?.LogError(ex, $"历史报警异常");
|
||||
_logger?.LogError($"历史报警异常:" + ex.Message);
|
||||
}
|
||||
}, StoppingToken.Token
|
||||
, TaskCreationOptions.LongRunning);
|
||||
|
||||
@@ -142,8 +142,8 @@ public class CollectDeviceHostService : BackgroundService
|
||||
|
||||
var alarmHostService = _scopeFactory.GetBackgroundService<AlarmHostService>();
|
||||
var valueHisHostService = _scopeFactory.GetBackgroundService<ValueHisHostService>();
|
||||
alarmHostService.Stop(oldDeviceRuntime);
|
||||
valueHisHostService.Stop(oldDeviceRuntime);
|
||||
alarmHostService?.Stop(oldDeviceRuntime);
|
||||
valueHisHostService?.Stop(oldDeviceRuntime);
|
||||
var uploadDeviceHostService = _scopeFactory.GetBackgroundService<UploadDeviceHostService>();
|
||||
uploadDeviceHostService.RemoveDeviceThread();
|
||||
|
||||
@@ -171,8 +171,8 @@ public class CollectDeviceHostService : BackgroundService
|
||||
|
||||
var alarmHostService = _scopeFactory.GetBackgroundService<AlarmHostService>();
|
||||
var valueHisHostService = _scopeFactory.GetBackgroundService<ValueHisHostService>();
|
||||
alarmHostService.Start();
|
||||
valueHisHostService.Start();
|
||||
alarmHostService?.Start();
|
||||
valueHisHostService?.Start();
|
||||
var uploadDeviceHostService = _scopeFactory.GetBackgroundService<UploadDeviceHostService>();
|
||||
uploadDeviceHostService.StartDeviceThread();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using Microsoft.Extensions.Logging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Timers;
|
||||
|
||||
using UAParser;
|
||||
|
||||
@@ -40,7 +39,7 @@ namespace ThingsGateway.Web.Foundation
|
||||
[Description("Stage环境")]
|
||||
public string Stage { get; set; }
|
||||
}
|
||||
public class HardwareInfoService:ISingleton
|
||||
public class HardwareInfoService : ISingleton
|
||||
{
|
||||
public TGHardwareInfo HardwareInfo
|
||||
{
|
||||
@@ -68,31 +67,26 @@ namespace ThingsGateway.Web.Foundation
|
||||
}
|
||||
}
|
||||
private readonly Hardware.Info.HardwareInfo hardwareInfo = new();
|
||||
private System.Timers.Timer DelayTimer10000;
|
||||
private System.Timers.Timer DelayTimer30000;
|
||||
ILogger _logger;
|
||||
public HardwareInfoService()
|
||||
{
|
||||
DelayTimer10000 = new System.Timers.Timer(10000);
|
||||
DelayTimer10000.Elapsed += timer10000_Elapsed;
|
||||
DelayTimer10000.AutoReset = true;
|
||||
DelayTimer10000.Start();
|
||||
DelayTimer30000 = new System.Timers.Timer(30000);
|
||||
DelayTimer30000.Elapsed += timer30000_Elapsed;
|
||||
DelayTimer30000.AutoReset = true;
|
||||
DelayTimer30000.Start();
|
||||
Scoped.Create((factory, scope) =>
|
||||
{
|
||||
var loggerFactory = scope.ServiceProvider.GetRequiredService<ILoggerFactory>();
|
||||
_logger = loggerFactory.CreateLogger(nameof(HardwareInfoService));
|
||||
});
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
timer10000_Elapsed(null, null);
|
||||
timer30000_Elapsed(null, null);
|
||||
|
||||
});
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
hardwareInfo.RefreshMemoryStatus();
|
||||
hardwareInfo.RefreshMemoryList();
|
||||
hardwareInfo.RefreshDriveList();
|
||||
hardwareInfo.RefreshNetworkAdapterList();
|
||||
hardwareInfo.RefreshCPUList();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
@@ -114,34 +108,6 @@ namespace ThingsGateway.Web.Foundation
|
||||
return "";
|
||||
}
|
||||
}
|
||||
private void timer10000_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
hardwareInfo.RefreshMemoryStatus();
|
||||
hardwareInfo.RefreshMemoryList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取硬件信息失败");
|
||||
}
|
||||
|
||||
}
|
||||
private void timer30000_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
hardwareInfo.RefreshDriveList();
|
||||
hardwareInfo.RefreshNetworkAdapterList();
|
||||
hardwareInfo.RefreshCPUList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取硬件信息失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
//添加采集/上传后台服务
|
||||
services.AddHostedService<CollectDeviceHostService>();
|
||||
services.AddHostedService<AlarmHostService>();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Hardware.Info" Version="10.1.1" />
|
||||
<PackageReference Include="Hardware.Info" Version="10.1.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
using Masa.Blazor;
|
||||
|
||||
using ThingsGateway.Application;
|
||||
|
||||
namespace ThingsGateway.Web.Rcl.Core
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -20,7 +20,13 @@ global using System.Diagnostics.CodeAnalysis;
|
||||
global using System.Globalization;
|
||||
global using System.Linq;
|
||||
global using System.Threading.Tasks;
|
||||
global using ThingsGateway.Web.Rcl;
|
||||
global using ThingsGateway.Web.Rcl.Core;
|
||||
|
||||
global using ThingsGateway.Application;
|
||||
global using ThingsGateway.Core;
|
||||
global using ThingsGateway.Core;
|
||||
|
||||
/* 项目“ThingsGateway.Web.Rcl.Core (net7.0)”的未合并的更改
|
||||
在此之前:
|
||||
global using ThingsGateway.Application;
|
||||
在此之后:
|
||||
global using ThingsGateway.Web.Rcl;
|
||||
*/
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
using BlazorComponent;
|
||||
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
using NewLife.Serialization;
|
||||
|
||||
using System;
|
||||
|
||||
using ThingsGateway.Core.Utils;
|
||||
|
||||
namespace ThingsGateway.Web.Rcl
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using BlazorComponent;
|
||||
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
|
||||
using System.Net.Http;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
global using Microsoft.AspNetCore.Components;
|
||||
|
||||
global using System.Collections.Generic;
|
||||
global using System.Net.Http;
|
||||
global using System.Threading.Tasks;
|
||||
|
||||
global using ThingsGateway.Application;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"ThingsGateway.Foundation",
|
||||
"ThingsGateway.Web.Foundation",
|
||||
"ThingsGateway.Web.Page",
|
||||
|
||||
"BlazorComponent",
|
||||
"ThingsGateway.Web.Rcl",
|
||||
"ThingsGateway.Web.Rcl.Core",
|
||||
"ThingsGateway.Core",
|
||||
|
||||
Reference in New Issue
Block a user