Main Content

getCallbackDataForSignal

Get callback data for a signal in real-time instrument object

Since R2020b

Description

example

[time,data] = getCallbackDataForSignal(instrument_object,event_data,blockPath,portIndex,Name,Value) gets callback data from the target computer for a signal by using the block path and the port index.

example

[time,data] = getCallbackDataForSignal(instrument_object,event_data,signalName) gets callback data from the target computer for a signal by using the signal name. The eventData for the callback shares all the new data available from the target computer since the last time the callback was executed.

Examples

collapse all

Get callback data for a signal by using the block path and port index of the signal in the real-time application file. Because the getCallbackDataForSignal function takes event data as an input argument, call this function from inside an slrealtime.instrument callback function.

mldatxfile = 'slrt_ex_tank.mldatx';
hInst = slrealtime.Instrument(mldatxfile);
connectCallback(hInst,@my_callback);
addSignal(hInst,'slrt_ex_tank/ControlValue',1);
% . . . inside the my_callback (an slrealtime.instrument callback), 
% . . . you can call getCallbackDataForSignal
[cv_time,cv_data] = getCallbackDataForSignal(hInst,hEvnt,'slrt_ex_tank/ControlValue',1);

Get callback data for a signal by using the signal name of the signal in the real-time application file. Because the getCallbackDataForSignal function takes event data as an input argument, call this function from inside an slrealtime.instrument callback function.

mldatxfile = 'slrt_ex_tank.mldatx';
hInst = slrealtime.Instrument(mldatxfile);
connectCallback(hInst,@my_callback);
addSignal(hInst,'ControlValue');
% . . . inside the my_callback (an slrealtime.instrument callback), 
% . . . you can call getCallbackDataForSignal
[cv_time,cv_data] = getCallbackDataForSignal(hInst,hEvnt,'ControlValue');

Input Arguments

collapse all

To create the instrument object, use the Instrument function.

Example: hInst

The eventData object identifies the event that triggers callback operation.

Example: hEvnt

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

Example: slrt_ex_tank/ControlValue

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

Example: 1

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

Example: ControlValueOut

Output Arguments

collapse all

The time value is the current time returned from the target computer.

The data value is the current signal data returned from the target computer.

Version History

Introduced in R2020b