Caplin Trader 5.1.0

Class: module:ct-trading/statemachine/State

module:ct-trading/statemachine/State(sName, nTimeoutopt, sTimeoutStateopt)

new module:ct-trading/statemachine/State(sName, nTimeoutopt, sTimeoutStateopt)

Constructs a new instance of State with the specified attributes.

A State represents one of the conditions that a StateMachine can be in. The complete set of states are held within a StateModel object, and the network diagram between those states is modeled as a list of possible state transitions from each State object.

Parameters:
Name Type Attributes Description
sName String

The name of this state.

nTimeout int <optional>

The number of seconds after which this state will automatically timeout to another state.

sTimeoutState int <optional>

The state that will be transitioned to, if this state times out.

Throws:

if sName is not a valid string.

Type
module:ct-core/Error

Methods

addTransition(oTransition)

Adds a state transition from this state, to some other state.

Parameters:
Name Type Description
oTransition module:ct-trading/statemachine/Transition

The transition to add — this may not share a trigger event with an already added module:ct-trading/statemachine/Transition.

Throws:

if the transition is null, or is not a valid instance of module:ct-trading/statemachine/Transition.

Type
module:ct-core/Error

getAttributes()

Returns a map of name value pairs associated with this state.

This method provides a simple way for applications to associate attribute information with particular states. How this may be used, or why this might be useful, is dependent on each application, but a concrete example within the reference implementation is to store the disabled state for a text field. If the module:ct-trading/statemachine/StateMachine is created from an XML file, these attributes will also be specified within the XML configuration.

getName()

Returns the name of this state.

getTimeout()

Returns the number of seconds after which this state will automatically timeout to another state.

See:
Returns:

The timeout in seconds, or null if no timeout has been configured.

getTimeoutState()

Returns the state that will be transitioned to, if this state times out.

See:
Returns:

The configured timeout state, or null if no timeout state has been configured.

getTransition(sEvent)

Returns the transition that will be used should the given event fire.

Parameters:
Name Type Description
sEvent String

A trigger event that could fire.

Throws:

if the event trigger is invalid.

Type
module:ct-core/Error

isFinalState()

Returns true if there are no other states that can be transitioned to from this state.