LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop an event structure in a while loop

> Does this attempt solve that problem?

 

No, it does not Smiley Very Happy. Your processing case is still going to hold up your loop. Use the goddam consumer/producer architecture suggested by Ben64! It takes some neuron stretching the first few times you try to use this concept, but eventually, you will use it all over the place. You can use queues instead of registered events if you prefer, but the idea is the same: have a UI loop that ONLY monitors user actions and whenever there is a user request, pass it to a parallel loop that will process the request. It is not going to speed up the processing, but it will leave your UI responsive.

0 Kudos
Message 11 of 26
(3,550 Views)

As I said in the last post, downconvert the example ben64 made to labview 8.5 or give me pictures!

No matter how many times I re-read the ni tips for producer/consumer structures I do not understand how I am supposed to wire in my selector case structure (the one that is in the event structure) to send its data to the main code in the consumer loop. 

 

So please please please, downconvert ben64's example to 8.5 or give me a picture instead of just telling me "use the producer/consumer pattern."  It doesn't have too be crazy detailed, or even a full .vi like ben64s, just take a screenshot of the first attachment I made, a screenshot of the producer/consumer events template, and just point out where they go.

0 Kudos
Message 12 of 26
(3,542 Views)

Here is an example. This example has multiple parallel tasks but the basics of a producer/consumer application are here.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 14 of 26
(3,535 Views)

Here is another example created the way described by Ben64 (that is, using the Producer/Consumer template). I have just added a refinement to the queue structure, which allows you to pass data to your consumer loop.

Message 15 of 26
(3,520 Views)

Oops. I should have tested my VI first... Anyhow, here is a slight mod which shows how to use the variant item of the queue to pass data from the producer to the consumer (if needed).

Message 16 of 26
(3,512 Views)

Thats for all the help, I am getting a better handle on the producer/consumer design, but I am a bit confused about something.

 

There are 2 distinct advantages that you guys made it seem like the producer/consumer design would have to the event/case structure I posted earlier, but I don't seem to get either of them with this new design.

 

I posted my new block diagram below in case I am doing something wrong, but from previous comments in this thread I was under the impression that with this new architecture 1) multiple clicks of the "que event" button WON'T que up multiple test runs while a particular test is running (i.e. if the user gets impatient and clicks the que event button 5 times while waiting for it to start, I don't want it to que up 5 runs) and 2) that the stop button would break and abort the code in the consumer loop if pressed (I still have to wait for the code in the consumer loop to run to completion if I click the stop button).

 

Maybe this structure was not intended to do these things and I just misread the previous posts, or maybe I just programmed it wrong, but it seemed like those were the two benifits of this design and for some reason I don't seem to be getting either of them.

0 Kudos
Message 17 of 26
(3,483 Views)

Immediately after putting up that last post I noticed a terminal labled "max que size" on the obtain que .vi that is auto-set to unlimited, so with regards to #1 I can probably just wire a constant value of 1 to that terminal and solve that problem.

 

A stop button that breaks the code would still be nice though...

0 Kudos
Message 18 of 26
(3,482 Views)

I would not limit your queue to a single element but rather put some state iformation in the producer (loop with the event structure) to restrict posting to the queue. This allows you to pass other commands such as Stop or Abort to the consumer. If you need to be more response to a Stop/Abort event than you need to break up your processing into more of a state machine that you can inject the Stop/Abort into the stream. There will be some things that you will need to wait for but using more of a state achine approach you can abort midstream during a test.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 19 of 26
(3,471 Views)

That or you could generate a notification from the Event Case where you detect a stop action (and of course have your processing VI monitor this notifier).

Personally, when things may take a long time and I expect the user to change his mind, I pop up a progress bar from within the "Computing VI" with a "Cancel" and "Abort" button.

"Cancel", well cancels the whole thing, While "Abort" returns the results achieved so far (if that aplies).

0 Kudos
Message 20 of 26
(3,455 Views)