change - 修改 PLC 参数遍历逻辑:通过 SDK 获取设备下所有需要读取的参数

dev
WenJY 1 week ago
parent 4df7223d25
commit 0927dce3a6

@ -43,39 +43,44 @@ public class GetHoistStatusResultModel
public string hoistCode { get; set; } public string hoistCode { get; set; }
/// <summary> /// <summary>
/// 反馈任务执行指令:是否可以下发任务 /// 设备参数
/// </summary> /// </summary>
public int canDispatchTask { get; set; } public string deviceParamStr{get;set;}
/// <summary> // /// <summary>
/// 当前楼层 // /// 反馈任务执行指令:是否可以下发任务
/// </summary> // /// </summary>
public int currentFloor { get; set; } // public int canDispatchTask { get; set; }
//
/// <summary> // /// <summary>
/// 接驳位状态1~5 楼) // /// 当前楼层
/// 索引 0 → 1楼索引 1 → 2楼... 索引 4 → 5楼 // /// </summary>
/// </summary> // public int currentFloor { get; set; }
public int[] transferStationStatus { get; set; } = new int[5]; //
// /// <summary>
/// <summary> // /// 接驳位状态1~5 楼)
/// 读写器触发状态1~5 楼) // /// 索引 0 → 1楼索引 1 → 2楼... 索引 4 → 5楼
/// 索引 0 → 1楼索引 1 → 2楼... 索引 4 → 5楼 // /// </summary>
/// </summary> // public int[] transferStationStatus { get; set; } = new int[5];
public int[] readerTriggerStatus { get; set; } = new int[5]; //
// /// <summary>
/// <summary> // /// 读写器触发状态1~5 楼)
/// 自动状态true = 自动模式false = 手动模式 // /// 索引 0 → 1楼索引 1 → 2楼... 索引 4 → 5楼
/// </summary> // /// </summary>
public int isAutoMode { get; set; } // public int[] readerTriggerStatus { get; set; } = new int[5];
//
/// <summary> // /// <summary>
/// 屏蔽调度true = 屏蔽中false = 未屏蔽 // /// 自动状态true = 自动模式false = 手动模式
/// </summary> // /// </summary>
public int isDispatchBlocked { get; set; } // public int isAutoMode { get; set; }
//
/// <summary> // /// <summary>
/// 状态指示(详见 <see cref="IndicatorState"/> // /// 屏蔽调度true = 屏蔽中false = 未屏蔽
/// </summary> // /// </summary>
public int stateIndicator { get; set; } // public int isDispatchBlocked { get; set; }
//
// /// <summary>
// /// 状态指示(详见 <see cref="IndicatorState"/>
// /// </summary>
// public int stateIndicator { get; set; }
} }

@ -179,6 +179,7 @@ public class HoistService:IHoistService
code = resp.code, code = resp.code,
message = resp.message, message = resp.message,
hoistCode = resp.hoistCode, hoistCode = resp.hoistCode,
deviceParamStr = resp.deviceParamStr
}, },
}; };

@ -23,6 +23,7 @@
#endregion << 版 本 注 释 >> #endregion << 版 本 注 释 >>
using Newtonsoft.Json;
using Sln.Wcs.HoistAdapter.Domain.Dto.GetHoistStatus; using Sln.Wcs.HoistAdapter.Domain.Dto.GetHoistStatus;
using Sln.Wcs.HoistAdapter.Domain.Enum; using Sln.Wcs.HoistAdapter.Domain.Enum;
using Sln.Wcs.HoistAdapter.Service; using Sln.Wcs.HoistAdapter.Service;
@ -33,11 +34,11 @@ using Sln.Wcs.Serilog;
namespace Sln.Wcs.HoistDispatcher; namespace Sln.Wcs.HoistDispatcher;
public class Dispatcher public class HoistDispatcher
{ {
private readonly SerilogHelper _logger; private readonly SerilogHelper _logger;
private readonly IHoistService _hoistAdapter; private readonly IHoistService _hoistAdapter;
public Dispatcher(IHoistService hoistAdapter, SerilogHelper logger) public HoistDispatcher(IHoistService hoistAdapter, SerilogHelper logger)
{ {
_hoistAdapter = hoistAdapter; _hoistAdapter = hoistAdapter;
_logger = logger; _logger = logger;
@ -88,8 +89,24 @@ public class Dispatcher
// 1、读取 RFID 条码 // 1、读取 RFID 条码
// 2、下发提升机任务起点、终点 // 2、下发提升机任务起点、终点
// 3、等待提升机完成任务 // 3、等待提升机完成任务
RefreshDeviceParams(hostCode,out List<BaseDeviceInfo> deviceInfos);
} }
public void RefreshDeviceParams(string hostCode,out List<BaseDeviceInfo> deviceParams)
{
deviceParams = null;
GetHoistStatusResultDto getRes = _hoistAdapter.GetHoistStatus(new GetHoistStatusDto(){hoistCode = hostCode});
if (getRes.code == HoistStatusEnum.)
{
deviceParams = JsonConvert.DeserializeObject<List<BaseDeviceInfo>>(getRes.data.deviceParamStr);
}
else
{
_logger.Info($"设备参数获取失败:{getRes.msg}");
}
}
} }

