How to call a script BEFORE opening a Simulink subsystem?
2 次查看(过去 30 天)
显示 更早的评论
When the user double clicks a Simulink subsystem, I would like to call a MATLAB .m script (to check if the block is a disabled library link, and issue a warning if the associated model file is not "locked" in the version control system), and then open the subsystem normally.
- By using the OpenFcn callback, I can only call the script INSTEAD of opening the subsystem.
- When I write an OpenFcn callback that calls the script and then calls open_system to open the subsystem, I get an error message which says I must not call OpenFcn recursively.
I'm using MATLAB version 2012b.
Any ideas would be appreciated!
0 个评论
回答(1 个)
Sebastian Castro
2014-10-2
Kurt,
I'd like to step back a little, if that's okay.
1. There is a display option on Simulink models that visual cues (badges) based on library links status. To access it, you can select Display > Library Links from the Simulink menu.
2. Alternatively, you could always run a model-wide check to test for disabled library links. You could write your own by searching through using the find_system function, or you can use built-in Model Advisor (Analysis > Model Advisor > Model Advisor) and run some of these checks.
Best, Sebastian
2 个评论
Sebastian Castro
2014-10-2
Well, how about this?
You can create a mask for your Subsystem block (right-click, select Mask > Create Mask ).
In the Initialization tab, you can add the following code:
Then, when your links are disabled you'll actually get a warning pop-up dialog! However, this won't be immediately when you open the block -- this will happen when the model updates before simulation, or when you hit Simulation > Update Diagram .
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subsystems 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!