// This example shows how to read data (value, timestamps, and status code) of 3 attributes at once. In this example,
// we are reading a Value attribute of 3 different nodes, but the method can also be used to read multiple attributes
// of the same node.
mle_outputtext.Text = ""
// Instantiate the client object
OLEObject client
client = CREATE OLEObject
client.ConnectToNewObject("OpcLabs.EasyOpc.UA.EasyUAClient")
// Prepare arguments. By default, the Value attributes of the nodes will be read.
OLEObject readArguments1
readArguments1 = CREATE OLEObject
readArguments1.ConnectToNewObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
readArguments1.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer"
readArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10845"
OLEObject readArguments2
readArguments2 = CREATE OLEObject
readArguments2.ConnectToNewObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
readArguments2.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer"
readArguments2.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10853"
OLEObject readArguments3
readArguments3 = CREATE OLEObject
readArguments3.ConnectToNewObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
readArguments3.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer"
readArguments3.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10855"
OLEObject readArgumentsList
readArgumentsList = CREATE OLEObject
readArgumentsList.ConnectToNewObject("OpcLabs.BaseLib.Collections.ElasticVector")
readArgumentsList.Add(readArguments1)
readArgumentsList.Add(readArguments2)
readArgumentsList.Add(readArguments3)
// Obtain attribute data.
OLEObject attributeDataResultList
attributeDataResultList = client.ReadList(readArgumentsList)
// Display results
Int i
FOR i = 0 TO attributeDataResultList.Count - 1
OLEObject attributeDataResult
attributeDataResult = attributeDataResultList.Item[i]
IF attributeDataResult.Succeeded THEN
mle_outputtext.Text = mle_outputtext.Text + "AttributeData: " + String(attributeDataResult.AttributeData) + "~r~n"
ELSE
mle_outputtext.Text = mle_outputtext.Text + "*** Failure: " + attributeDataResult.ErrorMessageBrief + "~r~n"
END IF
NEXT
// Example output:
//
//AttributeData: 51 {System.Int16} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good
//AttributeData: -1993984 {System.Single} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good
//AttributeData: Yellow% Dragon Cat) White Blue Dog# Green Banana- {System.String} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good