Transformation of Modes & States Machines

Get initialized Simulink® models implementing Capella Modes & States Machines with Stateflow

Workflow

The generic workflow is detailed in the Getting Started. Here in below are the specific options to choose in this workflow:

  1. Select in the Capella Project Explorer the Modes & States Machines to export.
  2. Open the "Capella Export to Simulink®" tool.
  3. Select the transformation type "State machines sorted by engineering perspective".
  4. Generate the export file.
  5. Import the Data Packages in the project using the generated .mlcore file.
How is the Capella Modes & States Machine transformed?

Creation of a Simulink® model

Each Modes & States machine is transformed as a Simulink® model containing a Chart block with root level input ports corresponding to all the Functional Exchanges that trigger the transitions. These input ports are typed with respect to the Functional Exchange definition in Capella. If the Functional Exchange does not carry Exchange items, then the Functional Exchange bus definition leads to an empty bus that requires to be detailed in the Data Dictionary.

Here in below the table captures how Capella Modes & States Machines element types are transformed as MATLAB®, Simulink® and StateFlow elements.

Transition trigger

Best practices for Time event trigger

The Time event trigger expression is not modified by the transformation. Hence it is recommended to apply this expression format: "<TimeValue> , <TimeUnitExpression>"

TimeValue: either a numerical value or a variable name defined in the data model. In case of a variable name, the name must comply with the naming rules defined in the Best Practices.

If the variable name does not comply with these rules, then there will be discrepancies between the variable name use to define the variable in MATLAB and the name to use this variable in the transition trigger expression.

TimeUnitExpression: might be one of these values:

  1. 'tick': number of times the chart has woken up.
  2. 'sec': seconds.
  3. 'msec': milliseconds.
  4. 'usec': microseconds.

Creation of Data Dictionaries

When transforming Modes & States Machines, the required data types (ie. data types used by Functional Exchanges triggering transitions) are also transformed and defined in Data Dictionaries. See Transformation of Data and Interfaces for more information on how these data types are transformed.

An extra Data Dictionary, named the same than the Modes or States machine Simulink® model and stored in the "data" folder, is created and linked to the created Simulink® model

Another Data Dictionary, named "<ArcadiaPerspective>_FunctionalExchanges_Categories.sldd", is created to store all the Functional Exchanges used by the MSM. This data dictionary is referenced by the data dictionary linked to the MSM model.

Assumptions & Limitations

Support of Guards

As Guard is transformed as comment in the transition label, this is very likely you need to create additional root level input ports for the Modes or States Machines to access to the data used by the guard expression.

No support of Exchange Item as transition trigger

The use of Exchange item as transition trigger might be ambiguous since an Exchange Item can be carried by multiple Functonal Exchange. It is recommanded to select the Functional Exchanges that trigger the transition.

No support of Change Event

Change event as transition trigger is not supported since a change is described by an expression that requires complex logic to be implemented. Recommanded practice is to model this event detection logic at the model root level so as to feed the MSM.

Functional Exchanges as Message (R2019a and earlier)

If you are using MATLAB R2019a or earlier, messages cannot cross model boundaries. As Functional Exchanges triggering transitions are transformed as messages, you need to adapt the root-level model content in order to be able to cross the boundaries.

For each Inport carrying Functional Exchange, insert a Send block between the inport and the Chart block.