XML-DA method to read a set of item values from an XML-DA or OPC-DA server.
Syntax
Parameters
- Options
- Container with options used in most server calls.
- ItemList
- The container for the individual Items.
It is expected that there are one or more Items per ItemList.
- RItemList
- A container with an arrrya of item elements and their value information.
It is expected that there are one or more Item elements per RItemList.
The ReadResponse will maintain the Item order in the Read request.
If an item is write-only the server will return E_WRITEONLY in the response for this item.
The response will provide no value element for the affected item.
- Errors
- An array of OPCError elements with the description of the errors occured in this server call.
Errors are only present if Items contain result codes.
Return Value
Container of information that represents the basic information for most responses.
Example
Visual Basic | Copy Code |
---|
Private Sub readValues(ByVal Srv As XmlServer, ByVal itemList As ListBuilder )
Dim readItemList As ReadRequestItemList
readItemList = itemList.GetReadItemList( "Read1" )
Dim reply As ReplyBase
Dim options As RequestOptions = New RequestOptions
options.ReturnErrorText = True
Dim rslt As ReplyItemList
Dim err As OPCError()
Try
reply = Srv.Read(options, readItemList, rslt, err)
If err Is Nothing Or err.Length = 0 Then ' no errors
Dim rItem As ItemValue
For Each rItem In rslt.Items
' handle the read values
Next
Else
MessageBox.Show(err(0).Text, "Error at Write")
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Exception in Read")
Close()
End Try
End Sub |
C# | Copy Code |
---|
private void readValues( XmlServer Srv, ListBuilder itemList)
{
ReadRequestItemList readItemList ;
readItemList = itemList.GetReadItemList( "Read1" );
ReplyBase reply ;
RequestOptions options = new RequestOptions();
options.ReturnErrorText = true ;
ReplyItemList rslt ;
OPCError[] err ;
try
{
reply = Srv.Read( options, readItemList, out rslt, out err );
if( (err != null) && (err.Length>0) )
MessageBox.Show( err[0].Text, "Error at Write" );
else
{
foreach( ItemValue rItem in rslt.Items )
{
// handle read values
}
}
}
catch( Exception ex )
{
MessageBox.Show( ex.Message, "Exception in Read" );
this.Close();
}
} |
Requirements
Target Platforms:Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows 7, Windows Server 2008 family
>
See Also