Custom block libraries in Simulink: pre-compilation action

1 view (last 30 days)
I have created a custom Simulink library (I was able to create libraries and sub-libraries and add them to the simulink library browser).
Problem statement: Let's say we drag and drop 4 blocks, A, B, C, and D from the library. Let us assume, for now, that any block could be connected to any other (i.e., their I/O behaviors are compatible with every other block). However, logically, I would like to ensure while building my Simulink model that the blocks are connected in the correct fashion: Input --> A --> B --> C --> D --> Output. If they are not, I want Simulink to immediately warn me -- right when I make a wrong connection (via a pop-up message/dialog box). I think this would qualify as "pre-compilation" behavior.
Is this possible at all? If yes, could anyone point me in the right direction?
Note: I have gotten Simulink to generate errors (for logical/order mismatch of individual MATLAB function blocks) post-compilation. So I am clearly seeking help for the pre-compilation case.

Answers (1)

Maximilian
Maximilian on 3 Jul 2014
I am not how to make simulink warn you but perhaps you could try writing a short script that will automatically connect the blocks for you in order (assuming their port names remain the same). You would use the add_line command: Add Line You could create a dummy subsystem that you would place in the system with your A,B,C and D blocks and when double clicked it could run the script to automatically connect all the blocks in the proper order. You would do this by making a mask on the subsystem and using the callbacks to run the script.
Hope this helps!

Products

Community Treasure Hunt

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

Start Hunting!