.NET Based OPC UA Client/Server SDK
3.1.0.500
|
API documentation UnifiedAutomation.UaClient.Session
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.
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:
Where
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 Name | Description |
---|---|
Connect | Connects to the Server and creates a new Session. |
ReverseConnect | Connects to the Server via a channel initiated by the server. This is needed, when the server is behind a firewall and no port can be opened. |
Disconnect | Closes an existing Session and disconnects from the Server. |
ChangeUser | Changes the user identity associated with the Session. |
Read | Reads the value of one or more attributes. |
Write | Writes the value of one or more attributes. |
Call | Calls a single method. |
CallList | Calls multiple methods. |
Browse | Returns the references from a single node. |
BrowseNext | Fetches the next batch of references from a single node. |
BrowseList | Returns all references for multiple nodes. This service automatically processes any continuation points returned from the Server so there is no need to call BrowseNext. |
ReleaseBrowseContinuationPoint | Releases a continuation point returned in a Browse or BrowseNext response. |
TranslateBrowsePath | Finds the node at the end of one or more browse paths. |
RegisterNodes | Register nodes to create shortcuts in the server. |
UnregisterNodes | Unregister nodes to delete shortcuts in the server. |
TransferSubscriptions | Transfers the Subscriptions to the Session. |
HistoryReadRaw | Reads the raw historical data for one or more variables. |
HistoryReadEvent | Reads the event history for one or more event notifier objects. |
HistoryReadProcessed | Reads processed historical data for one or more variables. |
HistoryReadAtTime | Reads historical values at specific times one or more variables. |
HistoryReadModified | Reads the modified data for one or more variables. |
ReleaseHistoryContinationPoints | Releases a list of continuation points returned from one of the HistoryRead calls. |
HistoryDeleteAtTime | Deletes historical values at specific times one or more variables. |
HistoryDeleteEvent | Deletes the event history for a list of event notifier objects. |
HistoryDeleteRaw | Deletes the history for a list of variables in the passed time domain. |
HistoryUpdateData | Updates the history for a list of variables. |
HistoryUpdateEvent | Updates the event history for a list of event notifier objects. |
Query | Query against the server's address space. Not implemented by most servers. |
AddNodes | Adds nodes to the server's address space. This NodeManagement service is not implemented by most servers. |
AddReferences | Adds references to the server's address space. This NodeManagement service is not implemented by most servers. |
DeleteNodes | Deletes nodes from the server's address space. This NodeManagement service is not implemented by most servers. |
DeleteReferences | Deletes references from the server's address space. This NodeManagement service is not implemented by most servers. |
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.