Overview
This example shows how to convert shared variable addresses between APIs.
Description
There are multiple ways to access shared variables from LabVIEW without using an actual shared variable node. Unfortunately, the address formatting used within these APIs is often incompatible with other APIs. This example allows the user to convert shared variable addresses (formatted as strings) between the following APIs.
- Shared Variable API
- DataSocket
- Tag API (Part of the Datalogging and Supervisory Control Module)
Some APIs return "." or "My Computer" as an alias for localhost. All APIs will recognize "localhost", so this VI also replaces "." and "My Computer" with "localhost" if found. All other target names will be preserved in the converted address (also IP addesses).
The VI is designed to be used as a SubVI, so you can pass the string and desired output type in and receive the correctly formatted output address.
Example conversion (DataSocket --> Shared Variable API):
psp:\\localhost\OPC Library1\_ActiveTagCount --> ni.var.psp://localhost/OPC Library1/_ActiveTagCount
Example conversion (Shared Variable API --> DataSocket):
ni.var.psp://192.168.0.1/OPC Library1/_ActiveTagCount --> psp:\\192.168.0.1\OPC Library1\_ActiveTagCount
Requirements
Software
- LabVIEW Base Development System 2012 (or compatible)
- If running in a Real-Time context, you will need the LabVIEW Real-Time Module 2012 (or compatible)
Hardware
- No hardware is necessary to use this example VI
Steps to Implement or Execute Code
- Download and open the attached file "Convert Shared Variable Address LV2012 NIVerified.zip"
- Follow the instructions in Front Panel of "[Main] Convert Shared Variable Address LV2012 NIVerified.vi" and run the program
- To use the VI in another application copy content of the attached zip file to your application directory and use "[Main] Convert Shared Variable Address LV2012 NIVerified.vi" as a SubVI. Pass shared variable address and desired address type enum parameters to the SubVI.
Additional Information or References
**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**