Add Control Special Error.
This commit is contained in:
parent
3ae8a97d15
commit
0d400a0eea
|
@ -171,6 +171,16 @@ internal static class Program
|
|||
|
||||
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.ControlSystemState();
|
||||
|
||||
|
@ -202,6 +212,36 @@ internal static class Program
|
|||
// 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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue