15. Preparing Models for Use with Reactis#

To use Reactis on a Simulink / Stateflow model, you must ensure that the model satisfies certain constraints. This chapter describes what these constraints are. Please note that, while every effort is made to maintain the accuracy of the following list of supported and unsupported features, due to the complexity and continual evolution of the Simulink / Stateflow notation, this description may not be complete. For example, some blocks listed as supported do not support all parameters for the block. A block or feature not listed as either supported or unsupported should be assumed to be unsupported.

We encourage all potential customers to take advantage of a free evaluation license for Reactis to determine if the subset of Simulink / Stateflow supported by Reactis is adequate for your models. If it’s not, please let us know what features or blocks you would like to see Reactis support. Reactive Systems uses such feedback to prioritize enhancements to Reactis.

15.1. MATLAB#

Reactis can process Simulink / Stateflow models that contain MATLAB code in callbacks or mask initializations, provided that certain conventions are observed. On the one hand, files that define workspace data items referred to in a model must be “connected” to the model appropriately, and certain MATLAB functions should be avoided. The remainder of this section elaborates on these points.

15.1.1. Workspace Data Items#

Reactis invokes MATLAB to evaluate many MATLAB expressions, but it does not directly interact with an executing MATLAB session in the same way that Simulink does. For this reason, any workspace data items that a model uses must be initialized within one of the following locations:

  • Any Simulink model callback or block callback that is executed when loading or running the model (PreLoadFcn, PostLoadFcn, InitFcn, StartFcn).

  • A “startup.m” file located in the folder where the model file is located. When using this method, make sure that the “Execute startup.m and pathdef.m scripts in model folder” is checked in the “General” tab of the Reactis Info File Editor.

  • The “Callbacks” tab of the Reactis Info File Editor. If in your environment the MATLAB workspace for your model is set up via some external script or graphical user interface prior to loading the model, you can add the initialization code here so Reactis knows how to set up the workspace. Reactis will automatically execute the “Pre-Load Function” code prior to loading the model and the “Post-Load Function” code after loading the model. This method allows you to use Reactis in such an environment without having to modify your model.

  • The Simulink Data Dictionary.

For the cruise control example, the file cruise_constants.m defines two workspace variables that are used in cruise.mdl. One attaches cruise_constants.m to cruise.mdl as follows:

  1. Load cruise.mdl into Simulink.

  2. From the Modeling tab toolbar, select the Model Settings > Model Properties menu item.

  3. In the resulting dialog, select the Callbacks tab.

  4. In the Model pre-load function entry box enter cruise_constants;.

  5. Save the model.

In general, using the PreLoadFcn callback in this manner is good modeling practice, since once the .m files are attached to a model file, loading the model file into Simulink (and not just Reactis) will automatically load the .m files as well.

15.1.2. Unsupported MATLAB Features#

If any of the following MATLAB functions are used in the callbacks or mask initializations of a model, then the Reactis “Propagate set_param” setting must be enabled. To enable the feature for a model, load the model, select menu item Edit > General, and then check the box “Propagate set_param changes by saving the model to a temporary file”. To enable this feature for all models, select File > Model Defaults… and then check the box “Propagate set_param changes by saving the model to a temporary file” in the General tab. If this setting is enabled, Reactis will cause Simulink to apply all the changes to the model, then automatically save them to a temporary file. Reactis then imports the temporary model to see the applied changes.

Table 15.1 Expression Evaluation#


Assign variable in workspace.


Evaluate expression in workspace.

Table 15.2 Model Construction/Modification#


Add a block to a Simulink system.


Add a line to a Simulink system.


Add a parameter to a Simulink system.


Delete a block from a Simulink system.


Delete a line from a Simulink system.


Deletes a parameter from a Simulink system.


Create a new empty Simulink system.


Replace blocks in model.


Set Simulink system and block parameters.

15.3. Stateflow#

Reactis supports most of Stateflow. Some exceptions are the following unsupported features:

  • Charts with the action language set to MATLAB are currently supported if they use the language subset described in the Embedded MATLAB. Charts with “C” action language are supported.

  • Implicit “enter”, “exit” and “change” events

  • Range limits for variables.

  • “ml.” name-space operator and “ml()” function call.

  • Embedded MATLAB code. Reactis supports the language subset described in the Embedded MATLAB.

  • Using Stateflow keywords as variable names. The Stateflow keywords are: at, after, before, change, du, during, enter, en, entry, every, ex, exit, in, on, ml, send, abs, acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, fmod, labs, ldexp, log, log10, min, max, pow, rand, rem, sin, sinh, sqrt, tan, tanh, int8, int16, int32, uint8, uint16, uint32, double, boolean.

  • The explicit type cast function (“cast”).

  • The address operator (&) is supported only in calls to external C functions.

  • The pointer operator (*) is supported only inside a literal C code section.

  • Charts without trigger or sample time are supported only if the model has a fixed sample time.

  • In some cases, the detection of inner transitions fails for odd-shaped transitions (for example, single transition segments which leave and reenter a state).

  • The temporalCount operator.

  • Atomic Subcharts (introduced in R2010b).

15.4. Embedded MATLAB#

Reactis V2012 introduced black-box support for Embedded MATLAB. This includes:

  • MATLAB Function block

  • Truth Table block

  • MATLAB functions

  • Truth Table functions with MATLAB language option

  • MATLAB action language in Stateflow

Note that a subset of the full Embedded MATLAB language is supported. To use models containing Embedded MATLAB in Reactis, your model must only use the language subset supported by Reactis. Note that the same language restrictions apply no matter which of the five model constructs listed above are used to incorporate Embedded MATLAB into your model. To avoid confusion, we use the following abbreviations in the following discussion:

Embedded MATLAB (EML)

the subset of MATLAB supported by MathWorks for code generation.

Reactis Embedded MATLAB (REML)

the subset of EML supported by Reactis.

REML is under active development towards the ultimate goal of supporting a very large subset of EML. Please send requests to Reactive Systems (help@reactive-systems.com) if there are unsupported EML features you would like to use.

The V2015 release of Reactis included a new product: the Reactis for EML Plugin. It integrates with Reactis to offer white-box testing of the EML portions of a model. See the Reactis for EML Plugin chapter for a description of the Reactis for EML Plugin. If not using the new product, you can still test models containing EML; however, exercising coverage targets within the EML will not be an objective of test generation and tracking this coverage will not be available. Whether in white-box or black-box mode for EML, Reactis supports the same subset of EML. This subset is defined in the Subset of Embedded MATLAB Supported by Reactis section.