LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the problem with this code ? Race condition??

Solved!
Go to solution

Guys,

The idea behind the attached code is quite simple.

I have a 2D parent array. First, I print a subset of this array into a table control (based on a sensor selection). Now, I want edit the numbers in the table. I need the changes to be reflected in the table and the parent 2D array. (In simple terms, this is like replacing the the edited array subset into the parent 2D array)

 

The problem is when I change(edit) any entry in the table, the entry changes back to its original value. The change doesnt seem to be reflecting on the parent 2D array and the table. .

 

Can anyone tell me where the problem is?

 

Thanks

Ravi

0 Kudos
Message 1 of 7
(2,944 Views)

Confession up front: I did not look at your code.

 

What I suggest you do is watch the code in execution-highlighting mode (turn on the light bulb) and watch the data flow. It sounds like the data is being copied from you called the parent to the other repedly.

 

"The Light bulb reveals all"

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 7
(2,939 Views)

Thanks for the advice Ben. It was really helpful. I dint knew the option before.

The problem is solved via introducing an additional integer variable and new case structure.

 

Cheers.

Message 3 of 7
(2,924 Views)

Ravi,

 

I would suggest trying to reduce your use of local variables as much as possible.  When passing a value from one loop iteration to another, shift registers are the preferred method.  If you use a shift register you should be able to eliminate all of the 'output array' local variables.  Local variables are useful in some cases, but they make it very easy for a race condition to happen.

 

Chris M. 

0 Kudos
Message 4 of 7
(2,911 Views)

I agree with Chris, here's an idea (of whatI think your code does):

 

The case structure in your code was unnecessary, all the cases were the same so I removed them.

The sequence structure was unnecessary.

 

Ton

Message Edited by TonP on 11-20-2008 07:52 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 5 of 7
(2,908 Views)
Solution
Accepted by topic author rpula

Thanks for the advice Chris and Ton,

The code now looks neat and does exaclty what I wanted. 

 

Cheers

0 Kudos
Message 6 of 7
(2,895 Views)

Please don't check your thank you message as the solution to your question.  Mark the actual message that was the most help to you.

 

http://forums.ni.com/ni/board/message?board.id=130&thread.id=5401

0 Kudos
Message 7 of 7
(2,880 Views)