Model Callbacks in Referenced Models
2 次查看(过去 30 天)
显示 更早的评论
I see inconsistent behavior in the execution of model callback functions in model references. Should the model callback functions of referenced models run whenever the same model callback function runs in the top model? If so, in what order? For example, suppose the top model contains two references to the same model and that model contains two references to different models. Which model callbacks run, how many times, and when? How are model callbacks in referenced models handled during the code generation process?
0 个评论
回答(1 个)
Kaustubha Govind
2012-10-22
My guess is that the callbacks are executed in the order that each referenced model is compiled - I would expect this to be the same as the block sorted order, but I'm not absolutely certain. Here is a description of when each model callback is executed. A good exercise might be to dump debugging statements in each callback such as:
fprintf('Executing InitFcn callback for %s', gcs)
2 个评论
Kaustubha Govind
2012-10-23
Paul: Thanks for posting the results of your experiment.
1) makes sense, because no code is generated for the referenced model, so it is executed normally. 2) makes sense too since InitFcn is executed during model compilation, which happens during code-generation. Then, the generated code is executed, and not the model itself, so the StopFcn will not run (since callbacks are not present in generated code). 3) Could this be because both references are to the same model? Simulink only needs to generate code once.
I agree that this should be clearly documented - could you please submit an enhancement request to MathWorks Tech Support, so that the appropriate team is notified.
I don't recall explicitly looking for R2012a documentation - it may have been what showed up in my web search.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Model, Block, and Port Callbacks 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!