STATE
- the State
type, e.g. typically an enumCONTEXT
- the context type, i.e. a class wrapping a State-Machine
contextpublic abstract class AbstractStateMachine<STATE extends State<STATE>,CONTEXT>
extends java.lang.Object
Constructor and Description |
---|
AbstractStateMachine(STATE initialState)
Initialize the State-Machine and set an initial State.
|
Modifier and Type | Method and Description |
---|---|
void |
forceNextState(STATE state)
Forcibly change the next State from outside.
|
STATE |
getCurrentState()
Gets the currently activate State.
|
abstract StateHandler<STATE,CONTEXT> |
getStateHandler(STATE state)
Gets the
StateHandler for each State. |
void |
run(CONTEXT context)
Execute the StateMachine.
|
public AbstractStateMachine(STATE initialState)
TODO Note that for the initialState the {@link StateHandler#onEntry(Object) method is not called in the beginning.
initialState
- the initial Statepublic abstract StateHandler<STATE,CONTEXT> getStateHandler(STATE state)
StateHandler
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.
state
- the StateStateHandler
for the given Statepublic STATE getCurrentState()
public void forceNextState(STATE state)
Note that transition events will get called.
state
- the next Statepublic void run(CONTEXT context) throws OpenemsError.OpenemsNamedException
OpenemsError.OpenemsNamedException
- on error