Executing callbacks of custom simulink blocks in a subsystem reference
41 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
men8th
el 26 de En. de 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
el 7 de Feb. de 2021
Editada: Fabian Müller
el 7 de Feb. de 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.
Respuestas (1)
Mark McBroom
el 20 de Feb. de 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 comentario
men8th
el 22 de Feb. de 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.
Ver también
Categorías
Más información sobre Subsystems en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!