C++ Based OPC UA Client/Server SDK  1.5.3.346
ServerManager Class Reference

Main management class of the server core module. More...

#include <servermanager.h>

Public Member Functions

 ServerManager ()
 Construction.
 
virtual ~ServerManager ()
 Destruction.
 
UaStatus startUp (ServerConfig *pServerConfig)
 Start up server manager. More...
 
UaStatus shutDown ()
 Shut down server manager. More...
 
ServerConfiggetServerConfig ()
 Returns the server configuration object. More...
 
NodeManagergetNodeManagerRoot ()
 Returns the root node manager object. More...
 
NodeManagergetNodeManagerNS1 ()
 Returns the node manager object responsible for namespace index 1 nodes. More...
 
SessionManagergetSessionManager ()
 Returns the OPC UA Session manager object. More...
 
OpcUa::HistoryServerCapabilitiesTypegetHistoryServerCapabilities ()
 Returns the OPC UA HistoryServerCapabilities object. More...
 
UaThreadPoolgetThreadPool ()
 Returns the thread pool of the server core module. More...
 
void registerDynamicEventManager (EventManager *pEventManager)
 Inform the server manager about a new event manager added after server start-up. More...
 
void registerApplicationControlCallback (UaApplicationControlCallback *pCallback)
 Allows the application to set a callback for application control.
 
UaApplicationControlCallbackgetApplicationControlCallback ()
 Returns the application control callback interface (NULL if not set)
 
OpcUa_UInt32 startServerShutDown (OpcUa_Int32 secondsTillShutdown, const UaLocalizedText &shutdownReason)
 Inform the server manager about the shutdown of the server. More...
 
OpcUa_UInt32 startServerShutDown (OpcUa_Int32 secondsTillShutdown, const UaLocalizedTextArray &shutdownReason)
 Inform the server manager about the shutdown of the server. More...
 
void changeServerState (OpcUa_ServerState newState)
 Change the server state represented in the address space. More...
 
void changeServiceLevel (OpcUa_Byte serviceLevel, OpcUa_Byte changeMask)
 Update the ServiceLevel property of the Server object. More...
 
SessiongetInternalSession ()
 Returns the default internal Session object with root rights. More...
 
SessioncreateInternalSession (const UaString &sessionName, const UaString &localeId, UaUserIdentityToken *pUserIdentityToken)
 Creates an internal session for a special user. More...
 
UaStatus browse (const UaNodeId &startingNode, const UaNodeId &referenceTypeFilter, ContinuationPointWrapper &continuationPoint, UaReferenceDescriptions &references)
 Browse function for internal use. More...
 
UaStatus browse (const UaNodeId &startingNode, OpcUa_Boolean isInverse, const UaNodeId &referenceTypeFilter, OpcUa_UInt32 nodeClassMask, ContinuationPointWrapper &continuationPoint, UaReferenceDescriptions &references)
 Browse function for internal use. More...
 
UaStatus browse (Session *pSession, const UaNodeId &startingNode, ContinuationPointWrapper &continuationPoint, UaReferenceDescriptions &references)
 Browse function for internal use. More...
 
UaStatus browse (Session *pSession, const UaNodeId &startingNode, OpcUa_Boolean isInverse, const UaNodeId &referenceTypeFilter, OpcUa_UInt32 nodeClassMask, ContinuationPointWrapper &continuationPoint, UaReferenceDescriptions &references)
 Browse function for internal use. More...
 
UaStatus read (Session *pSession, OpcUa_Double maxAge, const UaReadValueIds &nodesToRead, UaDataValues &results)
 Read function for internal use. More...
 
UaStatus read (Session *pSession, OpcUa_Double maxAge, const PVariableHandleArray &variableHandles, const UaReadValueIds &nodesToRead, UaDataValues &results)
 Read function for internal use. More...
 
UaStatus write (Session *pSession, const UaWriteValues &nodesToWrite, UaStatusCodeArray &results)
 Write function for internal use. More...
 
