Caplin Trader 4.7.1

Class: module:caplin/workbench/model/MiniStateMachine

module:caplin/workbench/model/MiniStateMachine

Constructor

new module:caplin/workbench/model/MiniStateMachine(mStates, sInitialState)

The MiniStateMachine provides a simple configurable state Machine. You must provide a valid representation of the state model the MiniStateMachine will be in.


The format will be a map, with each key representing a state, and an array of valid states that can be transitioned to as the value


mStates["state1"] = ["state2", "state3"]
mStates["state2"] = ["steate1"]
mStates["state3"] = ["state1", "state2"]
Parameters:
Name Type Description
mStates Object Representation of the states the MinisStateMachine will use.
sInitialState String Initial state your MiniStateMachine is on.

Methods

getAvailableStates()

Returns the available states that the MiniStateMachine can be in.

getCurrentState()

Returns the current MiniStateMachine state.

getValidTransitions(The)

Returns the available states that can be transitioned from the state given. If no state is given it will return the available transitions from the current state.
Parameters:
Name Type Description
The String state from which we want to know the transitions

setState(sNewState)

Sets the given state. This state must be within the available ones.
Parameters:
Name Type Description
sNewState String The new state to be set