diff --git a/csharp/App/SaliMax/src/Program.cs b/csharp/App/SaliMax/src/Program.cs index d94cc3576..89db95910 100644 --- a/csharp/App/SaliMax/src/Program.cs +++ b/csharp/App/SaliMax/src/Program.cs @@ -226,9 +226,29 @@ internal static class Program // Power Calculated Values var islandToGridBusPower = inverterPower + islandLoadPower; - var gridLoadPower = gridPower - islandToGridBusPower; - - var gridPowerByPhase = s.GridMeter.Ac.L1.Power.Active.ToString()+ "," + s.GridMeter.Ac.L2.Power.Active + s.GridMeter.Ac.L3.Power.Active; + var gridLoadPower = s.LoadOnAcGrid is null ? 0: s.LoadOnAcGrid.Power.Active; + + var gridPowerByPhase = TextBlock.AlignLeft(s.GridMeter.Ac.L1.Power.Active.ToStringRounded(), + s.GridMeter.Ac.L2.Power.Active.ToStringRounded(), + s.GridMeter.Ac.L3.Power.Active.ToStringRounded()); + + var gridVoltageByPhase = TextBlock.AlignLeft(s.GridMeter.Ac.L1.Voltage.ToStringRounded(), + s.GridMeter.Ac.L2.Voltage.ToStringRounded(), + s.GridMeter.Ac.L3.Voltage.ToStringRounded()); + + var inverterPowerByPhase = TextBlock.AlignLeft(s.AcDc.Ac.L1.Power.Active.ToStringRounded(), + s.AcDc.Ac.L2.Power.Active.ToStringRounded(), + s.AcDc.Ac.L3.Power.Active.ToStringRounded()); + + // ReSharper disable once CoVariantArrayConversion + var inverterPowerByAcDc = TextBlock.AlignLeft(s.AcDc.Devices + .Select(s1 => s1.Status.Ac.Power) + .ToArray()); + + var dcLinkVoltage = TextBlock.CenterHorizontal("", + s.DcDc.Dc.Link.Voltage.ToStringRounded(), + ""); + //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 @@ -239,22 +259,21 @@ internal static class Program var batterySoc = s.Battery.Soc; var batteryCurrent = s.Battery.Dc.Current; var batteryTemp = s.Battery.Temperature; - - gridPowerByPhase.Split(","); - var gridBusColumn = ColumnBox("Pv", "Grid Bus", "Load" , "Voltage", gridLoadPower); - var islandBusColumn = ColumnBox("Pv", "Island Bus", "Load" , "Voltage", islandLoadPower); - var dcBusColumn = ColumnBox("Pv", "Dc Bus", "Load" , "DC Link V", 0, pvOnDcPower); + + var gridBusColumn = ColumnBox("Pv", "Grid Bus", "Load" , gridVoltageByPhase , gridLoadPower); + var islandBusColumn = ColumnBox("Pv", "Island Bus", "Load" , inverterPowerByPhase, islandLoadPower); + var dcBusColumn = ColumnBox("Pv", "Dc Bus", "Load" , dcLinkVoltage, 0, pvOnDcPower); var gridBusFlow = Flow.Horizontal(gridPower); var flowGridBusToIslandBus = Flow.Horizontal((ActivePower)islandToGridBusPower); var flowIslandBusToInverter = Flow.Horizontal(inverterPower); var flowInverterToDcBus = Flow.Horizontal(inverterPower); - var flowDcBusToDcDc = Flow.Horizontal(-dcdcPower); - var flowDcDcToBattery = Flow.Horizontal(-dcBatteryPower); + var flowDcBusToDcDc = Flow.Horizontal(dcdcPower); + var flowDcDcToBattery = Flow.Horizontal(dcBatteryPower); - var gridBox = TextBlock.AlignLeft("none","none", "none").TitleBox("Grid"); - var inverterBox = TextBlock.AlignLeft("none","none", "none").TitleBox("Inverter"); + var gridBox = TextBlock.AlignLeft(gridPowerByPhase).TitleBox("Grid"); + var inverterBox = TextBlock.AlignLeft(inverterPowerByAcDc).TitleBox("Inverter"); var dcDcBox = TextBlock.AlignLeft(dc48Voltage).TitleBox("DC/DC"); - var batteryBox = TextBlock.AlignLeft(batteryVoltage, batterySoc, batteryCurrent, batteryTemp).TitleBox("Battery"); + var batteryBox = TextBlock.AlignLeft(batteryVoltage.ToStringRounded(), batterySoc.ToStringRounded(), batteryCurrent.ToStringRounded(), batteryTemp.ToStringRounded()).TitleBox("Battery"); @@ -275,17 +294,17 @@ internal static class Program totalBoxes.WriteLine(); } - private static TextBlock ColumnBox(String pvTitle, String busTitle, String loadTitle, String dataBox) + private static TextBlock ColumnBox(String pvTitle, String busTitle, String loadTitle, TextBlock dataBox) { return ColumnBox(pvTitle, busTitle, loadTitle, dataBox, 0); } - private static TextBlock ColumnBox(String pvTitle, String busTitle, String loadTitle, String dataBox, ActivePower loadPower) + private static TextBlock ColumnBox(String pvTitle, String busTitle, String loadTitle, TextBlock dataBox, ActivePower loadPower) { return ColumnBox(pvTitle, busTitle, loadTitle, dataBox, loadPower, 0); } - private static TextBlock ColumnBox(String pvTitle, String busTitle, String loadTitle, String dataBox, ActivePower loadPower, ActivePower pvPower) + private static TextBlock ColumnBox(String pvTitle, String busTitle, String loadTitle, TextBlock dataBox, ActivePower loadPower, ActivePower pvPower) { var pvBox = TextBlock.AlignLeft("").TitleBox(pvTitle); var pvToBus = Flow.Vertical(pvPower);