Filter löschen
Filter löschen

How to dynamically change the Mask dialog box in Simulink

6 Ansichten (letzte 30 Tage)
Sylvain
Sylvain am 30 Jul. 2021
Kommentiert: Sylvain am 4 Aug. 2021
I have created a dynamic mask, which change if the block parameter "Command" is equal to Reset. The Command is set when I click apply, then it hides the Channel and Channel Electrical Parameters inputs, see below
I would like to improve my mask and make it more dynamic, without the need to click on Apply.
I put the piece of code that is in my Mask Editor belwo. Can anyone advise on how to get access directly to the selected Command?
disp('AD5665r')
mask = Simulink.Mask.get(gcb);
switch get_param(gcb,'Command') % I suppose this is where I need to change the code
case {'Write_To_Input_Register_n' ,'Write_To_Input_Register_n_And_Update_all' ,'Write_To_And_Update_DAC_Channel_n'}
[control,handle]=mask.getDialogControl("ChannelA_param_container");
control.Visible='on';
mask.getParameter("Channel").Visible = 'on';
port_label('input', 1, 'VoltageSetpoint')
case 'Reset'
[control,handle]=mask.getDialogControl("ChannelA_param_container");
control.Visible='off';
mask.getParameter("Channel").Visible = 'off';
port_label('input', 1, 'ResetTrigger')
end
port_label('output', 1, 'i2c status')

Akzeptierte Antwort

Mark McBroom
Mark McBroom am 1 Aug. 2021
I am assuming the code you provided is from the "Initialization" tab? You could try putting the same code in the "callback" for the Command parameter on the Mask Editor -> Parameter and Dialog pane.
  1 Kommentar
Sylvain
Sylvain am 4 Aug. 2021
No, it is from the Icon and Ports. the initialization tab contains the following code, which modify blocks under the mask. Though using the same piece of code (minus the function port_label() ) works very well.
Many thanks
Sylvain

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Author Block Masks finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by