LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer Consumer Loop Hanging

Solved!
Go to solution

Hi everyone,

 

I am starting what I hoped would be a simple program.  I have a producer consumer loop with three events; Run, Load and Stop.  Within the Run event, I use the timeout of an event structure to time how long to wait between measurements.  I use to always use a wait/delay, but I would like to be able to interrupt the wait if I push stop.  

 

If I first push run in my code, it goes to the run event and if I push the load button it goes to that event, and if I push run again, it goes back to the run event.  Of course, when I push stop, it stops the program.

 

But if I push Load first, before any other button, it goes to the load event but gets stuck there.  I really can't see why and I was hoping someone could help me see what's going on.

 

Thank you!

0 Kudos
Message 1 of 6
(3,498 Views)
Solution
Accepted by topic author _natalie_

You have an event structure buried inside of a case structure.  And you have the events set to lock the front panel until called.  A bad combination.

 

If you trigger an event, the front panel locks, but if the event structure is not in the path of execution and will never get there because you need front panel interaction to change your case structure.  You've locked yourself out cold.

 

It is a bad idea to have multiple event structures in a VI unless you really know what you are doing.  And a buried event structure is really asking for trouble.

 

Read Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2015 Help

0 Kudos
Message 2 of 6
(3,496 Views)

Thanks for your help!  I have made it now so that the front panel does not lock, and my code is working how I want it to (for the moment).  I think I understand why this is happening, and I will certainly read more from the link you sent me.  🙂

0 Kudos
Message 3 of 6
(3,482 Views)

@_natalie_ wrote:

Thanks for your help!  I have made it now so that the front panel does not lock, and my code is working how I want it to (for the moment).  I think I understand why this is happening, and I will certainly read more from the link you sent me.  🙂


Well, unlocking the front panel is treating the symptom and not the cause.  The cause is poor LabVIEW coding practices.  But it seems you are trying to remedy that by learning, so that's a GOOD thing!  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 6
(3,451 Views)

Yes, I agree; I am just fixing the symptom.  I wanted to try using the timeout of the event structure to wait between a measurement instead of using a wait/delay because you can't interrupt that.  I didn't realize until I tried it that the buried event structure would be such poor coding.

0 Kudos
Message 5 of 6
(3,447 Views)

Hi natalie,

To avoid burried event structure you can replace it with case structure and dequeue element function

0 Kudos
Message 6 of 6
(3,392 Views)