addSignal

Adds signal for streaming to make it available in callback

Description

example

addSignal(instrument_object,blockPath,portIndex,Name,Value) adds a signal by using block path and port index for streaming to make the signal available in a callback. Use this approach when the signal is not used in a scalar displace or line plot.

example

addSignal(instrument_object,signalName,Name,Value) adds a signal by using signal name for streaming to make the signal available in a callback. Use this approach when the signal is not used in a scalar displace or line plot.

example

addSignal(instrument_object,signalList,Name,Value) adds signals by using signal list SimulinkRealTime.SignalList function for streaming to make the signals in the list available in a callback. Use this approach when the signals are not used in a scalar displace or line plot.

Examples

collapse all

Add a signal for streaming to the real-time instrumentation object by using the block path and port index.

mldatxfile = 'my_xpctank.mldatx';
hInst  = SimulinkRealTime.prototype.Instrumentation(mldatxfile);
% for technical preview in R2019b, function name includes '.prototype'
addSignal(hInst,'my_xpctank/ControlValue',1);

Add a signal for streaming to the real-time instrumentation object by using the signal name.

% added signal name to model before building mldatxfile
mldatxfile = 'my_xpctank.mldatx';
hInst  = SimulinkRealTime.prototype.Instrumentation(mldatxfile);
% for technical preview in R2019b, function name includes '.prototype'
addSignal(hInst,'ControlValueOut');

Add signals for streaming to the real-time instrumentation object by using a signal list object.

% added signals to signal list object after building mldatxfile
mldatxfile = 'my_xpctank.mldatx';
hInst  = SimulinkRealTime.prototype.Instrumentation(mldatxfile);
% for technical preview in R2019b, function name includes '.prototype'
mySignals = SimulinkRealTime.SignalList;
mySignals.add('my_xpctank/ControlValue',1);
mySignals.add('ControlValueOut');
addSignal(hInst,mySignals);

This example adds signals for streaming to the real-time instrumentation object by using a signal list object. The addSignal function also sets a property value for the signals.

% added signals to signal list object after building mldatxfile
mldatxfile = 'my_xpctank.mldatx';
hInst  = SimulinkRealTime.prototype.Instrumentation(mldatxfile);
% for technical preview in R2019b, function name includes '.prototype'
addSignal(hInst,mySignals,'HistoryFlag',1);

Input Arguments

collapse all

To create the instrumentation object, use the SimulinkRealTime.prototype.Instrumentation function.

Example: hInst

For the selected block, gcb returns the full block path name.

Example: xpctank/ControlValue

For the selected signal, the output port index and signal name are visible in the signal hierarchy viewer or model data editor.

Example: 1

For the selected signal, the port index and signal name are visible in the signal hierarchy viewer or model data editor.

Example: ControlValueOut

To create a signal list object for a model or real-time application, use the SimulinkRealTime.SignalList function.

Example: mySignals

The Name,Value pair argument selects the signal properties that are added to the instrumentation object instrument_object and sets values for the properties.

Example: 'HistoryFlag',1

Introduced in R2019b