Network Variable Data
- Updated2023-02-21
- 3 minute(s) read
Network variable data consists of four possible pieces of information—value, timestamp, quality, and server error information. The data you create using the Create functions in the library contain only values. The data you get from a network variable server can contain one or more values of value, timestamp, quality, and server error information. Network variable data is represented by the CNVData handle. When you finish using the data, you must dispose the handle using the CNVDisposeData function.
The LabWindows/CVI Network Variable Library supports scalar and multi-dimensional array values of the following data types:
- char
- short
- int
- __int64
- unsigned char
- unsigned short
- unsigned int
- unsigned __int64
- boolean
- float
- double
- string
You can create scalar values using the CNVCreateScalarDataValue function and create array values using the CNVCreateArrayDataValue function. The Network Variable Library does not support string arrays with a number of dimensions greater than two. Note that different programming environments may interpret multi-dimensional arrays in different formats. For example, two-dimensional arrays can be interpreted in row-major or column-major formats. This can affect the dimensions and data of multi-dimensional arrays communicated between different programming environments.
You also can use struct values containing members of the preceding data types. You can create struct values using the CNVCreateStructDataValue function. This function takes an array of data handles representing the members in the struct. The library does not support arrays of structs.
You can change the value of an existing data item using the CNVSetScalarDataValue, CNVSetArrayDataValue, and CVNSetStructDataValue functions. Setting the value of an existing data item is faster than creating a data item with the new value. When continuously writing data in a loop, you may want to use the Set functions to change the value of an existing data item and write it. This is faster and more efficient than creating and disposing a data item in each iteration.
When you read a value from the server, you can find the type and dimensions of the value using the CNVGetDataType function. If the data does not contain a value, for example, when you read an uninitialized, implicitly created variable, the type will be empty. Other environments might support additional data types like wide-strings, waveforms, waveform collections, and so on that are not supported in LabWindows/CVI. CNVGetDataType will return an appropriate error if the data has a type that is not supported. You can get the value of scalar, array, and struct data using CNVGetScalarDataValue, CNVGetArrayDataValue, and CNVGetStructFields, respectively. CNVGetStructFields returns an array of data handles representing the members in the struct.
You can get the timestamp information in the data using the CNVGetDataUTCTimestamp function. This function returns 1 if the data does not have timestamp information. The timestamp is represented by an unsigned 64-bit number. You can get the date and time information in the timestamp using the CNVGetTimestampInfo function.
You can get the quality information in the data using the CNVGetDataQuality function. This function returns 1 if the data does not have quality information. The quality is represented by CNVDataQuality, which is a 64-bit entity. You can get more information about the quality using the CNVGetDataQualityDescription and CNVCheckDataQuality functions.
You can get the server error information using the CNVGetDataServerError function. This function returns 1 if the data does not have any server error information. The server error is a 32-bit unsigned number that represents a server or device error that occurred when generating the data. For more information about this error value, refer to the documentation of the server or device.