In order to use shared variables effectively, it is important to understand the nature of the Shared Variable Engine (SVE) and its role in communication. The SVE is installed with every version of LabVIEW since version 8.0. When running executables on a computer without LabVIEW, you need to install SVE on that computer. Shared variables use the Publish-Subscribe-Protocol (PSP), which is a form of User Datagram Protocol (UDP) communication. Refer to Understanding Shared Variable Technology for more information about PSP.
The SVE is where a variable resides on a computer. The SVE is responsible for network communication and for managing bindings, all of which you can configure from within LabVIEW. THE SVE also includes the Variable Manager, which allows users to monitor the status of variables deployed locally and on real-time targets, reassign bindings, and to un-deploy.
If data values transmit correctly when running the application from within LabVIEW, the network is functioning properly. Ensuring this works is a quick and easy way to ensure that no firewalls or network security procedures hamper communication.
Otherwise, if you experience difficulties while attempting communication from within LabVIEW, follow these troubleshooting steps.
The library containing the shared variables in use by an application must be deployed on any and every machine that is using them for communication. Autodeploy is checked in LabVIEW projects by default, so running a VI from within LabVIEW that uses shared variables will automatically deploy the library.
**Note: It is very important to understand that no autodeploy functionality is available for executables.
In order to deploy shared variables in executables, the use of a property node is necessary. For information on how to do this, consult the KB, “How Do I Deploy Network Shared Variables From a Compiled Executable?”
Shared variables work based upon a PSP. As such, the variables of the subscriber must be bound to a source or publisher. Data can flow both ways, but this concept can be helpful when attempting to understand how to configure a project. Without the LabVIEW DSC addon, bindings are configured statically from the shared variable’s option menu dialog and cannot be modified programmatically.
One publisher must exist in a shared variable application, to which many subscribers are allowed to bind. The publisher’s variables cannot be bound to anything.
**Note: It is not necessary to bind a subscriber’s variable to the publisher if it is intended for use on the same machine as the publisher.
Since the subscriber’s variables must be bound to the publisher’s, it is easiest to use separate libraries for the subscriber and for the publisher. Duplicate the variables between the two libraries and bind the variables of B to A as discussed earlier. Ensure that you are using a network address that will still be valid from the remote location.
This method is possible and very similar to what is required when using the same project. Create variables of the same data type and bind those of the subscriber to the publisher’s.
These variables will exist within separate libraries for both development techniques, so ensure that you are deploying the correct library for the VI programmatically and that the variables being referenced in the code belong to the correct library. Using distinct names is helpful when troubleshooting this.
The zip file attached below has been tested successfully across multiple computers. It does not use DSC property nodes, so it cannot programmatically bind. Because of this, it will be necessary to reset the bindings for the client’s library and recompile the client executable. Run the server executable on the computer that is intended to publish the variables and then set the network address to the location of these deployed variables. Further instructions are included with the actual VIs.
When you launch the executables, they will prompt you for the location of the library to use. This is the library that contains the shared variables that the executable needs to communicate with. Make sure that you are specifying the correct library as they will be different for the client and the server.
The build specifications for the client and server both reference the necessary VIs and the associated library. By doing so, the necessary library is included in a subfolder of the executable’s folder named, Data.