How can I trigger activity in a top level gui from a timer in a lower level object?

2 ビュー (過去 30 日間)
Sean
Sean 2012 年 5 月 3 日
I have an object that is polling status from a piece of equipment at regular intervals. It is doing this by starting a timer at object instantiation. I would like to trigger higher level application behavior off of certain types of status changes and I'm not sure how to get a trigger signal from the lower level timer object to the high level main gui object. Any ideas would be appreciated. :)
Pseudo-Detail:
1. GUI -> CommObj -> TimerObj -> Callback (embedded in CommObj.ConstructorMethod)
2. Callback toggles a bit property in CommObj instance.
3. ???
4. GUI detects change in CommObj property and does stuff! (a.k.a. PROFIT!!!)
Thanks in Advance :)

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 5 月 3 日
Unfortunately it is not really possible to prod an active routine to do something. You can change the value of a variable that the routine has access to, and you can have the routine test the value of that variable.
In some situations it makes sense to use add_listener(), and possibly notify() as well.
In some situations it make sense to use waitfor() to wait for a condition.
  2 件のコメント
Sean
Sean 2012 年 5 月 3 日
Hello Walter,
This may be a stupid question, but I've never used listeners before... If I have an object being used by a standard/normal function (in an .m file), can a callback in the function be setup as a listener for events inside the object? (e.g. if event happens in objectA, disable and grey out controlX on the GUI)
Thanks
Walter Roberson
Walter Roberson 2012 年 5 月 3 日
To cross-check, are you referring to "object" in the object-oriented programming sense? And in particular, to classes defined using the newer classdef mechanism?
If so then unfortunately that is a topic I have not had an opportunity to investigate.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConstruct and Work with Object Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by