Executing callbacks of custom simulink blocks in a subsystem reference

35 vues (au cours des 30 derniers jours)
Alexander Lampe
Alexander Lampe le 17 Avr 2020
Commenté : men8th le 22 Fév 2021
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 commentaires
men8th
men8th le 26 Jan 2021
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 le 7 Fév 2021
Modifié(e) : Fabian Müller le 7 Fév 2021
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.

Connectez-vous pour commenter.

Réponses (1)

Mark McBroom
Mark McBroom le 20 Fév 2021
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 commentaire
men8th
men8th le 22 Fév 2021
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Subsystems dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by