mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-27 05:37:10 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a64ab7df4e | ||
|
|
82cd64cb50 | ||
|
|
065bfb8694 | ||
|
|
6db335cf87 | ||
|
|
155f4670e9 | ||
|
|
50522b571a | ||
|
|
8e138863ce | ||
|
|
7d8dfe628d | ||
|
|
8baed5b306 | ||
|
|
41a5ffd214 |
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
|
||||
<Version>4.0.0.4</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Authors>Diego</Authors>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
|
||||
<Version>4.0.0.4</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Authors>Diego</Authors>
|
||||
<Product>ThingsGateway</Product>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Install-Package Microsoft.NETFramework.ReferenceAssemblies.net45
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<Version>4.0.0.4</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<TargetFrameworks>net45;netstandard2.0;net6.0;net8.0;</TargetFrameworks>
|
||||
|
||||
@@ -134,21 +134,19 @@ internal class ModbusHelper
|
||||
|
||||
if (response[1] >= 0x80)//错误码
|
||||
return new OperResult<byte[], FilterResult>(GetDescriptionByErrorCode(response[2])) { Content2 = FilterResult.Success };
|
||||
if (response[1] <= 0x05)
|
||||
if (response[1] <= 0x04)
|
||||
{
|
||||
if ((response.Length < response[2] + 5))
|
||||
return new OperResult<byte[], FilterResult>("数据长度不足" + response.ToHexString()) { Content2 = FilterResult.Cache };
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((response.Length < 8))
|
||||
return new OperResult<byte[], FilterResult>("数据长度不足" + response.ToHexString()) { Content2 = FilterResult.Cache };
|
||||
|
||||
}
|
||||
|
||||
|
||||
var data = response.SelectMiddle(0, response[2] != 0 ? response[2] + 5 : 8);
|
||||
var data = response.SelectMiddle(0, response[1] <= 0x04 ? response[2] != 0 ? response[2] + 5 : 8 : 8);
|
||||
if (crcCheck && !CRC16Utils.CheckCRC16(data))
|
||||
return new OperResult<byte[], FilterResult>("Crc校验失败" + DataTransUtil.ByteToHexString(data, ' ')) { Content2 = FilterResult.Success };
|
||||
return GetModbusData(send, data.RemoveLast(2));
|
||||
|
||||
@@ -40,6 +40,14 @@ namespace ThingsGateway.Foundation.Sockets
|
||||
{
|
||||
this.Protocol = Protocol.Tcp;
|
||||
}
|
||||
/// <summary>
|
||||
/// <inheritdoc/>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(SocketClient)}:{IP}:{Port}";
|
||||
}
|
||||
|
||||
#region 变量
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>4.0.0.4</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
|
||||
|
||||
@@ -43,14 +43,16 @@ public abstract class CollectBase : DriverBase
|
||||
|
||||
public override async Task AfterStopAsync()
|
||||
{
|
||||
await base.AfterStopAsync();
|
||||
//去除全局设备变量
|
||||
lock (_globalDeviceData.CollectDevices)
|
||||
{
|
||||
_globalDeviceData.CollectDevices.RemoveWhere(it => it.Id == DeviceId);
|
||||
}
|
||||
await base.AfterStopAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void Init(DeviceRunTime device)
|
||||
{
|
||||
base.Init(device);
|
||||
|
||||
@@ -235,8 +235,8 @@ public abstract class DeviceService<T> : DbRepository<T> where T : Device, new()
|
||||
}
|
||||
deviceDicts.TryGetValue(devData.RedundantDeviceId, out var redundantDevice);
|
||||
|
||||
//设备实体没有包含插件名称,手动插入
|
||||
devExport.Add(ExportHelpers.PluginName, devData.PluginName);
|
||||
////设备实体没有包含插件名称,手动插入
|
||||
//devExport.Add(ExportHelpers.PluginName, devData.PluginName);
|
||||
//设备实体没有包含冗余设备名称,手动插入
|
||||
devExport.Add(ExportHelpers.RedundantDeviceName, redundantDevice?.Name);
|
||||
|
||||
@@ -376,22 +376,22 @@ public abstract class DeviceService<T> : DbRepository<T> where T : Device, new()
|
||||
{
|
||||
var device = ((ExpandoObject)item).ConvertToEntity<T>(true);
|
||||
#region 特殊转化名称
|
||||
//转化插件名称
|
||||
var hasPlugin = item.TryGetValue(ExportHelpers.PluginName, out var pluginObj);
|
||||
////转化插件名称
|
||||
//var hasPlugin = item.TryGetValue(ExportHelpers.PluginName, out var pluginObj);
|
||||
|
||||
if (pluginObj == null || !driverPluginFullNameDict.TryGetValue(pluginObj.ToString(), out var plugin))
|
||||
{
|
||||
//找不到对应的插件
|
||||
importPreviewOutput.HasError = true;
|
||||
importPreviewOutput.Results.Add((row++, false, $"{ExportHelpers.PluginName}不存在"));
|
||||
return;
|
||||
}
|
||||
//if (pluginObj == null || !driverPluginFullNameDict.TryGetValue(pluginObj.ToString(), out var plugin))
|
||||
//{
|
||||
// //找不到对应的插件
|
||||
// importPreviewOutput.HasError = true;
|
||||
// importPreviewOutput.Results.Add((row++, false, $"{ExportHelpers.PluginName}不存在"));
|
||||
// return;
|
||||
//}
|
||||
//转化冗余设备名称
|
||||
var hasRedundant = item.TryGetValue(ExportHelpers.PluginName, out var redundantObj);
|
||||
var hasRedundant = item.TryGetValue(ExportHelpers.RedundantDeviceName, out var redundantObj);
|
||||
|
||||
#endregion
|
||||
//设备ID、冗余设备ID都需要手动补录
|
||||
if (hasRedundant && deviceDicts.TryGetValue(redundantObj.ToString(), out var rendundantDevice))
|
||||
if (hasRedundant && redundantObj != null && deviceDicts.TryGetValue(redundantObj.ToString(), out var rendundantDevice))
|
||||
{
|
||||
device.RedundantDeviceId = rendundantDevice.Id;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ public class DriverPluginService : ISingleton
|
||||
|
||||
}
|
||||
return plugins;
|
||||
}, false);
|
||||
}, true);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ThingsGateway.Gateway.Application;
|
||||
/// </summary>
|
||||
public class CollectDeviceWorker : DeviceWorker
|
||||
{
|
||||
|
||||
private GlobalDeviceData _globalDeviceData;
|
||||
public CollectDeviceWorker(IServiceScopeFactory serviceScopeFactory, IHostApplicationLifetime appLifetime) : base(serviceScopeFactory, appLifetime)
|
||||
{
|
||||
_logger = _serviceScope.ServiceProvider.GetService<ILoggerFactory>().CreateLogger("南向设备服务");
|
||||
@@ -49,6 +49,10 @@ public class CollectDeviceWorker : DeviceWorker
|
||||
await StopOtherHostService();
|
||||
//停止全部采集线程
|
||||
await RemoveAllDeviceThreadAsync();
|
||||
|
||||
//清空内存列表
|
||||
_globalDeviceData.CollectDevices.Clear();
|
||||
|
||||
//创建全部采集线程
|
||||
await CreatAllDeviceThreadsAsync();
|
||||
//开始其他后台服务
|
||||
@@ -197,6 +201,7 @@ public class CollectDeviceWorker : DeviceWorker
|
||||
{
|
||||
await _easyLock?.WaitAsync();
|
||||
_driverPluginService = _serviceScope.ServiceProvider.GetService<DriverPluginService>();
|
||||
_globalDeviceData = _serviceScope.ServiceProvider.GetService<GlobalDeviceData>();
|
||||
//重启采集线程,会启动其他后台服务
|
||||
await RestartDeviceThreadAsync();
|
||||
await WhileExecuteAsync(stoppingToken);
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class DeviceWorker : BackgroundService
|
||||
/// </summary>
|
||||
public List<DriverBase> DriverBases => _deviceThreads
|
||||
.Where(a => a.DriverBases.Any(b => b.CurrentDevice != null))
|
||||
.SelectMany(a => a.DriverBases).ToList();
|
||||
.SelectMany(a => a.DriverBases).OrderByDescending(a => a.CurrentDevice.DeviceStatus).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// 设备子线程列表
|
||||
|
||||
@@ -35,7 +35,7 @@ public partial class CollectDevicePage : BaseComponentBase
|
||||
List<CollectDevice> _devices = new();
|
||||
List<DriverPlugin> _driverPlugins;
|
||||
ImportExcel _importExcel;
|
||||
string _searchName;
|
||||
//string _searchName;
|
||||
[Inject]
|
||||
AjaxService _ajaxService { get; set; }
|
||||
[Inject]
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
<MCard Class="ma-2" Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight + 80}px );")>
|
||||
<MCardTitle>
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_collectDeviceGroupSearchName"
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_collectDeviceSearchName"
|
||||
Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.DeviceGroup)) />
|
||||
</MCardTitle>
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
}
|
||||
} )
|
||||
Items="_collectDeviceGroups" ItemText="r=>r" ItemChildren="r=>null"
|
||||
Search="@_collectDeviceGroupSearchName"
|
||||
Search="@_collectDeviceSearchName"
|
||||
Activatable ItemKey=@(r=>r)>
|
||||
<LabelContent>
|
||||
<span title=@context.Item>
|
||||
@@ -77,10 +77,10 @@
|
||||
<MCol Md=5 Cols="12">
|
||||
<MCard Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight + 80}px; )") Style="overflow-y:auto;" Flat Class="ml-2 my-4">
|
||||
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_collectDeviceGroupSearchName"
|
||||
Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.DeviceGroup)) />
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_collectDeviceSearchName"
|
||||
Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.Name)) />
|
||||
|
||||
<MVirtualScroll Context="item" Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight+140}px)") OverscanCount=2 ItemSize="60" Items="_collectDriverBases.WhereIF(!_collectDeviceGroupSearchName.IsNullOrEmpty(),a=>a.CurrentDevice.DeviceGroup==_collectDeviceGroupSearchName).ToList()">
|
||||
<MVirtualScroll Context="item" Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight+140}px)") OverscanCount=2 ItemSize="60" Items="_collectDriverBases.WhereIF(!_collectDeviceSearchName.IsNullOrEmpty(),a=>a.CurrentDevice.Name.Contains(_collectDeviceSearchName)).ToList()">
|
||||
|
||||
<ItemContent>
|
||||
@if (item.CurrentDevice != null)
|
||||
@@ -255,7 +255,7 @@
|
||||
@* <MCol Md=2 Cols="12">
|
||||
<MCard Class="ma-2" Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight + 80}px); )")>
|
||||
<MCardTitle>
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_uploadDeviceGroupSearchName"
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_uploadDeviceSearchName"
|
||||
Outlined Label=@typeof(Device).GetDescription(nameof(Device.DeviceGroup)) />
|
||||
</MCardTitle>
|
||||
<MTreeview Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight+240}px);overflow-y:auto") Dense TItem="string" TKey="string" ActiveChanged=@(async a=>
|
||||
@@ -267,7 +267,7 @@
|
||||
}
|
||||
} )
|
||||
Items="_uploadDeviceGroups" ItemText="r=>r" ItemChildren="r=>null"
|
||||
Search="@_uploadDeviceGroupSearchName"
|
||||
Search="@_uploadDeviceSearchName"
|
||||
Activatable ItemKey=@(r=>r)>
|
||||
<LabelContent>
|
||||
<span title=@context.Item>
|
||||
@@ -279,10 +279,10 @@
|
||||
</MCol> *@
|
||||
<MCol Md=5 Cols="12">
|
||||
<MCard Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight+80}px)") Style="overflow-y:auto;" Flat Class="ml-2 my-4">
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_uploadDeviceGroupSearchName"
|
||||
Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.DeviceGroup)) />
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_uploadDeviceSearchName"
|
||||
Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.Name)) />
|
||||
|
||||
<MVirtualScroll Context="item" Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight+140}px)") OverscanCount=2 ItemSize="60" Items="_uploadDriverBases.WhereIF(!_uploadDeviceGroupSearchName.IsNullOrEmpty(),a=>a.CurrentDevice.DeviceGroup==_uploadDeviceGroupSearchName).ToList()">
|
||||
<MVirtualScroll Context="item" Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight+140}px)") OverscanCount=2 ItemSize="60" Items="_uploadDriverBases.WhereIF(!_uploadDeviceSearchName.IsNullOrEmpty(),a=>a.CurrentDevice.Name.Contains(_uploadDeviceSearchName)).ToList()">
|
||||
|
||||
<ItemContent>
|
||||
@if (item.CurrentDevice != null)
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
|
||||
using BlazorComponent;
|
||||
|
||||
using Mapster;
|
||||
|
||||
using Masa.Blazor;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -30,10 +28,11 @@ namespace ThingsGateway.Gateway.Blazor;
|
||||
public partial class DeviceStatusPage : IDisposable
|
||||
{
|
||||
readonly PeriodicTimer _periodicTimer = new(TimeSpan.FromSeconds(3));
|
||||
private string _collectDeviceGroup;
|
||||
private bool _isShowDetailUI;
|
||||
List<string> _collectDeviceGroups = new();
|
||||
string _collectDeviceGroupSearchName;
|
||||
//List<string> _collectDeviceGroups = new();
|
||||
//string _collectDeviceGroupSearchName;
|
||||
//private string _collectDeviceSearchName;
|
||||
string _collectDeviceSearchName;
|
||||
List<CollectBase> _collectDriverBases = new();
|
||||
CollectBase _collectDriverItem;
|
||||
BootstrapDynamicComponent _driverComponent;
|
||||
@@ -42,9 +41,10 @@ public partial class DeviceStatusPage : IDisposable
|
||||
bool _isAllRestart;
|
||||
bool _isRestart;
|
||||
StringNumber _tabNumber;
|
||||
private string _uploadDeviceGroup;
|
||||
List<string> _uploadDeviceGroups = new();
|
||||
string _uploadDeviceGroupSearchName;
|
||||
//private string _uploadDeviceSearchName;
|
||||
//List<string> _uploadDeviceGroups = new();
|
||||
//string _uploadDeviceGroupSearchName;
|
||||
string _uploadDeviceSearchName;
|
||||
List<DriverBase> _uploadDriverBases = new();
|
||||
DriverBase _uploadDriverItem;
|
||||
AlarmWorker _alarmWorker { get; set; }
|
||||
@@ -121,8 +121,8 @@ public partial class DeviceStatusPage : IDisposable
|
||||
|
||||
void CollectDeviceQuery()
|
||||
{
|
||||
_collectDeviceGroups = _globalDeviceData.CollectDevices.Adapt<List<CollectDevice>>()?.Select(a => a.DeviceGroup)?.Where(a => a != null).Distinct()?.ToList() ?? new();
|
||||
_collectDriverBases = _collectDeviceWorker?.DriverBases?.WhereIF(!_collectDeviceGroup.IsNullOrEmpty(), a => a.CurrentDevice?.DeviceGroup == _collectDeviceGroup).Select(a => (CollectBase)a).ToList() ?? new();
|
||||
//_collectDeviceGroups = _globalDeviceData.CollectDevices?.Select(a => a.DeviceGroup)?.Where(a => !a.IsNullOrEmpty()).Distinct()?.ToList() ?? new();
|
||||
_collectDriverBases = _collectDeviceWorker?.DriverBases?.WhereIF(!_collectDeviceSearchName.IsNullOrEmpty(), a => a.CurrentDevice?.Name.Contains(_collectDeviceSearchName) == true).Select(a => (CollectBase)a).ToList() ?? new();
|
||||
}
|
||||
async Task DeviceRedundantThreadAsync(long devId)
|
||||
{
|
||||
@@ -207,10 +207,6 @@ public partial class DeviceStatusPage : IDisposable
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
_collectDeviceGroups = _globalDeviceData.CollectDevices.Adapt<List<CollectDevice>>()?.Select(a => a.DeviceGroup)?.Where(a => a != null).Distinct()?.ToList() ?? new();
|
||||
_collectDriverBases = _collectDeviceWorker?.DriverBases?.WhereIF(!_collectDeviceGroup.IsNullOrEmpty(), a => a.CurrentDevice?.DeviceGroup == _collectDeviceGroup).Select(a => (CollectBase)a).ToList() ?? new();
|
||||
}
|
||||
if (_collectDriverBases?.FirstOrDefault()?.CurrentDevice == null || _collectDeviceWorker?.DriverBases.Count != _collectDriverBases.Count)
|
||||
{
|
||||
CollectDeviceQuery();
|
||||
@@ -248,8 +244,8 @@ public partial class DeviceStatusPage : IDisposable
|
||||
|
||||
void UploadDeviceQuery()
|
||||
{
|
||||
_uploadDeviceGroups = _uploadDeviceWorker.DriverBases.Select(a => a.CurrentDevice)?.Select(a => a.DeviceGroup)?.Where(a => a != null).Distinct()?.ToList() ?? new();
|
||||
_uploadDriverBases = _uploadDeviceWorker?.DriverBases?.WhereIF(!_uploadDeviceGroup.IsNullOrEmpty(), a => a.CurrentDevice?.DeviceGroup == _uploadDeviceGroup).ToList() ?? new();
|
||||
//_uploadDeviceGroups = _uploadDeviceWorker.DriverBases.Select(a => a.CurrentDevice)?.Select(a => a.DeviceGroup)?.Where(a => a != null).Distinct()?.ToList() ?? new();
|
||||
_uploadDriverBases = _uploadDeviceWorker?.DriverBases?.WhereIF(!_uploadDeviceSearchName.IsNullOrEmpty(), a => a.CurrentDevice?.Name.Contains(_uploadDeviceSearchName) == true).ToList() ?? new();
|
||||
}
|
||||
async Task UpRestartAsync(long devId)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ public partial class DeviceVariablePage
|
||||
|
||||
ImportExcel _importExcel;
|
||||
Dictionary<long, List<string>> _otherMethods = new();
|
||||
string _searchName;
|
||||
//string _searchName;
|
||||
|
||||
List<Device> _uploadDevices = new();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public partial class DeviceVariableRunTimePage
|
||||
private IAppDataTable _datatable;
|
||||
private List<DeviceTree> _deviceGroups = new();
|
||||
private EventCallback<string> _onWrite;
|
||||
private string _searchName;
|
||||
//private string _searchName;
|
||||
/// <summary>
|
||||
/// 设备名称
|
||||
/// </summary>
|
||||
|
||||
@@ -35,7 +35,7 @@ public partial class UploadDevicePage
|
||||
List<Device> _devices = new();
|
||||
List<DriverPlugin> _driverPlugins;
|
||||
ImportExcel _importExcel;
|
||||
string _searchName;
|
||||
//string _searchName;
|
||||
[Inject]
|
||||
AjaxService _ajaxService { get; set; }
|
||||
[Inject]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\admin\ThingsGateway.Admin.Blazor\ThingsGateway.Admin.Blazor.csproj" />
|
||||
<ProjectReference Include="..\..\admin\ThingsGateway.Components\ThingsGateway.Components.csproj" />
|
||||
<ProjectReference Include="..\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>4.0.0.4</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
||||
@@ -69,18 +69,19 @@ public partial class KafkaProducer : UpLoadBaseWithCacheT<DeviceData, VariableDa
|
||||
|
||||
#region Kafka 生产者
|
||||
|
||||
Enum.TryParse<SecurityProtocol>(_driverPropertys.SecurityProtocol, out var SecurityProtocol);
|
||||
Enum.TryParse<SaslMechanism>(_driverPropertys.SaslMechanism, out var SaslMechanism);
|
||||
|
||||
//1、生产者配置
|
||||
producerconfig = new ProducerConfig
|
||||
{
|
||||
BootstrapServers = _driverPropertys.BootStrapServers,
|
||||
SecurityProtocol = SecurityProtocol,
|
||||
SaslMechanism = SaslMechanism,
|
||||
SaslUsername = _driverPropertys.SaslUsername,
|
||||
SaslPassword = _driverPropertys.SaslPassword,
|
||||
SecurityProtocol = _driverPropertys.SecurityProtocol,
|
||||
SaslMechanism = _driverPropertys.SaslMechanism,
|
||||
|
||||
};
|
||||
if (!string.IsNullOrEmpty(_driverPropertys.SaslUsername))
|
||||
producerconfig.SaslUsername = _driverPropertys.SaslUsername;
|
||||
if (!string.IsNullOrEmpty(_driverPropertys.SaslPassword))
|
||||
producerconfig.SaslPassword = _driverPropertys.SaslPassword;
|
||||
|
||||
//2、创建生产者
|
||||
producerBuilder = new ProducerBuilder<Null, string>(producerconfig);
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
//------------------------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
using Confluent.Kafka;
|
||||
|
||||
namespace ThingsGateway.Plugin.Kafka;
|
||||
|
||||
/// <summary>
|
||||
@@ -53,12 +55,10 @@ public class KafkaProducerProperty : UploadPropertyWithCacheT
|
||||
/// </summary>
|
||||
[DeviceProperty("密码", "")]
|
||||
public string SaslPassword { get; set; } = "none";
|
||||
[DeviceProperty("SecurityProtocol", "")]
|
||||
public string SecurityProtocol { get; set; } = "SaslPlaintext";
|
||||
[DeviceProperty("SaslMechanism", "")]
|
||||
public string SaslMechanism { get; set; } = "Plain";
|
||||
|
||||
|
||||
[DeviceProperty("SecurityProtocol", "Plaintext, Ssl, SaslPlaintext, SaslSsl")]
|
||||
public SecurityProtocol SecurityProtocol { get; set; } = SecurityProtocol.Plaintext;
|
||||
[DeviceProperty("SaslMechanism", " Gssapi, Plain, ScramSha256, ScramSha512, OAuthBearer")]
|
||||
public SaslMechanism SaslMechanism { get; set; } = SaslMechanism.Plain;
|
||||
|
||||
/// <summary>
|
||||
/// 设备实体脚本
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ModbusTcpDtu : CollectBase
|
||||
var client1 = new TcpService();
|
||||
((TcpService)client1).Setup(FoundataionConfig);
|
||||
//载入配置
|
||||
_plc = new((TcpService)client)
|
||||
_plc = new((TcpService)client1)
|
||||
{
|
||||
DataFormat = _driverPropertys.DataFormat,
|
||||
FrameTime = _driverPropertys.FrameTime,
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
||||
@@ -48,7 +48,7 @@ public class OPCUAClient : CollectBase
|
||||
public override Task AfterStopAsync()
|
||||
{
|
||||
_plc?.Disconnect();
|
||||
return Task.CompletedTask;
|
||||
return base.AfterStopAsync();
|
||||
}
|
||||
protected override string GetAddressDescription()
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>4.0.0.4</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
|
||||
|
||||
Reference in New Issue
Block a user