UaStatus write (Session *pSession, const PVariableHandleArray &variableHandles, const UaWriteValues &nodesToWrite, UaStatusCodeArray &results)
 Write function for internal use. More...
 
UaStatus call (Session *pSession, const UaNodeId &objectId, const UaNodeId &methodId, const UaVariantArray &inputArguments, UaStatusCodeArray &inputArgumentResults, UaVariantArray &outputArguments)
 Internal function to call a method. More...
 
UaStatus createDataMonitoredItems (Session *pSession, DataMonitoredItemSpecArray &dataMonitoredItems)
 Internal function to create a list of data monitored items. More...
 
UaStatus createEventMonitoredItem (Session *pSession, const UaNodeId &objectToMonitor, EventCallback *pEventCallback, OpcUa_EventFilter *pEventFilter, OpcUa_UInt32 &monitoredItemId)
 Internal function to create an event monitored item. More...
 
void setEventManagerInvalid (OpcUa_UInt32 monitoredItemId, OpcUa_UInt32 eventManagerIndex)
 Internal function to inform the event monitored item about an invalidated EventManager. More...
 
UaStatus conditionRefresh (Session *pSession, OpcUa_UInt32 monitoredItemId)
 Internal function to request a condition refresh for the event monitored item. More...
 
UaStatus deleteMonitoredItems (Session *pSession, const UaUInt32Array &monitoredItemIds, UaStatusCodeArray &results)
 Internal function to delete a list of monitored items. More...
 

Protected Member Functions

virtual SessionManagercreateSessionManager ()
 Creates the SessionManager. More...
 
virtual NodeManagercreateNodeManagerNS1 (const UaString &sServerUri)
 Creates the NodeManagerNS1. More...
 

Detailed Description

Main management class of the server core module.

The class manages the central components of the server core module like NodeManagerRoot and SessionManager. The object is passed to all NodeManagers and modules during start up.

The class provides also an internal client API that can be used to retrieve information provided by the server. It is using the information already provided for OPC UA Clients. There are no changes required in the data integration modules implementing the interfaces like NodeManager and IOManager.

Member Function Documentation

UaStatus ServerManager::browse ( const UaNodeId startingNode,
const UaNodeId referenceTypeFilter,
ContinuationPointWrapper continuationPoint,
UaReferenceDescriptions references 
)

Browse function for internal use.

This method provides a simplified browse function for internal use. It uses the normal NodeManager::browse but hides the handling that is necessary for remote access from a client. It makes that sure that the internal browsing works, regardless of the way the different NodeManagers in the server are implemented.

// Starting node of browse
UaNodeId startingNode(OpcUaId_ObjectsFolder);
ContinuationPointWrapper continuationPoint;
UaNodeId referenceFilter(OpcUaId_HierarchicalReferences);
// Call internal browse, there are other overloads
UaStatus status = pServerManager->browse(
startingNode, referenceFilter, continuationPoint,
references);
if ( status.isGood() )
{
OpcUa_UInt32 i;
for ( i=0; i<references.length(); i++ )
{
// Process references here
}
// Handle continuation points
while ( continuationPoint.isContinuationPointSet() != OpcUa_False )
{
status = pServerManager->browse(
startingNode, referenceFilter, continuationPoint,
references);
if ( status.isGood() )
{
for ( i=0; i<references.length(); i++ )
{
// Process references here
}
}
else
{
break;
}
}
}

This version of the simplified browse is browsing forward and returns all node classes.

Returns
Status result code for the call.
Parameters
[in]startingNodeStarting node for the browse call
[in]referenceTypeFilterReference type filter to return only nodes referenced from the starting node with this reference type or a subtype
[in,out]continuationPointContinuation point for the browse. Indicates whether more results are available
[out]referencesList of browse results for the browsed node
UaStatus ServerManager::browse ( const UaNodeId startingNode,
OpcUa_Boolean  isInverse,
const UaNodeId referenceTypeFilter,
OpcUa_UInt32  nodeClassMask,
ContinuationPointWrapper continuationPoint,
UaReferenceDescriptions references 
)

