create Topology display for Kaco product

This commit is contained in:
atef 2026-02-27 12:56:18 +01:00
parent 4d27515c14
commit 0db9406b9c
1 changed files with 15 additions and 55 deletions

View File

@ -32,40 +32,6 @@ namespace InnovEnergy.App.KacoCommunication;
// └──────┘ // └──────┘
// //
// New (simplified) topology:
//
// ┌────┐
// │ PV │
// └────┘
// V
// V
// (i) 13.2 kW
// V
// V
// ┌─────────┐ ┌─────────┐ (h) ┌────────┐ (k) ┌───────┐ (l) ┌────────────┐ ┌────────────┐ ┌────────────┐
// │ Grid │<<<│ AC/DC │<<<<<<<<<<<<<│ Dc Bus │>>>>>>>>│ DC/DC │>>>>>>>>│ Battery K1 │ │ Battery K2 │ │ Battery K3 │
// ├─────────┤ ├─────────┤ ├────────┤ ├───────┤ ├────────────┤ ├────────────┤ ├────────────┤
// │ -3205 W │ │ -6646 W │ │ 776 V │ │ 56 V │ │ 52.3 V ... │ │ 52.3 V ... │ │ 52.3 V ... │
// │ -3507 W │ │ -5071 W │ └────────┘ └───────┘ └────────────┘ └────────────┘ └────────────┘
// │ -3605 W │
// └─────────┘
//
// V
// V
// (j) 0 W
// V
// V
// ┌──────┐
// │ Load │
// └──────┘
//
// Notes:
// - (a) is grid power (to/from grid)
// - (h) is AC/DC -> DC link power (or your chosen link variable)
// - (i) PV -> DC bus
// - (j) DC load
// - (k) DC bus -> DC/DC link
// - (l) DC/DC -> battery power (or total battery power)
public static class SimpleTopology public static class SimpleTopology
{ {
@ -74,17 +40,17 @@ public static class SimpleTopology
// Keep the same variable letters as your diagrams (where possible) // Keep the same variable letters as your diagrams (where possible)
var a = status.GridMeterRecord?.ActivePowerTotal; var a = status.GridMeterRecord?.ActivePowerTotal;
// In your existing code, "AC/DC column" shows per-device AC power;
// and "h" is a separate link (AcDcToDcLink?.Power.Value). // and "h" is a separate link (AcDcToDcLink?.Power.Value).
var h = 0; var h = status.InverterRecord?.ActivePowerW;
var i = 0; var i = 0;
var j = 0; var j = 0;
var k = 0; var k = status.DcDc?.Dc.Battery.Power.Value;
// You mentioned this changed: l is now equal total battery power // You mentioned this changed: l is now equal total battery power
var l = status.BatteryKabinet1.Power;
var l = status.ListOfBatteriesRecord?.Sum(r => r.Power);
var grid = status.CreateGridColumn(a); var grid = status.CreateGridColumn(a);
var acdc = status.CreateAcDcColumn(h); var acdc = status.CreateAcDcColumn(h);
@ -138,7 +104,7 @@ public static class SimpleTopology
// └─────────┘ (h) flow to DC Bus // └─────────┘ (h) flow to DC Bus
var acdcBox = TextBlock var acdcBox = TextBlock
.AlignLeft(status.InverterRecord?.ActivePowerSetPercent.ToString() ?? "???") .AlignLeft(status.InverterRecord?.ActivePowerW.ToString() ?? "???")
.TitleBox("AC/DC"); .TitleBox("AC/DC");
var flowToDcBus = Flow.Horizontal(h); var flowToDcBus = Flow.Horizontal(h);
@ -175,7 +141,7 @@ public static class SimpleTopology
var pvToBus = Flow.Vertical(i); var pvToBus = Flow.Vertical(i);
// DC bus box (voltage from your DcDc record matches your existing code) // DC bus box (voltage from your DcDc record matches your existing code)
var dcBusVoltage = 0.0; var dcBusVoltage = status.DcDc.Dc.Link.Voltage.Value;
var dcBusBox = dcBusVoltage var dcBusBox = dcBusVoltage
.ToString(CultureInfo.InvariantCulture) .ToString(CultureInfo.InvariantCulture)
.Apply(TextBlock.FromString) .Apply(TextBlock.FromString)
@ -203,7 +169,7 @@ public static class SimpleTopology
// │ 56 V │ // │ 56 V │
// └───────┘ (l) flow to batteries // └───────┘ (l) flow to batteries
var dc48Voltage =0.0; var dc48Voltage = status.DcDc?.Dc.Battery.Voltage;
var dcdcBox = TextBlock var dcdcBox = TextBlock
.AlignLeft(dc48Voltage) .AlignLeft(dc48Voltage)
@ -219,13 +185,13 @@ public static class SimpleTopology
// Battery K1 | Battery K2 | Battery K3 (side-by-side) // Battery K1 | Battery K2 | Battery K3 (side-by-side)
// Each box: voltage, soc, current, temp, etc. (you can tailor) // Each box: voltage, soc, current, temp, etc. (you can tailor)
var bat = status.BatteryKabinet1; var bat = status.ListOfBatteriesRecord;
if (bat is null) if (bat is null)
return TextBlock.AlignLeft("no battery").Box(); return TextBlock.AlignLeft("no battery").Box();
// If you actually have relay names K1/K2/K3 per battery, wire them here. // If you actually have relay names K1/K2/K3 per battery, wire them here.
// For now we label by index as "Battery K{n}" to match your picture. // For now we label by index as "Battery K{n}" to match your picture.
var boxes = bat.Devices var boxes = bat
.Select((b, idx) => CreateBatteryKBox(b, idx)) .Select((b, idx) => CreateBatteryKBox(b, idx))
.ToReadOnlyList(); .ToReadOnlyList();
@ -235,30 +201,24 @@ public static class SimpleTopology
: TextBlock.AlignLeft("no battery devices").Box(); : TextBlock.AlignLeft("no battery devices").Box();
} }
private static TextBlock CreateBatteryKBox(BatteryDeligreenRecord battery, int idx) private static TextBlock CreateBatteryKBox(BatteryDeligreenRecords battery, int idx)
{ {
// Minimal “K-style” battery box matching your diagram fields
var data = battery.BatteryDeligreenDataRecord;
// Some of your sample screen values look like: // Some of your sample screen values look like:
// 52.3 V, 99.1 %, 490 mA, 250 °C, 445 A // 52.3 V, 99.1 %, 490 mA, 250 °C, 445 A
// Map these to whatever fields you trust in your record. // Map these to whatever fields you trust in your record.
var voltage = data.BusVoltage.ToDisplayString(); var voltage = battery.Voltage.ToDisplayString();
var soc = data.Soc.ToDisplayString(); var soc = battery.Soc.ToDisplayString();
var current = data.BusCurrent.ToDisplayString(); var current = battery.Current.ToDisplayString();
var temp = data.TemperaturesList.PowerTemperature.ToDisplayString(); var count = battery.Devices.Count;
// If you have a better “pack current” field, replace this line.
// Keeping it as a separate line to mimic the pictures extra current-like line.
var extraCurrent = data.BusCurrent.ToDisplayString();
return TextBlock return TextBlock
.AlignLeft( .AlignLeft(
voltage, voltage,
soc, soc,
current, current,
temp, count
extraCurrent
) )
.TitleBox($"Battery K{idx + 1}"); .TitleBox($"Battery K{idx + 1}");
} }