@ -1,123 +0,0 @@
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2026 WenJY
* CLR4.0.30319.42000
* Mr.Wen's MacBook Pro
* Sln.Wcs.HoistDispatcher
* E94B669C-DB45-4891-B01E-43E80B790AFB
*
* WenJY
*
* 2026-06-01 17:50:44
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
using Sln.Wcs.HoistAdapter.Domain.Dto.GetHoistStatus;
using Sln.Wcs.HoistAdapter.Domain.Model.GetHoistStatus;
using Sln.Wcs.HoistAdapter.Service;
using Sln.Wcs.Model.Domain;
using Sln.Wcs.Repository.service;
namespace Sln.Wcs.HoistDispatcher;
public class HoistListener
{
private readonly IHoistService _hoistAdapter;
public delegate void RefreshHoistStatus(List<GetHoistStatusResultDto> hoistStatusResult);
public static event RefreshHoistStatus RefreshHoistStatusEvent;
public HoistListener(IHoistService hoistAdapter)
{
_hoistAdapter = hoistAdapter;
}
public void Run(List<dynamic> paramInfo)
{
bool isflag = true;
do
{
List<GetHoistStatusResultDto> result = new List<GetHoistStatusResultDto>();
paramInfo.ForEach(x =>
{
try
{
GetHoistStatusResultDto hoistStatus = _hoistAdapter.GetHoistStatus(new GetHoistStatusDto()
{
hoistCode = x.hoistCode,
canDispatchTask = x.canDispatchTask,
currentFloor = x.currentFloor,
transferStationStatus = x.transferStationStatus,
readerTriggerStatus = x.readerTriggerStatus,
isDispatchBlocked = x.isDispatchBlocked,
stateIndicator = x.stateIndicator,
});
result.Add(hoistStatus);
}
catch (Exception e)
{
isflag = false;
}
});
RefreshHoistStatusEvent?.Invoke(result);
} while (isflag);
}
// private List<dynamic> GetPlcParams()
// {
// List<BaseDeviceInfo> deviceInfos = _deviceInfoService.GetDeviceInfos(x => x.isFlag == 1).ToList();
// List<dynamic> plcParams = new List<dynamic>();
//
// foreach (var item in deviceInfos)
// {
// dynamic virtualEntity = new System.Dynamic.ExpandoObject();
// virtualEntity.hoistCode = item.deviceCode;
// virtualEntity.hostCode = item.hostCode;
// virtualEntity.deviceNumber = item.deviceName.Contains("1#") ? 1 : 2;
// if (item.deviceParams != null)
// {
// string canDispatchTask = item.deviceParams.Where(x => x.paramName .Contains("提升机反馈任务状态")).Select(x => x.paramAddress)
// .FirstOrDefault();
// string currentFloor = item.deviceParams.Where(x => x.paramName .Contains("提升机当前层")).Select(x => x.paramAddress)
// .FirstOrDefault();
// List<string> transferStationStatus = item.deviceParams.Where(x => x.paramName .Contains("接驳位状态")).Select(x => x.paramAddress)
// .ToList();
// List<string> readerTriggerStatus = item.deviceParams.Where(x => x.paramName .Contains("读写器读取触发")).Select(x => x.paramAddress)
// .ToList();
// string isDispatchBlocked = item.deviceParams.Where(x => x.paramName .Contains("提升机屏蔽调度")).Select(x => x.paramAddress)
// .FirstOrDefault();
// string stateIndicator = item.deviceParams.Where(x => x.paramName .Contains("提升机状态指示")).Select(x => x.paramAddress)
// .FirstOrDefault();
// virtualEntity.canDispatchTask = canDispatchTask;
// virtualEntity.currentFloor = currentFloor;
// virtualEntity.transferStationStatus = transferStationStatus;
// virtualEntity.readerTriggerStatus = readerTriggerStatus;
// virtualEntity.isDispatchBlocked = isDispatchBlocked;
// virtualEntity.stateIndicator = stateIndicator;
// }
// else
// {
// virtualEntity.canDispatchTask = string.Empty;
// virtualEntity.currentFloor = string.Empty;
// virtualEntity.transferStationStatus = string.Empty;
// virtualEntity.readerTriggerStatus = string.Empty;
// virtualEntity.isDispatchBlocked = string.Empty;
// virtualEntity.stateIndicator = string.Empty;
// }
// plcParams.Add(virtualEntity);
// }
// return plcParams;
// }
}

