Centralize configs: DeviceConfig & SystemConfig

This commit is contained in:
ig 2023-07-03 15:59:05 +02:00
parent 83cd63d390
commit d7cb9401da
2 changed files with 15 additions and 42 deletions

View File

@ -1,42 +0,0 @@
using Newtonsoft.Json;
namespace InnovEnergy.App.SaliMax;
public class DeviceConfig
{
public String RelaysIp { get; set; }
public String TruConvertAcIp { get; set; }
public String TruConvertDcIp { get; set; }
public String GridMeterIp { get; set; }
public String InternalMeter { get; set; }
public String AmptIp { get; set; }
public byte[] BatteryNodes { get; set; }
public String BatteryTty { get; set; }
[JsonConstructor]
public DeviceConfig(string relaysIp, string truConvertAcIp, string truConvertDcIp, string gridMeterIp, string internalMeter, string amptIp, byte[] batteryNodes, string batteryTty)
{
RelaysIp = relaysIp;
TruConvertAcIp = truConvertAcIp;
TruConvertDcIp = truConvertDcIp;
GridMeterIp = gridMeterIp;
InternalMeter = internalMeter;
AmptIp = amptIp;
BatteryNodes = batteryNodes;
BatteryTty = batteryTty;
}
public static DeviceConfig? LoadDeviceConfig(String configFilePath)
{
try
{
var json = File.ReadAllText(configFilePath);
return JsonConvert.DeserializeObject<DeviceConfig>(json);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
}

View File

@ -0,0 +1,15 @@
using InnovEnergy.Lib.Utils.Net;
namespace InnovEnergy.App.SaliMax.SystemConfig;
public class DeviceConfig
{
public required Ip4Address RelaysIp { get; init; }
public required Ip4Address TruConvertAcIp { get; init; }
public required Ip4Address TruConvertDcIp { get; init; }
public required Ip4Address GridMeterIp { get; init; }
public required Ip4Address InternalMeterIp { get; init; }
public required Ip4Address AmptIp { get; init; }
public required Ip4Address BatteryIp { get; init; }
public required Byte[] BatteryNodes { get; init; }
}