Main Content


Get Simulink.ProtectedModel.CallbackInfo object for use by callbacks


cbinfobj = Simulink.ProtectedModel.getCallbackInfo(modelName,event,functionality) returns a Simulink.ProtectedModel.CallbackInfo object that provides information for protected model callbacks. The object contains information about the protected model, including:

  • 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.


Use Protected Model Information in Code Generation Callback

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

s1 = 'Code interface is: ';
cbinfobj = Simulink.ProtectedModel.getCallbackInfo(...
disp([s1 cbinfobj.CodeInterface]);

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

pmCallback = Simulink.ProtectedModel.Callback('Build',...
'CODEGEN', 'pm_callback.m')
'Mode', 'CodeGeneration','Callbacks',{pmCallback})

Build the protected model. Before the start of the protected model build process, the code interface is displayed.


Input Arguments

collapse all

Protected model name, specified as a string or character vector.

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'.

Output Arguments

collapse all

Callback information, specified as a Simulink.ProtectedModel.CallbackInfo object.

Version History

Introduced in R2016a