RSI Logo

Model-Based Testing and Validation with Reactis®

White Papers > Testing TargetLink Models and C Code with Reactis
spacer
Download: PDF  



 
Spacer

2  Working with TargetLink Models in Reactis

As shown in Figure 2, some preparation steps are necessary before working with a TargetLink model in Reactis. After performing these steps, users can manipulate TargetLink models in Reactis in the same way native Simulink models are processed. Namely it is easy to:

  • Generate tests from a model with Reactis Tester.
  • Simulate and debug models in Reactis Simulator.
  • Check that a model meets its requirements with Reactis Validator.

Reactis is compatible with a number of different TargetLink versions including 2.1.6, 2.2.1, 2.3.0, 3.0, 3.1, 3.2, 3.3, and 3.4. Most of the model-preparation steps are similar for the different versions. When differences exist, they are described below. The biggest difference is that when using version 3.0 or later of the TargetLink blockset, it is not necessary to switch to the stand-alone blockset as is required to work with previous versions of the TargetLink blocks in Reactis.


Figure 2: Preparing TargetLink models for use with Reactis.

2.1  Reactis-Friendly TargetLink Settings

A few TargetLink settings may need adjustment before working with a model in Reactis. We describe those settings in this section.

2.1.1  Disabling Block Logging

TargetLink provides a useful mechanism for logging and graphing the output signals of blocks selected by the user. During or shortly after a simulation (depending on the version of Targetlink) a window with graphs will appear that displays the selected signals. This feature is not compatible with Reactis, so the user should disable the feature as follows:

  1. Double-click on the TargetLink block at the top of your model to open the TargetLink Main Dialog.
  2. In the Simulation Frame Options section of the Code Generation tab, select “Do not log anything” as the “Global logging option”.

Reactis provides alternative ways to view signal graphs when running a model in Reactis Simulator.

2.1.2  Making Ports Virtual

TargetLink inports and outports are used to augment its code generation capability. The ports frequently serve to define various interface boundaries. Most of the functionality is interpreted only by the TargetLink code generator, but in certain situations, the blocks can affect simulation behavior. Certain settings will cause the dynamic insertion of Data Type Conversion blocks that are typically invisible to the user (as shown in Figure 3), but cause problems for Reactis.

To prevent this problem, one should configure the block as a pass-through. This is done as follows:

  1. Load the model in Simulink
  2. Double-click on the TargetLink Inport (or Outport)
  3. Select the Logging & Autoscaling tab
  4. Under Simulation Behavior, check the box Virtual Port.

Figure 3: TargetLink ports should be set to virtual.

2.1.3  TargetLink Full-Featured and Stand-alone Installations

dSPACE offers two ways to install TargetLink on your computer: full-featured and stand-alone.

The full-featured version is intended to be used in the main TargetLink environment when the objective is code generation or Software-in-the-Loop (SIL) simulation.

The stand-alone installation enables users to simulate TargetLink models in the Simulink environment, but not generate code or access many of the advanced TargetLink features. Use of the stand-alone installation does not require a TargetLink license.

When using a full installation it is possible to switch a model back and forth between the full and stand-alone versions of the TargetLink blocks. Prior to TargetLink Version 3.0, it was necessary to switch to the stand-alone blockset to work with a model in Reactis. As of TargetLink 3.0, Reactis is compatible with both the full-featured and the stand-alone blockset.

When using the full blockset, prepare a model for use with Reactis as follows:

  1. Start MATLAB (the version paired with TargetLink)
  2. At the MATLAB command prompt enter: tl_switch_blockset
  3. Load the model in Simulink
  4. Save the model

To switch back to the full-featured blockset, just enter the tl_switch_blockset command a second time and save the model. To determine which blockset is currently active, at the MATLAB command prompt enter: tl_get_blockset_mode. The blockset setting is persistent over different MATLAB sessions, so this step need not be performed each time a model is opened in Reactis.

2.2  TargetLink-Friendly Reactis Settings

2.2.1  Selecting the MATLAB Version in Reactis

Reactis can be configured to use a specific version of MATLAB/Simulink as follows:

  1. Start Reactis
  2. Select File->Global Settings...
  3. In the resulting Global Settings dialog, select the MATLAB tab and then select the appropriate MATLAB version using the pulldown menu.
  4. Click OK to dismiss the Global Settings dialog.

2.2.2  Configuring the Reactis Path

Like MATLAB, Reactis maintains a path variable consisting of a list of folders to be searched for various files used by a model. These files include libraries, including the TargetLink libraries. Unlike MATLAB, Reactis maintains both a global and a model-specific path. The model-specific path is prepended to the global path to construct the full search path used with a model.

When using Reactis with TargetLink, we recommend updating the model-specific path to include the folders containing the TargetLink libraries. The following steps set the model-specific path:

  1. Make sure the model loads and simulates properly in the Simulink environment.
  2. Start Reactis and load the model.
  3. Select Edit->Search Path...
  4. Click the Import button. This will cause Reactis to:
    1. load the model in Simulink (executing any initialization files that might update the path),
    2. query Simulink for the resulting path for the model,
    3. add the returned MATLAB path to the model-specific Reactis path for the model.
  5. Select File->Save to save the updated path into the .rsi file maintained by Reactis for the model.

The model-specific path should now include the dSPACE directories required to simulate a TargetLink model.

2.2.3  Enable Propagate set_param changes

Some TargetLink blocks have attributes that are dynamically updated after the model is loaded. Models using these self-modification methods (e.g. ’set_param’, ’add_block’, etc. ) could previously cause problems because Reactis would not see the changes made by them. To avoid these issues, Reactis now offers a setting that should be turned on when working with TargetLink models.

The setting is named Propagate set_param changes by saving the model to a temporary file and can be enabled as follows:

  1. load your model in Reactis
  2. select Edit->General...
  3. in the resulting dialog ensure the setting is checked

When this setting is enabled, Reactis will:

  1. invoke Simulink/TargetLink to apply the changes to the model
  2. automatically save changed model to a temporary file
  3. import the temporary model file, allowing Reactis to see the applied changes

All of this happens invisibly without any need for interaction from the user.

2.3  Pitfalls to Avoid

2.3.1  Nonstandard Switching Between TargetLink Versions

In earlier releases, each TargetLink version mapped to one distinct MATLAB® 1 installation. To switch mapping, the dSPACE Installation Manager required a system reboot to complete the activation. Some users created backdoor scripts to more quickly switch between installations of TargetLink. Unfortunately, these scripts are not compatible with Reactis, so the user should use the normal TargetLink activation procedure through dSPACE Installation Manager. In later versions of the dSPACE Installation Manager, switching between TargetLink versions is unnecessary in most circumstances, and otherwise very quick.

2.3.2  Incidental TargetLink Dialogs

Because Reactis reads and interprets TargetLink models, occasionally a TargetLink dialog will appear that requires user interaction. Typically, the user will only need to close the dialog or click OK. But it is important the user remain attentive to these dialogs as they may suspend further processing of the model.


Figure 4: Some warning dialogs might appear, but can be dismissed.