LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shared variable for concurrent users

Hi, so I'm planning on creating a remote VI using shared variables. The scope of this project is kind of a network where a user (PC1) connects to a kiosk (PC2) which connects to devices (PC3). The VI would preferably run only on PC2. Now I was able to do this using shared variables but a question came up. What if multiple users (multiple PC1s) use the VI at the same time? Would the data stored in the variable grab data from whoever used it last?

For example: if I have a VI that multiplies A and B and outputs it to C, and I chose 3 for A and 5 for B but another user uses 10 for A and 20 for B (assume all A, B, and C are shared variables) what would C show to me and the other user?  

0 Kudos
Message 1 of 8
(2,853 Views)
Seems like an incredibly wrong use of shared variables. I've only used shared variables where one VI publishes and the other Vis only do a read. You have a race condition.
0 Kudos
Message 2 of 8
(2,847 Views)

Dennis_Knutson,

Thanks for the reply. Can you elaborate? Does that mean that it will only take the recent value? If so, do you have any suggestions on how I might be able to implement this "network"?

 

Thanks.

0 Kudos
Message 3 of 8
(2,842 Views)

You Need a Server-Client Structure. Data resides in 1 place. The Server. And each client can read data from the server and then also change the data on the server. Each client then reads the new updated values from the server.  How your sever  updates the data to the client can be any method of communications. Network variables, TCP, UDP, ect.,  The connection limitations to the server and data output is the only limitation to the number of clients and performance. Network Variables seams to have a lot of overhead and would be hard to determine who actually changed a variable.

 

 

0 Kudos
Message 4 of 8
(2,841 Views)

Dave_Brandt

 

Wouldn't network variables run into the same problem as shared variables? My server also needs to connect to multiple computers that are connected to multiple devices (PC3, see first post).

0 Kudos
Message 5 of 8
(2,837 Views)
I really don't understand the type of network you are trying to implement. What is the purpose of writing some control values to the same place?
0 Kudos
Message 6 of 8
(2,823 Views)

If you used udp multicast or broadcast you could publish data from each source and that would make data available to all clients. This would give great streaming ability and the lowest network traffic.  There can be missed data because this is a connectionless protocol. Make sure you put a send counter in your udp data to be able to check quality. This increments each time you send data out. You can also create network problems if you send to much data out. Also how critical is timing and jitter? 

0 Kudos
Message 7 of 8
(2,821 Views)

Yes, shared variables will just take the last value written so I wouldn't really recommend them here.

 

It sounds to me like the RT sample projects might work well for you. Basically it has a single network connection for doing commands (update value X, configure Y), but then shared variables to pass read-only values back to any number of clients (if I remember correctly, the sample code just sends back CPU usage and memory but you could do other stuff).

0 Kudos
Message 8 of 8
(2,787 Views)