Executing callbacks of custom simulink blocks in a subsystem reference

조회 수: 37 (최근 30일)
Alexander Lampe
Alexander Lampe 2020년 4월 17일
댓글: men8th 2021년 2월 22일
I have a custom Simulink block with a mask that executes callback on mask paramater changes and changes the underlying subsystem content (e.g. rename a signal)
When I want to use this block in a subsystem reference and I get the error:
  • Error in 'XXX: Failed to evaluate mask initialization commands.
  • Caused by:
Block 'XXX' is inside a Subsystem Reference block 'XXX'. Incorrect to modify contents of a Subsystem Reference block using callback code.
How can I fix it?
Thanks in advance!
  댓글 수: 4
men8th
men8th 2021년 1월 26일
I have the same problem. I have a Subsystem Reference block, inside that is a Variant Subsystem set to label mode control. Inside the Variant Subsystem I have two model variants.
The Subsystem Reference has a mask, with the intent that the mask can be used to control the variant selection. The mask for the Subsystem Reference model has the following initialisation commands
choice = get_param(gcb,'nTubePass');
vssBlk = [gcb,'/VariantHeatExchanger'];
switch choice
case '1'
set_param(vssBlk, 'LabelModeActiveChoice', 'One pass');
case '2'
set_param(vssBlk, 'LabelModeActiveChoice', 'Two pass');
otherwise
error('Unrecognised number of passes')
end
This works fine if previewed from inside the Subsystem Reference model. When the Subsystem Reference model is integrated into a larger model and I attempt to use the mask, I get the error as above:
  • Error in 'HeatExchanger_Harness/SwFwHeatExchanger': Failed to evaluate mask initialisation commands.
  • Caused by:
  • Block 'HeatExchanger_Harness/SwFwHeatExchanger' is inside a Subsystem Reference block. Incorrect to modify contents of a Subsystem Reference using callback code.
So... presumably using a Subsystem Reference like this is not supported?
Fabian Müller
Fabian Müller 2021년 2월 7일
편집: Fabian Müller 2021년 2월 7일
Hi! I have also the same problem. I want to promote units from input / output ports to the mask. The initialization code is:
set_param([gcb '/In1'], 'Unit', S_unit);
set_param([gcb '/Out1'], 'Unit', q_unit);
It is not possible to initialize the subsystem reference. With the same error message:
Block 'XXX' is inside a Subsystem Reference block 'XXX'. Incorrect to modify contents of a Subsystem Reference block using callback code.
However, it works when defining the subsystem directly in a library without subsystem reference.
Is this intended? It would be nice if that also works with a subsystem reference.

댓글을 달려면 로그인하십시오.

답변 (1개)

Mark McBroom
Mark McBroom 2021년 2월 20일
I believe you need to put a mask on the subsystem reference and use this mask to pass values for each instance down into your custom simulink block mask that exists inside the subsystem reference.
This link contains instructions for creating a mask on the subsystem reference.
  댓글 수: 1
men8th
men8th 2021년 2월 22일
I came to the conclusion, after posting my original comment above, that it should not be possible to change the contents of a Subsystem Reference block using mask initialisation code. If the point of a Subsystem Reference is that each block is an identical copy of the saved subsystem file, using the mask initialisation to reconfigure the internals of the Subsystem Reference blocks will cause some of the Subsystem Reference blocks to be different to the others. Once this is done, which one is the true copy? After having that though, I gave up.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Subsystems에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by