State Machine Diagram/State Transition Table
Overview
You can use state machine diagrams to describe the states and behavior of systems and classes. In addition to state machine diagrams, you can also use state transition tables, allowing you to seamlessly design by switching between state machine diagrams and state transition tables.
In state transition tables, you can highlight areas with transitions and areas without transitions, and check transitions for which triggers are not defined. Then, by noting information that the trigger is ignored or cannot occur instead of a transition, you can design without any omissions.
This page explains the operations for using state machine diagrams and state transition tables in the following order.
- Placing a state machine diagram
- Defining states
- Defining transitions
- Describing design information in a state transition table
The following functions are also provided to assist users in modeling.
These will be explained in order.
- Validating the model
- Setting the display content
Placing a state machine diagram
To place a state machine diagram, follow the steps below.
- Select a package in the Model Navigator and click [Add Model] > [State machine diagram] in the context menu.
- The state machine diagram will be placed as a child element of the selected package.
In the current version, if the display scale in the display settings is set to a value greater than 100%, some of the text in the state transition table cells may be cut off.
To avoid this issue, set the display scale in the display settings to 100%.
For other restrictions, see here.
Define a state
To define a state, follow the steps below.
- Drag and drop [State] from the toolbox onto the displayed state machine diagram.
- A new state will be added as a child element of the displayed state machine diagram or state.
The following elements displayed in the Toolbox can be placed on a state machine diagram.
Icon | Name |
---|---|
State | |
Entry Point | |
Exit Point | |
Start | |
End | |
History | |
Merge | |
Select | |
Parallel | |
Merge | |
Note | |
Label | |
Shape |
Place the entry and exit points as port shapes for the following elements.
- State
Add behavior to state
To add entry processing, follow the steps below.
-
Select a state.
-
Double-click the [Behavior] > [Entry Processing] field in the Property Inspector to enter the edit state.
-
Write the entry processing and confirm the edit, and the entry processing will be set for the state and displayed on the state machine diagram.
When you enter text in the body of a state on a state machine diagram, the text is parsed according to the notation format and reflected in each field value of the state.
Of course, if you change the value of each field, it will be reflected in the text on the diagram.
State behavior, text format, and field value correspondence
The behavior for a state is displayed and analyzed in text according to the following format.
-
Format:
<behavior> ::= ['entry/'<entry action>]['\n']['do/'<stay action>]['\n']['exit/'<exit action>]
-
Example
Entry action:set display on
Stay action:show distance
Exit action:set display off
In this case, the following text will be displayed.
entry/set display on
do/show distance
exit/set display off
Add a stereotype to a state
To add a stereotype, follow the steps below.
- Select the state.
- Click the [Add] button in the [Basic information] > [Stereotype] field of the Property Inspector to display the options.
- Select a stereotype and click the [OK] button to set the stereotype to the state and display the stereotype on the state machine diagram.
You can define your stereotype choices in the Detail view of the package model.
You can edit the stereotype you added from the state machine diagram by following the steps below.
- Double-click the stereotype displayed on the state to enter the edit state.
- When you change the stereotype and confirm the edit, it is reflected on the state machine diagram and the stereotype of the state is changed.
Define a transition
To define a transition between states, follow the steps below.
- Move the pointer over the state that will be the start point of the transition.
- Drag the [▲] icon displayed on each side of the state and drop it on the state that will be the end point of the transition.
Add a trigger to a transition
To add a trigger, follow the steps below.
-
Select a transition.
-
Click the [Add] button in the [Basic information] > [Trigger] field of the Property Inspector to display the options.
-
Select a trigger and press the [OK] button to set a trigger for the transition and display the trigger on the state machine diagram.
When you enter text in the transition label on the state machine diagram, the text is parsed according to the notation format and reflected in each field value of the transition.
Of course, if you change the value of each field, it will be reflected in the text on the diagram.
Transition text format and correspondence between each field value
Transitions are displayed and analyzed in text according to the following format.
- Format:
<transition> ::= [<list of triggers>] ['[' <guard> ']'] ['/' <effect>]
- Notes
<list of triggers>
is displayed in the following format.<List of triggers> ::= <Trigger>[','<Trigger>]*
- Example
Trigger:close
Guard:doorway -> isEmpty()
Effect:closed
In this case, the following text will be displayed:
close [doorway -> isEmpty()]/closed
Add a stereotype to a transition
To add a stereotype, follow the steps below.
- Select the transition.
- Double-click the grayed-out [<<stereotype>>] to enter editing mode.
- When you enter the stereotype you want to set, the stereotype will be displayed on the transition of the state machine diagram and the stereotype will be set on the transition.
Define design information in a state transition table
Display a state transition table
To display the design information of a state machine diagram in a state transition table, follow the steps below.
- Follow the instructions below to switch the editor display to the [State Transition Table] view.
- [Next Design User Manual > Modeling > Model Editing > Model Editing Basics > Editing in the Main Editor > Switching Views](../../../../docs/modeling-guide/model-edit/model-edit-basics.md#Switching Views)
The following elements are displayed as states in the state transition table.
Icon | Name |
---|---|
Start | |
Entry point | |
State | |
History | |
Select | |
Parallel | |
Merge | |
Join | |
Exit point | |
End |
States are sorted in the order listed above.
However, they are not sorted between the following elements.
- Selected
- Parallel
- Merge
- Joined
:::note
- All states including substates are displayed.
- Transitions without triggers are displayed in the
<None>
column. - If you select a range of merged cells, cells outside the range may also be selected.
- The position of the state and trigger (row and column) can be switched by selecting [State-Trigger] and [Trigger-State] in the [View Switching] combo box.
:::
Define a state
To define a state in the state transition table, follow the steps below.
- Select a cell in the state transition table and perform one of the following operations.
- Click [Add state (S)...] in the context menu.
- Click the [+] button displayed on the toolbar at the top of the state transition table.
- The [Add state] dialog will be displayed, so enter the name of the state you want to add and confirm it.
- A new state with the name entered in 2. will be added to the row below the selected cell.
- A state will be added with the same type of element as the element (start, entry point, state, history, etc.) in the row of the selected cell.
- If you want to add a substate, you can add it from [Add substate (U)...] in the context menu using the same procedure as above.
- To delete a state, select the cell of the row you want to delete and do one of the following:
- Click [Delete State (D)] in the context menu.
- Click the [-] button displayed on the toolbar at the top of the State Transition Table.
- Press the Delete key.
- If there are no rows of state definitions, you cannot add a state in the State Transition Table view.
Switch to the State Machine Diagram view and add a state by following [Define a State](#Define a State).
Define a Trigger
To define a trigger in the State Transition Table, follow the steps below.
- Select a cell in the State Transition Table and click [Add Trigger (T)...] in the context menu.
- The [Add Trigger] dialog box will appear, so enter the name of the trigger you want to add and confirm.
- A new trigger with the name entered in 2. will be added to the column to the right of the selected cell.
-
If you want to delete a trigger, select the cell in the column you want to delete and select [Delete Trigger (E)] from the context menu.
-
If there is no trigger definition in any column, you cannot add a trigger in the [State Transition Table] view.
Switch to the [State Machine Diagram] view and add a trigger by following [Define Transition > Add Trigger to Transition](#Add Trigger to Transition).
Define Transition
To define a transition in the state transition table, follow the steps below.
- Select a cell in the state transition table and click [Change Transition Destination (C)...] in the context menu.
- If you want to add Ignore to a transition, click [Make Ignored] in the context menu.
- If you want to add NotHappen to a transition, click [Make NotHappen] in the context menu.
- Follow the dialog that appears to select the state to which you want to transition.
- The transition is added to the selected cell.
- If a transition is already defined in the selected cell, delete the existing transition before adding the transition.
Please note that the field values (guards, effects, behavior, etc.) set for the transition will be deleted.
:::note
- If you want to delete a transition, select the cell of the transition you want to delete and delete it from [Clear Cell Value] in the context menu.
:::
- Cells with defined transitions are highlighted.
If you want to change the type of cell to highlight, you can change it from the drop-down list on the toolbar at the top of the state transition table. - This setting is saved for each user.
Add a transition
To add a transition in the state transition table, follow the steps below.
- Select a cell in the state transition table and click [Add transition destination (A)...] in the context menu.
- Follow the displayed dialog to select the state to which the transition will be made.
- The transition will be added to the selected cell. This operation will maintain existing transitions.
When you enter text in a cell of a transition in the state transition table, the text is parsed according to the notation format and reflected in each field value of the transition.
Of course, if you change each field value, it will be reflected in the text on the diagram.
Transition text notation format and correspondence between each field value
Transitions are displayed and parsed in text according to the following format.
-
Format:
<text> ::= <transition> [ <line break> <transition> ] *
-
<transition>
is displayed in the following format. -
<transition> ::= ['['<guard>']'] <name of transition destination state>
-
Example: If one trigger has two conditional transitions, the text is displayed as follows.
-
Transition 1:
-
Destination state name:
Cleaning
-
Guard:
t>1
-
Transition 2:
-
Destination state name:
Driving
-
Guard:
t<=1
-
Text display
-
[t>1]Cleaning <Line feed>[t<=1]Driving
-
Supplementary information
-
If
<Destination state name>
is not found in the selected state machine diagram, an error is notified in the [Information window] > [Output] tab > [State transition table] category.
Please correct as necessary based on the error content. -
If a state is deleted, the
<Transition>
that defined that state as<Destination state name>
is deleted. -
Depending on the IME you are using, when you confirm the text conversion state while editing a cell, the edit state of the cell will also be confirmed.
To avoid this phenomenon, switch IME. It has been confirmed that this phenomenon does not occur with Microsoft IME.
Copy and paste transitions
To copy and paste transitions in the state transition table, follow the steps below.
- Select the cell of the transition you want to copy.
- Copy the selected cell with ctrl+c.
- Select the cell to which you want to paste the transition and press ctrl+v to paste the copied transition.
When selecting the cell of the transition you want to copy, you can select multiple cells by holding down ctrl and clicking the cell to copy and paste them all at once.
Check the details of a transition
To check the details of a transition in the state transition table, follow the steps below.
- Select the cell of the row of the state for which you want to check the transition.
- Click [View] > [Pane] > [Inspector] from the ribbon to display the Inspector.
- Make sure that [Transition] is selected in the tab at the top of the Inspector, or click to select it.
- The Inspector displays the transitions and their fields for the row state of the selected cell.
In the state transition table, you can check the following transition details:
Field Name | Summary |
---|---|
Trigger | Name of the trigger referenced by the transition |
Guard | Guard of the transition |
Effect | Effect of the transition |
Transition behavior | Name of the transition behavior owned by the transition |
- If you change the trigger or transition behavior text box, the name of the owned/referenced model will change.
Please note that the owned/referenced model will not be replaced.
Set the display content
You can display only the information you are interested in in the state transition table without changing the model.
To hide transitions with no trigger defined, follow the steps below.
- Click the [Show no trigger] button on the toolbar at the top of the state transition table.
- The transitions in the Trigger<None> column will be hidden.
- This setting is saved for each user.
Export to Excel
To export the state transition table to Excel, follow the steps below.
- Click the [Export to Excel] button on the toolbar at the top of the state transition table.
- In the [Export to Excel] dialog, determine the destination for the Excel file and save it.
Validate the model
The following items are validated in a state machine diagram:
- Check whether there is a transition that ends at the initial state
- Check whether there is a transition that starts at the final state
To validate a model, follow the steps below.
- Run [UML] > [Validate] > [Check Consistency] from the ribbon.
- If an invalid transition is detected for all models under the project, an error is displayed.
Clicking the [Home] > [Model] > [Check Error] button on the ribbon will validate all models in addition to the standard validation.
When you add a new transition to a state machine diagram, the added transition is checked in real time.
Setting the display content
You can display only the information you are interested in on a state machine diagram without changing the model.
To set the display content of transition behavior, follow the steps below.
- Display the state machine diagram you want to switch the display of.
- Check or uncheck the behavior check box in the [Transition] group on the [UML Diagram] tab of the Inspector.
You can switch the display of the following elements on a state machine diagram.
Category | Element |
---|---|
Common | Stereotype |
State | Behavior |
Transition | Guard |
Behavior |
Restrictions
- If the display scale in the display settings is set to a value greater than 100%, some of the text in the state transition table cells may be cut off.
- Parallel states cannot be defined.
- State areas, list displays, and functions cannot be expressed or described.
- Subsystem states are expressed by displaying an underline in the state name, unlike the UML standard notation.
- Underlining cannot be specified in the state name style. When a state is a submachine, underlining is automatically displayed.
- When you switch the checkbox in the [Transition] group on the [UML Diagram] tab of the Inspector, the displayed content is not updated immediately. The displayed content will be updated by displaying another view once and then displaying the state machine diagram again.
- The following values are reserved words. They may be misinterpreted if used as state names or guards.
- Strings containing "[" (opening bracket) or "]" (closing bracket)
- I
- N
- In the state transition table view, if there are many elements in the matrix, it may take some time to respond when displaying or editing. Please use a hierarchy as necessary.
- When performing clipboard operations (copy, cut, paste) in the state transition table view, use the buttons on the toolbar at the top of the state transition table, not the [Home] > [Clipboard] buttons on the ribbon.
- Documents are not generated for the state transition table view.
- Even if you execute [Export to Excel] on the toolbar of the state transition table view, the alignment (direction of arrangement) of the cell contents and the cell color are not reflected in the output Excel file.
- Only state transition tables with states in rows and triggers in columns are supported. State transition tables with triggers in rows and states in columns, and state transition tables with previous states in rows and next states in columns are not supported.
- You cannot set notes in the No Trigger column in the State Transition Table view.
- If you add or delete a state or trigger in a view other than the State Transition Table while the State Transition Table is displayed, the contents displayed in the State Transition Table will not be updated immediately. You can update it by pressing [Update] on the toolbar, or by displaying another view once and then displaying the State Transition Table again.
- If you edit the attributes (trigger, guard) of a newly added transition while the State Transition Table is displayed in a view other than the State Transition Table, the contents displayed in the State Transition Table will not be updated immediately. You can update it by pressing [Update] on the toolbar, or by displaying another view once and then displaying the State Transition Table again.
- Immediately after adding a state with [+] on the State Transition Table toolbar, you cannot create a transition to that state by editing the text in the cell. Please use [Change Transition Destination (C)...] in the cell context menu.
- If you have a model of a unique class derived from a metamodel related to the State Machine Diagram (State Machine Diagram, State Base, Trigger), the State Transition Table view cannot be displayed correctly.
- If there is an unloaded model as a child element of the state machine diagram, the state transition table view cannot be displayed correctly.
- State names must be unique in the state transition table view. If the same name is used for multiple states, the transition may be misidentified.
- If multiple triggers are assigned to a transition, the transition may be misidentified in the state transition table view.
- For advanced functionality expansion in the future, you can add state transition table view definitions from the context menus and ribbons of various navigators.
- Do not use as this is a reserved feature.