04-17-2015 03:18 PM
This snippet is from a "working" program that has been running happily away for some time now. It is a data acquisition program based on a simple producer/consumer structure. I added a consumer loop to do a bit of error checking before the data acquisition and now the program hangs whenever the false case in the new loop happens - even if the false case is empty ! i.e. I've removed all fcns from inside.
False Case
Ideally the case structure should be connected to the > comparator, but I separated them just to test exactly what was going on.
The true case runs just fine.i.e. change the boolean constant attached to the case structure to T. The program happily behaves the way it always has cycling and taking data.
I've tried adding a queue operation to a NOP case, but that didn't help. I know the code in the false case executes OK because the Stop button goes back to false and the simple error handler doesn't report anything. I also know that the code never returns to the producer i.e. none of the events that should fire it do. The program is well and truly hung (Labview itself seems to still run fine) and only the abort button can stop it
It would be helpful if I could find a way for the program to tell what it is doing. I've dosed it liberally with breakpoints to try and find out where it is going and gotten nothing. I've attached the full code in case someone wants to have a go at this. You would need to dummy out all the DAQmx stuff. I've tried deleting all of the case structure and rebuilding it to no effect. I'm open to suggestions
04-17-2015 04:22 PM
Have you turned on execution highlighting to watch it hang? (My bet is on the dequeue operation...)
Mike...
04-17-2015 05:14 PM
04-17-2015 11:22 PM
I'd be worried about the 2nd event structure you have in the acquire case. That along with all your event cases locking the front panel until they complete.
You could very well be having LabVIEW locking up because of that.
Read Caveats and Recommendations when Using Events in LabVIEW
04-18-2015 07:40 AM
04-18-2015 08:30 AM
04-20-2015 07:57 AM
I'm with Mike here, that queue is not really doing anything for you except add complication. A good state machine is all you need here.
04-20-2015 10:44 AM
Following the advice above I have rewritten the whole thing as a state machine - no queues anywhere (only took an hour or so). The new main vi is attached. Unfortunately, it still locks up in excactly the same spot. At least now with execution highlighting on, one can see that it is just spinning its wheels in the event loop that traps front panel events (under the state case "Idle"). It would appear that somehow the front panel events have become disconnected from this event structure. Again, if I change things so that the True case under the Stop button click event (in Idle) goes to Start Acq instead of Pre Acq, the program runs normally. The thing that is bizarre is that the Pre-Acq case runs without errors. I tried taking out the one button dialog (the only piece of UI in that loop) and it made no difference. Suggestions?
04-20-2015 12:03 PM
Firstly, remove the inner while loop around he event astructure in the idle case. It has no purpose. Then you have a second event structure inside the "acquire" state. That's just asking for trouble.
Secondy, all your events are set to lock the front panel until the event completes, so if an event occurs while the code is in a different state, the event structure cannot execute and will lock up the front panel forever. Your code is completely constipated.
04-20-2015 12:17 PM
Learn to use Type Definitions! I'm not certain this is the problem, but it might be:
See the little red triangle? That indicates that the data types don't match. The enums are not all identical. LabVIEW will use the numeric value, not the text value, to determine which case to go to next. Your Actions enumeration should be a type definition, and every Action constant should be linked back to that it, so that when you update the list of enumeration values in the type definition it is reflected everywhere that enumeration is used.