NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Knight of NI
Knight of NI
Ben
Posts: 16,150

Re: How can I control concurrency in my VI?

I'll add to this thraed as well so we can say we have at lest 50 years of LabVIEW experience all telling you the same thing.

 

THere are two issues Spagetti and a Race Condition.

 

Both of those type of problem can be solved by using sub-VI's. The sooner you get used to being able to create and use Sub-VI, the sooner your code will turn the corner toward reliabilty and ease of maintenance.

 

Take a quick look at the inmages I posted in this albumn to get an idea of how sub-VIs can clean-up your code.

 

In your case you should first select parts of your code that do something that you can describe with a short title. That portion should be come a sub-VI. Use Type definitions for clusters to make you life easier.

 

For those potential sub-VI that get the data from a local, use an Action Engine to store the data (Thanks Bill for the mention and link earlier). Action Engines in wrappers (read that thread on Action Engines) is one of the single things yo can do that is most effective in cleaning up your code. Action Engines (AEs) store the data inside them so the "wires" you want to avoid seeing are encapsulated in the AE.

 

In general...

 

Unlike other langauges that insist you name everything that stores data, LV stores its data in un-named wires. Locals look like data storage thingies for non-LV developers but they are not. They should be viewed as an I/O device that are used to get info in or push it out. Miss-using locals lead to Race conditions as you have discovered.

 

Done adding to the pile while trying to help,

 

Ben

Ben Rayner
Who is now transitioning to John Galt.. just building Rayner's Ridge
Rayner's Ridge is under construction
Trusted Enthusiast
P@Anand
Posts: 2,414
0 Kudos

Re: How can I control concurrency in my VI?

Good explanation Ben I guess atleast now iCat will stop to argue and understand the fact. Its always good to argue on some statement that is worthy and thats not been discussed. (If already done then pull that sub vi into this main vi and use it :smileywink: )

-----

The best solution is the one you find it by yourself
Trusted Enthusiast
SteveChandler
Posts: 2,257

Re: How can I control concurrency in my VI?


iCat wrote:
The screenshot of my code reminds me of sparse spaghetti.

Naw, it could look much more like spaghetti.

 

spaghetti_BD.png

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


Trusted Enthusiast
billko
Posts: 2,227
0 Kudos

Re: How can I control concurrency in my VI?


Steve Chandler wrote:

iCat wrote:
The screenshot of my code reminds me of sparse spaghetti.

Naw, it could look much more like spaghetti.

 

spaghetti_BD.png


Looks like the code I just cleaned up.  The original author did not believe in Sub-VIs and was married to the stacked sequence structure!  Imagine having to hunt through something that was four 1280 x 1024 panels big with a main stacked sequence of 5 frames with myriads of smaller stacked sequences inside - like a stacked sequence fractal!  :smileyvery-happy:

 

Don't understand the philosophy at all.  I wouldn't ever write text-based code with all my code in the main().

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proven Zealot
Jeff·Þ·Bohrer
Posts: 8,028
0 Kudos

Re: How can I control concurrency in my VI?

[ Edited ]

billko wrote:

Steve Chandler wrote:

iCat wrote:
The screenshot of my code reminds me of sparse spaghetti.

Naw, it could look much more like spaghetti.

 

 


Looks like the code I just cleaned up.  The original author did not believe in Sub-VIs and was married to the stacked sequence structure!  Imagine having to hunt through something that was four 1280 x 1024 panels big with a main stacked sequence of 5 frames with myriads of smaller stacked sequences inside - like a stacked sequence fractal!  :smileyvery-happy:

 

Don't understand the philosophy at all.  I wouldn't ever write text-based code with all my code in the main().


I really am ROTFL-

\

 

Stevev, You should be ashamed!

8-Ball Consulting advertising banner

Certified LabVIEW Consultant. The partner you can bank on when you're behind the 8-Ball.
Proven Zealot
Jeff·Þ·Bohrer
Posts: 8,028

Re: How can I control concurrency in my VI?

The nice young men in the clean white coats.....

8-Ball Consulting advertising banner

Certified LabVIEW Consultant. The partner you can bank on when you're behind the 8-Ball.