Exercise 12.4 - SysML to Stateflow with Behaviors
Objectives
The new learning objectives of this exercise are to generate a more complex state machine structure in a Stateflow from a state machine in a MagicDraw SysML model, including state entry, do and exit behaviors and transition triggers, guards and effects.
Preparation
This exercise assumes the student has
Cameo System Modeler 18.0 - 19.0 (or MagicDraw with SysML plug-in) installed correctly on his or her machine with a valid license for use, and
Syndeia 3.4 installed as a plugin for Cameo/MagicDraw with a valid license for use
Syndeia Stateflow interface, correctly installed with a valid license for user.
MATLAB/Simulink/Stateflow installed, licensed and available to the user,
A local operating system network connection in the Syndeia Repository Manager
The user can use any local operating system network connection they have available. It is generally advisable to carry out these exercises in a non-production repository, a "sandbox", set up for training and practice purposes.
An empty destination folder in the local operating system to receive the model.
Example – SysML to Stateflow
The SysML model shown in Figure 1 will be used in a model transform to Stateflow. In addition to the transform of states and transitions, Syndeia 3.3 also supports transform of state entry, do and exit behaviors and transition triggers, guards, and effects. Only certain SysML-Stateflow mappings are supported:
SysML state behaviors and transition effects must be modeled as opaque behaviors.
SysML transition triggers must be time events.
SysML transition guards are strings.
Figure 1 SysML Starter Model
The SysML model ThreeStates Plus is found in the Syndeia Tutorial Testbed.mdzip (get it here - SysML Models, Profiles and Mappings) file in the Three State Model with Behaviors package and may be inspected for the exact treatment of these features.
Exercise
If not already open, open the Syndeia Tutorial Testbed.mdzip (get it here - SysML Models, Profiles and Mappings) model and launch the Syndeia dashboard from the Three State Model with Behaviors package. Select a Syndeia Cloud project if necessary. Go to the Settings tab. Check the Generate/compare state and transition behaviors and Synchronize state and transition behaviors checkboxes, as shown in Figure 2.
Figure 2 Syndeia Settings tab
Go to the Connection Manager tab. Expand your SysML model in the left column to show the ThreeStates Plus state machine and your local operating system on the right side to show the empty destination folder (1_Demo_ Stateflow with Behaviors in Figure 3).
Figure 3Â Syndeia Dashboard, Connection Manager tab
Select Model Transform for Connection Type in the central column. Drag and drop the ThreeStates Plus state machine onto the destination folder in the local operating system. Click Yes to confirm. When complete, expand the newly-created Simulink Model to view new Stateflow State Chart and its contents, as shown in Figure 4.
Figure 4Â Syndeia Dashboard, Connection Manager tab, after generation of state machine structure in the local file system (red highlight shows ThreeStates Plus.slx Simulink model).
In the Connection Manager, right-click the ThreeStates Plus.slx Simulink model (see red highlight in Figure 4) and choose Open. Double-click the state chart symbol to see the states and transitions (Figure 5).
Figure 5Â ThreeStates Plus Statechart
In the Syndeia dashboard Connection Browser tab, expand the SysML model to show the connections for the ThreeStates Plus state machine, as highlighted in Figure 6. Right-click the row and select Compare Source & Target.
Figure 6Â Syndeia dashboard, Connection Browser tab, new connection between state machines
The Comparison Results are shown in Figure 7.
Figure 7 Syndeia Comparison Results after model transform.
Make some changes to the state behaviors or transition characteristics and repeat Compare Source & Target. The differences should appear similar to Figure 8.
Figure 8Â Syndeia Comparison Results after minor changes to Stateflow model
Â