How To Include One Instance Of A Block In A Model

2 views (last 30 days)
I am working on a SIMULINK model that is used with a vendor provided toolchain. The top level of the model has a target definition block (provided by the vendor) that specifies the hardware the model will run on. There are other blocks in the vendor toolchain that are used to interface with the hardware (send CAN messages, read from GPIO, etc) and those blocks also require the target defintion block exist in the model in order for the right settings to show up.
This is fine when I have the top level model open, but I also make use of a lot of subsystem references, so its very common for a subsystem reference to contain a "Read CAN Message" block but no target definition block. This is painful for comparing code between changes because if I open the subsystem reference by itself I don't see any of the mask settings.
I tried just putting a target definition block in every subsystem reference but when I try to compile the model it throws an error because the model isn't allowed to have more than one target definition block. I am talking with the vendor to see if they can make any improvements to their toolchain to solve this issue, but I also wanted to ask if there was any way to handle this in Simulink myself.
The only idea I have is to make a block that acts as a wrapper to the target definition block. The wrapper block would have a callback function that gets called before compiling the model. The callback would find the target definition block at the top level of the model and comment out all of the other wrapper blocks to prevent errors. Is this a good way to do this or is there some SIMULINK functionality I am not aware of that would do this for me?
Thanks!

Answers (1)

Fangjun Jiang
Fangjun Jiang on 9 Jan 2024
I don't see a solution other than, either
  1. Don't use subsystem references. Use customized library instead. Or,
  2. Ask your vendor to support subsystem references.

Categories

Find more on Event Functions in Help Center and File Exchange

Tags

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!