Prev Next

Executable StateMachine Artifact

An Executable StateMachine Artifact is key to generating StateMachines that can interact with each other.  It specifies the objects that will be involved in a simulation, their state and how they connect. A big advantage in using Executable StateMachine Artifacts is that each of several parts in an Artifact can represent an instance of a StateMachine, so you can set up simulations using multiple instances of each StateMachine and observe how they interact. An example is provided in the Example Executable StateMachine Help topic.

Creating the Properties of an Executable StateMachine

Each Executable StateMachine scenario involves one or more StateMachines. The StateMachines included are specified by UML Property elements; each Property will have a UML Classifier (Class) that determines the StateMachine(s) included for that type. Multiple types included as multiple Properties can end up including many StateMachines, which are all created in code and initialized on execution.

Action

Description

Drop a Class from the Project Browser on to the <<Executable StateMachine>> Artifact

The easiest way to define properties on an Executable StateMachine is to drop the Class onto the Executable StateMachine from the Project Browser. On the dialog that is shown, select the option to create a Property. You can then specify a name describing how the Executable StateMachine will refer to this property.

Note: Depending on your options, you might have to hold down the Ctrl key to choose to create a property. This behavior can be changed at any time using the 'Hold Ctrl to Show this dialog' checkbox.

Use and Connect Multiple UML Properties

An Executable StateMachine describes the interaction of multiple StateMachines. These can be different instances of the same StateMachine, different StateMachines for the same instance, or completely different StateMachines from different base types. To create multiple properties that will use the same StateMachine, drop the same Class onto the Artifact multiple times. To use different types, drop different Classes from the Project Browser as required.

Defining the initial state for properties

The StateMachines run by an Executable StateMachine will all run in the context of their own Class instance. An Executable StateMachine allows you to define the initial state of each instance by assigning property values to various Class attributes. For example you might specify a Player's age, height, weight or similar if these properties have relevance to the scenario being run. By doing this it is possible to set up detailed initial conditions that will influence how the scenario plays out.

Action

Description

Set Property Values dialog

The dialog for assigning property values can be opened by right-clicking on a Property and selecting 'Features & Properties | Set Property Values', or by using the keyboard shortcut Ctrl+Shift+R.

Assign a value

The 'Set Property Values' dialog allows you to define values for any attribute defined in the original Class. To do this, select the variable, set the operator to '=' and enter the required value.

Defining relationships between properties

In addition to describing the values to assign to variables owned by each property, an Executable StateMachine allows you to define how each property can reference others based on the Class model that they are instances of.

Action

Description

Create a connector

Connect multiple properties using the Connector relationship from the Composite toolbox.

Alternatively, use the Quick Linker to create a relationship between two Properties and select 'Connector' as the relationship type.

Map to Class model

Once a connector exists between two properties, you can map it back to the Association it represents in the Class model. To do this, select the connector and use the keyboard shortcut Ctrl+L. The 'Choose an Association' dialog displays, which allows the generated StateMachine to send signals to the instance filling the role specified in the relationship during execution.

Learn more