Unexpected behavior using mask popup controls with externally defined enum and get_param

4 次查看(过去 30 天)
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.

回答(1 个)

Benjamin Thompson
Benjamin Thompson 2024-1-20
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.

类别

Help CenterFile Exchange 中查找有关 Subsystems 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by