UA Bundle SDK .NET  2.2.1.258
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Groups Pages
Read – Read With Data Encoding

Prerequisites

A session with the server must be established.

Description

The following dialog shows an example implementation of the Read service. Press the button “Show Code” to display the corresponding code, and the button “Help” to show this documentation page.

Press the button “...” to open a Browse window and select a NodeId of a structure variable. Confirm your choice by pressing “OK”. The NodeId is now displayed in the field “Node Id”.

Now you can use the drop-down menu to select a data encoding.

On pressing the button “Read”, the variable is read using the specified data encoding and the response is displayed at “Read Response”. Check the box in front of “Use Asynchronous Pattern” to call “BeginRead” instead of “Read”.

Sample Code

The following code reads the Value of the specified Variable from the server.

try
{
// get the current session from the parent form.
Session session = m_parent.Session;
// build a list of values to read.
List<ReadValueId> nodesToRead = PrepareRequest(session);
if (nodesToRead == null)
{
return;
}
// this is a blocking call so show the wait cursor.
Cursor = Cursors.WaitCursor;
// read the value (setting a 10 second timeout).
List<DataValue> results = session.Read(
nodesToRead,
0,
new RequestSettings() { OperationTimeout = 10000 });
// update the controls.
ProcessResults(results);
}
catch (Exception exception)
{
ExceptionDlg.Show(this.Text, exception);
}