Unexpected behavior using mask popup controls with externally defined enum and get_param
4 views (last 30 days)
Show older comments
I have a subsystem model with a mask parameter (Parameter1) with a popup control. The popup control references an externally defined enum (E) that is defined in a linked data dictionary to have two values (Foo and Bar). In the callback code for Parameter1, I have this code:
function Parameter1_callback()
disp(get_param(gcb, "value@Parameter1");
end
When I press "Preview Dialog" in the mask editor, I immediately see Foo printed in the matlab console. So far, everything is as I expect. Now, if I click on the Parameter1 popup and select E.Bar instead, what I expect to happen is to see Bar printed in the matlab console, but instead I see Foo again while the mask UI is showing E.Bar.
To further illustrate the problem, I have a second mask parameter (Parameter2) with a popup control that is also using the E definition. The only difference is that the callback is slightly different (note the removal of value@).
function Parameter2_callback()
disp(get_param(gcb, "Parameter2");
end
When I press "Preview Dialog" in the mask editor, I immediately see E.Foo printed in the matlab console (as a string, since it's not being evaluated). If I click on the Parameter2 popup and select E.Bar instead, I see E.Bar printed in the matlab console. The value printed in the console always matches what the mask UI is showing.
0 Comments
Answers (1)
Benjamin Thompson
on 20 Jan 2024
It may be a race condition between the callback getting evaluated and other Simulink diagnostics getting generated related to an empty subsystem. Especially since the parameter 2 display works. If the subsystem has some blocks in it, both parameter 1 and 2 seem to work as expected.
0 Comments
See Also
Categories
Find more on Subsystems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!