AcDcToDclink nullable

This commit is contained in:
atef 2023-11-02 13:43:07 +01:00
parent a59051dcc1
commit 5714d9457b
1 changed files with 6 additions and 5 deletions

View File

@ -70,7 +70,7 @@ public static class Topology
var e = status.PvOnAcIsland?.Dc.Power.Value;
var f = status.LoadOnAcIsland?.Ac.Power.Active;
var g = status.AcDc.Dc.Power.Value;
var h = status.AcDcToDcLink.Power.Value;
var h = status.AcDcToDcLink?.Power.Value;
var i = status.PvOnDc?.Dc.Power.Value;
var k = status.DcDc.Dc.Link.Power.Value;
var l = status.Battery is not null ? status.Battery.Dc.Power.Value : 0;
@ -367,6 +367,10 @@ public static class Topology
private static TextBlock CreateBatteryColumn(this StatusRecord status)
{
var bat = status.Battery;
if (bat is null)
return TextBlock.AlignLeft("no battery").Box();
var batteryAvgBox = CreateAveragedBatteryBox(bat);
var batteryBoxes = bat
@ -387,11 +391,8 @@ public static class Topology
return status.Config.DisplayIndividualBatteries ? individualWithAvgBox : batteryAvgBox;
}
private static TextBlock CreateAveragedBatteryBox(Battery48TlRecords? bat)
private static TextBlock CreateAveragedBatteryBox(Battery48TlRecords bat)
{
if (bat is null)
return TextBlock.AlignLeft("no battery").Box();
var voltage = bat.Dc.Voltage.ToDisplayString();
var soc = bat.Devices.Any() ? bat.Devices.Average(b => b.Soc).Percent().ToDisplayString() : "0"; // TODO
var current = bat.Dc.Current.ToDisplayString();