Knowledge Base

Welcome to OPAL-RT’s Knowledge Base

OPAL-RT offers a repository of support information for optimal use of its technology.

Please note that OPAL-RT knowledge base is not fully optimized for mobile platforms.

For optimal experience, use a desktop computer.

Reference Number: AA-01862 // Views: 45 // Created: 2020-03-11 17:06:23 // Last Updated: 2020-03-16 14:10:33
HowTo
How to create a RT-LAB package and run it on a Linux target


In this article we will see how to create, from an RT-LAB project , a package that could be exported to a Linux target. This package could then for example, be loaded, and ran directly on the simulator without having RT-LAB open. For that we will execute a script present on the package that will be launched through an SSH command. This script could then be modified to realize other commands.

Requirement:

  • RT-LAB: Version later than 2019.3.1 ( in order to have Python 2.7 installed on the target )
  • A host Windows PC with RT-LAB installed

Procedure:

1- Create a project, and compile it on the desired target


2- After the compilation is done, you will need to create a package for this project that will then be exported to the target. The command line to create a package is the following:

 RtlabApi.CreatePackage(absoluteFilePathName, targetPlatform)


absoluteFilePathName: The package name is an absolute path name to specify the name AND the path where the package will be created. The compressed package will have the name of the package path name with .zip added at the end.

/!\ Note : absoluteFilePathName must be different from the actual project path directory


targetPlatform : Indicate for which platform the package will be created. It should be RtlabApi.REDHAWK_TARGET.

/!\ Note : Models have to be assigned to the right target, the same as the desired platform. To assign a model to a target, you can use RTLAB or RtlabApi (An example below show how).

If you have never used Python with RT-LAB, we suggest that you first have a look at this tutorial video: https://www.opal-rt.com/opal_tutorial/video-tutorial-1-test-automation-using-the-python-api/

Here an example of a script that will create a package:

____

import sys

import RtlabApi as r

project = "C:/Users/vithuranvilvarajah/OPAL-RT/RT-LABv2019.3_Workspace/Example_project/Example_project.llp"


## Open the project

r.OpenProject(project)

print "The model has been selected"


## Creation of the package

r.CreatePackage(r'C:\Users\vithuranvilvarajah\OPAL-RT\RT-LABv2019.3_Workspace\Example_project\test', r.REDHAWK_TARGET)

print "Package has been created"

_____

In this example, the package will be created in "C:\Users\vithuranvilvarajah\OPAL-RT\RT-LABv2019.3_Workspace\Example_project\" and will have the name "test.zip"


3- Connect to the target using MobaXterm for example: https://www.opal-rt.com/support-knowledge-base/?article=AA-01044


4- Create a folder with the same name as the package and drag and drop it there. In this example the package is copied here: /usr/test/



5- Unzip the zip using the following command:

[root@RTServer ~]# cd /usr/test/

[root@RTServer test]# unzip test.zip

By refreshing the folder, you should have unzip your file now


6- An example script is provided under the folder "script" : execute.py

This script is an example which run the current instance during 200 seconds. Steps followed are:

  • Open the current instance
  • Load models one by one
  • Execute all the models
  • Wait 200 seconds
  • Reset the models

Python version 2.7 minimum is required to run the script. You can launch by using the following command:

[root@RTServer ~]# cd /usr/test/

[root@RTServer test]# /usr/bin/python2.7 scripts/execute.py

You should have an output similar to this one:


This script can then be modified in order to do other command.