RSI Logo

Model-Based Testing and Validation with Reactis®

White Paper: 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, and 3.2. 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.2  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.3  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->Settings...
  3. In the resulting Settings dialog, select the MATLAB tab and then select the appropriate MATLAB version using the pulldown menu.
  4. Click OK to dismiss the Settings dialog.

2.4  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.5  Pitfalls to Avoid

2.5.1  Nonstandard Switching Between TargetLink Versions

Each time a user installs TargetLink, it is mapped to one distinct MATLAB® 1 installation. Additionally, TargetLink must be activated for one specific MATLAB installation before using it. Before using TargetLink models in Reactis, the user should make sure TargetLink is activated for the version of MATLAB intended for use with Reactis.

To select the desired TargetLink version, use the dSPACE Installation Manager application. A reboot of the computer may be required to complete the process. Some users create scripts to quickly switch between installations of TargetLink. Unfortunately, these scripts are not compatible with Reactis, so the user should use the normal TargetLink activation procedure with the dSPACE Installation Manager.

2.5.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.


1
MATLAB is a registered trademark of The MathWorks.