GUIDE - a perpetual loop affected by GUI - advice sought - threading model confusing
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have what I guess is not so uncommon a model. A perpetually repeating loop does processing & display. I want to affect the processing & display from options in a GUI. Communication by checking the GUI values or persistent flags, &c. Also, starting the loop working on the initial settings, without user intervention would be good. GUIDE is convenient, but fitting to the model has several options. I seek advice on which is best.
Entities: GUIDE gives me
a myGui main function named after the file I create,
a myGui_OpeningFcn which runs before the GUI get displayed,
& a myGui_OutputFcn which runs before returning to the command line
.
So, if I want to start a function which has an infinite loop, reading GUI settings & changing each loop if requested, where is it best called from?
Options
Run events from the GUI, eg press the "Go" button. Sort of using an event dispatch thread permanently? Seems to leave the command line thread doing nothing?
Auto-starting could be arranged by a timer: so same question, where is the timer placed? Then the main loop runs in some timer thread?
If the main function initialises, then calls the open function & the output function, then returns to the command line, then making this call the infinite loop seems the most obvious model.
There seems no way to get it called last, after returning to the commend line.
Using uiwait & uiresume to control the loop seems an obvious option. uiwait in the main loop function, waiting for a gui "go" --> uiresume.
For the GUI I have created with GUIDE, a little investigation with persistent variables & looking at the call stack suggests that the main function myGui() is not only called more than once, but reentrantly. An unexpected complication to putting anything in there.
myGui_OpeningFcn is called before the GUI gets displayed, so not so obvious to put a main processing loop in there.
Accepting the statement that Matlab is generally single-threaded & if I find no GUIDE-produced function that I can call an infinite loop from, I can start a timer to put a call the loop function on some queue. Does it matter where the timer is set up?
Is there a more elegant way to get the loop function called?
So, any advice on where is the best place from which to call the infinite loop gratefully accepted.
Abandon using GUIDE?
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!