07-25-2008 04:17 AM
07-25-2008 06:50 AM
If you want to avoid changing the basic structure of your program, you can simply create a "clean up and exit" user event which will do everything you want. Then, fire that event when you want to exit (e.g. tray icon, Panel Close event, the stop button, timeout, etc.).
If you want your program to be more flexible, you can try running the DAQ code in a separate loop and use a synchronization mechanism to pass the data, like you suggested. Then, ending the loop will also close all resources. You should be able to find some examples if you search for "queued state machines" and "producer consumer".
07-25-2008 10:35 AM
If I made a "producer consumer" architecture how can I stop the producer in the middle of his work (for example: "front panel close event" in the consumer event structure)?
And how can I synchronize both the start and the stop of the DAQ loop with notifiers?? Am I obliged to use queues?
I think I'm making confusion about the usage of the notifiers...
07-26-2008 02:04 PM
I didn't look at all the details of your setup, but you can try something like this:
Stopping the loops can be done using a global variable or a notifer.
P.S. I mentioned globals twice - you should note that they are dangerous. You can usually use them in cases like this where you have a single producer, but even then you should be aware of the potential for race conditions and often there are better solutions.
07-28-2008 03:02 AM
I know action engines, untill now I made one to manage a "timer" whereever I want ("get timer" gets the millisecond elapsed from the "start timer" action, by means of time difference).
But I don't want to acquire data *always*. I would like to do the following:
1) Start the DAQ (in my case by means of "ModBus function 3 (read register)") with a button (start).
2) "stop&clean" : this event fires when
A) I click stop button
B) Timeout expires (timeout is a control on UI, if not zero, after that time the event is fired)
C) panel close event occurs, or exit from the "User_event_systrayIcon_Exit" event occurs
the stop&clean should close communication and resources and save the data collected to a file.
What is the best architecture to use ??
Another problem: In the event structure I have events from the front panel controls. Then I added the "user events" connector, and wired the user event generated by the VI of the systray (see "LabviewTray Icon.vi" in the forum). Now I can see some "user_events" together with the rest (only the user events programmed in that vi). Is it possibile to add OTHER custom user events???? How?
Thanks
07-28-2008 06:20 AM
Again, in my opinion the better architecture is to let the DAQ VI (or loop) run all the time and put the most recent value into a notifier. Then, you can decide whether you want to get that data or not.
Stopping the DAQ loop will also run the code which closes the VISA resource.
The event registration refnum is typed, meaning it holds the exact types of all the events in it (you can see this if you open the context help window and hover over it). This means that you can only configure the basic list of events in one place. The ActiveX object does this in a subVI, so you can go into that subVI and add more events to the list, but this will break the indicator in the VI and you will need to recreate it.
Slyfer wrote:
Is it possibile to add OTHER custom user events???? How?