05-09-2017 01:10 PM
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!
Solved! Go to Solution.
05-09-2017 01:16 PM
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
05-09-2017 01:32 PM
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. 🙂
05-09-2017 02:24 PM
@_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! 🙂
05-09-2017 02:29 PM
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.
05-10-2017 04:53 AM
Hi natalie,
To avoid burried event structure you can replace it with case structure and dequeue element function