How to draw a State Machine Diagram with EA
For an example of a State Machine Diagram (stm) to be drawn using EA, we will use the diagram below from the State Machine Diagram Chapter of Lenny Delligatti’s SysML Distilled.
First, create a project and create a package.
State Machine Diagram The model element that the diagram represents is a State Machine, and a State Machine is generally included in a block and represents the states that the block can have and the transition between states.
Now we create an Attitude Control Subsystem block that will contain the State Machine. Then, use the Add → State Machine function in the context menu of the block to create a State Machine and State Diagram. (State Machine and State Machine Diagram are named the same as in the example above.)
Now let’s add a Simple State. Using the states on stm’s tool box, create 5 states named Orbit Insertion, Acquisition, Slew, Safe Mode, and On-Station on the canvas. Then, use Initial on the Tool Box to add it to the Canvas to set the starting point of the State Machine.
Use Transition in the SysML State Relationships item to connect Transition between Initial, Orbit Insertion, and Safe Mode Acquisition State. Then, use the Junction on the Toolbox to connect the transition between Acquisition and Slew, and add Final to the Canvas to set the end point of the State Machine. Once completed, it will look like this:
Add Sub State
Now let’s add Sub-State of On-Station State. If you create a State and drag it into On-Station, it will be added as a Sub-State of On-Station.
Add two Sub-States of On-Station, name them No Comm Link and Have Comm Link respectively, and connect Transition. Add Initial for Sub-State of On-Station and connect with Have Comm Link and Transition. Then, each Sub-State is connected to Safe Mode and Slew to complete the transition.
Add Transition
Let’s add Transition with Trigger, Guard, and Effect. You can set each in the Transition Properties window that appears when you double-click Transition.
You can set the event type in the Type of Triggers. Let’s assume that transferComplete, which is the trigger of the transition between Orbit Insertion State → Acquisition State, is a Signal Type.
Trigger of Signal Type must assign a signal defined somewhere in the model. Therefore, a signal called transferComplete is created.
Now, in Type of transferComplete Trigger, Signal, and in Specification… Click the button to assign a signal. And enter TransferComplete (current Update) in Name. (I couldn’t find a separate function to set the Argument to Trigger in EA.)
And in the transition from Junction → On-Station, enter the Boolean Expression currentAttitude == orderedAttitude in the Guard field.
An effect is set for the transition between Have Comm Link Sub-State and Slew State. An effect generally assigns an Activity or Interaction defined somewhere in the model. Add an Activity called Dump Momentum to the Attitude Control Subsystem Block and assign it to the corresponding effect.
Also, in the case of Time and Change Event Type in Trigger, it seems necessary to set the Trigger according to SysML grammar through Name. Transition between No Comm Link → Safe Mode is entered as Type: Time, Name: after (2min).
In this way, you can add Trigger, Guard, and Effect to Transition.
Add Internal Behavior of State
Now let’s assign the internal behavior of each State.
By clicking State, you can assign each internal action to entry, do, and exit in the Behavior tab of the Feater window. Orbit Insertion State has Execute spin stabilization assigned to do and Despin action assigned to exit. In the Feature → Behavior tab of Orbit Insertion State, enter Execute spin stabilization and Despin in do and exit, respectively. Then, each Orbit Insertion State operation is automatically added.
(For reference, when you double-click Operation in the Feature → Behavior tab, the Operation window appears. You can explicitly assign the Operation using the Behavior tab → Element button in the window. Perhaps, if you actually need to perform tasks such as Code Generation with the State Machine, I think you need to set it more explicitly like this.)
And in the Feature window, there is an Internal Triggers tab. In this tab, you can assign internal transitions to the State. Right-click the mouse, click New Internal Trigger, and add an internal trigger.
The Trigger Type was set to Change and named when (available memory < data per orbit). In EA, when is not automatically added even if the Event Type is set to Change, so I added When to the name as much as possible to conform to SysML grammar.
Add Sub-State Region
Next, let’s add the Sub-State Region. In the context menu of State, select Advanced → Define Concurrent Substates… You can add State Regions using the function.
As an example, I added two Regions, upper and bottom. And the procedure for adding a Sub-State to the region is the same as adding a Sub-State to the State described above.
Add Composite State
Lastly, in order to reuse a specific Composite State (i.e., a State with a Sub-State), an Entry Point and an Exit Point can be added to the State.
This can be done in the Insert New Embedded Element window that appears when you go to the Connection Points tab in the Feature window, right-click the mouse, and click the Add New button. If you add an Entry or Exit Point in the window, an Entry or Exit Point is created at the boundary of the Composition State. For practice, I added Entry 1,2 and Exit 1,2.
If you are interested in other articles about the basic Knowledge of SysML with EA, please refer to the links below!
[SysML] #1. Understanding SysML Diagrams
[SysML] #2. Understanding SysML Package Diagram
[SysML] #3. Understanding Dependencies of Pkg Diagram
[SysML] #4. How to draw a Pkg Diagram with EA
[SysML] #5. Understanding SysML Requirement Diagram
[SysML] #6. Understanding Relations In Req Diagram
[SysML] #7. How to draw a Req Diagram with EA
[SysML] #8. Understanding SysML UseCase Diagram
[SysML] #9. How to draw a UseCase Diagram with EA
[SysML] #10. Understanding SysML bdd Diagram
[SysML] #11. Understanding SysML ibd Diagram
[SysML] #12. Understanding Part Property of Block
[SysML] #13. Understanding Reference Property of Block
[SysML] #14. Understanding Value Type
[SysML] #15 Understanding Parametric Diagram
[SysML] #16. Understanding Flow Property
[SysML] #17. Understanding Port and Association Block
[SysML] #18. Understanding Behavior of Block
[SysML] #19. Understanding Generalizations
[SysML] #20. Understanding Dependencies, Allocate, Comment
[SysML] #21. Understanding Activity Diagram
[SysML] #22. How to draw a Activity Diagram with EA
[SysML] #23. Seq Diagram LifeLine and Message
[SysML] #24. Seq Diag Constraints Fragment Decompose
[SysML] #25. How to draw a Sequence Diagram with EA
[SysML] #26. Understanding Stm Diagram State and Transition
[SysML] #27. Understanding Stm Diagram Event Pseudostate Region