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!