Exercise 12.1 - SysML to Stateflow.

Objectives

The new learning objectives of this exercise are to generate a state machine structure in a Stateflow from a state machine in a Rhapsody SysML model. Stateflow to SysML model generation is covered in Exercise 12.3.

Preparation

This exercise assumes the student has

  • IBM Rational Rhapsody 8.2 installed correctly on his or her machine with a valid license for use, and

  • Syndeia 3.3 installed as a plugin for Rhapsody 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.

Caution: Rhapsody has, by default, restrictions on the naming of SysML elements, which can create problems when Syndeia tries to create Rhapsody model elements that violate these restriction, e.g. beginning a SysML block name with a number. We recommend modifying any Rhapsody models you create to relax these restrictions. Modify the properties of the top-level package of the model under General::Model::NamesRegExp with the following string and save.

^(([a-zA-Z0-9_][a-zA-Z0-9_ ():-]*)|(operator.+))$

Exercise

  1. Open the Syndeia Tutorial Testbed.rpy model. We will demonstrate the Syndeia Stateflow interface using the Three States State Machine in the Three State Model package shown in Figure 1.

    Figure 1 Rhapsody showing ThreeStates state machine diagram

  2. Launch the Syndeia dashboard from the ThreeStates package in the Rhapsody model view browser, select a Syndeia Cloud project if necessary, and go to the Connection Manager tab. Expand your SysML model in the left column to show the ThreeStates state machine and your local operating system network connection on the right side to show the empty destination folder (1_Demo_ Stateflow_Rhp in Figure 2).

    Figure 2  Syndeia Dashboard, Connection Manager tab

  3. Select Model Transform for Connection Type in the central column. Drag and drop the Three States::statechart_0 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 the new Stateflow State Chart and its contents, as shown in Figure 3.

    Figure 3  Syndeia Dashboard, Connection Manager tab, after generation of state machine structure in the local file system (red highlight shows statechart_0.slx Simulink model).

  4. In the Connection Manager, right-click the statechart_0.slx Simulink model (see red highlight in Figure 3) and choose Open. Double-click the state chart symbol (left side, Figure 4) to see the states and transitions (right side, Figure 4).

    Figure 4  Simulink with Stateflow diagram symbol on left.  Double-click the ThreeStates symbol to open state machine, as shown on right

  5. Rearrange the states and transitions as in Figure 5. The model is ready to add triggers, state behaviors and other stateflow elements. Save and close Simulink model when done.

    Figure 5 Stateflow state chart, final.