UA Bundle SDK .NET  2.2.5.284
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Groups Pages
Session

API documentation UnifiedAutomation.UaClient.Session

Overview

The Session class represents a connection between the Client application and a single server. A process can create many Session objects connected to different Servers. The Session object is responsible for monitoring the connection with the Server and attempting to reconnect if there are any errors. The application can receive notifications of changes to the connection status with the ConnectionStatusUpdate event.

A Session object is thread-safe.

Synchronous vs. Asynchronous Design Pattern

The application can communicate with the Server using one of the several methods defined in the Session object (described in more detail below). Each of these methods has a synchronous and asynchronous version. The design pattern is illustrated below:

List<RESULT> SERVICE(
IList<REQUEST> requests,
RequestSettings settings);
IAsyncResult BeginSERVICE(
IList<REQUEST> requests,
RequestSettings settings,
AsyncCallback callback,
object userData);
List<RESULT> EndSERVICE(IAsyncResult result);

Where

  • SERVICE is the name of the service;
  • REQUEST is a class that stores an operation to perform;
  • RESULT is a class that stores the results of an operation.

The RequestSettings class allows the application to specify common parameters such as the RequestTimeout or the DiagnosticMasks. IAsyncResult and AsyncCallback parameters are defined as part of the standard .NET asynchronous method call design pattern.

The services supported by the Session object are shown in the following table:

Service NameDescription
ConnectConnects to the Server and creates a new Session.
DisconnectCloses an existing Session and disconnects from the Server.
ChangeUserChanges the user identity associated with the Session.
ReadReads the value of one or more attributes.
WriteWrites the value of one or more attributes.
CallCalls a single method.
CallListCalls multiple methods.
BrowseReturns the references from a single node.
BrowseNextFetches the next batch of references from a single node.
BrowseListReturns all references for multiple nodes. This service automatically processes any continuation points returned from the Server so there is no need to call BrowseNext.
ReleaseBrowseContinuationPointReleases a continuation point returned in a Browse or BrowseNext response.
TranslateBrowsePathFinds the node at the end of one or more browse paths.
HistoryReadRawReads the raw historical data for one or more variables.
HistoryReadProcessedReads processed historical data for one or more variables.
HistoryReadAtTimeReads historical values at specific times one or more variables.
HistoryReadModifiedReads the modified data for one or more variables.
ReleaseHistoryContinationPointsReleases a list of continuation points returned from one of the HistoryRead calls.

Connection Model

The Connect service establishes and maintains a Session with a Server. The process involved is shown in the following figure:

The BeginConnect action is started when the application initiates it and when an error occurs at any stage (assuming the RetryInitialConnect or AutomaticReconnect property is TRUE).

The GetEndpoints action is started to get a complete EndpointDescription for the Server if only the Endpoint url is passed to the Connect method. It fetches the available endpoints from the Server using its discovery endpoint. It then picks the best endpoint based on the security selection provided in the BeginConnect action. If the property UseDnsNameAndPortFromDiscoveryUrl is set to true, the DNS name and port from the Endpoint Url will be used to connect to the server. You can also have influence on the Endpoint url by adding an UpdateEndpointEventHandler.

The CreateSession action is started once the Session object has a complete EndpointDescription for the Server. It could have gotten this EndpointDescription directly in the BeginConnect call or by calling GetEndpoints. It sends a CreateSession request to the Server.

The ActivateSession action is started once the CreateSession action completes or the watchdog timer detects an error. It sends an ActivateSession request to the Server.

The Session object enters the Connected state when the ActivateSession action completes successfully. While in the Connected state a watchdog timer will periodically expire and check the status of the connection to the Server.

The WatchdogExpired action is started when the watchdog timer expires. If there is a communication error with the Server and the AutomaticReconnect property is TRUE then the ActivateSession action is periodically called until communication is re-established.