Add Control Special Error.
This commit is contained in:
parent
3ae8a97d15
commit
0d400a0eea
|
@ -170,6 +170,16 @@ internal static class Program
|
||||||
Watchdog.NotifyAlive();
|
Watchdog.NotifyAlive();
|
||||||
|
|
||||||
var record = ReadStatus();
|
var record = ReadStatus();
|
||||||
|
|
||||||
|
// If control Special Error return true, we must stop the system.(break;)
|
||||||
|
var specialErrorOccured = record.ControlSpecialError();
|
||||||
|
|
||||||
|
if (specialErrorOccured.Item1)
|
||||||
|
{
|
||||||
|
//stop the system
|
||||||
|
//return
|
||||||
|
specialErrorOccured.Item2.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
record.ControlConstants();
|
record.ControlConstants();
|
||||||
record.ControlSystemState();
|
record.ControlSystemState();
|
||||||
|
@ -202,6 +212,36 @@ internal static class Program
|
||||||
// ReSharper disable once FunctionNeverReturns
|
// ReSharper disable once FunctionNeverReturns
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static (Boolean, String) ControlSpecialError (this StatusRecord r) // to find a better name
|
||||||
|
{
|
||||||
|
// Those errors must not occurs. Stop the system in case this is happen.
|
||||||
|
var isSpecialErrorOccured = false;
|
||||||
|
var errorMessage = "No Error";
|
||||||
|
|
||||||
|
// 1. relay0 is open and K2 Close.
|
||||||
|
if (r.Relays is { K2ConnectIslandBusToGridBus: false, K2IslandBusIsConnectedToGridBus: true } )
|
||||||
|
{
|
||||||
|
isSpecialErrorOccured = true;
|
||||||
|
errorMessage = " Contradiction: R0 is opening the K2 but the K2 is still close ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. If K1 is open, K2 must be open .
|
||||||
|
if (r.Relays is { K1GridBusIsConnectedToGrid: false, K2IslandBusIsConnectedToGridBus: true } )
|
||||||
|
{
|
||||||
|
isSpecialErrorOccured = true;
|
||||||
|
errorMessage = " Contradiction: K1 is open but the K2 is still close ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. If FI error is occured, K2 must be open.
|
||||||
|
if (r.Relays is { FiError: true, K2IslandBusIsConnectedToGridBus: true } )
|
||||||
|
{
|
||||||
|
isSpecialErrorOccured = true;
|
||||||
|
errorMessage = " Contradiction: Fi error occured but the K2 is still close ";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return (isSpecialErrorOccured, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
private static void ControlConstants(this StatusRecord r)
|
private static void ControlConstants(this StatusRecord r)
|
||||||
{
|
{
|
||||||
|
@ -228,7 +268,7 @@ internal static class Program
|
||||||
dcDevices.ForEach(d => d.Control.VoltageLimits.MaxBatteryVoltage = configFile.MaxChargeBatteryVoltage);
|
dcDevices.ForEach(d => d.Control.VoltageLimits.MaxBatteryVoltage = configFile.MaxChargeBatteryVoltage);
|
||||||
dcDevices.ForEach(d => d.Control.VoltageLimits.MinBatteryVoltage = configFile.MinDischargeBatteryVoltage);
|
dcDevices.ForEach(d => d.Control.VoltageLimits.MinBatteryVoltage = configFile.MinDischargeBatteryVoltage);
|
||||||
dcDevices.ForEach(d => d.Control.ControlMode = DcControlMode.VoltageDroop);
|
dcDevices.ForEach(d => d.Control.ControlMode = DcControlMode.VoltageDroop);
|
||||||
|
|
||||||
r.DcDc.ResetAlarms();
|
r.DcDc.ResetAlarms();
|
||||||
r.AcDc.ResetAlarms();
|
r.AcDc.ResetAlarms();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue