Lamp VS Guage - App Designer
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi,
I am trying to build an app to instrumentate my Simulink Real time application. The version is 2020a.
On the startup function I call the instrumentation starter, which goes like this.
function setupInstrumentation(app)
app.hInst = SimulinkRealTime.prototype.Instrumentation(app.mdl);
app.hInst.connectScalar(app.ReadyLamp,[app.mdl '/Initialization_Check'],14); % Link a boolean signal to a lamp on the app
app.StartStopButton.Icon = app.startIcon;
app.StartStopButton.Text = 'Start';
end
The ConnectScalar line then produces the following error:
Error using SimulinkRealTime.prototype.Scalar
Unknown property name for hScalar
Error in SimulinkRealTime.prototype.Instrumentation/connectScalar
I tried to find the parameter and aparently it is the output of the script. So I tried with a Guage instead of a Lamp, and this code works fine.
app.hInst.connectScalar(app.Gauge,[app.mdl '/Initialization_Check'],14); % Link the same signal to a Guage
So, we can instrumentate a Scalar to a Guage, but not to a lamp? Is there a work around to link the signal to the lamp?
Thank you in advance.
EDIT:
I think I got an update about how this does not work.
The Gauge display has a entry for the value to display, while the Lamp only has a parameter for the color of the lamp. What I think it is required is a way to change the color of the lamp depending on the value of the signal. this link seems to have a connection between the Simulink signal and the Visible parameter of the lamps, but I don't understand what it is happening and no example is shown, just code. Is it also possible to link the signal to the color parameter of the lamp?
This code can change the visibility parameter of the lamp, (signal==1 -> 'On', signal~=1-> 'Off')
app.hInst.connectScalar(app.Lamp,'Signal_location',1, 'PropertyName', 'Visible', 'Callback', @(t,d)string(slprivate('onoff',d==1)));
Looking for an answer to change the color.
댓글 수: 12
Timothy
2022년 9월 27일
Thanks for posting this, I was having a hard time finding this information.
It's a bit ridiculous that we have to know to use a hidden function to connect the uilamp object with the instrument data stream. Shouldn't there at least be some default behavior where it is able to connect the scalar data stream to the uilamp and these additional settings are only necessary to deviate from the default - rather than the code just failing.
Joep van Baren
2024년 1월 25일
I completely agree with Timothy's statement. Thanks for the explanation, but it is very illogical.
채택된 답변
추가 답변 (1개)
Pablo Romero
2023년 10월 24일
편집: Pablo Romero
2023년 10월 24일
Please check out the documentation page below for a built-in example.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Target Computer Setup에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!