mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-30 23:24:00 +08:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f972aa515 | ||
|
|
7407ba6313 | ||
|
|
1c79de207b | ||
|
|
257c79db92 | ||
|
|
9d1934a308 | ||
|
|
d70f959902 | ||
|
|
e4d810222f | ||
|
|
bc1af4ae07 | ||
|
|
6e688ef43f | ||
|
|
f0fe1b23dc | ||
|
|
aaf2006401 | ||
|
|
b821e26935 | ||
|
|
7ae4287157 | ||
|
|
c6fcc38a65 | ||
|
|
ab2d5c8853 | ||
|
|
5e557ff0bc | ||
|
|
918ca449a1 | ||
|
|
8e73368008 |
@@ -5,12 +5,11 @@
|
||||
|
||||
**NetCore** 跨平台边缘采集网关(工业设备采集)
|
||||
|
||||
**ThingsGateway** 存储库同时提供 [**设备采集驱动**](https://www.nuget.org/profiles/KimDiego)
|
||||
**ThingsGateway** 存储库同时提供 [**设备采集驱动**](https://www.nuget.org/packages?q=Tags%3A%22ThingsGateway%22)
|
||||
|
||||
**ThingsGateway** 存储库同时提供 **基于Blazor的权限框架** 查看 [**ThingsGateway.Admin**](https://gitee.com/dotnetchina/ThingsGateway/blob/master/framework/ThingsGateway.Admin.sln)
|
||||
|
||||
|
||||
|
||||
## 文档
|
||||
|
||||
[ThingsGateway](https://diego2098.gitee.io/thingsgateway-docs/) 文档。
|
||||
|
||||
@@ -81,6 +81,15 @@ dotnet_diagnostic.CA2208.severity = none
|
||||
# IDE0057: 使用范围运算符
|
||||
dotnet_diagnostic.IDE0057.severity = none
|
||||
|
||||
# IDE0056: 使用索引运算符
|
||||
dotnet_diagnostic.IDE0056.severity = none
|
||||
|
||||
# CA1830: 最好使用 StringBuilder 的强类型 Append 和 Insert 方法重载
|
||||
dotnet_diagnostic.CA1830.severity = none
|
||||
|
||||
# CA1847: 将字符型文本用于单个字符查找
|
||||
dotnet_diagnostic.CA1847.severity = none
|
||||
|
||||
[*.vb]
|
||||
#### 命名样式 ####
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
||||
<Version>2.0.3.0</Version>
|
||||
<Version>2.0.5.0</Version>
|
||||
<Authors>Diego</Authors>
|
||||
<Product>ThingsGateway</Product>
|
||||
<Copyright>© 2023-present Diego</Copyright>
|
||||
|
||||
@@ -19,7 +19,7 @@ using ThingsGateway.Admin.Core;
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 后台登录控制器
|
||||
/// 文件下载
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(CateGoryConst.ThingsGatewayAdmin, Order = 200)]
|
||||
[Route("file")]
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</member>
|
||||
<member name="T:ThingsGateway.Admin.Application.FileController">
|
||||
<summary>
|
||||
后台登录控制器
|
||||
文件下载
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Admin.Application.FileController.#ctor(ThingsGateway.Admin.Application.IFileService,ThingsGateway.Admin.Application.IOperateLogService,ThingsGateway.Admin.Application.IVisitLogService)">
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ItemColWithDTTemplate!=null)
|
||||
if (ItemColWithDTTemplate != null)
|
||||
{
|
||||
@ItemColWithDTTemplate(context)
|
||||
}
|
||||
@@ -220,7 +220,7 @@
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
</ItemColContent>
|
||||
@@ -310,16 +310,24 @@
|
||||
{
|
||||
string value = DetailModelPairs[item.Value];
|
||||
{
|
||||
<tr @key="item.Text">
|
||||
<td class="text-start table-minwidth">
|
||||
@item.Text
|
||||
</td>
|
||||
<td class="text-start ">
|
||||
<div style="word-break:break-all; white-space:pre-wrap;">
|
||||
@value
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@if (Detailemplate != null)
|
||||
{
|
||||
@Detailemplate((item,value))
|
||||
}
|
||||
else
|
||||
{
|
||||
<tr @key="item.Text">
|
||||
<td class="text-start table-minwidth">
|
||||
@item.Text
|
||||
</td>
|
||||
<td class="text-start ">
|
||||
<div style="word-break:break-all; white-space:pre-wrap;">
|
||||
@value
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,12 +72,6 @@ public partial class AppDataTable<TItem, SearchItem, AddItem, EditItem> : IAppDa
|
||||
[Parameter]
|
||||
public bool Dense { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 明细行模板
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public RenderFragment<TItem> DetailRowTemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编辑项委托
|
||||
/// </summary>
|
||||
@@ -89,6 +83,11 @@ public partial class AppDataTable<TItem, SearchItem, AddItem, EditItem> : IAppDa
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public RenderFragment<EditItem> EditTemplate { get; set; }
|
||||
/// <summary>
|
||||
/// 获得/设置 详情模板
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public RenderFragment<(DataTableHeader<TItem>, string)> Detailemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 表头过滤,返回DataTableHeader列表,传输参数已包含全部初始表头与表头标题
|
||||
|
||||
@@ -43,11 +43,6 @@
|
||||
表格紧凑
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Admin.Blazor.Core.AppDataTable`4.DetailRowTemplate">
|
||||
<summary>
|
||||
获得/设置 明细行模板
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Admin.Blazor.Core.AppDataTable`4.EditCallAsync">
|
||||
<summary>
|
||||
编辑项委托
|
||||
@@ -58,6 +53,11 @@
|
||||
获得/设置 编辑模板
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Admin.Blazor.Core.AppDataTable`4.Detailemplate">
|
||||
<summary>
|
||||
获得/设置 详情模板
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Admin.Blazor.Core.AppDataTable`4.FilterHeaders">
|
||||
<summary>
|
||||
表头过滤,返回DataTableHeader列表,传输参数已包含全部初始表头与表头标题
|
||||
|
||||
@@ -21,7 +21,7 @@ using ThingsGateway.Application;
|
||||
namespace ThingsGateway.ApiController;
|
||||
|
||||
/// <summary>
|
||||
/// 后台登录控制器
|
||||
/// 文件下载
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(CateGoryConst.ThingsGatewayAdmin, Order = 200)]
|
||||
[Route("gatewayFile")]
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</member>
|
||||
<member name="T:ThingsGateway.ApiController.FileController">
|
||||
<summary>
|
||||
后台登录控制器
|
||||
文件下载
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.ApiController.FileController.#ctor(ThingsGateway.Application.IRpcLogService,ThingsGateway.Application.IBackendLogService,ThingsGateway.Application.ICollectDeviceService,ThingsGateway.Application.IUploadDeviceService,ThingsGateway.Application.IVariableService)">
|
||||
|
||||
@@ -31,7 +31,7 @@ public class DeviceVariable : MemoryVariable
|
||||
public virtual long DeviceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 写入表达式
|
||||
/// 单位
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Unit", ColumnDescription = "单位", Length = 200, IsNullable = true)]
|
||||
[DataTable(Order = 3, IsShow = true, Sortable = true)]
|
||||
@@ -59,12 +59,7 @@ public class DeviceVariable : MemoryVariable
|
||||
[DataTable(Order = 3, IsShow = true, Sortable = true)]
|
||||
public string VariableAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 写入表达式
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "WriteExpressions", ColumnDescription = "写入表达式", Length = 200, IsNullable = true)]
|
||||
[DataTable(Order = 7, IsShow = true, Sortable = true)]
|
||||
public string WriteExpressions { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否中间变量
|
||||
|
||||
@@ -51,7 +51,12 @@ public class MemoryVariable : BaseEntity
|
||||
[SugarColumn(ColumnName = "ReadExpressions", ColumnDescription = "读取表达式", Length = 200, IsNullable = true)]
|
||||
[DataTable(Order = 7, IsShow = true, Sortable = true, CellClass = " table-text-truncate ")]
|
||||
public string ReadExpressions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 写入表达式
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "WriteExpressions", ColumnDescription = "写入表达式", Length = 200, IsNullable = true)]
|
||||
[DataTable(Order = 7, IsShow = true, Sortable = true)]
|
||||
public string WriteExpressions { get; set; }
|
||||
/// <summary>
|
||||
/// 是否中间变量
|
||||
/// </summary>
|
||||
|
||||
@@ -20,6 +20,8 @@ public class VariableData
|
||||
public long Id { get; set; }
|
||||
/// <inheritdoc cref="MemoryVariable.Name"/>
|
||||
public string Name { get; set; }
|
||||
/// <inheritdoc cref="DeviceVariable.Unit"/>
|
||||
public string Unit { get; set; }
|
||||
/// <inheritdoc cref="MemoryVariable.Description"/>
|
||||
public string Description { get; set; }
|
||||
/// <inheritdoc cref="DeviceVariableRunTime.DeviceName"/>
|
||||
@@ -36,7 +38,7 @@ public class VariableData
|
||||
public bool IsOnline { get; set; }
|
||||
/// <inheritdoc cref="MemoryVariable.ReadExpressions"/>
|
||||
public string ReadExpressions { get; set; }
|
||||
/// <inheritdoc cref="DeviceVariable.WriteExpressions"/>
|
||||
/// <inheritdoc cref="MemoryVariable.WriteExpressions"/>
|
||||
public string WriteExpressions { get; set; }
|
||||
/// <inheritdoc cref="DeviceVariable.IntervalTime"/>
|
||||
public int IntervalTime { get; set; }
|
||||
|
||||
@@ -17,8 +17,6 @@ using Newtonsoft.Json.Linq;
|
||||
using ThingsGateway.Foundation;
|
||||
using ThingsGateway.Foundation.Serial;
|
||||
|
||||
using TouchSocket.Core;
|
||||
|
||||
namespace ThingsGateway.Application;
|
||||
/// <summary>
|
||||
/// <para></para>
|
||||
|
||||
@@ -360,7 +360,7 @@
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.DeviceVariable.Unit">
|
||||
<summary>
|
||||
写入表达式
|
||||
单位
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.DeviceVariable.IntervalTime">
|
||||
@@ -378,11 +378,6 @@
|
||||
变量地址,可能带有额外的信息,比如<see cref="T:ThingsGateway.Foundation.DataFormat"/> ,以;分割
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.DeviceVariable.WriteExpressions">
|
||||
<summary>
|
||||
写入表达式
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.DeviceVariable.IsMemoryVariable">
|
||||
<summary>
|
||||
是否中间变量
|
||||
@@ -524,6 +519,11 @@
|
||||
读取表达式
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.MemoryVariable.WriteExpressions">
|
||||
<summary>
|
||||
写入表达式
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.MemoryVariable.IsMemoryVariable">
|
||||
<summary>
|
||||
是否中间变量
|
||||
@@ -1791,6 +1791,9 @@
|
||||
<member name="P:ThingsGateway.Application.VariableData.Name">
|
||||
<inheritdoc cref="P:ThingsGateway.Application.MemoryVariable.Name"/>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.VariableData.Unit">
|
||||
<inheritdoc cref="P:ThingsGateway.Application.DeviceVariable.Unit"/>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.VariableData.Description">
|
||||
<inheritdoc cref="P:ThingsGateway.Application.MemoryVariable.Description"/>
|
||||
</member>
|
||||
@@ -1816,7 +1819,7 @@
|
||||
<inheritdoc cref="P:ThingsGateway.Application.MemoryVariable.ReadExpressions"/>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.VariableData.WriteExpressions">
|
||||
<inheritdoc cref="P:ThingsGateway.Application.DeviceVariable.WriteExpressions"/>
|
||||
<inheritdoc cref="P:ThingsGateway.Application.MemoryVariable.WriteExpressions"/>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.VariableData.IntervalTime">
|
||||
<inheritdoc cref="P:ThingsGateway.Application.DeviceVariable.IntervalTime"/>
|
||||
@@ -3561,6 +3564,11 @@
|
||||
开始采集
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Application.CollectDeviceThread.BeforeStopThreadAsync">
|
||||
<summary>
|
||||
停止采集前,提前取消Token
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Application.CollectDeviceThread.StopThreadAsync">
|
||||
<summary>
|
||||
停止采集
|
||||
@@ -3934,6 +3942,11 @@
|
||||
开始上传
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Application.UploadDeviceThread.BeforeStopThreadAsync">
|
||||
<summary>
|
||||
停止采集前,提前取消Token
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Application.UploadDeviceThread.StopThreadAsync">
|
||||
<summary>
|
||||
停止上传
|
||||
|
||||
@@ -85,6 +85,29 @@ public class CollectDeviceThread : IAsyncDisposable
|
||||
easyLock.Release();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 停止采集前,提前取消Token
|
||||
/// </summary>
|
||||
public virtual async Task BeforeStopThreadAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
await easyLock.WaitAsync();
|
||||
|
||||
if (DeviceTask == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var token in StoppingTokens)
|
||||
{
|
||||
token.Cancel();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
easyLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止采集
|
||||
@@ -173,7 +196,10 @@ public class CollectDeviceThread : IAsyncDisposable
|
||||
foreach (var device in CollectDeviceCores)
|
||||
{
|
||||
try
|
||||
{//初始化成功才能执行
|
||||
{
|
||||
if (stoppingToken.IsCancellationRequested)
|
||||
break;
|
||||
//初始化成功才能执行
|
||||
if (device.IsInitSuccess)
|
||||
{
|
||||
//如果是共享通道类型,需要每次转换时切换适配器
|
||||
|
||||
@@ -328,6 +328,18 @@ public class CollectDeviceWorker : BackgroundService
|
||||
/// </summary>
|
||||
private async Task RemoveAllDeviceThreadAsync()
|
||||
{
|
||||
await CollectDeviceThreads.ParallelForEachAsync(async (deviceThread, token) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await deviceThread.BeforeStopThreadAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger?.LogError(ex, deviceThread.ToString());
|
||||
}
|
||||
}, 10);
|
||||
|
||||
await CollectDeviceThreads.ParallelForEachAsync(async (deviceThread, token) =>
|
||||
{
|
||||
try
|
||||
|
||||
@@ -74,6 +74,29 @@ public class UploadDeviceThread : IAsyncDisposable
|
||||
easyLock.Release();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 停止采集前,提前取消Token
|
||||
/// </summary>
|
||||
public virtual async Task BeforeStopThreadAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
await easyLock.WaitAsync();
|
||||
|
||||
if (DeviceTask == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var token in StoppingTokens)
|
||||
{
|
||||
token.Cancel();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
easyLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止上传
|
||||
@@ -152,7 +175,10 @@ public class UploadDeviceThread : IAsyncDisposable
|
||||
foreach (var device in UploadDeviceCores)
|
||||
{
|
||||
try
|
||||
{//初始化成功才能执行
|
||||
{
|
||||
if (stoppingToken.IsCancellationRequested)
|
||||
break;
|
||||
//初始化成功才能执行
|
||||
if (device.IsInitSuccess)
|
||||
{
|
||||
|
||||
|
||||
@@ -239,6 +239,17 @@ public class UploadDeviceWorker : BackgroundService
|
||||
/// </summary>
|
||||
private async Task RemoveAllDeviceThreadAsync()
|
||||
{
|
||||
await UploadDeviceThreads.ParallelForEachAsync(async (deviceThread, token) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await deviceThread.BeforeStopThreadAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger?.LogError(ex, deviceThread.ToString());
|
||||
}
|
||||
}, 10);
|
||||
await UploadDeviceThreads.ParallelForEachAsync(async (deviceThread, token) =>
|
||||
{
|
||||
try
|
||||
|
||||
@@ -102,44 +102,6 @@
|
||||
|
||||
}
|
||||
|
||||
@foreach (var item in ImportPreviews)
|
||||
{
|
||||
<MSubheader Class="mt-2 font-weight-black">
|
||||
@(
|
||||
$"{item.Key},预计导入{item.Value.DataCount}条数据"
|
||||
)
|
||||
</MSubheader>
|
||||
<MSubheader Class=@((item.Value.HasError?"mt-2 red--text":"mt-2 green--text"))>
|
||||
@(
|
||||
(item.Value.HasError ? "出现错误" : "验证成功")
|
||||
)
|
||||
</MSubheader>
|
||||
|
||||
<MVirtualScroll Context="item1" Height=300 OverscanCount=2 ItemSize="60" Items="item.Value.Results">
|
||||
<ItemContent>
|
||||
<MListItem>
|
||||
<MListItemAction>
|
||||
<MChip Class="ma-2">
|
||||
@(
|
||||
$"第{item1.row}行"
|
||||
)
|
||||
</MChip>
|
||||
</MListItemAction>
|
||||
|
||||
<MListItemContent>
|
||||
<MListItemTitle Class=@((item1.isSuccess?"green--text":"red--text"))>
|
||||
<strong>@item1.resultString</strong>
|
||||
</MListItemTitle>
|
||||
</MListItemContent>
|
||||
|
||||
</MListItem>
|
||||
|
||||
<MDivider></MDivider>
|
||||
|
||||
</ItemContent>
|
||||
</MVirtualScroll>
|
||||
|
||||
}
|
||||
</div>
|
||||
<div class="mt-6">
|
||||
<MButton Color="primary" Disabled=@ImportPreviews.Any(it=>it.Value.HasError) OnClick="()=>Step=3">下一步</MButton>
|
||||
|
||||
@@ -78,8 +78,7 @@ public partial class SerialClientPage
|
||||
/// <inheritdoc/>
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
config?.Dispose();
|
||||
config = new TouchSocketConfig();
|
||||
config ??= new TouchSocketConfig();
|
||||
var LogMessage = new TouchSocket.Core.LoggerGroup() { LogLevel = TouchSocket.Core.LogLevel.Trace };
|
||||
LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = TouchSocket.Core.LogLevel.Trace });
|
||||
config.ConfigureContainer(a => a.RegisterSingleton<ILog>(LogMessage));
|
||||
|
||||
@@ -78,8 +78,7 @@ public partial class TcpClientPage
|
||||
/// <returns></returns>
|
||||
public TcpClientEx GetTcpClient()
|
||||
{
|
||||
config?.Dispose();
|
||||
config = new TouchSocketConfig();
|
||||
config ??= new TouchSocketConfig();
|
||||
var LogMessage = new TouchSocket.Core.LoggerGroup() { LogLevel = TouchSocket.Core.LogLevel.Trace };
|
||||
LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = TouchSocket.Core.LogLevel.Trace });
|
||||
config.ConfigureContainer(a => a.RegisterSingleton<ILog>(LogMessage));
|
||||
|
||||
@@ -67,8 +67,7 @@ public partial class TcpServerPage
|
||||
/// <returns></returns>
|
||||
public TcpService GetTcpServer()
|
||||
{
|
||||
config?.Dispose();
|
||||
config = new TouchSocketConfig();
|
||||
config ??= new TouchSocketConfig();
|
||||
var LogMessage = new TouchSocket.Core.LoggerGroup() { LogLevel = TouchSocket.Core.LogLevel.Trace };
|
||||
LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = TouchSocket.Core.LogLevel.Trace });
|
||||
config.ConfigureContainer(a => a.RegisterSingleton<ILog>(LogMessage));
|
||||
|
||||
@@ -67,8 +67,7 @@ public partial class UdpSessionPage : IDisposable
|
||||
/// <returns></returns>
|
||||
public UdpSession GetUdpSession()
|
||||
{
|
||||
config?.Dispose();
|
||||
config = new TouchSocketConfig();
|
||||
config ??= new TouchSocketConfig();
|
||||
var LogMessage = new TouchSocket.Core.LoggerGroup() { LogLevel = TouchSocket.Core.LogLevel.Trace };
|
||||
LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = TouchSocket.Core.LogLevel.Trace });
|
||||
config.ConfigureContainer(a => a.RegisterSingleton<ILog>(LogMessage));
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_collectDeviceGroupSearchName"
|
||||
Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.DeviceGroup)) />
|
||||
</MCardTitle>
|
||||
|
||||
<MTreeview Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight + 240}px; overflow-y:auto)") Dense TItem="string" TKey="string" ActiveChanged=@(async a=>
|
||||
{
|
||||
if(_collectDeviceGroup!=a.FirstOrDefault())
|
||||
|
||||
@@ -199,7 +199,6 @@ public partial class DeviceStatusPage : IDisposable
|
||||
// await MainLayout.StateHasChangedAsync();
|
||||
// }
|
||||
//}
|
||||
|
||||
private async Task RunTimerAsync()
|
||||
{
|
||||
while (await _periodicTimer.WaitForNextTickAsync())
|
||||
|
||||
@@ -180,8 +180,41 @@ else
|
||||
}
|
||||
|
||||
</ItemColTemplate>
|
||||
|
||||
<Detailemplate>
|
||||
@{
|
||||
switch (context.Item1.Value)
|
||||
{
|
||||
case nameof(DeviceVariable.DeviceId):
|
||||
<tr @key="context.Item1.Text">
|
||||
<td class="text-start table-minwidth">
|
||||
@context.Item1.Text
|
||||
</td>
|
||||
<td class="text-start ">
|
||||
<div style="word-break:break-all; white-space:pre-wrap;">
|
||||
@(App.GetService<ICollectDeviceService>().GetNameById(context.Item2.ToLong()))
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
break;
|
||||
default:
|
||||
<tr @key="context.Item1.Text">
|
||||
<td class="text-start table-minwidth">
|
||||
@context.Item1.Text
|
||||
</td>
|
||||
<td class="text-start ">
|
||||
<div style="word-break:break-all; white-space:pre-wrap;">
|
||||
@context.Item2
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
</Detailemplate>
|
||||
</AppDataTable>
|
||||
;
|
||||
;
|
||||
return renderFragment;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ else
|
||||
</span>
|
||||
</LabelContent>
|
||||
</MTreeview>
|
||||
|
||||
</MCard>
|
||||
</MCol>
|
||||
<MCol Md=10 Cols="12">
|
||||
@@ -119,7 +120,38 @@ else
|
||||
}
|
||||
|
||||
</ItemColTemplate>
|
||||
<Detailemplate>
|
||||
@{
|
||||
switch (context.Item1.Value)
|
||||
{
|
||||
case nameof(DeviceVariable.DeviceId):
|
||||
<tr @key="context.Item1.Text">
|
||||
<td class="text-start table-minwidth">
|
||||
@context.Item1.Text
|
||||
</td>
|
||||
<td class="text-start ">
|
||||
<div style="word-break:break-all; white-space:pre-wrap;">
|
||||
@(App.GetService<ICollectDeviceService>().GetNameById(context.Item2.ToLong()))
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
break;
|
||||
default:
|
||||
<tr @key="context.Item1.Text">
|
||||
<td class="text-start table-minwidth">
|
||||
@context.Item1.Text
|
||||
</td>
|
||||
<td class="text-start ">
|
||||
<div style="word-break:break-all; white-space:pre-wrap;">
|
||||
@context.Item2
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
</Detailemplate>
|
||||
</AppDataTable>
|
||||
|
||||
;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
@layout MainLayout
|
||||
|
||||
<MRow NoGutters>
|
||||
<MCol Md=@(IsShowTreeView?4:0)>
|
||||
<MCol Md=@(IsShowTreeView?3:0)>
|
||||
<MCard Show=IsShowTreeView Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight}px);border-radius:0px;")>
|
||||
<MCardTitle>
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_searchName" Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.PluginId)) />
|
||||
@@ -62,7 +62,7 @@
|
||||
</MTreeview>
|
||||
</MCard>
|
||||
</MCol>
|
||||
<MCol Md=@(IsShowTreeView?8:12)>
|
||||
<MCol Md=@(IsShowTreeView?9:12)>
|
||||
<MCard Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight}px);border-radius:0px;")>
|
||||
<MCard Class="mb-3 pa-2 text-h6" Elevation="0" Flat Rounded="false">
|
||||
<MRow Align="AlignTypes.Center" Class="mt-1">
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
<MCard Elevation="1" Class="ma-2">
|
||||
<MCardSubtitle Class=@("text-h6")>
|
||||
<div class="mt-1 d-flex align-center justify-space-between">
|
||||
<span>"当前内存/磁盘信息</span>
|
||||
<span>当前内存/磁盘信息</span>
|
||||
</div>
|
||||
</MCardSubtitle>
|
||||
<MDivider></MDivider>
|
||||
|
||||
@@ -149,6 +149,7 @@
|
||||
<MTextField Dense Outlined HideDetails="@("auto")" @bind-Value=@context.ReadExpressions />
|
||||
|
||||
</MCol>
|
||||
|
||||
<MCol Md=6 Cols=12 class="px-1">
|
||||
|
||||
<MSubheader Class="font-weight-black"> @(context.Description(x => x.WriteExpressions)) </MSubheader>
|
||||
|
||||
@@ -96,7 +96,7 @@ public partial class MemoryVariablePage
|
||||
|
||||
Task<Dictionary<string, ImportPreviewOutputBase>> DeviceImportAsync(IBrowserFile file)
|
||||
{
|
||||
return VariableService.PreviewAsync(file);
|
||||
return VariableService.MemoryVariablePreviewAsync(file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public abstract class ReadWriteDevicesSerialBase : ReadWriteDevicesClientBase
|
||||
public ReadWriteDevicesSerialBase(SerialClient serialClient)
|
||||
{
|
||||
SerialClient = serialClient;
|
||||
WaitingClientEx = SerialClient.GetWaitingClientEx(new());
|
||||
WaitingClientEx = SerialClient.GetWaitingClientEx(new() { BreakTrigger = true });
|
||||
|
||||
SerialClient.Connecting -= Connecting;
|
||||
SerialClient.Connected -= Connected;
|
||||
|
||||
@@ -26,7 +26,7 @@ public abstract class ReadWriteDevicesTcpClientBase : ReadWriteDevicesClientBase
|
||||
public ReadWriteDevicesTcpClientBase(TcpClientEx tcpClient)
|
||||
{
|
||||
TcpClientEx = tcpClient;
|
||||
WaitingClientEx = TcpClientEx.GetWaitingClientEx(new());
|
||||
WaitingClientEx = TcpClientEx.GetWaitingClientEx(new() { BreakTrigger = true });
|
||||
TcpClientEx.Connecting -= Connecting;
|
||||
TcpClientEx.Connected -= Connected;
|
||||
TcpClientEx.Disconnecting -= Disconnecting;
|
||||
|
||||
@@ -24,10 +24,8 @@ public abstract class ReadWriteDevicesUdpBase : ReadWriteDevicesClientBase
|
||||
/// <inheritdoc cref="ReadWriteDevicesUdpBase"/>
|
||||
public ReadWriteDevicesUdpBase(UdpSession udpSession)
|
||||
{
|
||||
|
||||
UdpSession = udpSession;
|
||||
WaitingClientEx = UdpSession.GetWaitingClientEx(new());
|
||||
|
||||
WaitingClientEx = UdpSession.GetWaitingClientEx(new() { BreakTrigger = true });
|
||||
SetDataAdapter();
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
|
||||
|
||||
using ThingsGateway.Foundation.Serial;
|
||||
|
||||
namespace ThingsGateway.Foundation;
|
||||
|
||||
internal class WaitingClientEx<TClient> : DisposableObject, IWaitingClient<TClient> where TClient : IClient, IDefaultSender, ISender
|
||||
@@ -52,6 +54,7 @@ internal class WaitingClientEx<TClient> : DisposableObject, IWaitingClient<TClie
|
||||
{
|
||||
this.Client = default;
|
||||
this.m_waitData.SafeDispose();
|
||||
this.m_waitDataAsync.SafeDispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
@@ -66,7 +69,11 @@ internal class WaitingClientEx<TClient> : DisposableObject, IWaitingClient<TClie
|
||||
this.m_breaked = true;
|
||||
this.Cancel();
|
||||
}
|
||||
|
||||
private void OnSerialClientDisconnected(ISerialClientBase client, DisconnectEventArgs e)
|
||||
{
|
||||
this.m_breaked = true;
|
||||
this.Cancel();
|
||||
}
|
||||
private bool OnHandleRawBuffer(ByteBlock byteBlock)
|
||||
{
|
||||
var responsedData = new ResponsedData(byteBlock.ToArray(), null, true);
|
||||
@@ -121,7 +128,10 @@ internal class WaitingClientEx<TClient> : DisposableObject, IWaitingClient<TClie
|
||||
{
|
||||
tcpClient.Disconnected += this.OnDisconnected;
|
||||
}
|
||||
|
||||
if (this.WaitingOptions.BreakTrigger && this.Client is ISerialClientBase serialClient)
|
||||
{
|
||||
serialClient.Disconnected += this.OnSerialClientDisconnected;
|
||||
}
|
||||
if (this.WaitingOptions.AdapterFilter == AdapterFilter.AllAdapter || this.WaitingOptions.AdapterFilter == AdapterFilter.WaitAdapter)
|
||||
{
|
||||
this.Client.OnHandleReceivedData += this.OnHandleReceivedData;
|
||||
@@ -179,7 +189,10 @@ internal class WaitingClientEx<TClient> : DisposableObject, IWaitingClient<TClie
|
||||
{
|
||||
tcpClient.Disconnected -= this.OnDisconnected;
|
||||
}
|
||||
|
||||
if (this.WaitingOptions.BreakTrigger && this.Client is ISerialClientBase serialClient)
|
||||
{
|
||||
serialClient.Disconnected -= this.OnSerialClientDisconnected;
|
||||
}
|
||||
if (this.WaitingOptions.AdapterFilter == AdapterFilter.AllAdapter || this.WaitingOptions.AdapterFilter == AdapterFilter.WaitAdapter)
|
||||
{
|
||||
this.Client.OnHandleReceivedData -= this.OnHandleReceivedData;
|
||||
@@ -191,6 +204,8 @@ internal class WaitingClientEx<TClient> : DisposableObject, IWaitingClient<TClie
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ResponsedData SendThenResponse(byte[] buffer, int timeout = 1000 * 5, CancellationToken token = default)
|
||||
{
|
||||
return this.SendThenResponse(buffer, 0, buffer.Length, timeout, token);
|
||||
@@ -216,7 +231,10 @@ internal class WaitingClientEx<TClient> : DisposableObject, IWaitingClient<TClie
|
||||
{
|
||||
tcpClient.Disconnected += this.OnDisconnected;
|
||||
}
|
||||
|
||||
if (this.WaitingOptions.BreakTrigger && this.Client is ISerialClientBase serialClient)
|
||||
{
|
||||
serialClient.Disconnected += this.OnSerialClientDisconnected;
|
||||
}
|
||||
if (this.WaitingOptions.AdapterFilter == AdapterFilter.AllAdapter || this.WaitingOptions.AdapterFilter == AdapterFilter.WaitAdapter)
|
||||
{
|
||||
this.Client.OnHandleReceivedData += this.OnHandleReceivedData;
|
||||
@@ -274,7 +292,10 @@ internal class WaitingClientEx<TClient> : DisposableObject, IWaitingClient<TClie
|
||||
{
|
||||
tcpClient.Disconnected -= this.OnDisconnected;
|
||||
}
|
||||
|
||||
if (this.WaitingOptions.BreakTrigger && this.Client is ISerialClientBase serialClient)
|
||||
{
|
||||
serialClient.Disconnected -= this.OnSerialClientDisconnected;
|
||||
}
|
||||
if (this.WaitingOptions.AdapterFilter == AdapterFilter.AllAdapter || this.WaitingOptions.AdapterFilter == AdapterFilter.WaitAdapter)
|
||||
{
|
||||
this.Client.OnHandleReceivedData -= this.OnHandleReceivedData;
|
||||
|
||||
@@ -45,4 +45,9 @@ public class SerialProperty
|
||||
/// </summary>
|
||||
[Description("停止位")]
|
||||
public StopBits StopBits { get; set; } = StopBits.One;
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{PortName}[{BaudRate},{DataBits},{StopBits},{Parity}]";
|
||||
}
|
||||
}
|
||||
@@ -2288,6 +2288,9 @@
|
||||
停止位
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Foundation.Serial.SerialProperty.ToString">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="T:ThingsGateway.Foundation.SerialPortExtensions">
|
||||
<summary>
|
||||
SocketExtension
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Foundataion\ThingsGateway.Foundation.Adapter.OPCUA\ThingsGateway.Foundation.Adapter.OPCUA.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>OPCUAClientDemo</name>
|
||||
</assembly>
|
||||
<members>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,26 @@
|
||||
using ThingsGateway.Foundation.Adapter.OPCUA;
|
||||
|
||||
using TouchSocket.Core;
|
||||
|
||||
namespace ModbusDemo
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
OPCUAClient oPCUAClient = new(new EasyLogger(a => Console.WriteLine(a)))
|
||||
{
|
||||
OPCNode = new()
|
||||
{
|
||||
OPCUrl = "opc.tcp://desktop-p5gb4iq:50001/StandardServer",
|
||||
IsUseSecurity = true,
|
||||
}
|
||||
};
|
||||
await oPCUAClient.ConnectAsync();
|
||||
|
||||
var testData1 = await oPCUAClient.ReadJTokenValueAsync(new[] { "ns=2;i=2897" });
|
||||
await oPCUAClient.WriteNodeAsync("ns=2;i=2897", testData1.FirstOrDefault().Item3);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
||||
<Version>2.0.3.0</Version>
|
||||
<Version>2.0.5.0</Version>
|
||||
<Authors>Diego</Authors>
|
||||
<Product>ThingsGateway</Product>
|
||||
<Copyright>© 2023-present Diego</Copyright>
|
||||
|
||||
@@ -82,12 +82,12 @@ public class ModbusRtu : ReadWriteDevicesSerialBase
|
||||
/// <inheritdoc/>
|
||||
public override void SetDataAdapter()
|
||||
{
|
||||
ModbusRtuDataHandleAdapter DataHandleAdapter = new()
|
||||
ModbusRtuDataHandleAdapter dataHandleAdapter = new()
|
||||
{
|
||||
Crc16CheckEnable = Crc16CheckEnable,
|
||||
CacheTimeout = TimeSpan.FromMilliseconds(CacheTimeout)
|
||||
};
|
||||
SerialClient.SetDataHandlingAdapter(DataHandleAdapter);
|
||||
SerialClient.SetDataHandlingAdapter(dataHandleAdapter);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -78,12 +78,12 @@ public class ModbusRtuOverTcp : ReadWriteDevicesTcpClientBase
|
||||
/// <inheritdoc/>
|
||||
public override void SetDataAdapter()
|
||||
{
|
||||
ModbusRtuDataHandleAdapter DataHandleAdapter = new()
|
||||
ModbusRtuDataHandleAdapter dataHandleAdapter = new()
|
||||
{
|
||||
Crc16CheckEnable = Crc16CheckEnable,
|
||||
CacheTimeout = TimeSpan.FromMilliseconds(CacheTimeout)
|
||||
};
|
||||
TcpClientEx.SetDataHandlingAdapter(DataHandleAdapter);
|
||||
TcpClientEx.SetDataHandlingAdapter(dataHandleAdapter);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -72,11 +72,14 @@ public class ModbusRtuOverUdp : ReadWriteDevicesUdpBase
|
||||
/// <inheritdoc/>
|
||||
public override void SetDataAdapter()
|
||||
{
|
||||
ModbusRtuOverUdpDataHandleAdapter DataHandleAdapter = new()
|
||||
ModbusRtuOverUdpDataHandleAdapter dataHandleAdapter = new()
|
||||
{
|
||||
Crc16CheckEnable = Crc16CheckEnable,
|
||||
};
|
||||
UdpSession.SetDataHandlingAdapter(DataHandleAdapter);
|
||||
UdpSession.Config.SetUdpDataHandlingAdapter(() =>
|
||||
{
|
||||
return dataHandleAdapter;
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -78,8 +78,8 @@ public class ModbusServer : ReadWriteDevicesTcpServerBase
|
||||
/// <inheritdoc/>
|
||||
public override void SetDataAdapter(SocketClient client)
|
||||
{
|
||||
ModbusServerDataHandleAdapter DataHandleAdapter = new();
|
||||
client.SetDataHandlingAdapter(DataHandleAdapter);
|
||||
ModbusServerDataHandleAdapter dataHandleAdapter = new();
|
||||
client.SetDataHandlingAdapter(dataHandleAdapter);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -79,12 +79,12 @@ public class ModbusTcp : ReadWriteDevicesTcpClientBase
|
||||
/// <inheritdoc/>
|
||||
public override void SetDataAdapter()
|
||||
{
|
||||
ModbusTcpDataHandleAdapter DataHandleAdapter = new()
|
||||
ModbusTcpDataHandleAdapter dataHandleAdapter = new()
|
||||
{
|
||||
IsCheckMessageId = IsCheckMessageId,
|
||||
CacheTimeout = TimeSpan.FromMilliseconds(CacheTimeout)
|
||||
};
|
||||
TcpClientEx.SetDataHandlingAdapter(DataHandleAdapter);
|
||||
TcpClientEx.SetDataHandlingAdapter(dataHandleAdapter);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -75,11 +75,14 @@ public class ModbusUdp : ReadWriteDevicesUdpBase
|
||||
/// <inheritdoc/>
|
||||
public override void SetDataAdapter()
|
||||
{
|
||||
ModbusUdpDataHandleAdapter DataHandleAdapter = new()
|
||||
ModbusUdpDataHandleAdapter dataHandleAdapter = new()
|
||||
{
|
||||
IsCheckMessageId = IsCheckMessageId
|
||||
};
|
||||
UdpSession.SetDataHandlingAdapter(DataHandleAdapter);
|
||||
UdpSession.Config.SetUdpDataHandlingAdapter(() =>
|
||||
{
|
||||
return dataHandleAdapter;
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -31,11 +31,6 @@ public static class JsonUtils
|
||||
/// <summary>
|
||||
/// 解析获取DataValue
|
||||
/// </summary>
|
||||
/// <param name="Context"></param>
|
||||
/// <param name="dataTypeId"></param>
|
||||
/// <param name="builtInType"></param>
|
||||
/// <param name="valueRank"></param>
|
||||
/// <param name="json"></param>
|
||||
/// <returns></returns>
|
||||
public static DataValue Decode(
|
||||
IServiceMessageContext Context,
|
||||
@@ -45,6 +40,7 @@ public static class JsonUtils
|
||||
JToken json
|
||||
)
|
||||
{
|
||||
|
||||
var data = DecoderObject(Context, dataTypeId, builtInType, valueRank, json);
|
||||
var dataValue = new DataValue(new Variant(data));
|
||||
return dataValue;
|
||||
@@ -54,11 +50,6 @@ public static class JsonUtils
|
||||
/// <summary>
|
||||
/// 解析获取object
|
||||
/// </summary>
|
||||
/// <param name="Context"></param>
|
||||
/// <param name="dataTypeId"></param>
|
||||
/// <param name="builtInType"></param>
|
||||
/// <param name="valueRank"></param>
|
||||
/// <param name="json"></param>
|
||||
/// <returns></returns>
|
||||
public static object DecoderObject(
|
||||
IServiceMessageContext Context,
|
||||
@@ -76,10 +67,9 @@ public static class JsonUtils
|
||||
{
|
||||
Value = new
|
||||
{
|
||||
TypeId = new { Id = dataTypeId.Identifier },
|
||||
TypeId = new { Id = dataTypeId.Identifier, Namespace = dataTypeId.NamespaceIndex },
|
||||
Body = json
|
||||
}
|
||||
|
||||
}.ToJson();
|
||||
break;
|
||||
case BuiltInType.Variant:
|
||||
|
||||
@@ -14,6 +14,7 @@ using Newtonsoft.Json.Linq;
|
||||
|
||||
using Opc.Ua;
|
||||
using Opc.Ua.Client;
|
||||
using Opc.Ua.Client.ComplexTypes;
|
||||
using Opc.Ua.Configuration;
|
||||
|
||||
using System.Collections.Generic;
|
||||
@@ -454,13 +455,24 @@ public class OPCUAClient : DisposableObject
|
||||
/// </summary>
|
||||
public async Task ConnectAsync()
|
||||
{
|
||||
m_session = await ConnectAsync(OPCNode.OPCUrl);
|
||||
await ConnectAsync(OPCNode.OPCUrl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 断开连接。
|
||||
/// </summary>
|
||||
public void Disconnect()
|
||||
{
|
||||
PrivateDisconnect();
|
||||
// disconnect any existing session.
|
||||
if (m_session != null)
|
||||
{
|
||||
Log.Debug("断开连接");
|
||||
m_session = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void PrivateDisconnect()
|
||||
{
|
||||
// stop any reconnect operation.
|
||||
if (m_reConnectHandler != null)
|
||||
@@ -468,15 +480,7 @@ public class OPCUAClient : DisposableObject
|
||||
m_reConnectHandler.SafeDispose();
|
||||
m_reConnectHandler = null;
|
||||
}
|
||||
|
||||
// disconnect any existing session.
|
||||
if (m_session != null)
|
||||
{
|
||||
Log.Debug("断开连接");
|
||||
m_session.Close(10000);
|
||||
m_session = null;
|
||||
}
|
||||
|
||||
m_session?.Close(10000);
|
||||
|
||||
|
||||
}
|
||||
@@ -508,6 +512,10 @@ public class OPCUAClient : DisposableObject
|
||||
AttributeId = Attributes.Value,
|
||||
};
|
||||
var node = (VariableNode)ReadNode(tag.ToString(), false);
|
||||
//var expandedNodeId = NodeId.ToExpandedNodeId(node.DataType, m_session.NamespaceUris);
|
||||
//var type = m_session.Factory.GetSystemType(expandedNodeId);
|
||||
//var data = value.ToObject(type);
|
||||
//var dataValue = new DataValue(new Variant(data));
|
||||
var dataValue = JsonUtils.Decode(
|
||||
m_session.MessageContext,
|
||||
node.DataType,
|
||||
@@ -859,7 +867,7 @@ public class OPCUAClient : DisposableObject
|
||||
/// <returns>The new session object.</returns>
|
||||
private async Task<ISession> ConnectAsync(string serverUrl)
|
||||
{
|
||||
Disconnect();
|
||||
PrivateDisconnect();
|
||||
|
||||
if (m_configuration == null)
|
||||
{
|
||||
@@ -889,7 +897,7 @@ public class OPCUAClient : DisposableObject
|
||||
60000,
|
||||
userIdentity,
|
||||
Array.Empty<string>());
|
||||
|
||||
await new ComplexTypeSystem(m_session).Load(false, true).ConfigureAwait(false);
|
||||
Log.Debug("连接成功");
|
||||
|
||||
m_session.KeepAliveInterval = OPCNode.KeepAliveInterval == 0 ? 60000 : OPCNode.KeepAliveInterval;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client" Version="1.4.371.96" />
|
||||
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes" Version="1.4.371.96" />
|
||||
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Server" Version="1.4.371.96" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -161,22 +161,12 @@
|
||||
<summary>
|
||||
解析获取DataValue
|
||||
</summary>
|
||||
<param name="Context"></param>
|
||||
<param name="dataTypeId"></param>
|
||||
<param name="builtInType"></param>
|
||||
<param name="valueRank"></param>
|
||||
<param name="json"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Foundation.Adapter.OPCUA.JsonUtils.DecoderObject(Opc.Ua.IServiceMessageContext,Opc.Ua.NodeId,Opc.Ua.BuiltInType,System.Int32,Newtonsoft.Json.Linq.JToken)">
|
||||
<summary>
|
||||
解析获取object
|
||||
</summary>
|
||||
<param name="Context"></param>
|
||||
<param name="dataTypeId"></param>
|
||||
<param name="builtInType"></param>
|
||||
<param name="valueRank"></param>
|
||||
<param name="json"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Foundation.Adapter.OPCUA.JsonUtils.DecodeRawData(Opc.Ua.JsonDecoder,Opc.Ua.BuiltInType,System.Int32,System.String)">
|
||||
|
||||
@@ -305,6 +305,8 @@ namespace ThingsGateway.Foundation.Adapter.Siemens
|
||||
foreach (var item in commandResult.Content)
|
||||
{
|
||||
ResponsedData result = await WaitingClientEx.SendThenResponseAsync(item, TimeOut, token);
|
||||
if (!((MessageBase)result.RequestInfo).IsSuccess)
|
||||
return OperResult.CreateFailedResult<byte[]>(((MessageBase)result.RequestInfo));
|
||||
bytes.Add(result);
|
||||
}
|
||||
return OperResult.CreateSuccessResult(bytes.ToArray());
|
||||
@@ -338,7 +340,7 @@ namespace ThingsGateway.Foundation.Adapter.Siemens
|
||||
if (commandResult.IsSuccess)
|
||||
{
|
||||
var result = await WaitingClientEx.SendThenResponseAsync(commandResult.Content, TimeOut, token);
|
||||
return OperResult.CreateSuccessResult(result);
|
||||
return (MessageBase)result.RequestInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.SerialPort" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MCheckbox Class="mx-1" Label=@(_plc.Description(x => x.Crc16CheckEnable)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Crc16CheckEnable></MCheckbox>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.FrameTime)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.FrameTime></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.CacheTimeout)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.CacheTimeout></MTextField>
|
||||
<MCheckbox Class="ma-1" Label=@(_plc.Description(x => x.Crc16CheckEnable)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Crc16CheckEnable></MCheckbox>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.FrameTime)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.FrameTime></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.CacheTimeout)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.CacheTimeout></MTextField>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
@@ -54,6 +54,7 @@
|
||||
{
|
||||
//载入配置
|
||||
_plc = new ThingsGateway.Foundation.Adapter.Modbus.ModbusRtu((SerialClient)defalutDebugDriverPage.SerialClientPage.GetSerialClient());
|
||||
defalutDebugDriverPage.Plc = _plc;
|
||||
}
|
||||
base.OnAfterRender(firstRender);
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.TcpClientEx" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MCheckbox Class="mx-1" Label=@(_plc.Description(x => x.Crc16CheckEnable)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Crc16CheckEnable></MCheckbox>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.FrameTime)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.FrameTime></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.CacheTimeout)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.CacheTimeout></MTextField>
|
||||
<MCheckbox Class="ma-1" Label=@(_plc.Description(x => x.Crc16CheckEnable)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Crc16CheckEnable></MCheckbox>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.FrameTime)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.FrameTime></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.CacheTimeout)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.CacheTimeout></MTextField>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.UdpSession" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MCheckbox Class="mx-1" Label=@(_plc.Description(x => x.Crc16CheckEnable)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Crc16CheckEnable></MCheckbox>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.FrameTime)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.FrameTime></MTextField>
|
||||
<MCheckbox Class="ma-1" Label=@(_plc.Description(x => x.Crc16CheckEnable)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Crc16CheckEnable></MCheckbox>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.FrameTime)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.FrameTime></MTextField>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.TcpServer" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MCheckbox Class="mx-1" Label=@(_plc.Description(x => x.MulStation)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.MulStation></MCheckbox>
|
||||
<MCheckbox Class="ma-1" Label=@(_plc.Description(x => x.MulStation)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.MulStation></MCheckbox>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
|
||||
@@ -25,13 +25,13 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.TcpClientEx" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MCheckbox Class="mx-1" Label=@(_plc.Description(x => x.IsCheckMessageId)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.IsCheckMessageId></MCheckbox>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.FrameTime)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.FrameTime></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.CacheTimeout)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.CacheTimeout></MTextField>
|
||||
<MCheckbox Class="ma-1" Label=@(_plc.Description(x => x.IsCheckMessageId)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.IsCheckMessageId></MCheckbox>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.FrameTime)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.FrameTime></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.CacheTimeout)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.CacheTimeout></MTextField>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.UdpSession" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MCheckbox Class="mx-1" Label=@(_plc.Description(x => x.IsCheckMessageId)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.IsCheckMessageId></MCheckbox>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.FrameTime)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.FrameTime></MTextField>
|
||||
<MCheckbox Class="ma-1" Label=@(_plc.Description(x => x.IsCheckMessageId)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.IsCheckMessageId></MCheckbox>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.FrameTime)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.FrameTime></MTextField>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Station)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Station></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
|
||||
@@ -89,7 +89,7 @@ public partial class ImportVariable
|
||||
|
||||
var dataTypeId = (Opc.Ua.NodeId)(await PLC.ReadNoteAttributeAsync(a.NodeId.ToString(), Attributes.DataType)).Content.FirstOrDefault().Value;
|
||||
var dataType = Opc.Ua.TypeInfo.GetSystemType(dataTypeId, PLC.Session.Factory);
|
||||
var result = dataType != null ? Enum.TryParse<DataTypeEnum>(dataType.Name, out dataTypeEnum) : false;
|
||||
var result = dataType != null && Enum.TryParse<DataTypeEnum>(dataType.Name, out dataTypeEnum);
|
||||
if (!result)
|
||||
{
|
||||
dataTypeEnum = DataTypeEnum.Object;
|
||||
|
||||
@@ -36,6 +36,34 @@ namespace ThingsGateway.OPCUA;
|
||||
/// </summary>
|
||||
public class OPCUAClient : CollectBase
|
||||
{
|
||||
readonly PeriodicTimer _periodicTimer = new(TimeSpan.FromSeconds(60));
|
||||
/// <summary>
|
||||
/// OPCUA客户端
|
||||
/// </summary>
|
||||
public OPCUAClient()
|
||||
{
|
||||
_ = RunTimerAsync();
|
||||
}
|
||||
|
||||
private async Task RunTimerAsync()
|
||||
{
|
||||
while (await _periodicTimer.WaitForNextTickAsync())
|
||||
{
|
||||
if (PLC != null && PLC.Session == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await PLC.ConnectAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogMessage.Exception(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal CollectDeviceRunTime Device;
|
||||
|
||||
internal Foundation.Adapter.OPCUA.OPCUAClient PLC = null;
|
||||
@@ -73,7 +101,11 @@ public class OPCUAClient : CollectBase
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool IsConnected() => PLC.Connected;
|
||||
public override bool IsConnected()
|
||||
{
|
||||
|
||||
return PLC.Connected;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override List<DeviceVariableSourceRead> LoadSourceRead(List<DeviceVariableRunTime> deviceVariables)
|
||||
@@ -99,7 +131,6 @@ public class OPCUAClient : CollectBase
|
||||
/// <inheritdoc/>
|
||||
public override async Task<OperResult<byte[]>> ReadSourceAsync(DeviceVariableSourceRead deviceVariableSourceRead, CancellationToken token)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
var result = await PLC.ReadJTokenValueAsync(deviceVariableSourceRead.DeviceVariables.Select(a => a.VariableAddress).ToArray(), token);
|
||||
foreach (var data in result)
|
||||
{
|
||||
@@ -163,6 +194,7 @@ public class OPCUAClient : CollectBase
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
_periodicTimer?.Dispose();
|
||||
if (PLC != null)
|
||||
{
|
||||
PLC.DataChangedHandler -= DataChangedHandler;
|
||||
|
||||
@@ -115,7 +115,7 @@ public partial class OPCUAClientDebugDriverPage
|
||||
try
|
||||
{
|
||||
var data = await _plc.ReadJTokenValueAsync(new string[] { defalutDebugDriverPage.Address });
|
||||
defalutDebugDriverPage.Messages.Add((Microsoft.Extensions.Logging.LogLevel.Debug, SysDateTimeExtensions.CurrentDateTime.ToDefaultDateTimeFormat(InitTimezone.TimezoneOffset) + " - " + data.ToJson()));
|
||||
defalutDebugDriverPage.Messages.Add((Microsoft.Extensions.Logging.LogLevel.Debug, SysDateTimeExtensions.CurrentDateTime.ToDefaultDateTimeFormat(InitTimezone.TimezoneOffset) + " - " + (data[0].Item1 + ":" + data[0].Item3)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -33,6 +33,11 @@
|
||||
OPCUA客户端
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.OPCUA.OPCUAClient.#ctor">
|
||||
<summary>
|
||||
OPCUA客户端
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.OPCUA.OPCUAClient.DriverDebugUIType">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
global using ThingsGateway.Foundation.Adapter.Siemens;
|
||||
|
||||
global using TouchSocket.Core;
|
||||
global using TouchSocket.Sockets;
|
||||
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.TcpClientEx" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.TcpClientEx" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.TcpClientEx" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.TcpClientEx" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.TcpClientEx" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<DefalutDebugDriverPage Channel="ChannelEnum.TcpClientEx" @ref=defalutDebugDriverPage>
|
||||
<MCard Flat Elevation="0">
|
||||
<MRow Class="my-1" NoGutters Justify="JustifyTypes.SpaceBetween" Align="AlignTypes.Center">
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Slot)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Slot></MTextField>
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.Rack)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.Rack></MTextField>
|
||||
|
||||
<MTextField Class="mx-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="mx-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
<MTextField Class="ma-1" Label=@(_plc.Description(x => x.TimeOut)) Dense Outlined HideDetails="@("auto")" @bind-Value=@_plc.TimeOut></MTextField>
|
||||
<MSelect Class="ma-1" Style="max-width:200px" @bind-Value="_plc.DataFormat" Outlined Label="@(_plc.Description(x => x.DataFormat))"
|
||||
Items=@(typeof(DataFormat).GetEnumList())
|
||||
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
|
||||
ItemText=@((u) =>u.des)
|
||||
|
||||
12
framework/ThingsGateway.Web.Entry/.config/dotnet-tools.json
Normal file
12
framework/ThingsGateway.Web.Entry/.config/dotnet-tools.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "7.0.10",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
45
framework/ThingsGateway.Web.Entry/SingleFilePublish.cs
Normal file
45
framework/ThingsGateway.Web.Entry/SingleFilePublish.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
#region copyright
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://diego2098.gitee.io/thingsgateway-docs/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
using Furion;
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
namespace ThingsGateway.Web.Entry;
|
||||
|
||||
/// <inheritdoc cref="ISingleFilePublish"/>
|
||||
public class SingleFilePublish : ISingleFilePublish
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Assembly[] IncludeAssemblies()
|
||||
{
|
||||
return Array.Empty<Assembly>();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string[] IncludeAssemblyNames()
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
"ThingsGateway.Web.Core",
|
||||
"ThingsGateway.Admin.ApiController",
|
||||
"ThingsGateway.Admin.Application",
|
||||
"ThingsGateway.Admin.Blazor",
|
||||
"ThingsGateway.Admin.Blazor.Core",
|
||||
"ThingsGateway.Admin.Core",
|
||||
"ThingsGateway.ApiController",
|
||||
"ThingsGateway.Application",
|
||||
"ThingsGateway.Blazor",
|
||||
"ThingsGateway.Foundation",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Foundataion.Demo", "Foundat
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModbusDemo", "ThingsGateway.Plugin\Foundataion.Demo\ModbusDemo\ModbusDemo.csproj", "{48D2CA26-E535-413D-8CA9-A4A2AAC6582D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OPCUAClientDemo", "ThingsGateway.Plugin\Foundataion.Demo\OPCUAClientDemo\OPCUAClientDemo.csproj", "{3F83EF0F-002D-4D06-87A8-739399074DBA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -186,6 +188,10 @@ Global
|
||||
{48D2CA26-E535-413D-8CA9-A4A2AAC6582D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{48D2CA26-E535-413D-8CA9-A4A2AAC6582D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48D2CA26-E535-413D-8CA9-A4A2AAC6582D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3F83EF0F-002D-4D06-87A8-739399074DBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3F83EF0F-002D-4D06-87A8-739399074DBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3F83EF0F-002D-4D06-87A8-739399074DBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3F83EF0F-002D-4D06-87A8-739399074DBA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -220,6 +226,7 @@ Global
|
||||
{E1C327FA-C442-45DD-9265-9EA26573B61E} = {F2DF3BE7-D497-44B3-9CD6-CDDBC4FBD09C}
|
||||
{E733E483-4823-4BD6-BC29-669426386A96} = {86119A5F-5717-42FF-8888-F034B4136A1B}
|
||||
{48D2CA26-E535-413D-8CA9-A4A2AAC6582D} = {E733E483-4823-4BD6-BC29-669426386A96}
|
||||
{3F83EF0F-002D-4D06-87A8-739399074DBA} = {E733E483-4823-4BD6-BC29-669426386A96}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {38B292E0-B3E7-4608-9912-1B057C2A508F}
|
||||
|
||||
Reference in New Issue
Block a user