Listening to events when Matlab GUI application is idle

7 views (last 30 days)
Hi, I would appreciate a piece of advice. I have a GUI application. I am able to listen to events (answers from a geodetic instrument) when there is a process running in my application (e.g. measurement). But how to listen to events when the application is idle (no matlab activity currently active, no function running, no button pressed). Is there a function (to where write definition of listening to events) which is active when aplication window rises (program starts) and active until it is closed? Thanks for help Filip
  2 Comments
per isakson
per isakson on 18 Aug 2013
Edited: per isakson on 18 Aug 2013
Why do you want that? My first answer is no, but then I am not sure what exactly you mean by "idle" and "no function running".
Filip Dvoracek
Filip Dvoracek on 18 Aug 2013
Why do I need that? Because I want to catch events! E.g. when an instrument throws an error or announcement, I want to know about it :-). By "idle" I mean that there is no Matlab function in process. E.g. application has just started and waits for user to press a button.

Sign in to comment.

Accepted Answer

per isakson
per isakson on 18 Aug 2013
Edited: per isakson on 18 Aug 2013
An alternative might be to
  • create a handle class, which creates the listener in the constructor
In startup.m
  • create an instance
  • put a copy of the handle somewhere, e.g. setappdata(0,'my_name',h)
  10 Comments
Filip Dvoracek
Filip Dvoracek on 19 Aug 2013
Ok, my idea was the same - try to store ltsync in handles structure. I cant test it because I dont have the instrument right now. I will let you know later this week... Thank you.
Filip Dvoracek
Filip Dvoracek on 21 Aug 2013
I confirm that if a litener is saved into the handles structure, it is active even "between functions" when no process is currently being executed in my application. Thank you for your help. The solution is easy but without you I am not sure I I would try that.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 18 Aug 2013
The closest you could get would be to have your startup.m fire a timer function that periodically checked.
  3 Comments
Filip Dvoracek
Filip Dvoracek on 18 Aug 2013
The application is not waiting (waitfor command was not used). With waitfor command I know it is possible to listen to events (some function is running). But without it (no function is running)? I do not understand your advice.
Walter Roberson
Walter Roberson on 18 Aug 2013
waitfor() is not used for all event types. timers and DAQ go through a different process.
waitfor() is not even used for the main GUI: it is really only used if you are executing something and need something else to complete before you continue. waitfor() is not needed for controls or events that are to be accessible when nothing else is running: the command line process will take notice of those kind of events.

Sign in to comment.

Categories

Find more on Graphics Objects in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!