LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I control concurrency in my VI?

Solved!
Go to solution

Okay.  Then don't listen to the experts on the forum.  And please keep posting questions about how your code doesn't work like you expect it to.

0 Kudos
Message 11 of 26
(899 Views)

@iCat wrote:

@Ravens Fan wrote:

It would solve your race condition problem.

 

I don't see where you have a spaghetti code problem.  Eliminating local variables, straightening wire runs, and sorting things out so wires don't run backwards will make the code look better.


The screenshot of my code reminds me of sparse spaghetti.

If I add a few more wires crossing over other wires perpendicularly, others will have difficulty reading my code.

 

 


 

 

 


You are making the code to work and you will give the user only the front panel and don't much bother to make your code readable to others. Make documentation that is sufficient for others to understand. Just check the size of your code and understand why Knights are advising to remove the local variables.

-----

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

@P Anand wrote:

@iCat wrote:

@Ravens Fan wrote:

It would solve your race condition problem.

 

I don't see where you have a spaghetti code problem.  Eliminating local variables, straightening wire runs, and sorting things out so wires don't run backwards will make the code look better.


The screenshot of my code reminds me of sparse spaghetti.

If I add a few more wires crossing over other wires perpendicularly, others will have difficulty reading my code.

 

 


 

 

 


You are making the code to work and you will give the user only the front panel and don't much bother to make your code readable to others. Make documentation that is sufficient for others to understand. Just check the size of your code and understand why Knights are advising to remove the local variables.


Assume that I have a control that has a default value. And I take measures to never write to the control.

If I only read from local variables for the control, would it be acceptable to use local variables for the control?

0 Kudos
Message 13 of 26
(881 Views)

If you are not using the control then why don't you make it as a constant and wire wherever required. I don't understand why you are fighting to use Local variables.

-----

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

@P Anand wrote:

If you are not using the control then why don't you make it as a constant and wire wherever required. I don't understand why you are fighting to use Local variables.


Does LabVIEW has a constant that can be used in more than one places?

 

Since the constant has to be used in many places and I need to change the value of it often,

I need the constant to be shared.

0 Kudos
Message 15 of 26
(876 Views)

More than one places means in the same vi or in sub vis?

-----

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

in the same VI.

0 Kudos
Message 17 of 26
(870 Views)

Then keep at the beginning and wire it wherever it is required.

-----

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

In general, if you encounter your code to become "spaghetti", it is most likely that the block diagram is also growing in size. So the easiest thing to fight BD size as well as spaghetti is to create subVIs. If done properly, you will be rewarded with easy to read code and reusable modules.

 

Norbert

 

EDIT: You should focus on redundant code segments first. Esp. case structures tend to include such segments because you always only see one case at a time, hiding all the other code.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 19 of 26
(863 Views)

It literally looks like the spaghetti I ate yesterday.  Well, mine was spaghetti squash instead of pasta, but they don't taste the same.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 20 of 26
(858 Views)