09-30-2008 02:25 PM - edited 09-30-2008 02:30 PM
Dear all,
I want to write a Tab program, when I change Tab page, the while loop in this page will run, other pages will stop running. It works fine. However, when I add an event to Tab page1, I can only change Tab page once, after that, my program doesn't response to Mouse click to change page, I can't change Tab page or press stop button any more. I feel Event is so tricky. Anyone can help me?
I attached two LabView 8.5 program, one is without Event, working good, the other is with Event, out of control.
Thank you very much!
09-30-2008 11:56 PM
Don't put an Event structure inside a case structure. Even though the event structure isn't in the line of execution, it still queues up events for it.
It is best to keep the event structure in its own parallel while loop and have it pass messages to another loop in a producer/consumer architecture.
10-01-2008 12:07 AM - edited 10-01-2008 12:09 AM
It is a common misconception that a tab control needs to be paired with a case structure. This is not true. Often, it is not even needed to connect the tab terminal to anything, you can use the tab to just logically group controls on the front panel. It does NOT need any associated code!
In the diagram, have a single event structure inside a single while loop, with events handling all possible controls from all possible tabs. That's all you need!!! 🙂
Your use of inner while loops is a very poor choice, because it traps execution and causes dataflow congestion. Also all you inner loops spin at near infinite rate, burning all CPU cycles in the process while not doing anything useful at all.
10-18-2008 02:08 AM
Hi, I have a tab control. My intention is to m ake the user do what is in the first tab, and then move on to the second tab and so on. It has to be sequential.
Eg:
Tab1 : Enter personal Details
Tab2 : Acquire some sensor data
Tab3 : Analyse data.
I want to hide Tab2 and Tab3 and show only Tab 1 initially. Once the user enters the personal details and click save button, I want to show Tab2 to the user and so on.
How do I go about this??
10-18-2008 04:41 PM
OK, it seems you want to create a "wizard". Create your tab control, but hide the tabs. Place "next" and "previous" buttons on most tabs and a "finish" on the last tab. (or even better, place them outside the tab control or "float" them over the tab control). Keep the tab value in a shift register and increment/decrement accodingly to switch between cases.
All you need is a simple while loop containing an event structure. See how far you get. 🙂
(sorry, I currently canot attach an example because of forum problems).
10-19-2008 10:58 PM
Thanks for the details. It works fine now for the tab control. I have another issue though. Once the user enter the personal details, he goes to the other page to acquire some sensor data. So my structure for the page 2 has the outer most while loop (for the program to continuosly run) and the event structure (to select pages). Then I have inner event structure which allows the user to select between acquiring sensor data and other stuff.
since I am acquiring sensor data continuosly I have the DAQmx Read inside a inner while loop. So when I press ACQUIRE BUTTON it goes inside the ACQUIRE event structure and starts acquiring sensor data continuously. The acquiring is to stop when a STOP button is pressed, which is linked to the stop of the inner while loop. But once I press acquire the sensor data is acquired continuouly and I have no way of clicking the STOP button. Its like it hanged.
10-20-2008 02:23 AM
OK, it seems you have some serious dataflow problem. I always cringe when I hear "inner event structure".
You should probably use a queued state machine for the user interface and run the DAQ in a parallel loop. Please show us your code so we can help you improve it.
10-20-2008 04:22 AM
Ok I am very confused now. Anyway attached is the example of what I want to do. You can see when you run the program and press the "Acquire" button everything will be frozen, but the acquiring part will keep on acquiring. I believe the issue is once the while loop executes even if I press the corresponsing STOP button it wont stop. It's like an infinity loop.
Thanks!
10-20-2008 04:42 AM
Hi Chathuri,
There is no major issue here, you just have to disable the "Lock front panel untill the event case for this event completes" for the acquire event.
This should slove your confusion. Let me know if not sloved.
Regards
Akshath
10-20-2008 04:59 AM
Oh Cool.
It worked and it was east. Thanks alot 🙂