add visual representation of relay states to topology
This commit is contained in:
parent
4435fb9774
commit
d4fdf92009
|
@ -213,6 +213,9 @@ internal static class Program
|
||||||
|
|
||||||
record.Config.Save();
|
record.Config.Save();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"===========================================".LogInfo();
|
"===========================================".LogInfo();
|
||||||
|
|
||||||
return record;
|
return record;
|
||||||
|
|
|
@ -11,7 +11,6 @@ public class RelaysRecord
|
||||||
public Boolean K1GridBusIsConnectedToGrid => _Regs.DigitalInput6;
|
public Boolean K1GridBusIsConnectedToGrid => _Regs.DigitalInput6;
|
||||||
public Boolean K2IslandBusIsConnectedToGridBus => !_Regs.DigitalInput4;
|
public Boolean K2IslandBusIsConnectedToGridBus => !_Regs.DigitalInput4;
|
||||||
|
|
||||||
|
|
||||||
public IEnumerable<Boolean> K3InverterIsConnectedToIslandBus
|
public IEnumerable<Boolean> K3InverterIsConnectedToIslandBus
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -28,8 +27,8 @@ public class RelaysRecord
|
||||||
public Boolean K3Inverter3IsConnectedToIslandBus => !_Regs.DigitalInput2;
|
public Boolean K3Inverter3IsConnectedToIslandBus => !_Regs.DigitalInput2;
|
||||||
public Boolean K3Inverter4IsConnectedToIslandBus => !_Regs.DigitalInput3;
|
public Boolean K3Inverter4IsConnectedToIslandBus => !_Regs.DigitalInput3;
|
||||||
|
|
||||||
public Boolean FiWarning => !_Regs.DigitalInput5;
|
public Boolean FiWarning => !_Regs.DigitalInput5;
|
||||||
public Boolean FiError => !_Regs.DigitalInput7;
|
public Boolean FiError => !_Regs.DigitalInput7;
|
||||||
|
|
||||||
public Boolean K2ConnectIslandBusToGridBus { get => _Regs.Relay0; set => _Regs.Relay0 = value;}
|
public Boolean K2ConnectIslandBusToGridBus { get => _Regs.Relay0; set => _Regs.Relay0 = value;}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
using InnovEnergy.Lib.Utils;
|
||||||
|
|
||||||
|
namespace InnovEnergy.App.SaliMax;
|
||||||
|
|
||||||
|
public static class Switch
|
||||||
|
{
|
||||||
|
public static TextBlock Open(String name)
|
||||||
|
{
|
||||||
|
return TextBlock.AlignCenterHorizontal
|
||||||
|
(
|
||||||
|
" __╱ __ ",
|
||||||
|
name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,7 +20,6 @@ public static class Controller
|
||||||
if (acDcs.NotAvailable())
|
if (acDcs.NotAvailable())
|
||||||
return 102;
|
return 102;
|
||||||
|
|
||||||
|
|
||||||
var k4 = acDcs.AllGridTied() ? 0
|
var k4 = acDcs.AllGridTied() ? 0
|
||||||
: acDcs.AllIsland() ? 1
|
: acDcs.AllIsland() ? 1
|
||||||
: 4;
|
: 4;
|
||||||
|
@ -38,6 +37,7 @@ public static class Controller
|
||||||
var k2 = relays.K2IslandBusIsConnectedToGridBus ? 1 : 0;
|
var k2 = relays.K2IslandBusIsConnectedToGridBus ? 1 : 0;
|
||||||
var k3 = relays.K3InverterIsConnectedToIslandBus.Take(nInverters).Any(c => c) ? 1 : 0;
|
var k3 = relays.K3InverterIsConnectedToIslandBus.Take(nInverters).Any(c => c) ? 1 : 0;
|
||||||
|
|
||||||
|
|
||||||
// states as defined in states excel sheet
|
// states as defined in states excel sheet
|
||||||
return 1 * k1
|
return 1 * k1
|
||||||
+ 2 * k2
|
+ 2 * k2
|
||||||
|
|
|
@ -14,13 +14,12 @@ public static class Topology
|
||||||
{
|
{
|
||||||
public static TextBlock CreateTopology(this StatusRecord status)
|
public static TextBlock CreateTopology(this StatusRecord status)
|
||||||
{
|
{
|
||||||
// Topology is built up from right to left
|
|
||||||
var islandTopology = status.CreateIslandTopology();
|
var islandTopology = status.CreateIslandTopology();
|
||||||
|
|
||||||
// TODO: check ACDCs if AC is available and synced to find out if grid meter OR grid is unavailable
|
// TODO: check ACDCs if AC is available and synced to find out if grid meter OR grid is unavailable
|
||||||
|
|
||||||
if (status.GridMeter is null) // no grid meter?
|
if (status.GridMeter is null) // no grid meter?
|
||||||
return islandTopology; // we're done
|
return islandTopology; // we're done
|
||||||
|
|
||||||
var gridTopology = status.CreateGridTopology();
|
var gridTopology = status.CreateGridTopology();
|
||||||
|
|
||||||
|
@ -36,10 +35,13 @@ public static class Topology
|
||||||
|
|
||||||
ActivePower islandToGridBusPower = inverterPower + islandLoadPower;
|
ActivePower islandToGridBusPower = inverterPower + islandLoadPower;
|
||||||
|
|
||||||
|
var k2 = status.Relays?.K2IslandBusIsConnectedToGridBus;
|
||||||
|
var gridToIslandConnection = SwitchedFlow(k2, islandToGridBusPower);
|
||||||
|
|
||||||
return TextBlock.AlignCenterVertical
|
return TextBlock.AlignCenterVertical
|
||||||
(
|
(
|
||||||
gridTopology,
|
gridTopology,
|
||||||
Flow.Horizontal(islandToGridBusPower),
|
gridToIslandConnection,
|
||||||
islandTopology
|
islandTopology
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -51,13 +53,25 @@ public static class Topology
|
||||||
var gridBusColumn = status.CreateGridBusColumn();
|
var gridBusColumn = status.CreateGridBusColumn();
|
||||||
var gridBox = status.GridMeter.CreateGridBox();
|
var gridBox = status.GridMeter.CreateGridBox();
|
||||||
|
|
||||||
|
var k1 = status.Relays?.K1GridBusIsConnectedToGrid;
|
||||||
|
var gridPower = status.GridMeter.Ac.Power.Active;
|
||||||
|
var gridFlow = SwitchedFlow(k1, gridPower);
|
||||||
|
|
||||||
return TextBlock
|
return TextBlock
|
||||||
.AlignCenterVertical
|
.AlignCenterVertical
|
||||||
(
|
(
|
||||||
gridBox,
|
gridBox,
|
||||||
Flow.Horizontal(status.GridMeter.Ac.Power.Active),
|
gridFlow,
|
||||||
gridBusColumn
|
gridBusColumn
|
||||||
);
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TextBlock SwitchedFlow(Boolean? switchClosed, ActivePower power)
|
||||||
|
{
|
||||||
|
return switchClosed is null ? TextBlock.FromString("??????????")
|
||||||
|
: !switchClosed.Value ? Switch.Open("K1")
|
||||||
|
: Flow.Horizontal(power);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextBlock CreateIslandTopology(this StatusRecord status)
|
private static TextBlock CreateIslandTopology(this StatusRecord status)
|
||||||
|
@ -74,18 +88,38 @@ public static class Topology
|
||||||
var islandBusColumn = status.CreateIslandBusColumn(islandLoadPower);
|
var islandBusColumn = status.CreateIslandBusColumn(islandLoadPower);
|
||||||
var inverterBox = status.CreateInverterBox();
|
var inverterBox = status.CreateInverterBox();
|
||||||
var dcDcBox = status.CreateDcDcBox();
|
var dcDcBox = status.CreateDcDcBox();
|
||||||
|
|
||||||
return TextBlock
|
return TextBlock
|
||||||
.AlignCenterVertical
|
.AlignCenterVertical
|
||||||
(
|
(
|
||||||
islandBusColumn, Flow.Horizontal(inverterPower),
|
islandBusColumn, status.InverterToIslandBusConnection(),
|
||||||
inverterBox , Flow.Horizontal(inverterPower),
|
inverterBox , Flow.Horizontal(inverterPower), // inverter to DC bus
|
||||||
dcBusColumn , Flow.Horizontal(dcdcPower),
|
dcBusColumn , Flow.Horizontal(dcdcPower),
|
||||||
dcDcBox , Flow.Horizontal(dcBatteryPower),
|
dcDcBox , Flow.Horizontal(dcBatteryPower),
|
||||||
batteries
|
batteries
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "PossibleMultipleEnumeration")]
|
||||||
|
private static TextBlock InverterToIslandBusConnection(this StatusRecord status)
|
||||||
|
{
|
||||||
|
if (status.Relays is null)
|
||||||
|
return TextBlock.FromString("????????");
|
||||||
|
|
||||||
|
var k3S = status
|
||||||
|
.Relays
|
||||||
|
.K3InverterIsConnectedToIslandBus
|
||||||
|
.Take(status.AcDc.Devices.Count);
|
||||||
|
|
||||||
|
if (k3S.All(s => s))
|
||||||
|
{
|
||||||
|
var inverterPower = status.AcDc.Ac.Power.Active;
|
||||||
|
return Flow.Horizontal(inverterPower);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Switch.Open("K3");
|
||||||
|
}
|
||||||
|
|
||||||
private static TextBlock CreateGridBox(this IAc3Connection gridMeter)
|
private static TextBlock CreateGridBox(this IAc3Connection gridMeter)
|
||||||
{
|
{
|
||||||
return gridMeter
|
return gridMeter
|
||||||
|
@ -153,7 +187,7 @@ public static class Topology
|
||||||
return CreateTopologyColumn
|
return CreateTopologyColumn
|
||||||
(
|
(
|
||||||
"PV" , pvOnDcPower,
|
"PV" , pvOnDcPower,
|
||||||
"DC Bus" , dcLinkVoltage,
|
"DC Bus ", dcLinkVoltage,
|
||||||
"DC Load", dcBusLoad
|
"DC Load", dcBusLoad
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -163,6 +197,9 @@ public static class Topology
|
||||||
var bat = status.Battery;
|
var bat = status.Battery;
|
||||||
var batteryAvgBox = CreateAveragedBatteryBox(bat);
|
var batteryAvgBox = CreateAveragedBatteryBox(bat);
|
||||||
|
|
||||||
|
return batteryAvgBox; // TODO: individualBatteries hidden atm
|
||||||
|
|
||||||
|
|
||||||
var batteryBoxes = bat
|
var batteryBoxes = bat
|
||||||
.Devices
|
.Devices
|
||||||
.Select(CreateBatteryBox)
|
.Select(CreateBatteryBox)
|
||||||
|
@ -175,8 +212,8 @@ public static class Topology
|
||||||
return TextBlock
|
return TextBlock
|
||||||
.AlignCenterVertical
|
.AlignCenterVertical
|
||||||
(
|
(
|
||||||
batteryAvgBox //,
|
batteryAvgBox ,
|
||||||
//individualBatteries // TODO
|
individualBatteries
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,9 +224,10 @@ public static class Topology
|
||||||
var current = bat.Dc.Current.ToDisplayString();
|
var current = bat.Dc.Current.ToDisplayString();
|
||||||
var temp = bat.Temperature.ToDisplayString();
|
var temp = bat.Temperature.ToDisplayString();
|
||||||
var heatingCurrent = bat.HeatingCurrent.ToDisplayString();
|
var heatingCurrent = bat.HeatingCurrent.ToDisplayString();
|
||||||
var alarms = bat.Alarms.Count + " Alarms";
|
var alarms = bat.Alarms.Count + " Alarms";
|
||||||
var warnings = bat.Warnings.Count + " Warnings";
|
var warnings = bat.Warnings.Count + " Warnings";
|
||||||
|
var nBatteries = bat.Devices.Count;
|
||||||
|
|
||||||
return TextBlock
|
return TextBlock
|
||||||
.AlignLeft
|
.AlignLeft
|
||||||
(
|
(
|
||||||
|
@ -201,7 +239,7 @@ public static class Topology
|
||||||
warnings,
|
warnings,
|
||||||
alarms
|
alarms
|
||||||
)
|
)
|
||||||
.TitleBox("Battery");
|
.TitleBox($"Battery x{nBatteries}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextBlock PhaseVoltages(this Ac3Bus ac)
|
private static TextBlock PhaseVoltages(this Ac3Bus ac)
|
||||||
|
|
Loading…
Reference in New Issue