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.
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subsystems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!