How to call a script BEFORE opening a Simulink subsystem?
Mostrar comentarios más antiguos
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!
Respuestas (1)
Sebastian Castro
el 2 de Oct. de 2014
1 voto
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 comentarios
Kurt Fischle
el 2 de Oct. de 2014
Sebastian Castro
el 2 de Oct. de 2014
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 .
Categorías
Más información sobre Subsystems en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!