Class StateMachine


  • 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
    • Constructor Detail

      • StateMachine

        public StateMachine()
    • Method Detail

      • status

        public String status()
        Returns current status of StateMachine. At first method validate, if current State is valid. If not, StateMachine will execute steps correct this.
        Returns:
        current StateMachine status
      • transition

        public boolean transition()