LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the preferred way to stop multiple loops?

Thank you Lynn! It does sound like it needs an overhaul, but that is the nature of my application. I guess there is no getting away from such parallel loops but, I could find a different way of Stopping and also using less of property value node.

 

I also have a parallel loop that records data from other loops, but I still use property node to send data from these loops to record loop. (only because each loop has a different rate). I have read the Producer/consumer architecture but finding it insanely difficult to integrate that in mine where it would be multiple producer one consumer.

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

@VeeJay wrote:

I also have a parallel loop that records data from other loops, but I still use property node to send data from these loops to record loop. (only because each loop has a different rate). I have read the Producer/consumer architecture but finding it insanely difficult to integrate that in mine where it would be multiple producer one consumer.


That is the beauty of queues. It easily supports multiple producers and eliminate the race conditions you will get by using property nodes. You can have 100 tasks posting to the queue. However you can only have one task pulling things off. So each consumer would need its own queue to receive data. You can use other techniques such as notifiers to have a generic means of stopping your tasks. With a notifier you can have multiple tasks listening to the notifier. We use  simple subVI that checks if there has been an update to a notifier. We defined an application wide technique which supports the basic actions such as start, stop or exit. This is a nice approach since it is a standard way for our applications to work and therefore is reusable across our projects. Define the methodology once and reuse it many times.



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 32 of 51
(1,407 Views)

VeeJay,

 

Parallel loops are not bad.  I was only concerned about parallel loops within one case of your state machine.  It has been my experience that using the while loop at the outside of the state machine properly avoids nested loops.  Rather than looping hundreds of times within one state to perform some evaluation or acquisition, do one step, exit from the state, and immediately return to the same state for the next step if the process is not complete.  This allows the state machine to be very responsive to external inputs such as the Stop command.  You may need to pass some data around the loop via shift registers, but this is a small inconvenience compared to the advantages of a clean machine.

 

As Mark indicated, multiple loop Producer/Consumer systems work well.  Before the term Producer/Consumer became common, I had develped a system involving three loops and six queues which worked well for several different programs. 

 

Lynn

Message 33 of 51
(1,396 Views)

Lynn,

 

I have a very simple looking application (my demo application from my NI Week presentation this year) which actually has 11 queues in it. We have developed various messaging, logging and and message routing classes that when created spawn background tasks. Each background task has its own queue. From the top level VI you don't see how many parallel tasks exist but under the hood there are quite a few. Obviously I don't see any problem with multiple tasks. The flip side is you have to have a good design and not abuse the concept.



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
0 Kudos
Message 34 of 51
(1,391 Views)

Mark,

 

I agree.  The planning and design are key.  The number of loops and queues is irrelevant. I think I missed your presentation, but messaging systems like that seem to be very powerful.

 

Lynn

0 Kudos
Message 35 of 51
(1,376 Views)

I didn't see your presentation either. Do you have a link to it? I am building an application that has about fifteen loops. Each has an input and output queue. The technique I use to keep it clean and digestable is the one described by Daklu here on Lava.

=====================
LabVIEW 2012


0 Kudos
Message 36 of 51
(1,374 Views)

I need to get my presentation up somewhere. I have been working with my company to allow me to release the code to the publich. I need to add quite a bit of supplemental information if I can't release the code too. Maybe this is a good project for the Christmas break.

 

You wouldn't know it by looking at it but via our messaging system the four circled VIs will result in updating 2 Boolean indicators, 3 String indicators and 4 files. The highlighted VIs have no knowledge of any of those items. It seems sends messages. Through backgorund tasks (configured in the application initialization) the messages get routed to all registers listeners which then process the message for whatever purpose it needs. We created classes to encapsulate this functionality and now we have very powerful reusable code.

 

Practical LVOOP.PNG



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 37 of 51
(1,368 Views)

THis is such a brilliant conversation. Honestly, guys I really appreciate your help. I have come a long way learning LabVIEW and everything I know is self taught with the help of people like you here. I am doing a design rev on my software, and now that i have time to invest in the whole design again, I am going all in to get to a point where i can say "hey, take this DVD and install it on your system" and then it works.

 

I am also taking the CLAD exam finally (after rescheduling for overr 4 months because of work constraints) and hope it goes well.

 

The main main problem I have is visualizing the code functioning. I know what to do, how to do puts me in a spot for a while. Now, I have a working program (maybe not efficient, but working) but, it has many disadvantages I am sure.If you guys have examples like these, please post them. even simple examples like using queues to write to a file, or how to write to a single file from multiple loops, etc.

 

I will be posting many more questions as I move forward and I hope they are not too tedious, coz sometimes I tend to be that way 🙂

 

V

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

Hi Lynn!! I understand you concern. But, the outer state machine can just be run at one rate.  I have parallel systems, which have to be run in "Operation" state of my main SM. Also, one of the parallel system has it's own state machine which I have implemented the way you suggested.

 

Not all applications (if I am understanding correctly) can be programmed using the while loop that comes with the SM architecture. I guess I am using the outer state machine to define my overall state positions of my system and using inner state machine for each system to react accordingly in the approproate state it is in with respect to the outer SM.

 

Here I go again, being too tedious :), but am I missing some critial understanding here? Thanks!

 

VB

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

Or would you think implementing parallel state machines for each parallel system would be more efficient?

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