Browse function for internal use.

This method provides a simplified browse function for internal use. It uses the normal NodeManager::browse but hides the handling that is necessary for remote access from a client. It makes sure that the internal browsing works, regardless of the way the different NodeManagers in the server are implemented.

Returns
Status result code for the call.
Parameters
[in]startingNodeStarting node for the browse call
[in]isInverseFlag indicating whether the browse is inverse (True) or forward (False)
[in]referenceTypeFilterReference type filter to return only nodes referenced from the starting node with this reference type or a subtype
[in]nodeClassMaskNode class filter mask identifing the node classes to include in the browse result Bit mask containing the following options:
OpcUa_NodeClass_Object = 1
OpcUa_NodeClass_Variable = 2
OpcUa_NodeClass_Method = 4
OpcUa_NodeClass_ObjectType = 8
OpcUa_NodeClass_VariableType = 16
OpcUa_NodeClass_ReferenceType = 32
OpcUa_NodeClass_DataType = 64
OpcUa_NodeClass_View = 128
If set to zero, all node classes are returned.
[in,out]continuationPointContinuation point for the browse. Indicates if more results are available
[out]referencesList of browse results for the browsed node
UaStatus ServerManager::browse ( Session pSession,
const UaNodeId startingNode,
ContinuationPointWrapper continuationPoint,
UaReferenceDescriptions references 
)

Browse function for internal use.

This method provides a simplified browse function for internal use. It uses the normal NodeManager::browse but hides the handling that is necessary for the remote access from a client. It makes sure that the internal browsing works, regardless of the way the different NodeManagers in the server are implemented.

This version of the simplified browse is browsing hierarchical references in forward direction and returns all node classes.

// Starting node of browse
UaNodeId startingNode(OpcUaId_ObjectsFolder);
Session* pInternalSession = pServerManager->createInternalSession("InternalBrowse", "en", NULL);
ContinuationPointWrapper continuationPoint;
// Call internal browse, there are other overloads
UaStatus status = pServerManager->browse(
pInternalSession, startingNode, continuationPoint,
references);
if ( status.isGood() )
{
OpcUa_UInt32 i;
for ( i=0; i<references.length(); i++ )
{
// Process references here
}
// Handle continuation points
while ( continuationPoint.isContinuationPointSet() != OpcUa_False )
{
status = pServerManager->browse(
pInternalSession, startingNode, OpcUa_False, referenceFilter, 0, continuationPoint,
references);
if ( status.isGood() )
{
for ( i=0; i<references.length(); i++ )
{
// Process references here
}
}
else
{
break;
}
}
}
// Keep the session if there are more browse operations
// or other internal client calls
pInternalSession->releaseReference();
Returns
Status result code for the call.
Parameters
[in]pSessionSession context for the browse call
[in]startingNodeStarting node for the browse call
[in,out]continuationPointContinuation point for the browse. Indicates whether more results are available
[out]referencesList of browse results for the browsed node
UaStatus ServerManager::browse ( Session pSession,
const UaNodeId startingNode,
OpcUa_Boolean  isInverse,
const UaNodeId referenceTypeFilter,
OpcUa_UInt32  nodeClassMask,
ContinuationPointWrapper continuationPoint,
UaReferenceDescriptions references 
)

Browse function for internal use.

This method provides a simplified browse function for internal use. It uses the normal NodeManager::browse but hides the handling that is necessary for the remote access from a client. It makes sure that the internal browsing works, regardless of the way the different NodeManagers in the server are implemented.

