State

State represents a location of control with a particular set of reactions to conditions and/or events. A state can be either simple or, if it contains other states, composite. Control always resides in one of simple states, but the current set of reactions is a union of those of the current simple state and of all composite states containing it – i.e., a transition exiting any of these states may be taken.


States

 To draw a state
  1. Drag the  State element from the  Statechart palette onto the diagram of agent.
  2. In some cases (especially when you want to draw a composite state) it is more convenient to use drawing mode. To activate it, double-click the  State element in the palette. Its icon will turn into . Now you can draw a state of the required size simply by dragging in the diagram.

Properties

Name – The name of the state. The name is used to identify the state within the statechart.

Show name – If selected, the name of the state is displayed on a presentation diagram.

Ignore – If selected, the state is excluded from the model.

Fill color – Sets the fill color for the state. Click inside the control and choose a color from the set of most used ones, or choose some custom color using the Colors dialog box.

Entry actionHere you can write Java code to be executed when the statechart enters the state.

Exit actionHere you can write Java code to be executed when the statechart exits the state.

Functions

Function

Description

T getContainerState()

Returns the upper level state of the current state or null if this state is at the topmost level (has no container state).

Set<T> getFullState()

Returns the unordered set containing this state and all composite states (if any) containing the current state.

Collection<T> getSimpleStatesDeep()

Returns the collection of all simple states inside the current state.

Statechart<T> getStatechart( Agent agent )

Returns the statechart for the given agent that owns the current state. Returns null if the agent has no statechart with the current state.

Parameter: agent - the agent that owns the current state.

Set<T> getStatesInside()

Returns the unordered set of all states (both simple and composite) contained inside the current state.

boolean inState( Agent agent )

Returns true if the current state is active for the specified agent; returns false otherwise.

Parameter: agent - the agent that owns the current state.

boolean isSimpleState()

Returns true if the current state is a simple state; returns false if the current state is a composite state.

String name()

Returns the name of the current state.

int ordinal()

Returns the ordinal number of this state (states are numbered in a deterministic order).



Related topics

 Statecharts

 Statechart declaration rules

 Statechart execution order