Custom block libraries in Simulink: pre-compilation action

1 回表示 (過去 30 日間)
Shruthi Kubatur
Shruthi Kubatur 2014 年 6 月 27 日
回答済み: Maximilian 2014 年 7 月 3 日
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.

回答 (1 件)

Maximilian
Maximilian 2014 年 7 月 3 日
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!

カテゴリ

Help Center および File ExchangeSubsystems についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by