// Starting node of browse
UaNodeId startingNode(OpcUaId_ObjectsFolder);
Session* pInternalSession = pServerManager->createInternalSession("InternalBrowse", "en", NULL);
ContinuationPointWrapper continuationPoint;
UaNodeId referenceFilter(OpcUaId_HierarchicalReferences);
// Call internal browse, there are other overloads
UaStatus status = pServerManager->browse(
pInternalSession, startingNode, OpcUa_False, referenceFilter, 0, continuationPoint,
references);
if ( status.isGood() )
{
OpcUa_UInt32 i;
for ( i=0; i<references.length(); i++ )
{
// Process references here
}
// Handle continuation points
while ( continuationPoint.isContinuationPointSet() != OpcUa_False )
{
status = pServerManager->browse(
pInternalSession, startingNode, OpcUa_False, referenceFilter, 0, continuationPoint,
references);
if ( status.isGood() )
{
for ( i=0; i<references.length(); i++ )
{
// Process references here
}
}
else
{
break;
}
}
}
// Keep the session if there are more browse operations
// or other internal client calls
pInternalSession->releaseReference();
Returns
Status result code for the call.
Parameters
[in]pSessionSession context for the browse call
[in]startingNodeStarting node for the browse call
[in]isInverseFlag indicating whether the browse is inverse (True) or forward (False)
[in]referenceTypeFilterReference type filter to return only nodes referenced from the starting node with this reference type or a subtype
[in]nodeClassMaskNode class filter mask identifing the node classes to include in the browse result Bit mask containing the following options:
OpcUa_NodeClass_Object = 1
OpcUa_NodeClass_Variable = 2
OpcUa_NodeClass_Method = 4
OpcUa_NodeClass_ObjectType = 8
OpcUa_NodeClass_VariableType = 16
OpcUa_NodeClass_ReferenceType = 32
OpcUa_NodeClass_DataType = 64
OpcUa_NodeClass_View = 128
If set to zero, all node classes are returned.
[in,out]continuationPointContinuation point for the browse. Indicates whether more results are available
[out]referencesList of browse results for the browsed node
UaStatus ServerManager::call ( Session pSession,
const UaNodeId objectId,
const UaNodeId methodId,
const UaVariantArray inputArguments,
UaStatusCodeArray inputArgumentResults,
UaVariantArray outputArguments 
)

Internal function to call a method.

Returns
Status result code for the call.
Parameters
[in]pSessionSession context for the function call
[in]objectIdObject node for the call
[in]methodIdMethod node for the call
[in]inputArgumentsArray of input arguments
[out]inputArgumentResultsArray of input argument results
[out]outputArgumentsArray of output argumens
void ServerManager::changeServerState ( OpcUa_ServerState  newState)

Change the server state represented in the address space.

This method allows the application to change the server state if the state is not longer running or to change the state back to running after an error situation.

Parameters
[in]newStateNew server status
void ServerManager::changeServiceLevel ( OpcUa_Byte  serviceLevel,
OpcUa_Byte  changeMask 
)

Update the ServiceLevel property of the Server object.

Parameters
serviceLevelThe new service level to set.
changeMaskA mask indicating which bits of the service level should be set. If a bit is set to 1, the corresponding bit of serviceLevel is set in the server's serviceLevel. If a bit is set to 0, the corresponding bit in the server's serviceLevel will remain untouched.
UaStatus ServerManager::conditionRefresh ( Session pSession,
OpcUa_UInt32  monitoredItemId 
)

Internal function to request a condition refresh for the event monitored item.

Returns
Status result code for the call.
Parameters
[in]pSessionSession context for the function call
[in]monitoredItemIdId of the affected monitored item
UaStatus ServerManager::createDataMonitoredItems ( Session pSession,
DataMonitoredItemSpecArray dataMonitoredItems 
)

Internal function to create a list of data monitored items.

Returns
Status result code for the call.
Parameters
[in]pSessionSession context for the function call
[in,out]dataMonitoredItemsArray of DataMonitoredItemSpec objects containing the information for the creation in a data monitored item.
UaStatus ServerManager::createEventMonitoredItem ( Session pSession,
const UaNodeId objectToMonitor,
EventCallback pEventCallback,
OpcUa_EventFilter pEventFilter,
OpcUa_UInt32 &  monitoredItemId 
)

Internal function to create an event monitored item.