@ -30,6 +30,8 @@ namespace Sln.Wcs.HoistSdk.Config;
public class HoistConfig public class HoistConfig
{ {
public readonly string hoist_control_addr = ""; public readonly string hoist_control_addr = "";
public readonly string hoist_plc_param = "";
/// <summary> /// <summary>
/// 注入提升机配置文件 /// 注入提升机配置文件
@ -49,5 +51,7 @@ public class HoistConfig
} }
hoist_control_addr = configuration["提升机控制地址"]; hoist_control_addr = configuration["提升机控制地址"];
hoist_plc_param = configuration["PLC参数"];
} }
} }

@ -46,37 +46,42 @@ public class GetHoistStatusResultDto
/// <summary> /// <summary>
/// 反馈任务执行指令:是否可以下发任务 /// 反馈任务执行指令:是否可以下发任务
/// </summary> /// </summary>
public int canDispatchTask { get; set; } //public int canDispatchTask { get; set; }
/// <summary> /// <summary>
/// 当前楼层 /// 当前楼层
/// </summary> /// </summary>
public int currentFloor { get; set; } //public int currentFloor { get; set; }
/// <summary> /// <summary>
/// 接驳位状态1~5 楼) /// 接驳位状态1~5 楼)
/// 索引 0 → 1楼索引 1 → 2楼... 索引 4 → 5楼 /// 索引 0 → 1楼索引 1 → 2楼... 索引 4 → 5楼
/// </summary> /// </summary>
public int[] transferStationStatus { get; set; } = new int[5]; //public int[] transferStationStatus { get; set; } = new int[5];
/// <summary> /// <summary>
/// 读写器触发状态1~5 楼) /// 读写器触发状态1~5 楼)
/// 索引 0 → 1楼索引 1 → 2楼... 索引 4 → 5楼 /// 索引 0 → 1楼索引 1 → 2楼... 索引 4 → 5楼
/// </summary> /// </summary>
public int[] readerTriggerStatus { get; set; } = new int[5]; //public int[] readerTriggerStatus { get; set; } = new int[5];
/// <summary> /// <summary>
/// 自动状态true = 自动模式false = 手动模式 /// 自动状态true = 自动模式false = 手动模式
/// </summary> /// </summary>
public int isAutoMode { get; set; } //public int isAutoMode { get; set; }
/// <summary> /// <summary>
/// 屏蔽调度true = 屏蔽中false = 未屏蔽 /// 屏蔽调度true = 屏蔽中false = 未屏蔽
/// </summary> /// </summary>
public int isDispatchBlocked { get; set; } //public int isDispatchBlocked { get; set; }
/// <summary> /// <summary>
/// 状态指示(详见 <see cref="IndicatorState"/> /// 状态指示(详见 <see cref="IndicatorState"/>
/// </summary> /// </summary>
public int stateIndicator { get; set; } //public int stateIndicator { get; set; }
/// <summary>
/// 设备参数Json 格式输出
/// </summary>
public string deviceParamStr{get;set;}
} }

