How can I find the top level of the entire system from within an active model reference?

My MEX functions look upwards in the subsystem heirarchy to get some information from top-level configuration blocks, which specify system wide parameters for my system. Normally I would find these with find_system(bdroot(gcb), ...).
But supposing I want to use model referencing. Is there any way a block in a referenced model can, during initialization of a system referencing it, find the top level of the referencing system? bdroot(gcb) will only get me to the top of the referenced model - not the active referencing model.

 採用された回答

Titus Edelhofer
Titus Edelhofer 2011 年 5 月 13 日
Hi Mark,
the only way I could think of:
myModelName = get_param(bdroot(gcb), 'Name');
% find all model reference blocks that contain "me"
blocks = find_system('BlockType', 'ModelReference', ...
'ModelName', myModelName);
models = bdroot(blocks);
Does this help?
Titus

その他の回答 (4 件)

Titus Edelhofer
Titus Edelhofer 2011 年 5 月 13 日

0 投票

Hi,
I guess, not directly. And it should not be done anyway: the idea of model referencing is, that the referenced model is self-sufficient, i.e., it can stand alone without the system referencing it. The other way round of course is fine: the model containing the referenced model might very well do something with this model ...
Titus
Mark
Mark 2011 年 5 月 13 日

0 投票

Ok. Put it another way: is there any way I can see from inside a model being initialized whether it is being initialized as a referenced model from inside a higher-level model, and find out what that model is? For the moment I don't care whether this is the correct thing to do ... I may rearchitect my methodology at a later date, for now I'd just like to get something working.
Mark
Mark 2011 年 5 月 13 日

0 投票

That will work for the moment ... thanks for your prompt replies!
Todd
Todd 2020 年 9 月 29 日

0 投票

If your reference model is open in a tab of your top model (R2020a+) then you can try this:
h = gcbp;
sys = bdroot(h.getBlock(1));

カテゴリ

ヘルプ センター および File ExchangeSubsystems についてさらに検索

製品

質問済み:

2011 年 5 月 13 日

回答済み:

2020 年 9 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by