new module:ct-trading /statemachine /State(sName, nTimeoutopt, sTimeout Stateopt)
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
sNameis not a valid string. - Type
-
module:ct-core
/Error
Methods
add Transition(oTransition)
Adds a state transition from this state, to some other state.
Parameters:
| Name | Type | Description |
|---|---|---|
oTransition |
module:ct-trading |
The transition to add — this may not share a
trigger event with an already added |
Throws:
-
if the transition is
null, or is not a valid instance ofmodule:ct-trading/statemachine/Transition. - Type
-
module:ct-core
/Error
get Attributes()
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.
get Name()
Returns the name of this state.
get Timeout()
Returns the number of seconds after which this state will automatically timeout to another state.
Returns:
The timeout in seconds, or null if no timeout has been configured.
get Timeout State()
Returns the state that will be transitioned to, if this state times out.
Returns:
The configured timeout state, or null if no timeout state has been configured.
get Transition(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
is Final State()
Returns true if there are no other states that can be transitioned to from this state.