rename SystemState => StateMachine
This commit is contained in:
parent
5aad1c6ddf
commit
075c54d179
|
@ -45,9 +45,9 @@ public static class Controller
|
||||||
|
|
||||||
public static Boolean ControlSystemState(this StatusRecord s)
|
public static Boolean ControlSystemState(this StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Id = s.GetSystemState();
|
s.StateMachine.State = s.GetSystemState();
|
||||||
|
|
||||||
return s.SystemState.Id switch
|
return s.StateMachine.State switch
|
||||||
{
|
{
|
||||||
1 => State1(s),
|
1 => State1(s),
|
||||||
2 => State2(s),
|
2 => State2(s),
|
||||||
|
@ -89,7 +89,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State1(StatusRecord s)
|
private static Boolean State1(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Inverters are off. Switching to Island Mode.";
|
s.StateMachine.Message = "Inverters are off. Switching to Island Mode.";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -103,7 +103,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State2(StatusRecord s)
|
private static Boolean State2(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Inverters are disconnected from Island Bus. Switching to GridTie Mode. C";
|
s.StateMachine.Message = "Inverters are disconnected from Island Bus. Switching to GridTie Mode. C";
|
||||||
|
|
||||||
s.DcDc.Disable();
|
s.DcDc.Disable();
|
||||||
s.AcDc.Disable();
|
s.AcDc.Disable();
|
||||||
|
@ -117,7 +117,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State4(StatusRecord s)
|
private static Boolean State4(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Turning on Inverters";
|
s.StateMachine.Message = "Turning on Inverters";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -132,7 +132,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State6(StatusRecord s)
|
private static Boolean State6(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Inverters are off. Waiting for them to disconnect from Island Bus.";
|
s.StateMachine.Message = "Inverters are off. Waiting for them to disconnect from Island Bus.";
|
||||||
|
|
||||||
s.DcDc.Disable();
|
s.DcDc.Disable();
|
||||||
s.AcDc.Disable();
|
s.AcDc.Disable();
|
||||||
|
@ -148,7 +148,7 @@ public static class Controller
|
||||||
private static Boolean State9(StatusRecord s)
|
private static Boolean State9(StatusRecord s)
|
||||||
{
|
{
|
||||||
|
|
||||||
s.SystemState.Message = "Inverters have disconnected from Island Bus. Turning them off.";
|
s.StateMachine.Message = "Inverters have disconnected from Island Bus. Turning them off.";
|
||||||
|
|
||||||
s.DcDc.Disable(); // TODO: leave enabled?
|
s.DcDc.Disable(); // TODO: leave enabled?
|
||||||
s.AcDc.Disable();
|
s.AcDc.Disable();
|
||||||
|
@ -179,7 +179,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State12(StatusRecord s)
|
private static Boolean State12(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Waiting for Inverters to connect to Island Bus";
|
s.StateMachine.Message = "Waiting for Inverters to connect to Island Bus";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -195,7 +195,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State13(StatusRecord s)
|
private static Boolean State13(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Disconnected from AcIn (K2), awaiting inverters to disconnect from AcOut (K3)";
|
s.StateMachine.Message = "Disconnected from AcIn (K2), awaiting inverters to disconnect from AcOut (K3)";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -209,7 +209,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State15(StatusRecord s)
|
private static Boolean State15(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Grid has been lost, disconnecting AcIn from AcOut (K2)";
|
s.StateMachine.Message = "Grid has been lost, disconnecting AcIn from AcOut (K2)";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -232,7 +232,7 @@ public static class Controller
|
||||||
// HighActivePinState.Closed
|
// HighActivePinState.Closed
|
||||||
// );
|
// );
|
||||||
|
|
||||||
s.SystemState.Message = "ESS";
|
s.StateMachine.Message = "ESS";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -247,7 +247,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State17(StatusRecord s)
|
private static Boolean State17(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Inverters are in Island Mode. Waiting for them to connect to AcIn.";
|
s.StateMachine.Message = "Inverters are in Island Mode. Waiting for them to connect to AcIn.";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -282,7 +282,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State21(StatusRecord s)
|
private static Boolean State21(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Island Mode";
|
s.StateMachine.Message = "Island Mode";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -296,7 +296,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State22(StatusRecord s)
|
private static Boolean State22(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Grid became available (K1). Turning off inverters.";
|
s.StateMachine.Message = "Grid became available (K1). Turning off inverters.";
|
||||||
|
|
||||||
s.DcDc.Disable();
|
s.DcDc.Disable();
|
||||||
s.AcDc.Disable();
|
s.AcDc.Disable();
|
||||||
|
@ -314,26 +314,26 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State101(StatusRecord s)
|
private static Boolean State101(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Relay device is not available";
|
s.StateMachine.Message = "Relay device is not available";
|
||||||
return s.EnableSafeDefaults();
|
return s.EnableSafeDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean State102(StatusRecord s)
|
private static Boolean State102(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "ACDCs not available";
|
s.StateMachine.Message = "ACDCs not available";
|
||||||
return s.EnableSafeDefaults();
|
return s.EnableSafeDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Boolean State103(StatusRecord s)
|
private static Boolean State103(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Panic: ACDCs have unequal grid types";
|
s.StateMachine.Message = "Panic: ACDCs have unequal grid types";
|
||||||
return s.EnableSafeDefaults();
|
return s.EnableSafeDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean State104(StatusRecord s)
|
private static Boolean State104(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.SystemState.Message = "Panic: DCDCs not available";
|
s.StateMachine.Message = "Panic: DCDCs not available";
|
||||||
return s.EnableSafeDefaults();
|
return s.EnableSafeDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
namespace InnovEnergy.App.SaliMax.System;
|
namespace InnovEnergy.App.SaliMax.System;
|
||||||
|
|
||||||
public class SystemState
|
public class StateMachine
|
||||||
{
|
{
|
||||||
public String Message { get; set; } = "Panic: Unknown State!";
|
public String Message { get; set; } = "Panic: Unknown State!";
|
||||||
public Int32 Id { get; set; } = 100;
|
public Int32 State { get; set; } = 100;
|
||||||
}
|
}
|
Loading…
Reference in New Issue