From 171d3715b0fc27c4b879b9cfa4a7ac579ce6dd7c Mon Sep 17 00:00:00 2001 From: atef Date: Mon, 23 Oct 2023 10:35:13 +0200 Subject: [PATCH] update config class, create salimax device and device state attribute for devices --- csharp/App/SaliMax/src/Devices/DeviceState.cs | 8 +++ .../App/SaliMax/src/Devices/SalimaxDevice.cs | 8 +++ csharp/App/SaliMax/src/SystemConfig/Config.cs | 58 +++++++++++-------- .../SaliMax/src/SystemConfig/DeviceConfig.cs | 21 ++++--- 4 files changed, 64 insertions(+), 31 deletions(-) create mode 100644 csharp/App/SaliMax/src/Devices/DeviceState.cs create mode 100644 csharp/App/SaliMax/src/Devices/SalimaxDevice.cs diff --git a/csharp/App/SaliMax/src/Devices/DeviceState.cs b/csharp/App/SaliMax/src/Devices/DeviceState.cs new file mode 100644 index 000000000..728e3c3f1 --- /dev/null +++ b/csharp/App/SaliMax/src/Devices/DeviceState.cs @@ -0,0 +1,8 @@ +namespace InnovEnergy.App.SaliMax.Devices; + +public enum DeviceState +{ + Disabled, + Measured, + Computed +} \ No newline at end of file diff --git a/csharp/App/SaliMax/src/Devices/SalimaxDevice.cs b/csharp/App/SaliMax/src/Devices/SalimaxDevice.cs new file mode 100644 index 000000000..ff7c8c6ca --- /dev/null +++ b/csharp/App/SaliMax/src/Devices/SalimaxDevice.cs @@ -0,0 +1,8 @@ +using InnovEnergy.Lib.Utils.Net; + +namespace InnovEnergy.App.SaliMax.Devices; + +public class SalimaxDevice : Ip4Address +{ + public required DeviceState DeviceState { get; init; } +} \ No newline at end of file diff --git a/csharp/App/SaliMax/src/SystemConfig/Config.cs b/csharp/App/SaliMax/src/SystemConfig/Config.cs index 32468ee0d..61089d13a 100644 --- a/csharp/App/SaliMax/src/SystemConfig/Config.cs +++ b/csharp/App/SaliMax/src/SystemConfig/Config.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using InnovEnergy.App.SaliMax.Devices; using InnovEnergy.Lib.Utils; using static System.Text.Json.JsonSerializer; @@ -26,11 +27,11 @@ public class Config //TODO: let IE choose from config files (Json) and connect t public required Double MaxBatteryDischargingCurrent { get; set; } public required Double MaxDcPower { get; set; } - public required Double MaxChargeBatteryVoltage { get; set; } - public required Double MinDischargeBatteryVoltage { get; set; } + public required Double MaxChargeBatteryVoltage { get; set; } + public required Double MinDischargeBatteryVoltage { get; set; } - public required DeviceConfig Devices { get; set; } - public required S3Config? S3 { get; set; } + public required DeviceConfig Devices { get; set; } + public required S3Config? S3 { get; set; } private static String? LastSavedData { get; set; } @@ -86,15 +87,20 @@ public class Config //TODO: let IE choose from config files (Json) and connect t Devices = new () { - TruConvertAcIp = new() { Host = "localhost", Port = 5001}, - TruConvertDcIp = new() { Host = "localhost", Port = 5002}, - GridMeterIp = new() { Host = "localhost", Port = 5003}, - IslandBusLoadMeterIp = new() { Host = "localhost", Port = 5004}, - AmptIp = new() { Host = "localhost", Port = 5005}, - RelaysIp = new() { Host = "localhost", Port = 5006}, - BatteryIp = new() { Host = "localhost", Port = 5007}, + RelaysIp = new() { Host = "localhost", Port = 5006, DeviceState = DeviceState.Measured}, + GridMeterIp = new() { Host = "localhost", Port = 5003, DeviceState = DeviceState.Measured}, + PvOnAcGrid = new() { Host = "false" , Port = 0 , DeviceState = DeviceState.Measured}, + LoadOnAcGrid = new() { Host = "false" , Port = 0 , DeviceState = DeviceState.Measured}, + PvOnAcIsland = new() { Host = "true" , Port = 0 , DeviceState = DeviceState.Measured}, + IslandBusLoadMeterIp = new() { Host = "localhost", Port = 5004, DeviceState = DeviceState.Measured}, + TruConvertAcIp = new() { Host = "localhost", Port = 5001, DeviceState = DeviceState.Measured}, + PvOnDc = new() { Host = "localhost", Port = 5005, DeviceState = DeviceState.Measured}, + LoadOnDc = new() { Host = "false" , Port = 0 , DeviceState = DeviceState.Measured}, + TruConvertDcIp = new() { Host = "localhost", Port = 5002, DeviceState = DeviceState.Measured}, + BatteryIp = new() { Host = "localhost", Port = 5007, DeviceState = DeviceState.Measured}, BatteryNodes = new []{ 2, 3, 4, 5, 6 } }, + S3 = new() { Bucket = "1-3e5b3069-214a-43ee-8d85-57d72000c19d", @@ -155,24 +161,30 @@ public class Config //TODO: let IE choose from config files (Json) and connect t MaxChargeBatteryVoltage = 57, MinDischargeBatteryVoltage = 0, + S3 = new() { - Bucket = "saliomameiringen", + Bucket = "1-3e5b3069-214a-43ee-8d85-57d72000c19d", Region = "sos-ch-dk-2", Provider = "exo.io", - ContentType = "text/plain; charset=utf-8", - Key = "EXO2bf0cbd97fbfa75aa36ed46f", - Secret = "Bn1CDPqOG-XpDSbYjfIJxojcHTm391vZTc8z8l_fEPs" + Key = "EXObb5a49acb1061781761895e7", + Secret = "sKhln0w8ii3ezZ1SJFF33yeDo8NWR1V4w2H0D4-350I", + ContentType = "text/plain; charset=utf-8" }, - Devices = new () + + Devices = new () { - RelaysIp = new() { Host = "10.0.1.1", Port = 502}, - TruConvertAcIp = new() { Host = "10.0.2.1", Port = 502}, - TruConvertDcIp = new() { Host = "10.0.3.1", Port = 502}, - GridMeterIp = new() { Host = "10.0.4.1", Port = 502}, - IslandBusLoadMeterIp = new() { Host = "10.0.4.2", Port = 502}, - AmptIp = new() { Host = "10.0.5.1", Port = 502}, - BatteryIp = new() { Host = "localhost", Port = 6855}, + RelaysIp = new() { Host = "10.0.1.1", Port = 502, DeviceState = DeviceState.Measured}, + GridMeterIp = new() { Host = "10.0.4.1", Port = 502, DeviceState = DeviceState.Measured}, + PvOnAcGrid = new() { Host = "false" , Port = 0 , DeviceState = DeviceState.Measured}, + LoadOnAcGrid = new() { Host = "true" , Port = 0 , DeviceState = DeviceState.Measured}, + PvOnAcIsland = new() { Host = "false" , Port = 0 , DeviceState = DeviceState.Measured}, + IslandBusLoadMeterIp = new() { Host = "10.0.4.2", Port = 502, DeviceState = DeviceState.Measured}, + TruConvertAcIp = new() { Host = "10.0.2.1", Port = 502, DeviceState = DeviceState.Measured}, + PvOnDc = new() { Host = "10.0.5.1", Port = 502, DeviceState = DeviceState.Measured}, + LoadOnDc = new() { Host = "false" , Port = 0 , DeviceState = DeviceState.Measured}, + TruConvertDcIp = new() { Host = "10.0.3.1", Port = 502, DeviceState = DeviceState.Measured}, + BatteryIp = new() { Host = "localhost", Port = 6855, DeviceState = DeviceState.Measured }, BatteryNodes = new []{ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, }, }; diff --git a/csharp/App/SaliMax/src/SystemConfig/DeviceConfig.cs b/csharp/App/SaliMax/src/SystemConfig/DeviceConfig.cs index 3663fe7fe..546b92a7c 100644 --- a/csharp/App/SaliMax/src/SystemConfig/DeviceConfig.cs +++ b/csharp/App/SaliMax/src/SystemConfig/DeviceConfig.cs @@ -1,15 +1,20 @@ +using InnovEnergy.App.SaliMax.Devices; 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 IslandBusLoadMeterIp { get; init; } - public required Ip4Address AmptIp { get; init; } - public required Ip4Address BatteryIp { get; init; } - public required Int32[] BatteryNodes { get; init; } + public required SalimaxDevice RelaysIp { get; init; } + public required SalimaxDevice GridMeterIp { get; init; } + public required SalimaxDevice PvOnAcGrid { get; init; } + public required SalimaxDevice LoadOnAcGrid { get; init; } + public required SalimaxDevice PvOnAcIsland { get; init; } + public required SalimaxDevice IslandBusLoadMeterIp { get; init; } + public required SalimaxDevice TruConvertAcIp { get; init; } + public required SalimaxDevice PvOnDc { get; init; } + public required SalimaxDevice LoadOnDc { get; init; } + public required SalimaxDevice TruConvertDcIp { get; init; } + public required SalimaxDevice BatteryIp { get; init; } + public required Int32[] BatteryNodes { get; init; } }