Reading Array Elements with TOP Server Client Drivers
Can TOP Server read single elements of Array data types with the OPC Client Drivers?
By Default OPC Client Drivers (OPC DA, UA, XML-DA) do not support addressing Array Elements Individually. Because of this there are workarounds to read individual elements out of Arrays.
For non-String arrays
- Utilize the TOP Server Advanced Tags plugin and Memory Based Driver
- This example shows how to split a Word Array with 3 elements read from a OPC UA data source using the OPC UA Client driver, and the Quick Client as client application
- Create a OPC UA Client Driver channel.device "OPCUAChannel.OPCUADevice" connecting to the OPC UA data source
- Create a tag named "ArrayFromDevice" with data type Word Array in the OPC UA Client and test that an array with 3 elements can be read
- use the OPC Quick Client as test client application
- Create a Memory Based Driver channel.device "MemoryChannel.MemoryDevice" using the Memory Based driver keeping all default values
Note: the memory registers simulated by this driver are 8bit
-
- In the "MemoryDevice" create a new Tag named "MemoryArray" with addressing D0[3] (3 elements array) and data type Word Array
- Then also under the "MemoryDevice" device create separate additional Tags named "Element1 /2 /3" with addresses D0 / D2 / D4 and data type Word (16bit)
Note: when reading a single Word starting at address D0, the Word value would consist of addresses D0 and D1 (8+8=16)
-
- Under Advanced Tags create a "Link" tag and specify the Input to be the "ArrayFromDevice" tag from the "OPCUADevice" device and under Output the "MemoryArray" tag from the "Memory Device"
Note: the Link Rate of the Link tag should be the same as the Update Rate of the "MemoryChannel.MemoryDevice" group in Quick Client (default is normally 1000 for both so keeping the default should work fine)
-
- Open Quick Client and select on the groups tree on the left the memory based channel.device to monitor the single element tags D0, D2, D4
- Any other client application will be able to read the tags D0 / D1 / D2 from the TOP Server as single elements of the array with data type Word
- This procedure typically applies for client drivers or symbolic drivers that don't split out arrays themselves
- This procedure cannot be used with the Memory Based Driver to split string arrays into single elements
For String/Boolean arrays:
- Not possible to use the Memory Based driver
- Use the Simulator driver instead with similar approach as above
- For Boolean array, set Simulator tag address as below
- Boolean array tag : K0000 [n]
- Boolean tag : K0000, K0001, K0002...
- For Boolean array, set Simulator tag address as below
- The Simulator driver allows to create a device with 8-bit or 16-bit memory registers
- For 16-bit the address offsets will change accordingly
Important Note: the Simulator Driver is meant as a test driver and is not supported to be used in production use cases