Auto Refresh in app designer.

조회 수: 19 (최근 30일)
Jay Vaidya
Jay Vaidya 2021년 6월 6일
댓글: Adam Danz 2021년 6월 8일
I have a couple of controls in my GUI but it can also happen that I control my system manually (sometimes). So the below image shows the lamps 1 and 2 ON (set and read by GUI after setting) but the 3rd one has turned ON anytime. When I turn the 3rd one ON, I want the GUI to change the lamp color and also the switch direction. I know commands to change the color of the lamp and switch position, but I am not getting how can I introduce this sensing part in my GUI.
In other words, I need a refresh function that can refresh the GUI at an as fast a rate as it can and then change the lamp colors accordingly.
Please let me know your inputs. Thanks a lot, in advance!
  댓글 수: 8
J. Alex Lee
J. Alex Lee 2021년 6월 8일
편집: J. Alex Lee 2021년 6월 8일
in response to built-in classes where the value is not observable, if you are using a matlab release that has the new custom ui component (https://www.mathworks.com/help/matlab/developing-custom-ui-component-classes.html), you can wrap your switches into a custom app where you can "fake" access into the switch value.
in fact, it probably makes sense to create a custom component anyway that bundles a switch with a lamp. a lamp doesn't appear to have a "Value" anyway.
by the way, i still do not understand the situation with the "external script that is not editable"...how exactly is it interacting with your hardware and/or gui?
Adam Danz
Adam Danz 2021년 6월 8일
For the lamp you'd listen to the color property (which is also not observable).
The only scenario I can imagine where this makes sense it's that OP is not the owner of the app nor the external script (I hope it's a function) and cannot make changes to either files and the switch can be changed by progresses not within OP's control.

댓글을 달려면 로그인하십시오.

채택된 답변

J. Alex Lee
J. Alex Lee 2021년 6월 6일
in general for "auto refresh" you can use the timer object to schedule recurrent execution - disclaimer i have only played with this in non-GUI context with intent to eventually incorporate in a appdesigner app, but haven't got that far
but if you mean you have hardware switches that your GUI is supposed to be somehow connected to, and if you flip physical switch 3, you need the GUI switch 3 to know about it, maybe there are other/better mechanisms through the software/hardware interface
  댓글 수: 5
J. Alex Lee
J. Alex Lee 2021년 6월 7일
you could give your other script access to your GUI switch to flip it on whenever it switches the actual switch, or if it is not allowed by appdesigner, you can provide a public method in your app that will do the switching that the second script can invoke
Jay Vaidya
Jay Vaidya 2021년 6월 7일
As I said, I cannot link the two by any means as the other script is not controllable. Also, the valve can be manually turned ON in which case what you are suggesting cannot work.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by