Generate Code for HMI Application Using SCADE Display — Lesson 2

Aim: Compile the display source code for a static screen without any animation logic and execute it on Raspberry Pi.

 


2. A. On the Host

Note: You can skip steps 1-11 if you use the files from Lesson 2 under the folder CodeForPi.

Navigate to SCADE Examples in the install location using File Browser and make a copy of the FlightControlDisplay example.

  1. For example, the folder is located here:  C:\Program Files\ANSYS Inc\v231\SCADE\examples\FlightControl and copied to the desktop of this system.
  2. Open SCADE Display to open this newly saved PFD example. Save the example as PFD2.
  3. Cut the Structures from the LightContainer and paste them in the symbology_layer.

Figure 2a: Snapshot of the changes to be made to the Structure tab in the SCADE Display model

  1. Delete the LightContainer.

Figure 2b: Snapshot of the Structure tab after LightContainer is deleted

  1. Delete JV_Alti_Alarm from the Dictionary.

Figure 2c: Snapshot of the Dictionary to delete JV_Alti_Alarm

  1. Right-click on PFD2 under Specifications and click on Properties.

Figure 2d: Snapshot of the Properties selection

  1. Set the resolution to the resolution observed on the Raspberry Pi.

Figure 2e: Selection of the screen resolution under the Specification tab

  1. Generate code for the display model.
  2. Navigate to the generated code using File Browser.
  3. Copy the .c and .h generated files from PFD2_Code folder to a new folder called code.

Figure 2f: Snapshot of the file structure of the files copied into the new code folder

  1. Copy kcg_assign.h file from the install folder location into the code folder.
  2. Copy the code folder from the host system to the PiPFD folder on the Raspberry Pi using the following command from the Windows Command Prompt. Ensure you are in the PFD2 folder in Windows CMD while executing this command to be able to find the code folder.
    • scp -r code\ pi@<PI_IP_ADDRESS>:/home/pi/Desktop/OGLX/SDYOGLX67/examples/PiPFD

 


2. B. On the Raspberry Pi

Note: You can skip steps 1-3 if you use the updated specific.c and main.c from the src folder under Lesson 2 in CodeForPi.

  1. Ensure that the PiPFD folder has a code and src folder with the necessary files.

Figure 2g: Snapshot of the src folder on the Raspberry Pi

  1. Navigate to the src folder and open the specific.c file. Comment the following lines and save the file. This is because our model does not have any static sequences; hence, there isn’t a aol_static_sequences.h file generated:
      • #include “aol_static_sequences.h”                                        - line 31
      • aol_static_sequences();                                                  - line 156
  1. Open the main.c file and make the following changes. These changes are to address that the PFD display model has bitmap fonts and textures. If the model uses stroke fonts, then the file could stay as it is:
    • Comment the following lines under void oglx_init().
      • static sgl_parameters lParameters;                                       - line 45
      • ul_screen_width = getW();                                                - line 51
      • ul_screen_height = getH();                                               - line 52
      • pb_texture_buffer = SGL_NULL;                                            - line 53
      • ul_texture_max_width = 0;                                                - line 54
      • ul_texture_max_height = 0;                                               - line 55
      • p_texture_attrib = SGL_NULL;                                             - line 56
      • ul_number_of_textures = 0;                                               - line 57
      • p_gradient_attrib = SGL_NULL;                                            - line 58
      • ul_number_of_gradients = 0UL;                                            - line 59
    • Uncomment the following lines under void oglx_init().
      • static SGLbyte glob_tub_texture_buffer
        [4 * SGL_TEXTURE_MAX_WIDTH * SGL_TEXTURE_MAX_HEIGHT];                    - line 67
      • sgl_texture_attrib *glob_texture_attrib 
        = malloc(sizeof(sgl_texture_attrib) * getTextureTableSize());            - line 68
      • static sgl_parameters lParameters;                                       - line 69
      • ul_screen_width = getW();                                                - line 71
      • ul_screen_height = getH();                                               - line 72
      • pb_texture_buffer = glob_tub_texture_buffer;                             - line 73
      • ul_texture_max_width = SGL_TEXTURE_MAX_WIDTH;                            - line 74
      • ul_texture_max_height = SGL_TEXTURE_MAX_HEIGHT;                          - line 75
      • p_texture_attrib = glob_texture_attrib;                                  - line 76
      • ul_number_of_textures = getTextureTableSize();                           - line 77
    • Move the following line after the uncommented section above.
      • sglInit(&glob_s_context, &lParameters);                                  - line 61

The following image show how the code should look:

Figure 2h: Snapshot of the changes to be made in the main.c file

  1. In the src folder, execute the following command in the Raspberry Pi command terminal. This command links all the .c files along with all the necessary headers and links the necessary libraries:
    • gcc -o out main.c specific.c ../code/*.c ../../../extras/utils/src/*.c 
      ../../../lib/libOGLX.a -I../code/ -I../src/ -I../../../include/ 
      -I../../../extras/opengl/ -I../../../extras/utils/include 
      -L/usr/lib -lX11 -lGL -lglut -lm
  1. After the executable is generated, run the executable using the following command:
    • ./out
  1. You will observe the executable as follows with a no-moving display:

Figure 2i: Executable generated using GCC without animation