Returns
Status result code for the call.
Parameters
[in]pSessionSession context for the function call
[in]objectToMonitorObject node used as event notifier
[in]pEventCallbackEvent callback interface for the event monitored item. The implementation of this callback should never block.
[in]pEventFilterEvent filter for the monitored item
[out]monitoredItemIdId of the created monitored item
Session * ServerManager::createInternalSession ( const UaString sessionName,
const UaString localeId,
UaUserIdentityToken pUserIdentityToken 
)

Creates an internal session for a special user.

The default intenal session with root rights is available through getInternalSession().

The Session is a reference counted object. The caller must release the reference it gets by creating the session if the session is not longer needed.

Session* pInternalSession = pServerManager->createInternalSession("InternalSession", "en", NULL);
// Use session for different internal client calls
// Keep the session if there are frequent internal client calls
pInternalSession->releaseReference();
Returns
The new session. NULL if creation fails. The caller is responsible for releasing the Session if it is not longer needed.
Parameters
[in]sessionNameName of the session. This is mainly used in the session diagnostics
[in]localeIdLocale used for the session
[in]pUserIdentityTokenUser identity used for the session. NULL for anonymous.
NodeManager * ServerManager::createNodeManagerNS1 ( const UaString sServerUri)
protectedvirtual

Creates the NodeManagerNS1.

This virtual function can be overwritten by a class derived from ServerManager to create a class derived from NodeManagerNS1. An instance of the class derived from ServerManager can be passed to CoreModule::initialize() to force the CoreModule to use this instance instead of creating its own ServerManager.

SessionManager * ServerManager::createSessionManager ( )
protectedvirtual

Creates the SessionManager.

This virtual function can be overwritten by a class derived from ServerManager to create a class derived from SessionManager. An instance of the class derived from ServerManager can be passed to CoreModule::initialize() to force the CoreModule to use this instance instead of creating its own ServerManager.

UaStatus ServerManager::deleteMonitoredItems ( Session pSession,
const UaUInt32Array monitoredItemIds,
UaStatusCodeArray results 
)

Internal function to delete a list of monitored items.

Returns
Status result code for the call.
Parameters
[in]pSessionSession context for the function call
[in]monitoredItemIdsArray of Ids of the monitored items to delete
[out]resultsResult array for the monitored items to delete
OpcUa::HistoryServerCapabilitiesType * ServerManager::getHistoryServerCapabilities ( )

Returns the OPC UA HistoryServerCapabilities object.

The object is used to indicate the supported historical access features. The object will be created if it does not exist.

Returns
OPC UA HistoryServerCapabilities object.
Session * ServerManager::getInternalSession ( )

Returns the default internal Session object with root rights.

This Session can be used for all internal calls like read, write and browse where the user rights may be checked by the responsible handlers like NodeManager or IOManager. This session has full access to all functionality.

If the action must be limited to a certain user or group, another internal session must be created with createInternalSession().

The following code provides an example for getting access to the ServerManager from any place in your OPC UA server application:

Returns
Session object.
NodeManager * ServerManager::getNodeManagerNS1 ( )

Returns the node manager object responsible for namespace index 1 nodes.

Returns
Namespace index 1 node manager object.
NodeManager * ServerManager::getNodeManagerRoot ( )

Returns the root node manager object.

Returns
Root node manager object.
ServerConfig * ServerManager::getServerConfig ( )

Returns the server configuration object.

Returns
Server configuration object.
SessionManager * ServerManager::getSessionManager ( )

Returns the OPC UA Session manager object.

Returns
OPC UA Session manager object.
UaThreadPool * ServerManager::getThreadPool ( )

Returns the thread pool of the server core module.

Returns
Thread pool of the server core module.
UaStatus ServerManager::read ( Session pSession,
OpcUa_Double  maxAge,
const UaReadValueIds nodesToRead,
UaDataValues results 
)

Read function for internal use.

