Package: Simulink.ProtectedModel
Superclasses:
Protected model information for use in callbacks
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.
cbinfobj = Simulink.ProtectedModel.getCallbackInfo(modelName,event,functionality)
creates
a Simulink.ProtectedModel.CallbackInfo
object.
getBuildInfoForModel | Get build information object for specified model |
Handle. To learn how handle classes affect copy operations, see Copying Objects.
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