Main Content

Application

Represent application files on development computer

Description

An application object represents application files on the development computer. You can create application objects for real-time applications that you build from models.

An application object provides access to methods and properties that let you work with the application blocks and signals.

Creation

app_object = slrealtime.Application(application_name) creates an object that you can use to manipulate real-time application files on the development computer. You can create the object only after the real-time application has been built.

The slrealtime.Application function accepts these arguments:

  • application_name — Name of real-time application (character vector or string scalar). For example, 'slrt_ex_osc_inport'.

    This argument is the file name without the .mldatx file extension of the MLDATX file that the build produces on the development computer.

  • app_object — Represent real-time application files on the development computer.

    This argument provides access to methods that manipulate the real-time application files.

Create an application object for real-time application slrt_ex_osc_inport.

app_object = slrealtime.Application('slrt_ex_osc_inport');

Example: Extract ASAP2 File

Example: Update Root-Level Inport Data

Example: Get and Set Application Options

Example: Get Application Signals and Parameters

Properties

expand all

This property is read-only.

Name of real-time application created when you built the application.

This property is read-only.

Name of the Simulink model from which you build the real-time application.

You can assign arbitrary vector data to the UserData field. You can access this data from only the development computer.

Example: {'This string', 10}

This property is read-only.

Use the Options property to get and set real-time application options. For an example, see Get and Set Application Options. The options are:

  • fileLogMaxRuns selects the number of simulation runs that are stored for the real-time application when file logging is enabled.

  • loglevel selects the log message level for the target computer system log. The available levels are error, warning, info, debug, and trace.

  • pollingThreshold selects the sample rate below which the RTOS thread scheduler switches polling mode, instead of interrupt-driven mode, for clocking the real-time application. Polling mode can be useful for reducing sample time jitter. But, enabling this option causes the real-time application to consume a CPU core completely to clock and execute the base rate.

  • stoptime selects the stop time for the real-time application.

Object Functions

addParamSetAdd a parameter set to a real-time application
extractASAP2Extract generated A2L file from real-time application file
getInformationGet real-time application information
getParametersGet real-time application parameters
getSignalsGet real-time application signals
updateRootLevelInportDataReplace external input data in real-time application with input data
updateStartupParameterSetUpdate the startup parameter set for an application

Examples

collapse all

Retrieve the ASAP2 file from real-time application.

Create an application object for the real-time application.

app_obj =  slrealtime.Application("myModel.mldatx");

Retrieve the ASAP2 file from the real-time application.

extractASAP2(app_obj);

Change waveform data from square wave to sine wave.

Change inport waveform data from a square wave to sine wave.

waveform = sinewave;

Create an application object.

app_object = slrealtime.Application('slrt_ex_osc_inport');

Update the inport data.

updateRootLevelInportData(app_object)

Download the updated inport data to the default target computer.

tg = slrealtime('TargetPC1');
load(tg, 'slrt_ex_osc_inport');

You can get and set real-time application options by using the application Options property.

Create an application object.

my_app = slrealtime.Application('slrt_ex_osc_inport');

View application options by getting the application Options property values.

my_app.Options.get
ans = 

  struct with fields:

      fileLogMaxRuns: 1
            loglevel: "info"
    pollingThreshold: 1.0000e-04
            stoptime: Inf

Change the application stop time value option.

my_app.Options.set("stoptime",20);

Save application options to a MATLAB variable. Apply options from the variable to the real-time application by using the load function.

my_options = my_app.Options.get;
save("my_options.mat", "my_options");
load("my_options.mat", "my_options");
my_app.Options.set(my_options);

You can get real-time application signals and parameters by using the getParameters and getSignals functions.

Create an application object.

my_app = slrealtime.Application('slrt_ex_param_tuning')
my_app = 

  Application with properties:

    ApplicationName: 'slrt_ex_param_tuning'
          ModelName: 'slrt_ex_param_tuning'
           UserData: []
            Options: [1×1 slrealtime.internal.ApplicationOptions]

Get the application Signals values as structures in an array.

my_sigs = getSignals(my_app)
my_sigs = 

  1×9 struct array with fields:

    BlockPath
    PortIndex
    SignalLabel

View application signals as array elements.

my_sigs(1).BlockPath
ans =

    'slrt_ex_param_tuning/Gain'

Get the application Parameters values as structures in an array.

my_params = getParameters(my_app)
my_params = 

  1×7 struct array with fields:

    BlockPath
    BlockParameterName

View application parameters as array elements.

my_params(1).BlockParameterName
ans =

    'Gain'
Introduced in R2020b