11-05-2009 02:09 PM
This document contains a number of examples highlighting the use of the shared variable in LabVIEW 2009, focusing on more advanced uses of the feature. More examples will be added over time.
SV Dynamic Creation.zip
There are a couple of methods to dynamically create and deploy shared variables in LabVIEW code. This example shows how to use VI server methods and the DSC process/variable API for this purpose.
This solution can be used in VIs running in the Windows development environment to create new variables as it uses the project object in VI server. This methods does not work in a compiled executable (i.e. is not supported in the LV run-time engine) and alos does not work in a VI deployed to an RT target.
The Application Library.Deploy Library method, which is used to deploy a shared variable library and its contents to a Windows or RT target, can be used in a compiled Windows executable. This method is not supported in a LV RT VI.
This API and example requires the LabVIEW DSC module. If you want to use this methodology to create variables in a compiled executable you must select the Enable Enhanced DSC Run-Time support option in the Application Builder build specification.
Enable Enhanced DSC Run-Time support—This option only appears if you have the LabVIEW Datalogging and Supervisory Control (DSC) Module installed. Builds the application with the enhanced DSC Module Run-Time Engine. The DSC Module Run-Time Engine adds additional support for programmatic project library and shared variable management in applications that you build with the DSC Module. You must place a checkmark in this checkbox in the following situations:
If you do not enable the enhanced DSC Module Run-Time Engine in these two situations, LabVIEW returns error code 1055 when you run the built application, shared library, or .NET interop assembly.
Note: Enabling this option increases the file size and reduces the start-up performance of the built application, shared library, or .NET interop assembly.
SV PSP Browser.zip - requires AMC reference library
This example shows how to use LabVIEW VI server methods to browse and retrieve a list of shared variables and other tags available through PSP on the local network. PSP (Publish and Subscribe Protocol) is used to remotely access shared variables as well as tags in an I/O server as well as network-shared I/O variables in the Scan Engine.
Through a reference to the local PSP/Shared Variable Engine the VI Server methods provide access to a list of PSP engines forund on the local subnet and for each of these a list of all the variables published through PSP. The example uses the Asynchronous Message Communication (AMC) library available on Developer Zone.
The PSP Browser subVI (SV Select Network Shared Variables.vi) can be used to interactively select a list of PSP tags from the local subnet for use in a VI or application.
A simple reader (SV Read Network SVs.vi) is included that can read and chart a list of numeric tags/variables.