public class StateMachine
extends Object
This class handles transitions between states to simulate real usage of actuators.
It creates loop of States, that holds information about its status and time duration that is needed for State to finish its action.
Action is handled with instance StopWatch. Value from stopwatch is compared with duration from State on every interaction
with StateMachine to determinate if State should prevail or should be changed for next.
Extending (duration)
/ \
Retracted (0.0) Extended (0.0)
\ /
Retracting (duration)
This StateMachine is create as follows:
new StateMachine()
.addState("Retracted")
.addState("Extending", duration)
.addState("Extended")
.addState("Retracting", duration)
.build();
StateMachine uses two types of States:
- without duration or duration equals 0.0:
StateMachine is waiting for external input to change State to next in line
- with defined duration:
State needs to last set amount of time (duration). After time expires State is changed