LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event structure does not allow for loop to stop after writing data

Hi all, 

 

I am writing some new data aqusition software for our lab.  In short, the entire stacked sequence acquisition code is in a for loop which allows for as many sequences as I would like to run (esentially automated scanning for n scans).  We have a running joke in our lab, so I built a small event structure (currently sitting outside the for loop) to display a funny quote in a pop up box when a boolean (this boolean is a large vertical toggle) is clicked on screen.  There is no loop around the event structure and it currently sits outside the main for loop.  For some reason, it will not allow the code to finish and stop LabView; the code is desinged to stop LabView after it is done taking data.  Additionally, after a single click of the toggle, the entire code is rendered useless and I have to kill it the hard way woth the abort button.  I have tried to place this event structure in various places - in the stacked sequenc of the data aq, in the for loop, external and nothing seems to work.  Probably something I am missing.

 

My code is included here.  Any suggestions are helpful.  Thanks!

Download All
0 Kudos
Message 1 of 4
(3,215 Views)

The Event Structure will sit there and wait until an event is fired.  It must handle an event before it is complete.  It is that simple.  You could use a Timeout or a User Event.  But really, it would be best to just leave the jokes out of this.

 

BTW, I often make dialog boxes with nothing but an Event Structure.  Events that it usually has is Ok:Value Changed and Cancel:Value Changed.  Until one of those two events is fired, my dialog box stays open.  No loop necessary.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 4
(3,210 Views)

Thanks for the reply Tim.  I only decided to include the jokes because it's an old lab tradition.  On the old data aq system (which used a LeCroy o-scope and a custom QuikBasic code connected via GPIB) jokes would appear at random times throughout the day at the top of the o-scope screen.  I could not figure out how to do that in LV (if you have any suggestion about making strings appear at random times without having to click a button I am open to suggestions) so I decided that an event structure would be easier.   

 

I would have thought that if I put the event structure in a while loop (let's say), that I could run the data aq and event structures independently since there is no data being passed between them.  Please correct me if I am wrong - I'll take it as a leaning moment.  Thanks!

0 Kudos
Message 3 of 4
(3,205 Views)

Just add an event for the stop button to that event structure. This way it can complete even if no joke is triggered.

(The loop actually stops. It is just the event structure that prevents the VI from completing)

 

You cannot be serious in the way you programmed these "jokes" (ha ha) using a seperate express VI for each possible joke. Since there is no while loop around the event structure, you can never get more than one joke per session (but maybe that's enough!). Make it scalable and simply read a text file with one line per joke, then randomly pick one of them when called. Just generate a random index (ranged according to the number of lines/jokes) and index into the array of lines. Now it is scalable and you can change the jokes even once the program is a standalone executable by just changing the text file. No need even for a case structure. (If you want a fixed set of jokes, just use a string array diagram cosstant).

0 Kudos
Message 4 of 4
(3,195 Views)