The Shared Variable Engine (SVE) is a data processing engine that manages the use and connectivity of shared variables. The SVE runs independently from LabVIEW as a separate process. Whereas LabVIEW follows a dataflow model for running VIs, the SVE is event-driven.
After you configure shared variables in a LabVIEW project, you deploy the shared variables to the SVE. When you use shared variables in a VI, you therefore must ensure that the SVE has enough CPU time to process shared variable updates and read requests. For example, running a VI that writes to or reads from shared variables continuously without a Wait function can cause instability and prevent the SVE from updating or returning the most recent value for a shared variable.
You can pass data between LabVIEW and the SVE by using one of the following methods:
|Note LabVIEW supports the first three methods for accessing shared variable data. The LabVIEW Datalogging and Supervisory Control (DSC) Module extends the capability of LabVIEW by supporting the last three methods for accessing shared variable data.|
The complexity of the application you build determines the data access method to use. For example, passing data between LabVIEW and the SVE requires significantly more resources than updating a local variable in LabVIEW. Therefore, you must minimize the number of writes and reads that you make to or from shared variables in a VI. Though performance varies greatly depending on the system configuration, the SVE can process at least 5,000 updates per second for double-typed shared variables.
The data access methods are either static or programmatic. Static data access methods are useful in small applications that contain a small number of shared variables. Using a Shared Variable node is a static method for accessing data. Programmatic data access methods are useful when developing large applications that contain hundreds of shared variables. Using the DataSocket VI and functions, front panel data binding, and shared variable Event structure support are programmatic methods for accessing data. Static and programmatic data access methods are useful in different applications. The following sections describe the various data access methods.
You can configure Shared Variable nodes to read data from or write data to the SVE. Shared Variable nodes follow a static data access model. This static data access model is suitable for small applications that contain a small number of shared variables and do not gain in complexity over time. Shared Variable nodes update automatically if you rename or move the corresponding shared variable in a project. Thus, you also can use this method when you develop an entire application within one project. However, with Shared Variable nodes, you cannot change the source of the data at run-time. Shared Variable nodes also are difficult to use in subVIs. Therefore, maintaining or reusing applications developed with this method can be difficult because this method has limited scalability.
If you want to allow for an growing application, you can use the DataSocket VI and functions with the psp protocol to read data from or write data to the SVE programmatically. The DataSocket VI and functions behave similarly to the Shared Variable node. However, with the DataSocket VI and functions, you can reconfigure the source of the data at run-time.
You can bind shared variables to a front panel object using the NI Publish-Subscribe Protocol (NI-PSP) protocol. Binding a front panel object enables you to create a flexible and reconfigurable user interface with minimal programming requirements. You can configure front panel data binding programmatically by using VI Server properties and methods. To set the URL of a front panel control bound using the NI-PSP protocol, obtain a control reference to the control or indicator and write to the Data Binding:Path Property property of the control.
|Note You must configure the control or indicator to bind to the URL that the Network:URL property specifies before you can write to the URL property programmatically.|
The DSC Module enables you to monitor shared variables using the Shared Variables VIs and the Event structure. Shared variable Event structure support allows you to receive raw event data directly from the SVE. This programming model most closely resembles the execution model running in the SVE. Shared variable Event structure support is read-only but allows you to process all events, including value changes, quality changes, instantiations, and deletions, that the SVE passes. This programmatic data access method is useful in supervisory control applications where the VI needs to take a predefined action upon encountering a change in the system.