ARCS logo.js Augmented Reality Component System

Class: StateMachine

StateMachine

new StateMachine(obj)

Describes a statemachine
Parameters:
Name Type Description
obj object an object describing a state machine. If obj is empty then the statemachine is empty
Properties
Name Type Description
initial String name of the initial state of the statemachine
final String name of the final state of the statemachine
transitions Object transition object. Each key of the object is named after the name of a state and its associated value is an object whose keys are tokens and values the name of the state the transition should reach once activated by the token

Methods

addTransition(start, token, end)

Adds a transition to the state machine
Parameters:
Name Type Description
start string name of the state at the beginning of the transition
token string name of the token triggering the transition
end string name of the state reached at the end of the transition

setFinalState(string)

Sets the final state of the statemachine
Parameters:
Name Type Description
string string name of the final state

setInitialState(string)

Sets the initial state of the statemachine
Parameters:
Name Type Description
string string name of the initial state

setToken(token)

Gives a token to the statemachine. According to its list of transitions and the current state, it may trigger a transition
Parameters:
Name Type Description
token string name of the token

setTransitions(obj)

Sets transitions from a list of transitions
Parameters:
Name Type Description
obj Array.<object> list of transitions

start()

Initialize and starts the statemachine, setting its current state to the initial state (by default, it is the departure of the first transition