reduce debug clutter

This commit is contained in:
ig 2023-08-16 10:36:31 +02:00
parent bf4bd20efa
commit 2d6c6b6140
2 changed files with 23 additions and 69 deletions

View File

@ -31,8 +31,6 @@ namespace InnovEnergy.App.SaliMax;
internal static class Program
{
private static readonly UnixTimeSpan UpdateInterval = UnixTimeSpan.FromSeconds(2);
private static readonly IReadOnlyList<Byte> BatteryNodes;
@ -100,25 +98,12 @@ internal static class Program
StatusRecord ReadStatus()
{
"Reading battery".LogInfo();
var battery = batteryDevices.Read().WriteLine();
"Reading AcDC".LogInfo();
var acDc = acDcDevices.Read();
"Reading DcDc".LogInfo();
var dcDc = dcDcDevices.Read();
"Reading relays".LogInfo();
var relays = saliMaxRelaysDevice.Read();
"Reading loadOnAcIsland".LogInfo();
var loadOnAcIsland = acIslandLoadMeter.Read();
"Reading gridMeter".LogInfo();
var gridMeter = gridMeterDevice.Read();
"Reading pvOnDc".LogInfo();
var pvOnDc = amptDevice.Read();
var pvOnAcGrid = AcPowerDevice.Null;
@ -214,7 +199,6 @@ internal static class Program
(t + "\n").LogInfo();
$"{record.StateMachine.State}: {record.StateMachine.Message}".LogInfo();
$"Batteries SOC: {record.Battery.Soc}".LogInfo();
var essControl = record.ControlEss().LogInfo();
@ -339,24 +323,23 @@ internal static class Program
if (s.GridMeter is not null)
{
totalBoxes = TextBlock.AlignCenterVertical(gridBox,
gridBusFlow,
gridBusColumn,
flowGridBusToIslandBus,
islandBusColumn,
flowIslandBusToInverter,
inverterBox,
flowInverterToDcBus,
dcBusColumn,
flowDcBusToDcDc,
dcDcBox,
flowDcDcToBattery,
batteryAvgBox,
individualBatteries);
gridBusFlow,
gridBusColumn,
flowGridBusToIslandBus,
islandBusColumn,
flowIslandBusToInverter,
inverterBox,
flowInverterToDcBus,
dcBusColumn,
flowDcBusToDcDc,
dcDcBox,
flowDcDcToBattery,
batteryAvgBox,
individualBatteries);
}
else
{
totalBoxes = TextBlock.AlignCenterVertical(
islandBusColumn,
totalBoxes = TextBlock.AlignCenterVertical(islandBusColumn,
flowIslandBusToInverter,
inverterBox,
flowInverterToDcBus,

View File

@ -1,9 +1,7 @@
using InnovEnergy.App.SaliMax.Ess;
using InnovEnergy.App.SaliMax.SaliMaxRelays;
using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc;
using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes;
using InnovEnergy.Lib.Devices.Trumpf.TruConvertDc;
using InnovEnergy.Lib.Utils;
using static InnovEnergy.Lib.Devices.Trumpf.SystemControl.DataTypes.GridType;
namespace InnovEnergy.App.SaliMax.System;
@ -22,42 +20,17 @@ public static class Controller
if (acDcs.NotAvailable())
return 102;
var i = 0;
foreach (var s in acDcs.Devices)
{
i++;
s.Control.PowerStageEnable.WriteLine(" Inverter "+ i + ": Power Stage");
String.Join(Environment.NewLine + i, s.Status.Alarms).LogInfo();
}
var allDisabled = acDcs.AllDisabled();
var allEnabled = acDcs.AllEnabled();
var allGridTied = acDcs.AllGridTied();
var allIsland = acDcs.AllIsland();
var k4 = allGridTied ? 0
: allIsland ? 1
var k4 = acDcs.AllGridTied() ? 0
: acDcs.AllIsland() ? 1
: 4;
var k5 = allDisabled ? 0
: allEnabled ? 1
var k5 = acDcs.AllDisabled() ? 0
: acDcs.AllEnabled() ? 1
: 4;
// After testing this, It looks it more messing up the system and get stuck in a cycle of open one inverter and close the other one.
// The solution is always to send the open/close command in every cycle, if one open before the other(s) , the next cycle will open the other inverter(s).
//if (!acDcs.AllTheSame())
//{
// k4 = 4;
// "Panic: ACDCs have unequal power stage".LogError();
//}
if (k4 == 4 || k5 == 4)
{
return 103; //Message = "Panic: ACDCs have unequal grid types or power stage",
}
var nInverters = r.AcDc.Devices.Count;
@ -66,12 +39,11 @@ public static class Controller
var k3 = relays.K3InverterIsConnectedToIslandBus.Take(nInverters).Any(c => c) ? 1 : 0;
// states as defined in states excel sheet
return
1*k1
+ 2*k2
+ 4*k3
+ 8*k4
+ 16*k5;
return 1 * k1
+ 2 * k2
+ 4 * k3
+ 8 * k4
+ 16 * k5;
}
public static Boolean ControlSystemState(this StatusRecord s)
@ -322,7 +294,6 @@ public static class Controller
return s.EnableSafeDefaults();
}
private static Boolean State103(StatusRecord s)
{
s.StateMachine.Message = "Panic: ACDCs have unequal grid types or PowerStage";