C/C++ Platform

Given is a C implementation of the lights controller: Since the implementation of the lights controller provided contains a scaling of the signal variables, scaling for the fix-point implementation must be provided in TPT to keep the physical modeling in TPT while communicating with the scaled software in C.

The scaling for the light intensity equals 2-9 which is equal to 1/512 with no bias. The implemented data type for the light_intensity is uint16.

Select View|Declaration Editor or press Ctrl+D to open the Declaration Editor. Click Edit mappings in the editor to open the Mapping Editor. In the Mapping Editor, click Create a new Mapping.

Create a new mapping

A mapping consists of a name and several flavors. Rename the mapping to EXE_Mapping and select the mapping flavor Scaling.

Select the mapping flavor "Scaling"

Close the Mapping Editor and select the EXE_Mapping from the Mapping drop-down list in the Declaration Editor.

Select the mapping

The example has a Scaling mapping flavor of an inverse slope of 512. In the Declaration Editor, select the channel light_intensity. In the Scaling tab, set Scaling_mode to ON and Slope-Inv to 512.

Set the Scaling values

Select Execution|Platform Configuration to open the Platform Configuration dialog. Click Create a platform configuration and select C/C++ Platform.

If the C code uses variables or functions that are not supported by the C/C++ Platform, or if you want to customize the code more freely, select and configure the EXE Platform, see Advanced Tutorial - EXE Platform.

C/C++ platform configuration dialog

Source settings

Compiler

Choose a compiler from the drop-down list.

In the Preferences, you can configure the general compiler settings. Select Options|Preferences|C Compiler.

Select Compile as 64 bit if you want to compile your code as 64-bit instead of 32-bit.

Project root folder

Select the path, for example to the SUT-C-Code with Scaling folder you have copied from the examples and pasted next to your TPT project.

Source

Click Create a new C Source to select a C file.

Analyze sources

Allows you to import functions and variables from the C code file to TPT. Click the button to see a list of all variables and functions available in the C code file.

Mapping

Select EXE-Mapping for the scaling information.

Click Generate & Compile to generate a test frame that contains the test automation code.