Class AbstractStateMachine<STATE extends State<STATE>,CONTEXT extends AbstractContext<?>>
java.lang.Object
io.openems.edge.common.statemachine.AbstractStateMachine<STATE,CONTEXT>
- Type Parameters:
STATE
- theState
type, e.g. typically an enumCONTEXT
- the context type, i.e. a class wrapping a State-Machine context
- Direct Known Subclasses:
AbstractForceChargeDischarge
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
,StateMachine
public abstract class AbstractStateMachine<STATE extends State<STATE>,CONTEXT extends AbstractContext<?>>
extends Object
Manages the States of the StateMachine.
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractStateMachine
(STATE initialState) Initialize the State-Machine and set an initial State. -
Method Summary
Modifier and TypeMethodDescriptionvoid
forceNextState
(STATE state) Forcibly change the next State from outside.Gets the currently activate State.Gets the previously activate State.abstract StateHandler<STATE,
CONTEXT> getStateHandler
(STATE state) Gets theStateHandler
for each State.void
Execute the StateMachine.
-
Constructor Details
-
AbstractStateMachine
Initialize the State-Machine and set an initial State.TODO Note that for the initialState the
StateHandler.onEntry(Object)
method is not called in the beginning.- Parameters:
initialState
- the initial State
-
-
Method Details
-
getStateHandler
Gets theStateHandler
for each State.This method is called once for every available State during construction of the StateMachine in order to initialize an internal list of StateHandlers.
- Parameters:
state
- the State- Returns:
- the
StateHandler
for the given State
-
getPreviousState
Gets the previously activate State.- Returns:
- the State
-
getCurrentState
Gets the currently activate State.- Returns:
- the State
-
forceNextState
Forcibly change the next State from outside. Use with care!Note that transition events will get called.
- Parameters:
state
- the next State
-
run
Execute the StateMachine.- Parameters:
context
- the Context object- Throws:
OpenemsError.OpenemsNamedException
- on error
-