@ -23,23 +23,25 @@
#endregion << 版 本 注 释 >> #endregion << 版 本 注 释 >>
using Newtonsoft.Json;
using Sln.Wcs.HoistSdk.Config; using Sln.Wcs.HoistSdk.Config;
using Sln.Wcs.HoistSdk.Dto.GetHoistStatus; using Sln.Wcs.HoistSdk.Dto.GetHoistStatus;
using Sln.Wcs.HoistSdk.Dto.HoistControl; using Sln.Wcs.HoistSdk.Dto.HoistControl;
using Sln.Wcs.HoistSdk.Dto.HoistTaskExecutor; using Sln.Wcs.HoistSdk.Dto.HoistTaskExecutor;
using Sln.Wcs.Model.Configs;
using Sln.Wcs.Plc.Service; using Sln.Wcs.Plc.Service;
namespace Sln.Wcs.HoistSdk; namespace Sln.Wcs.HoistSdk;
public class HoistSdk:IHoistSdk public class HoistSdk:IHoistSdk
{ {
private readonly HoistConfig hoistConfig; private readonly HoistConfig _hoistConfig;
private readonly List<IPlc> _plcs; private readonly List<IPlc> _plcs;
public HoistSdk(HoistConfig hoistConfig, List<IPlc> plcs) public HoistSdk(HoistConfig hoistConfig, List<IPlc> plcs)
{ {
this.hoistConfig = hoistConfig; _hoistConfig = hoistConfig;
_plcs = plcs; _plcs = plcs;
} }
@ -49,7 +51,7 @@ public class HoistSdk:IHoistSdk
try try
{ {
var plc = _plcs.Where(x => x.ConfigKey.Equals(hoistControlDto.hoistCode)).ToList().First(); var plc = _plcs.Where(x => x.ConfigKey.Equals(hoistControlDto.hoistCode)).ToList().First();
var res = plc.writeInt16ByAddress(hoistConfig.hoist_control_addr, (int)hoistControlDto.action); var res = plc.writeInt16ByAddress(_hoistConfig.hoist_control_addr, (int)hoistControlDto.action);
if (res) if (res)
{ {
result.code = "0"; result.code = "0";
@ -76,55 +78,58 @@ public class HoistSdk:IHoistSdk
public GetHoistStatusResultDto GetHoistStatus(GetHoistStatusDto hoistStatusDto) public GetHoistStatusResultDto GetHoistStatus(GetHoistStatusDto hoistStatusDto)
{ {
//一号提升机
//反馈任务执行指令:是否可以下发任务
//当前楼层
//接驳位状态1-5楼
//读写器触发状态1-5楼
//自动状态true/1-自动模式
//屏蔽调度true/1-屏蔽中
//状态指示0-静态1-上升2-下降3-进料4-出料
GetHoistStatusResultDto result = new GetHoistStatusResultDto(); GetHoistStatusResultDto result = new GetHoistStatusResultDto();
try try
{ {
var plc = _plcs.Where(x => x.ConfigKey.Equals(hoistStatusDto.hoistCode)).ToList().First(); List<dynamic> paramStr = JsonConvert.DeserializeObject<List<dynamic>>(_hoistConfig.hoist_plc_param);
result.hoistCode = hoistStatusDto.hoistCode; List<dynamic> deviceParams = paramStr.Where(x => x.hostCode == hoistStatusDto.hoistCode).ToList();
result.canDispatchTask = plc.readInt16ByAddress(hoistStatusDto.canDispatchTask);
result.currentFloor = plc.readInt16ByAddress(hoistStatusDto.currentFloor); if (string.IsNullOrEmpty(hoistStatusDto.hoistCode))
//读取接驳位状态
List<int> transferStationStatus = new List<int>();
foreach (var item in hoistStatusDto.transferStationStatus)
{ {
transferStationStatus.Add(plc.readInt16ByAddress(item)); deviceParams = paramStr;
} }
result.transferStationStatus = transferStationStatus.ToArray();
//读取读写器触发状态 if (deviceParams != null && deviceParams.Count > 0)
List<int> readerTriggerStatus = new List<int>();
foreach (var item in hoistStatusDto.readerTriggerStatus)
{ {
readerTriggerStatus.Add(plc.readInt16ByAddress(item)); foreach (var item in deviceParams)
{
if (item.hostCode == hoistStatusDto.hoistCode)
{
// var plc = _plcs.Where(x => x.ConfigKey.Equals(item.hostCode)).FirstOrDefault();
// if (plc == null)
// {
// result.code = "99";
// result.message = $"未找到PLC: {item.hostCode}";
// result.hoistCode = hoistStatusDto.hoistCode;
// return result;
// }
//
foreach (var param in item.deviceParams)
{
//int value = plc.readInt16ByAddress(param.paramAddress);
param.paramValue = param.objId;
}
}
}
string jsonOutput = JsonConvert.SerializeObject(deviceParams, Formatting.Indented);
result.code = "0";
result.message = "状态更新成功";
result.hoistCode = hoistStatusDto.hoistCode;
result.deviceParamStr = jsonOutput;
}
else
{
result.code = "99";
result.message = $"未获取到设备参数:{hoistStatusDto.hoistCode}";
result.hoistCode = hoistStatusDto.hoistCode;
} }
result.readerTriggerStatus = readerTriggerStatus.ToArray();
result.isAutoMode = plc.readInt16ByAddress(hoistStatusDto.isAutoMode);
result.isDispatchBlocked = plc.readInt16ByAddress(hoistStatusDto.isDispatchBlocked);
result.stateIndicator = plc.readInt16ByAddress(hoistStatusDto.stateIndicator);
// hoistStatusDto.hoistCode = "";
// hoistStatusDto.canDispatchTask = "D3101";
// hoistStatusDto.currentFloor = "D3102";
// hoistStatusDto.transferStationStatus = new List<string>(){"D3104","D3105","D3106","D3107","D3108"};
// hoistStatusDto.readerTriggerStatus = new List<string>(){"D3109","D3110","D3111","D3112","D3113"};
// hoistStatusDto.isAutoMode = "D3124";
// hoistStatusDto.isDispatchBlocked = "D3125";
// hoistStatusDto.stateIndicator = "D3127";
result.code = "0";
result.message = "状态更新成功";
} }
catch (Exception e) catch (Exception e)
{ {
@ -133,4 +138,5 @@ public class HoistSdk:IHoistSdk
} }
return result; return result;
} }
} }

@ -80,6 +80,12 @@ public class BaseDeviceParam
[SugarColumn(ColumnName = "param_type")] [SugarColumn(ColumnName = "param_type")]
public string paramType { get; set; } public string paramType { get; set; }
/// <summary>
/// 参数值
/// </summary>
[SugarColumn(ColumnName = "param_value")]
public int paramValue { get; set; }
/// <summary> /// <summary>
/// Desc:操作类型1-只读2-只写0-默认读写 /// Desc:操作类型1-只读2-只写0-默认读写
/// Default: /// Default:

@ -1,8 +1,10 @@
using System.Reflection; using System.Reflection;
using Com.Ctrip.Framework.Apollo; using Com.Ctrip.Framework.Apollo;
using Flurl.Http; using Flurl.Http;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NeoSmart.Caching.Sqlite; using NeoSmart.Caching.Sqlite;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -10,22 +12,25 @@ using Sln.Wcs.HikRoBotAdapter.Domain.Dto.GbTaskSubmit;
using Sln.Wcs.HikRoBotAdapter.Domain.Dto.GenAgvSchedulingTask; using Sln.Wcs.HikRoBotAdapter.Domain.Dto.GenAgvSchedulingTask;
using Sln.Wcs.HikRoBotAdapter.Service; using Sln.Wcs.HikRoBotAdapter.Service;
using Sln.Wcs.HikRoBotAdapter.Service.Impl; using Sln.Wcs.HikRoBotAdapter.Service.Impl;
using Sln.Wcs.HoistAdapter.Service;
using Sln.Wcs.HoistSdk; using Sln.Wcs.HoistSdk;
using Sln.Wcs.HoistSdk.Dto.GetHoistStatus; using Sln.Wcs.HoistSdk.Dto.GetHoistStatus;
using Sln.Wcs.Model.Domain; using Sln.Wcs.Model.Domain;
using Sln.Wcs.Repository; using Sln.Wcs.Repository;
using Sln.Wcs.Repository.service;
using Sln.Wcs.Serilog; using Sln.Wcs.Serilog;
using Sln.Wcs.Plc; using Sln.Wcs.Plc;
using Sln.Wcs.Repository.service;
using Sln.Wcs.Strategy; using Sln.Wcs.Strategy;
using ZiggyCreatures.Caching.Fusion; using ZiggyCreatures.Caching.Fusion;
using ZiggyCreatures.Caching.Fusion.Serialization.NewtonsoftJson; using ZiggyCreatures.Caching.Fusion.Serialization.NewtonsoftJson;
using GetHoistStatusDto = Sln.Wcs.HoistAdapter.Domain.Dto.GetHoistStatus.GetHoistStatusDto;
using TargetRoute = Sln.Wcs.HikRoBotAdapter.Domain.Dto.GbTaskSubmit.TargetRoute; using TargetRoute = Sln.Wcs.HikRoBotAdapter.Domain.Dto.GbTaskSubmit.TargetRoute;
namespace Sln.Wcs namespace Sln.Wcs
{ {
public class Program public class Program
{ {
private static UpdateableConfigProvider _configProvider;
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
@ -41,7 +46,13 @@ namespace Sln.Wcs
log.Info($"系统启动成功,日志存放位置:{config["logPath"]}"); log.Info($"系统启动成功,日志存放位置:{config["logPath"]}");
//禁用 SSL var deviceInfoService = serviceProvider.GetService<IBaseDeviceInfoService>();
List<BaseDeviceInfo> baseDeviceInfos = deviceInfoService.GetDeviceInfos(x => x.isFlag == 1).ToList();
string serializeObject = JsonConvert.SerializeObject(baseDeviceInfos);
_configProvider.Set("PLC参数", serializeObject);
log.Info($"PLC参数已从数据库加载,共{baseDeviceInfos.Count}台设备");
//禁用 SSL
FlurlHttp.ConfigureClientForUrl("https://172.16.12.11") FlurlHttp.ConfigureClientForUrl("https://172.16.12.11")
.ConfigureInnerHandler(handler => .ConfigureInnerHandler(handler =>
{ {
@ -59,8 +70,8 @@ namespace Sln.Wcs
// } // }
// }); // });
var service = serviceProvider.GetService<IHoistSdk>(); var service = serviceProvider.GetService<HoistDispatcher.HoistDispatcher>();
service.GetHoistStatus(new GetHoistStatusDto()); service.Run(string.Empty,"tagCode",1,2);
Task.Delay(-1).Wait(); Task.Delay(-1).Wait();
} }
@ -82,6 +93,7 @@ namespace Sln.Wcs
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Plc.dll")), Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Plc.dll")),
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Business.dll")), Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Business.dll")),
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Strategy.dll")), Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.Strategy.dll")),
Assembly.LoadFrom(Path.Combine(basePath, "Sln.Wcs.HoistDispatcher.dll")),
}; };
services.Scan(scan => scan.FromAssemblies(assemblies) services.Scan(scan => scan.FromAssemblies(assemblies)
@ -126,11 +138,15 @@ namespace Sln.Wcs
services.AddSingleton<IConfiguration>(localConfiguration); services.AddSingleton<IConfiguration>(localConfiguration);
_configProvider = new UpdateableConfigProvider();
_configProvider.Set("PLC参数", "");
var configurationBuilder = new ConfigurationBuilder() var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(basePath) .SetBasePath(basePath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddApollo(apolloConfigSection) .AddApollo(apolloConfigSection)
.AddDefault(); .AddDefault()
.Add(_configProvider);
apolloConfiguration = configurationBuilder.Build(); apolloConfiguration = configurationBuilder.Build();

@ -0,0 +1,14 @@
using Microsoft.Extensions.Configuration;
namespace Sln.Wcs;
internal class UpdateableConfigProvider : ConfigurationProvider, IConfigurationSource
{
public new void Set(string key, string value)
{
base.Set(key, value);
OnReload();
}
public IConfigurationProvider Build(IConfigurationBuilder builder) => this;
}

@ -31,6 +31,7 @@
<ProjectReference Include="..\Sln.Wcs.HikRoBotAdapter\Sln.Wcs.HikRoBotAdapter.csproj" /> <ProjectReference Include="..\Sln.Wcs.HikRoBotAdapter\Sln.Wcs.HikRoBotAdapter.csproj" />
<ProjectReference Include="..\Sln.Wcs.HikRoBotSdk\Sln.Wcs.HikRoBotSdk.csproj" /> <ProjectReference Include="..\Sln.Wcs.HikRoBotSdk\Sln.Wcs.HikRoBotSdk.csproj" />
<ProjectReference Include="..\Sln.Wcs.HoistAdapter\Sln.Wcs.HoistAdapter.csproj" /> <ProjectReference Include="..\Sln.Wcs.HoistAdapter\Sln.Wcs.HoistAdapter.csproj" />
<ProjectReference Include="..\Sln.Wcs.HoistDispatcher\Sln.Wcs.HoistDispatcher.csproj" />
<ProjectReference Include="..\Sln.Wcs.HoistSdk\Sln.Wcs.HoistSdk.csproj" /> <ProjectReference Include="..\Sln.Wcs.HoistSdk\Sln.Wcs.HoistSdk.csproj" />
<ProjectReference Include="..\Sln.Wcs.Plc\Sln.Wcs.Plc.csproj" /> <ProjectReference Include="..\Sln.Wcs.Plc\Sln.Wcs.Plc.csproj" />
<ProjectReference Include="..\Sln.Wcs.Repository\Sln.Wcs.Repository.csproj" /> <ProjectReference Include="..\Sln.Wcs.Repository\Sln.Wcs.Repository.csproj" />

Loading…
Cancel
Save