Simulink.ProtectedModel.CallbackInfo class

Package: Simulink.ProtectedModel
Superclasses:

Protected model information for use in callbacks

Description

A Simulink.ProtectedModel.CallbackInfo object contains information about a protected model that you can use in the code executed for a callback. The object provides:

  • Model name.

  • List of models and submodels in the protected model container.

  • Callback event.

  • Callback functionality.

  • Code interface.

  • Current target. This information is available only for code generation callbacks.

Construction

example

cbinfobj = Simulink.ProtectedModel.getCallbackInfo(modelName,event,functionality) creates a Simulink.ProtectedModel.CallbackInfo object.

Properties

expand all

Code interface that the protected model generates.

Callback trigger event. Value is one of the following:

  • 'PreAccess': Callback code executed before simulation, build, or read-only viewing.

  • 'Build': Callback code executed before build. Valid only for 'CODEGEN' functionality.

Protected model functionality that the event applies to. Value is one of the following:

  • 'CODEGEN': Code generation.

  • 'SIM': Simulation.

  • 'VIEW': Read-only Web view.

  • 'AUTO': If the event is 'PreAccess', the callback executes for each functionality. If the event is 'Build', the callback executes only for 'CODEGEN' functionality.

If the value of functionality is blank, the default behavior is 'AUTO'.

Protected model name, specified as a character vector.

Names of all models and submodels in the protected model container, specified as a cell array of character vectors.

Current target identifier for the protected model, specified as a character vector. This property is available only for code generation callbacks.

Methods

getBuildInfoForModelGet build information object for specified model

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.

Examples

Use Protected Model Information in Simulation Callback

Create a protected model callback that uses information from the Simulink.ProtectedModel.Callback object.

First, on the MATLAB® path, create a callback script , pm_callback.m, containing:

s1 = 'Simulating protected model: ';
cbinfobj = Simulink.ProtectedModel.getCallbackInfo(...
'sldemo_mdlref_counter','PreAccess','SIM');
disp([s1 cbinfobj.ModelName])

When you create a protected model with a simulation callback, use the script.

pmCallback = Simulink.ProtectedModel.Callback('PreAccess'...
,'SIM', 'pm_callback.m')
Simulink.ModelReference.protect('sldemo_mdlref_counter',...
'Callbacks',{pmCallback})

Simulate the protected model. For each instance of the protected model reference in the top model, the output from the callback is listed.

sim('sldemo_mdlref_basic')
Simulating protected model: sldemo_mdlref_counter
Simulating protected model: sldemo_mdlref_counter
Simulating protected model: sldemo_mdlref_counter
Introduced in R2016a