Package: Simulink.ProtectedModel
Superclasses:
Represents callback code that executes in response to protected model events
For a protected model functionality, the Simulink.ProtectedModel.Callback
object
specifies code to execute in response to an event. The callback code
can be a character vector of MATLAB® commands or a MATLAB script.
The object includes:
The code to execute for the callback.
The event that triggers the callback.
The protected model functionality that the event applies to.
The option to override the protected model build.
When you create a protected model, to specify callbacks, call
the Simulink.ModelReference.protect function
with the 'Callbacks'
option. The value of this
option is a cell array of Simulink.ProtectedModel.Callback
objects.
creates
a callback object for a specific protected model functionality and
event. The pmCallback
= Simulink.ProtectedModel.Callback(event
,functionality
,callbackText
)callbackText
specifies MATLAB commands
to execute for the callback.
creates
a callback object for a specific protected model functionality and
event. The pmCallback
= Simulink.ProtectedModel.Callback(event
,functionality
,callbackFile
)callbackFile
specifies a MATLAB script
to execute for the callback. The script must be on the MATLAB path.
setOverrideBuild | Specify option to override protected model build |
Handle. To learn how handle classes affect copy operations, see Copying Objects.
Create a callback object with a character vector of MATLAB commands for the callback code. Specify the object when you create a protected model.
pmCallback = Simulink.ProtectedModel.Callback('PreAccess',... 'SIM','disp(''Hello world!'')') Simulink.ModelReference.protect('sldemo_mdlref_counter',... 'Callbacks',{pmCallback}) sim('sldemo_mdlref_basic')
For each instance of the protected model reference in the top model, the output is listed.
Hello world! Hello world! Hello world!
Create a callback object with a MATLAB script for the callback code. Specify the object when you create a protected model.
pmCallback = Simulink.ProtectedModel.Callback('Build',... 'CODEGEN','pm_callback.m') Simulink.ModelReference.protect('sldemo_mdlref_counter',... 'Mode', 'CodeGeneration','Callbacks',{pmCallback}) rtwbuild('sldemo_mdlref_basic')
Before the protected model build process begins, code in pm_callback.m
executes.