08-12-2019 05:40 AM
@crossrulz wrote:
@Yamaeda wrote:
So, AE with Init, Get queue ref, Queue data, Close
Init AE at start of program
Use Queue data whenever you want to update something
A loop which uses 'Get queue ref' to actually update the indicator
Close ref as you exit program.
I have learned over the years that this is not quite a good setup. You should only have 1 loop that is a consumer of the queue. So I do not even have the Get Queue Ref. The consumer calls the Init and gets the queue reference as part of that. It can then dequeue for the lifetime of the process. The consumer should then also be the one calling the Close. So what this points to is a library for the Consumer. The AE should be a private member of this library and you make public message VIs that call the Send case of the AE. This way, the reference is protected and the messages that can be sent to the consumer are explicitly defined.
You're right, the last time i used it i didn't have a "get ref" but just reused it from Init. I didn't use a library but it can clean some stuff up.
/Y
08-12-2019 06:48 AM
@rajiv85 wrote:
What I tried: I put the controls inside events: value change triggers update of global variables. These global variables I then use anywhere. However from within a subvi if I need to write to the global variable, how to change the value on the Front panel: guess I will need to update a local variable. Is there a better way?
Going back to reread the thread...
What I like to do is have 1 loop completely dedicated to the GUI. This loop is just a While Loop and an Event Structure. Use loops to control the state of your motor, DAQ, etc. The GUI loop can send messages to the other loops to start, stop, etc via Queues, Notifiers, or User Events. If a loop wants to send updates to the GUI, they use a User Event to send that update to the GUI loop, where the Event Structure will handle it. You can do whatever you wish with that update (update an indicator, update a progress bar, ignore it, etc). This will decouple your GUI from the logic of the other parts of your application, increasing reusability.
08-12-2019 06:50 AM
Thank you very much!!! This was very helpful!