From 4ee7aebf952b45f7ce00c496d86347b9a9f7a666 Mon Sep 17 00:00:00 2001 From: atef Date: Mon, 10 Jul 2023 10:10:39 +0200 Subject: [PATCH] Add display messages, Battery alarms and warnings --- csharp/App/SaliMax/src/Program.cs | 42 ++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/csharp/App/SaliMax/src/Program.cs b/csharp/App/SaliMax/src/Program.cs index 6ca756dae..ed99a83da 100644 --- a/csharp/App/SaliMax/src/Program.cs +++ b/csharp/App/SaliMax/src/Program.cs @@ -99,12 +99,25 @@ internal static class Program StatusRecord ReadStatus() { + Console.WriteLine(" Reading AcDC"); var acDc = acDcDevices.Read(); + + Console.WriteLine(" Reading dcDc"); var dcDc = dcDcDevices.Read(); + + Console.WriteLine(" Reading battery"); var battery = batteryDevices.Read(); + + Console.WriteLine(" Reading relays"); var relays = saliMaxRelaysDevice.Read(); + + Console.WriteLine(" loadOnAcIsland"); var loadOnAcIsland = acIslandLoadMeter.Read(); + + Console.WriteLine(" Reading gridMeter"); var gridMeter = gridMeterDevice.Read(); + + Console.WriteLine(" Reading pvOnDc"); var pvOnDc = amptDevice.Read(); var pvOnAcGrid = AcPowerDevice.Null; @@ -241,17 +254,15 @@ internal static class Program var dcLinkVoltage = TextBlock.AlignCenterHorizontal("", s.DcDc.Dc.Link.Voltage.ToDisplayString(), ""); - - //var inverterPowerByPhase = new ActivePower[(Int32)s.AcDc.Ac.L1.Power.Active, (Int32)s.AcDc.Ac.L2.Power.Active, (Int32)s.AcDc.Ac.L3.Power.Active]; - - // Voltage Measurement Values - //var inverterVoltage = new Voltage [(Int32)s.AcDc.Ac.L1.Voltage, (Int32)s.AcDc.Ac.L2.Voltage, (Int32)s.AcDc.Ac.L3.Voltage]; - //var dcLinkVoltage = s.DcDc.Dc.Link.Voltage; + var dc48Voltage = s.DcDc.Dc.Battery.Voltage.ToDisplayString(); - var batteryVoltage = s.Battery.Dc.Voltage.ToDisplayString(); - var batterySoc = s.Battery.Soc.ToDisplayString(); + var batteryVoltage = s.Battery.Dc.Voltage.Value.RoundToSignificantDigits(3); + var batterySoc = s.Battery.Devices.Any()? s.Battery.Devices.Average(b=>b.Soc).Percent().ToDisplayString() : "0"; var batteryCurrent = s.Battery.Dc.Current.ToDisplayString(); var batteryTemp = s.Battery.Temperature.ToDisplayString(); + var batteryHeatingCurrent = s.Battery.HeatingCurrent.ToDisplayString(); + var anyBatteryAlarm = s.Battery.Alarms.Any(); + var anyBatteryWarning = s.Battery.Warnings.Any(); var gridBusColumn = ColumnBox("Pv", "Grid Bus", "Load" , gridVoltageByPhase , gridLoadPower); var islandBusColumn = ColumnBox("Pv", "Island Bus", "Load" , inverterPowerByPhase, islandLoadPower); @@ -269,12 +280,15 @@ internal static class Program var batteryAvgBox = TextBlock.AlignLeft(batteryVoltage, batterySoc, batteryCurrent, - batteryTemp) + batteryTemp, + batteryHeatingCurrent, + anyBatteryWarning, + anyBatteryAlarm) .TitleBox("Battery"); //////////////////// Batteries ///////////////////////// - + IReadOnlyList batteryBoxes = s.Battery .Devices .Select(CreateIndividualBattery) @@ -303,13 +317,17 @@ internal static class Program private static TextBlock CreateIndividualBattery(Battery48TlRecord battery, Int32 i) { + var batteryWarnings = battery.Warnings.Any(); + var batteryAlarms = battery.Alarms.Any(); var content = TextBlock.AlignLeft(battery.Dc.Voltage.ToDisplayString(), battery.Soc.ToDisplayString(), battery.Dc.Current.ToDisplayString(), battery.Temperatures.Cells.Average.ToDisplayString(), - battery.BusCurrent.ToDisplayString(), - battery.HeatingCurrent.ToDisplayString()); + // battery.BusCurrent.ToDisplayString(), + battery.HeatingCurrent.ToDisplayString(), + batteryWarnings, + batteryAlarms); var box = content.TitleBox($"Battery {i + 1}");