Returns
Status result code for the call.
Parameters
[in]pSessionSession context for the function call
[in]maxAgeThe maximum age of a cached value that can be returned to the caller
[in]nodesToReadArray of nodes and attributes to read
[out]resultsArray of read results
UaStatus ServerManager::read ( Session pSession,
OpcUa_Double  maxAge,
const PVariableHandleArray variableHandles,
const UaReadValueIds nodesToRead,
UaDataValues results 
)

Read function for internal use.

This overloaded version provides optimization for cyclic calls to Read by avoiding the repeated retrieval of the VariableHandle in each Read call. Instead, the VariableHandle should be looked up once in the responsible NodeManager. The returned VariableHandle can then be passed to this method in cyclic read calls.

Returns
Status result code for the call.
Parameters
[in]pSessionSession context for the function call
[in]maxAgeThe maximum age of a cached value that can be returned to the caller
[in]variableHandlesArray of variable handles indicating the node and attribute to read
[in]nodesToReadArray of NodeIds and AttributeId to read. The NodeId and AttributeId are provided as additional information to the IOManager but are not used in the generic code.
[out]resultsArray of read results
void ServerManager::registerDynamicEventManager ( EventManager pEventManager)

Inform the server manager about a new event manager added after server start-up.

EventManagers can be responsible for information requests from clients even if they are created after the client initiated the request. This happes especially if a client is interested in all events from the server and a new event manager is added. This method allows an EventManager to get informed about already created event subscriptions.

Parameters
[in]pEventManagerNew and dynamically added EventManager
void ServerManager::setEventManagerInvalid ( OpcUa_UInt32  monitoredItemId,
OpcUa_UInt32  eventManagerIndex 
)

Internal function to inform the event monitored item about an invalidated EventManager.

This information is provided through the EventCallback interface

Parameters
[in]monitoredItemIdId of the affected monitored item
[in]eventManagerIndexIndex of the invalid EventManager
UaStatus ServerManager::shutDown ( )

Shut down server manager.

Returns
Error code
OpcUa_UInt32 ServerManager::startServerShutDown ( OpcUa_Int32  secondsTillShutdown,
const UaLocalizedText shutdownReason 
)

Inform the server manager about the shutdown of the server.

Returns
Number of active client connections.
Parameters
[in]secondsTillShutdownSeconds till shutdown of the server
[in]shutdownReasonReason for the shutdown
OpcUa_UInt32 ServerManager::startServerShutDown ( OpcUa_Int32  secondsTillShutdown,
const UaLocalizedTextArray shutdownReason 
)

Inform the server manager about the shutdown of the server.

This is an overload to provide the shutdown reason as a list of localized text in different languages

Returns
Number of active client connections.
Parameters
[in]secondsTillShutdownSeconds till shutdown of the server
[in]shutdownReasonReason for the shutdown in different languages
UaStatus ServerManager::startUp ( ServerConfig pServerConfig)

Start up server manager.

Parameters
pServerConfigServer configuration object.
Returns
Error code
UaStatus ServerManager::write ( Session pSession,
const UaWriteValues nodesToWrite,
UaStatusCodeArray results 
)

Write function for internal use.

Returns
Status result code for the call.
Parameters
[in]pSessionSession context for the function call
[in]nodesToWriteArray of nodes, attributes and values to write
[out]resultsArray of write results
UaStatus ServerManager::write ( Session pSession,
const PVariableHandleArray variableHandles,
const UaWriteValues nodesToWrite,
UaStatusCodeArray results 
)

Write function for internal use.

This overloaded version provides optimization for cyclic calls to Write by avoiding the repeated retrieval of the VariableHandle in each Write call. Instead, the VariableHandle should be looked up once in the responsible NodeManager. The returned VariableHandle can then be passed to this method in cyclic write calls.

Returns
Status result code for the call.
Parameters
[in]pSessionSession context for the function call
[in]variableHandlesArray of variable handles indicating the node and attribute to write
[in]nodesToWriteArray of NodeIds, AttributeId and values to write. The NodeId and AttributeId are provided as additional information to the IOManager but are not used in the generic code.
[out]resultsArray of write results

The documentation for this class was generated from the following files: