LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I prevent Buffered Network Published Shared variable from giving me old data?

I am attempting to use a buffered network shared variable to send information from one system to another.

 

On the first pass, I always get the last value from the previous execution, even after attempting to empty it.

 

Here is my scratchpad code:

 

npsvbuff.png

 

Is this correct functionality? If so, Why?

I was expecting that after reading all values from buffer that it would either contain the default value (-1 in my case) or give a timeout flag

 

 

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 1 of 3
(2,211 Views)

Hello Timmar, 

 

Thanks for posting.

Using network shared variables to send information from system to system is a great method, nevertheless you have to be very certain of the actions when deploying the variables.
 

Often times when you get an initial value as start point you need to initialize the variable to the state that you want this one to be at.

In the code it is not clear to me that you are re-initializing the variable, reading it does not mean you are clearing the variable. The variable is a reserved resource in the server and is going to read the written state to it.

 

Here is useful information about variables and Network published shared variables you might find interesting. 


 Using the LabVIEW Shared Variable 

 Buffered Network-Published Shared Variables: Components and Architect 

 

Regards, 

 

 

Lams.

 

 

0 Kudos
Message 2 of 3
(2,186 Views)

Lams,

 

Thanks for the response, and the second link,

 

It describes some of what I am observing.

 

My code:

 

Step 1: Read the variable until it times out (Clear old data, if any, from FIFO)

Step 2: Write to it 8 times

Step 3: Read it back 16 times

 

The NPSV is configured to have initialisation value of -1

 

Is there another special method for initialising a variable of this type?

 

The functionality I am seeing:

 

1. The NPSV FIFO is exhausted (read times out).

2. Writing to the variable re-instates the last valid value and pushes it to the front of the FIFO and then adds the new value to the FIFO

 

I understand that after the FIFO is exhausted that it continues to provide the last value.

I my Flush Loop it gives me the last value and a "Timed Out", Which is intuitive functionality.

 

I don't understand why after writing a new value to it, it gives me the old value without a "Timed out" Flag.

 

In my opinion, intuitive functionlity should be either:

A: Provide the Old Value with a timed out Flag, Then the new value on the next read

or

B: Provide the New Value without a tImed out flag.

 

My preference is B but I understand that many uses may like to be able to obtain the previous value so that "on change" functionality may be coded.

 

Kind regards,

 

Tim L

 

 

 

 

 

 

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 3 of 3
(2,178 Views)