LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I control concurrency in my VI?

Solved!
Go to solution
Solution
Accepted by iCat

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 21 of 26
(822 Views)

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 Smiley Wink )

-----

The best solution is the one you find it by yourself
0 Kudos
Message 22 of 26
(815 Views)

@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


Message 23 of 26
(798 Views)

@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!  😄

 

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.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 24 of 26
(773 Views)

@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!  😄

 

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!


"Should be" isn't "Is" -Jay
0 Kudos
Message 25 of 26
(766 Views)

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


"Should be" isn't "Is" -Jay
Message 26 of 26
(760 Views)