LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the preferred way to stop multiple loops?

Apart from error 1122, you need to handle the error 1 as well. This will be thrown if the queue is released while you are not waiting to dequeue an element (processing the last value). Thn you call the Dequeue element with the invalid refnum -> err 1.

 

Felix 

0 Kudos
Message 21 of 51
(2,105 Views)

Ahh, good call Felix, that's not one I've run into before.  Are there other ways for deQ to throw error 1 without the queue being released?

-Barrett
CLD
0 Kudos
Message 22 of 51
(2,078 Views)

Error 1 is invalid input parameter, so there are several other functions that throw it. I remember Generate User Event, Wait on Notification and Obtain Semaphore. But I also had it from other functions (not assiciated with passing data/sync). But these errors mostly occure during the developement process (because you did forget to wire something). A common scenario where it also occures if when you place the consumer in a subVI and forget to make the queue connector required and as such forget to wire the queue there.

 

Felix

0 Kudos
Message 23 of 51
(2,071 Views)

blawson wrote:

Nickerbocker wrote:


How interesting.  That does work.  Sorry, I was mistaken.  However, it doesn't appear to work with Text Rings, only Enums.  So let me update my opinion: Not all properties in a type def control will autoupdate to controls that reference the type def.


 

more to the point: changing a type defined control updates the values of the instances' data type.  So the strings of an enum will update, the strings of a ring control's item names will not.  (This is from the first paragraph of the help file.).  Some things will not: labels, default values, data ranges, etc.  My point is that what does and doesn't update is clearly defined and not hard to research for a particular control type (search for "data type" and the control name).

 

 

back on topic, though: I've stopped a queued (consumer) loop before by wrapping the dequeue element function in a subVI that handled the 1122 error case to select an enum for the main state machine.  Works well, doesn't put extra error cases out on the main VI, etc.


Sorry, I'm a newb who hasn't read every page of the help file.  The first paragraph of the help file says something different than that.  Would you please point me to the exact location where this information is?

0 Kudos
Message 24 of 51
(2,065 Views)

When I type "Data Type enumerator" I get 71 pages:

 

screen.png

 

It may be obvious to you, but I'm obviously not as smart as you.

 

0 Kudos
Message 25 of 51
(2,054 Views)

hey, whoa, you're reading me wrong - I wasn't trying to come off as condescending, I wanted to point out that it's documented.  My apologies for incomplete directions: look in the help index under "type definitions", which takes you to the paragraph im talking about in the "Creating controls" page.

 

There's also a decent reference in the index under "front panel, controls"

 

typdefs help.png

-Barrett
CLD
0 Kudos
Message 26 of 51
(2,031 Views)

In my application, I have 2 parallel loops, One for Serial communication and the other for actual functioning of my device. The second loop is a State machine. Now, each state has multiple parallel loops within itself.

 

My requirement: No matter what state my state machine is in, I need to end loops inside a state + end state machine loop and my SErial comm loop.

 

Here is what I did and I am sure I am going to get heat on the method I chose, but it works. Just want to understand why this isn't a good idea 😉

 

I use property (Value) node. If there is an error or intentional need for stopping, all errors/stop flag a halt boolean. I have property value nodes of this Halt boolen in every loop to stop all parallel loops.

 

I would like to implement queues or notifiers but, with the complexity of having parallal loops inside a state machine state, I am not sure how to undo this.

 

THanks!

I may not be perfect, but I'm all I got!
0 Kudos
Message 27 of 51
(1,522 Views)

VeeJay,

 

Your program architecture sounds like it is due for an overhaul.  Multiple parallel loops in each state?

 

The Value property node has several disadvantages.  1. It is the slowest of the common ways of doing this.  2. It forces all loops using it to run in the UI thread.  This may eliminate much of the advantage of parallelism.  If something blocks the UI thread, the whole program may block.

 

If you do not want to use queues or notifiers (good ways), try a functional global.  A dedicated Stop functional global can work quite well.  You can even give it a small icon so it does not occupy much BD sapce.

 

Lynn

0 Kudos
Message 28 of 51
(1,513 Views)

@johnsold wrote:

VeeJay,

 

Your program architecture sounds like it is due for an overhaul.  Multiple parallel loops in each state?

 

The Value property node has several disadvantages.  1. It is the slowest of the common ways of doing this.  2. It forces all loops using it to run in the UI thread.  This may eliminate much of the advantage of parallelism.  If something blocks the UI thread, the whole program may block.

 

If you do not want to use queues or notifiers (good ways), try a functional global.  A dedicated Stop functional global can work quite well.  You can even give it a small icon so it does not occupy much BD sapce.

 

Lynn


Nice idea and great argument.-  What's with that Select primative and FALSE constant in the read case?  Are you trying to make the RG thread?Smiley Very Happy (AND is cheaper) Smiley Wink 


"Should be" isn't "Is" -Jay
0 Kudos
Message 29 of 51
(1,507 Views)

Jeff,

 

Thanks.  I wrote that VI a long time ago.  They probably had not invented AND yet.  I was working at a university so cheaper was always a priority.

 

Some of the stuff I wrote even before that would qualify for the RG Hall of Fame (or Shame).  Fortunately, most of it does not exist any longer.

 

Lynn

0 Kudos
Message 30 of 51
(1,502 Views)