From d7cb9401daf28480f6c96b2f8f22389cae06fdeb Mon Sep 17 00:00:00 2001 From: ig Date: Mon, 3 Jul 2023 15:59:05 +0200 Subject: [PATCH] Centralize configs: DeviceConfig & SystemConfig --- csharp/App/SaliMax/src/DeviceConfig.cs | 42 ------------------- .../SaliMax/src/SystemConfig/DeviceConfig.cs | 15 +++++++ 2 files changed, 15 insertions(+), 42 deletions(-) delete mode 100644 csharp/App/SaliMax/src/DeviceConfig.cs create mode 100644 csharp/App/SaliMax/src/SystemConfig/DeviceConfig.cs diff --git a/csharp/App/SaliMax/src/DeviceConfig.cs b/csharp/App/SaliMax/src/DeviceConfig.cs deleted file mode 100644 index ca7982760..000000000 --- a/csharp/App/SaliMax/src/DeviceConfig.cs +++ /dev/null @@ -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(json); - } - catch (Exception e) - { - Console.WriteLine(e); - throw; - } - } -} \ No newline at end of file diff --git a/csharp/App/SaliMax/src/SystemConfig/DeviceConfig.cs b/csharp/App/SaliMax/src/SystemConfig/DeviceConfig.cs new file mode 100644 index 000000000..535ad917f --- /dev/null +++ b/csharp/App/SaliMax/src/SystemConfig/DeviceConfig.cs @@ -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; } +}