How Is the URL Built in DataSocket and How Is It Used in LabVIEW

Updated Dec 27, 2022



  • LabVIEW
  • OPC Servers

How is the URL structured when the Datasocket communicates with the OPC server, and how to use the URL in LabVIEW DataSocket communication?

When you use datasocket to connect with OPC object by DataSocket Open Connection. vi  in LabVIEW, it follow these steps:
  1. DataSocket Open Connection. vi creates default group, server, update rate and deadband based on the mode (Read, Write, ReadAutoUpdate, WriteAutoUpdate).
  2. Datasocket executes ValidateItems and AddItems commands for new objects.
  3. Pass the ItemName (ItemID and AccessPath) after the DataSocket.
For example, the URL opc:/National Instruments.OPCDemo/sine, sine is the ItemName, which is passed by the ItemID and AccessPath, but when using the datasocket to connect with OPC server, there is no way to give an AccessPath different from the ItemID. When the data is returned and communicated by datasocket , LabVIEW uses VariantChangeType to transfer the data to the original format requested by the user. Other input to AddItems are optional and usually do not pass any data.
The available attributes in the datasocket communication return object are Quality and TimeStamp. The TimeStamp property is only suitable timing to 1s. For a more accurate TimeStamp, you can use other properties, TimeHigh and TimeLow, which means TimeStamp is expressed as a 64-bit interval of 100ns starting from 1/1/1601. For more information, please refer to the links below.