LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect value change of network shared variable

Solved!
Go to solution

We are working on a project that use shared variable to update the changes made the web client. During the implementation, I notice that the event structure can not detect the value change of shared variable. In order to resolve this issue, we use a for loop to pull the value from the shared variable consistently and compare with previous value to detect change. 

 

I'd like to know, if there is other way to register the value change event of an shared variable. 

0 Kudos
Message 1 of 5
(4,474 Views)

Yes, this is one of my big pet peeves with shared variables.  There is no event integration.  So detecting a change and firing and event has to be done in other ways.

 

i generally use a while loop and set the shared variable read timeout.  If a timeout occurs, the loop cycles.  This avoids the polling approach and value comparison.  The while loop is independent and has a stop notifier as a control mechanism.

 

If it reads (the variable time stamp is other than the last read time stamp), I then fire a user event (of the same type as the shared variable) which is tied to an event structure.  It works adequately, but there's annoying side effects on program startup (the event fires because of the old data in the shared variable and the uninitialized time stamp).

 

Honestly, NI should integrate shared variable events.  This would make shared variables far more friendly and useful.  I only use them where I absolutely have to now and opt for STM for the vast bulk of my network comms.

 

 

Message 2 of 5
(4,420 Views)
Solution
Accepted by topic author marxious

xl600 wrote:

Honestly, NI should integrate shared variable events.


I think they are with the DSC Toolkit.  I have not tried it myself.  I also avoid NPSVs like the plague.  TCP/IP using STM is my go to communication method.  Network Streams are also good.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 5
(4,413 Views)

I've heard they are supported with the DSC toolkit as well, but this really should be a basic feature of shared variables for every level of LV where shared variables are supported.

Message 4 of 5
(4,409 Views)

NSV change of value can be also found using the "DSC Module" under DSC Module > Alarms & events > Read Events 

Gururaja_0-1651601081127.png

 

0 Kudos
Message 5 of 5
(2,105 Views)