Prevent execution of a block if link to library is not resolved

2 views (last 30 days)
Arthur Roué
Arthur Roué on 21 Dec 2020
Commented: Arthur Roué on 31 Dec 2020
I'm trying to protect some custom Simscape blocks (*.ssc) to run if the link to my library is not resolved.
This behaviour can be found with blocks of Simscape Power System library, but I can't find where this protection is implemented. It doesn't seem to be in block callback because you can remove them after breaking the link and the block won't run.
Does anyone have an idea or a lead to implement such a protection properly (forbid to run a block if its library link is not resolved) ?

Answers (1)

Aghamarsh Varanasi
Aghamarsh Varanasi on 29 Dec 2020
To protect the custom Simscape block, you can use the ‘Lock Links’ feature under the Library Tab. This doesnot allow the user to break the link of the block from the Parent Library
The documentation to Lock Links to Blocks in a Library can be found here.
  1 Comment
Arthur Roué
Arthur Roué on 31 Dec 2020
Thanks. Indeed, if my library model got locked links and the library source file is not writable for end users, then they will not be able to modify the library.
It only requires protecting the library source file from writing.
However, the behavior I tried to reproduce was this one:
1. Break the link for a block in a lib (i.e a Simscape electrical source)
2. Run a simulation and an error occurs
Here, the link can be broken but the simulation will not run. With locked link, we cannot break the link in the first place. Is this a special behavior for Simscape blocks or is it possible to throw this kind of error if a link is broken?

Sign in to comment.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!