Main Content

getsignal

Read a signal value from a real-time application

Since R2021a

Description

value = getsignal(target_object, blockPath, portIndex) returns the value of the signal selected by the portIndex in block block_path from the real-time application that is loaded on the Speedgoat® target computer. This function also supports multi-instance referenced models.

example

Examples

collapse all

This example builds a real-time application from model slrt_ex_osc, loads the application on the target computer, and gets the value of the signal from block 'Signal Generator' port 1.

tg = slrealtime;
mdlSTF = getSTFName(tg);
mdlName = 'slrt_ex_osc';
openExample(mdlName);
set_param(mdlName,"SystemTargetFile",mdlSTF);
slbuild(mdlName);
load(tg,mdlName);
getsignal(tg,'slrt_ex_osc/Signal Generator',1)
ans =

     0

This example builds a real-time application from model slrt_ex_mds_and_tasks, loads the application on the target computer, and gets the value of the signal from block 'unity math' port 1 in referenced model slrt_ex_mds_subsystem1.

tg = slrealtime;
mdlSTF = getSTFName(tg);
mdlName = 'slrt_ex_mds_and_tasks';
mdlName1 = 'slrt_ex_mds_subsystem1';
mdlName2 = 'slrt_ex_mds_subsystem2';
openExample(mdlName);
open_system(mdlName);
open_system(mdlName1);
open_system(mdlName2);
set_param(mdlName,"SystemTargetFile",mdlSTF);
set_param(mdlName1,"SystemTargetFile",mdlSTF);
set_param(mdlName2,"SystemTargetFile",mdlSTF);
slbuild(mdlName);
load(tg,mdlName);
getsignal(tg, {'slrt_ex_mds_and_tasks/Model1', 'slrt_ex_mds_subsystem1/unity math'} ,1)
ans =

  Columns 1 through 24

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  . . . Columns 25 through 576 omitted . . .

  Columns 577 through 600

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

Input Arguments

collapse all

Provides access to methods that manipulate the target computer properties.

Example: tg

The block_path values can a character vector or string.

Example: 'slrt_ex_osc/Signal Generator'

For the selected signal, the output port index is visible in the signal hierarchy available in Simulink Real-Time explorer or in the Model Data Editor.

Example: 1

Output Arguments

collapse all

The value is the value of the signal in the real-time application. If the signal is a bus, a struct is returned. Correct data type, complexity, and dimensions are returned.

Version History

Introduced in R2021a