LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shared variable dataflow

Hello all,

I am using a shared variable to share a 2D array of SGL datapoints between two networked PCs:

PC-1 has the shared variable setup in the project as a Network-published variable using Buffering (size = 1 array, Array size = 20 elements).

PC-2 reads the shared variable using an array indicated with data binding to (PC-1).  A colleague put the shared variable in a flat sequence with a wait state.  I couldn't see any reason why this would work, so I removed the flat sequence.  After that, I found that sometimes the array will be empty when it should have valid data.  I put the flat sequence back and viola!, the program works normally. 

Attached is a code snippet from PC-2 where the issue happens. ('Data' is the shared variable array').  Any ideas?






Message Edited by vt92 on 04-02-2008 10:04 AM
>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 1 of 6
(3,244 Views)

Hi vt92,

where did you get the data from? How many sources write data into your shared variable?

Mike



Message Edited by MikeS81 on 04-02-2008 08:15 PM
0 Kudos
Message 2 of 6
(3,212 Views)
Only one process (PC-1) writes to this array.  Then second process just reads it.


>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 3 of 6
(3,204 Views)
Look like you have a race condition occurring. He probably extracts the data and waits for a 100 ms to have the next data ready. When you removed the sequence, you the 100 ms not occurrs concurrently and will be a bit shorter. The process writing to the data may not be fast enough to get the data ready for the next operation. or loop thus getting false data or the process has not completed to put the data in. the sequence guarantees, that you wait 100 ms to occur after the data read, whereas when you removed it, it can be any time within the 100 ms.
0 Kudos
Message 4 of 6
(3,190 Views)
I would be interested to hear from others regarding how you synchronize periodic data between two machines using shared variables.  It seems that the buffering option on the shared variables would be one method.


>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 5 of 6
(3,164 Views)
vt92,

You can take a look at queues and notifiers.
I am not so sure how they would work over the network.

You can also program your own handshaking. Some sort of network published flag to indicate read and write to avoid race conditions.
Van L
NI Applications Engineer
0 Kudos
Message 6 of 6
(3,141 Views)