C++ UA Server SDK  1.5.0.318
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages

Implementation of the interface IOManager operating on a generic address space node model. More...

#include <iomanageruanode.h>

Inherits IOManager.

Inherited by NodeManagerBase.

Public Member Functions

 IOManagerUaNode ()
 Creates an IOManagerUaNode instance initialized with default values. More...
 
virtual ~IOManagerUaNode ()
 Destroys the IOManagerUaNode object. More...
 
virtual UaStatus startUpIO (ServerManager *pServerManager)
 Starts and initalizes the IOManager. More...
 
virtual UaStatus shutDownIO ()
 Shut down IOManager.
 
virtual UaStatus readValues (const UaVariableArray &arrUaVariables, UaDataValueArray &arrDataValues)
 Reads the value attributes for a list of UaVariables. More...
 
virtual UaStatus writeValues (const UaVariableArray &arrUaVariables, const PDataValueArray &arrpDataValues, UaStatusCodeArray &arrStatusCodes)
 Writes the value attributes for a list of UaVariables. More...
 
virtual OpcUa_Boolean beforeSetAttributeValue (Session *pSession, UaNode *pNode, OpcUa_Int32 attributeId, const UaDataValue &dataValue, OpcUa_Boolean &checkWriteMask)
 Event that is called before the value of an attribute of a Node is set. More...
 
virtual void afterSetAttributeValue (Session *pSession, UaNode *pNode, OpcUa_Int32 attributeId, const UaDataValue &dataValue)
 Event that is called after the value of an attribute of a Node was updated. More...
 
virtual void afterGetAttributeValue (Session *pSession, UaNode *pNode, OpcUa_Int32 attributeId, UaDataValue &dataValue)
 Event that is called after the value of an attribute of a Node was read from the node. More...
 
virtual UaStatus beforeMonitorAttributeValue (Session *pSession, UaNode *pNode, OpcUa_Int32 attributeId, OpcUa_Boolean &returnErrorInCreate)
 Event that is called before a data monitored item is created. More...
 
virtual void variableCacheMonitoringChanged (UaVariableCache *pVariable, TransactionType transactionType)
 Event that is called after the monitoring of a cache variable was changed. More...
 
void setTimestampWriteSupport (OpcUa_Boolean isSupported)
 Method used to enable or disable support for writing timestamp. More...
 
void setStatusWriteSupport (OpcUa_Boolean isSupported)
 Method used to enable or disable support for writing status. More...
 
UaStatus beginTransaction (IOManagerCallback *, const ServiceContext &, OpcUa_UInt32, OpcUa_UInt32, OpcUa_Double, OpcUa_TimestampsToReturn, TransactionType, OpcUa_Handle &)
 Begin a IOManager transaction. More...
 
UaStatus beginStartMonitoring (OpcUa_Handle, OpcUa_UInt32, IOVariableCallback *, VariableHandle *, MonitoringContext &)
 Begin start monitoring of an item. More...
 
UaStatus beginModifyMonitoring (OpcUa_Handle, OpcUa_UInt32, OpcUa_UInt32, MonitoringContext &)
 Begin modify monitoring of an item. More...
 
UaStatus beginStopMonitoring (OpcUa_Handle, OpcUa_UInt32, OpcUa_UInt32)
 Begin stop monitoring of an item. More...
 
UaStatus beginRead (OpcUa_Handle, OpcUa_UInt32, VariableHandle *, OpcUa_ReadValueId *)
 Begin reading an attribute value of a node. More...
 
UaStatus beginWrite (OpcUa_Handle, OpcUa_UInt32, VariableHandle *, OpcUa_WriteValue *)
 Begin writing an attribute value for a node. More...
 
UaStatus finishTransaction (OpcUa_Handle)
 Finish a transaction. More...
 
- Public Member Functions inherited from IOManager
 IOManager ()
 Construction.
 
virtual ~IOManager ()
 Destruction.
 

Additional Inherited Members

- Public Types inherited from IOManager
enum  TransactionType {
  TransactionRead, TransactionWrite, TransactionMonitorBegin, TransactionMonitorModify,
  TransactionMonitorStop, TransactionInvalid
}
 TransactionType enumeration. More...
 

Detailed Description

Implementation of the interface IOManager operating on a generic address space node model.

Constructor & Destructor Documentation

IOManagerUaNode::IOManagerUaNode ( )

Creates an IOManagerUaNode instance initialized with default values.

IOManagerUaNode::~IOManagerUaNode ( )
virtual

Destroys the IOManagerUaNode object.

Member Function Documentation

void IOManagerUaNode::afterGetAttributeValue ( Session pSession,
UaNode pNode,
OpcUa_Int32  attributeId,
UaDataValue dataValue 
)
virtual

Event that is called after the value of an attribute of a Node was read from the node.

This method needs to be overwritten by a derived class to change the value returned to the client. This can be used to return different localized text values or to check if the client is allowed to read the value.

Parameters
pSession[in] Interface to the Session context for the attribute read.
pNode[in] Interface of the UaNode to read.
attributeId[in] Id of the attribute to read.
dataValue[in/out] Value for the attribute.
void IOManagerUaNode::afterSetAttributeValue ( Session pSession,
UaNode pNode,
OpcUa_Int32  attributeId,
const UaDataValue dataValue 
)
virtual

Event that is called after the value of an attribute of a Node was updated.

This method needs to be overwritten by a derived class to get informed about an attribute change.

Parameters
pSession[in] Interface to the Session context for the attribute write.
pNode[in] Interface of the updated UaNode.
attributeId[in] Id of the updated attribute.
dataValue[in] New value for the attribute.
UaStatus IOManagerUaNode::beforeMonitorAttributeValue ( Session pSession,
UaNode pNode,
OpcUa_Int32  attributeId,
OpcUa_Boolean &  returnErrorInCreate 
)
virtual

Event that is called before a data monitored item is created.

This method needs to be overwritten by a derived class to influence the creation of monitored items based on the user rights. This can be used to reject the creation of a monitored item based on the user rights. The OPC UA recommended behavior is to create the monitored item but to send a bad status in the initial data callback. This behavior can be controlled with the flag returnErrorInCreate.

Parameters
pSession[in] Interface to the Session context for the attribute read.
pNode[in] Interface of the UaNode to read.
attributeId[in] Id of the attribute to read.
returnErrorInCreate[out] Indicates in the error case if the error should be returned in CreateMonitoredItems or in the first data change notification. The recommended option is to return the error in the first data change notification.
Returns
OpcUa_Good if the monitored item should be created. Any bad status code like OpcUa_BadUserAccessDenied if the user is not allowed to subsribe for the attribute.
OpcUa_Boolean IOManagerUaNode::beforeSetAttributeValue ( Session pSession,
UaNode pNode,
OpcUa_Int32  attributeId,
const UaDataValue dataValue,
OpcUa_Boolean &  checkWriteMask 
)
virtual

Event that is called before the value of an attribute of a Node is set.

Allows to reject the writing of the attribute. This method needs to be overwritten by a derived class to influence the handling of the writing of the attribute

Parameters
pSession[in] Interface of the Session context for the attribute write.
pNode[in] Interface of the UaNode to update.
attributeId[in] Attribute id indicating the attribute to set.
dataValue[in] New value for the attribute.
checkWriteMask[out] Flag indicating if the write mask of the node attribute or the access level for the value attribute should be checked in UaNode::setAttributeValue.
Returns
OpcUa_True if the value should be written, OpcUa_False if not.
UaStatus IOManagerUaNode::beginModifyMonitoring ( OpcUa_Handle  hIOManagerContext,
OpcUa_UInt32  callbackHandle,
OpcUa_UInt32  hIOVariable,
MonitoringContext monitoringContext 
)
virtual

Begin modify monitoring of an item.

Is called by the SDK for each node in a UA ModifyMonitoredItems service call. It is expected that this method does not block for external communication with the underlying system. See also beginRead description for more details. The corresponding callback method is the finishModifyMonitoring method.

Parameters
hIOManagerContextIOManager handle for the transaction context. This handle is used to identify the transaction in the IOManager.
callbackHandleHandle for the node in the callback.
hIOVariableThe handle of the variable in the IOManager created with beginStartMonitoring. The handle was passed to the SDK in the callback finishStartMonitoring.
monitoringContextObject containing the requested settings for the monitored item like sampling interval or deadband. The object is only valid during this method is called
Returns
Error code

Implements IOManager.

UaStatus IOManagerUaNode::beginRead ( OpcUa_Handle  hIOManagerContext,
OpcUa_UInt32  callbackHandle,
VariableHandle pVariableHandle,
OpcUa_ReadValueId pReadValueId 
)
virtual

Begin reading an attribute value of a node.

Is called by the SDK for each node in a UA Read service call. It is expected that this method does not block for external communication with the underlying system. If the read can be done inside the local process memory, the read can be executed and the finishRead method can be called inside this method call. If the underlying system is able to queue the read for the node without blocking for external communication, the beginRead can queue the node in the underlying system. If the communication with the underlying system can block, the node must be stored in the context of the transaction and the communication with the underlying system must be started asynchronous in the finishTransaction method. The corresponding callback method is the finishRead method. The in parameters are valid until the last finishRead method is called for the transaction.

Parameters
hIOManagerContextIOManager handle for the transaction context. This handle is used to identify the transaction in the IOManager.
callbackHandleHandle for the node in the callback.
pVariableHandleVariable handle provided by the NodeManager::getVariableHandle. This object contains the information needed by the IOManager to identify the node to read in its context. The object is reference counted. The reference used by the SDK is released after finishTransaction is called. If the IOManager needs the VariableHandle of asynchronous handling, the IOManager must add its own reference as long as the VariableHandle is used.
pReadValueIdContext for the node to read. The context contains the IndexRange and the DataEncoding requested by the client. The other parameters of this context are already handled by the VariableHandle. The read context pointer is valid until the transaction is completely finished.
Returns
Error code

Implements IOManager.

UaStatus IOManagerUaNode::beginStartMonitoring ( OpcUa_Handle  hIOManagerContext,
OpcUa_UInt32  callbackHandle,
IOVariableCallback pIOVariableCallback,
VariableHandle pVariableHandle,
MonitoringContext monitoringContext 
)
virtual

Begin start monitoring of an item.

Is called by the SDK for each node in a UA CreateMonitoredItems service call if sampling is enabled or for service calls enabling the sampling for a monitored item. It is expected that this method does not block for external communication with the underlying system. See also beginRead description for more details. The corresponding callback method is the finishStartMonitoring method.

Parameters
hIOManagerContextIOManager handle for the transaction context. This handle is used to identify the transaction in the IOManager.
callbackHandleHandle for the node in the callback.
pIOVariableCallbackCallback interface used for data change callbacks to the MonitoredItem managed by the SDK. The callback interface is valid until the monitoring is stopped through beginStopMonitoring.
pVariableHandleVariable handle provided by the NodeManager::getVariableHandle. This object contains the information needed by the IOManager to identify the node to monitor in its context. The object is reference counted. The reference used by the SDK is released after finishTransaction is called. If the IOManager needs the VariableHandle of asynchronous handling, the IOManager must add its own reference as long as the VariableHandle is used.
monitoringContextObject containing the requested settings for the monitored item like sampling interval or deadband. The object is only valid during this method is called
Returns
Error code

Implements IOManager.

UaStatus IOManagerUaNode::beginStopMonitoring ( OpcUa_Handle  hIOManagerContext,
OpcUa_UInt32  callbackHandle,
OpcUa_UInt32  hIOVariable 
)
virtual

Begin stop monitoring of an item.

Is called by the SDK for each node in a UA DeleteMonitoredItems service call if sampling is enabled for the monitored item to delete or for service calls disabling the sampling for a monitored item. It is expected that this method does not block for external communication with the underlying system. See also beginRead description for more details. The corresponding callback method is the finishStopMonitoring method.

Parameters
hIOManagerContextIOManager handle for the transaction context. This handle is used to identify the transaction in the IOManager.
callbackHandleHandle for the node in the callback.
hIOVariableThe handle of the variable in the IOManager created with beginStartMonitoring. The handle was passed to the SDK in the callback finishStartMonitoring.
Returns
Error code

Implements IOManager.

UaStatus IOManagerUaNode::beginTransaction ( IOManagerCallback pCallback,
const ServiceContext serviceContext,
OpcUa_UInt32  hTransaction,
OpcUa_UInt32  totalItemCountHint,
OpcUa_Double  maxAge,
OpcUa_TimestampsToReturn  timestampsToReturn,
TransactionType  transactionType,
OpcUa_Handle &  hIOManagerContext 
)
virtual

Begin a IOManager transaction.

Is called by the SDK before the first begin method call for a transaction. This method must create a context in the IOManager for the transaction.

Parameters
pCallbackCallback interface used for the transaction. The IOManager must use this interface to finish the action for each passed node in the transaction. The callback interface pointer is valid until the transaction is completely finished.
serviceContextService context including the session context used for the UA service call.
hTransactionHandle for the transaction used by the SDK to identify the transaction in the callbacks.
totalItemCountHintA hint for the IOManager about the total number of nodes in the transaction. The IOManager may not be responsible for all nodes but he can use this hint if he wants to optimize memory allocation.
maxAgeMax age parameter used only in the Read service.
timestampsToReturnIndicates which timestamps should be returned in a Read or a Publish response. The possible enum values are: OpcUa_TimestampsToReturn_Source OpcUa_TimestampsToReturn_Server OpcUa_TimestampsToReturn_Both OpcUa_TimestampsToReturn_Neither
transactionTypeType of the transaction. The possible enum values are:
  • READ
  • WRITE
  • MONITOR_BEGIN
  • MONITOR_MODIFY
  • MONITOR_STOP
hIOManagerContextHandle to the context in the IOManager for the transaction. The handle is managed by the IOManager and must be valid until the transaction is completely finished. This handle is passed into the IOManager begin methods to identify the transaction context in the IOManager.
Returns
Error code

Implements IOManager.

UaStatus IOManagerUaNode::beginWrite ( OpcUa_Handle  hIOManagerContext,
OpcUa_UInt32  callbackHandle,
VariableHandle pVariableHandle,
OpcUa_WriteValue pWriteValue 
)
virtual

Begin writing an attribute value for a node.

Is called by the SDK for each node in a UA Write service call. It is expected that this method does not block for external communication with the underlying system. See also beginRead description for more details. The corresponding callback method is the finishWrite method.

OPC UA is not providing data type conversions on the server side. The client is responsible for converting the variable data type to the data type he needs for internally. The server must return OpcUa_BadTypeMismatch if the client is not writing the variable data type or a subtype of it. The only exception is an array of Byte. In this case the client is allowed to write a ByteString instead since environments like JAVA and .NET can not preserve the distinction between a ByteString and a one dimensional array of Byte.

Parameters
hIOManagerContextIOManager handle for the transaction context. This handle is used to identify the transaction in the IOManager.
callbackHandleHandle for the node in the callback. The in parameters are valid until the last finishRead method is called for the transaction.
pVariableHandleVariable handle provided by the NodeManager::getVariableHandle. This object contains the information needed by the IOManager to identify the node to write in its context. The object is reference counted. The reference used by the SDK is released after finishTransaction is called. If the IOManager needs the VariableHandle of asynchronous handling, the IOManager must add its own reference as long as the VariableHandle is used.
pWriteValueContext for the node to write. The context contains the IndexRange requested by the client. The NodeId and Attribute parameters of this context are already handled by the VariableHandle The write context pointer is valid until the transaction is completely finished.
Returns
Error code

Implements IOManager.

UaStatus IOManagerUaNode::finishTransaction ( OpcUa_Handle  hIOManagerContext)
virtual

Finish a transaction.

Is called by the SDK after the last begin method call for a transaction. If the nodes for the transaction are stored in the transaction context and the access to the underlying system is done in the finishTransaction, this access must be done asynchronous like in an own worker thread. It is expected that this method does not block for external communication with the underlying system. After finishing the communication with the underlying system, the corresponding finish callback methods of the interface IOManagerCallback can be called for each node in the transaction

Parameters
hIOManagerContextIOManager handle for the transaction context. This handle is used to identify the transaction to finish in the IOManager.
Returns
Error code

Implements IOManager.

UaStatus IOManagerUaNode::readValues ( const UaVariableArray arrUaVariables,
UaDataValueArray arrDataValues 
)
virtual

Reads the value attributes for a list of UaVariables.

This method needs to be overwritten by a derived class if the value attribute should be read not from cache but from an external data source.

This method is called for Read calls from OPC UA clients and for monitoring of Variables where the UaVariable::valueHandling is not set to UaVariable_Value_CacheIsSource.

This method will be called for monitored items even if the Variable node was removed from the NodeManager. Monitored items are created by clients and they stay valid even if the node they were created for was removed. Only the status of the monitored item must change to BadNodeIdUnknown in `* this case. The Variable will be invalidated during removal from address space but will stay in memory until all monitored items are reoved for it. When the Variable is made invalid, the user data is deleted. If the user data is not longer available for a Node, readValue shall return BadNodeIdInvalid in this case.

Parameters
arrUaVariablesAn array of UaVariable interface pointers used to indicate which variables should be read. The implementation of the interface needs to have the necessary information to access the data from the external source.
arrDataValuesAn array of UaDataValue classes used to return the read values.
Returns
Error code

Reimplemented in NodeManagerRoot, and NodeManagerNS1.

void IOManagerUaNode::setStatusWriteSupport ( OpcUa_Boolean  isSupported)

Method used to enable or disable support for writing status.

Parameters
isSupported[in] Flag indicating if writing of status should be supported.
void IOManagerUaNode::setTimestampWriteSupport ( OpcUa_Boolean  isSupported)

Method used to enable or disable support for writing timestamp.

Parameters
isSupported[in] Flag indicating if writing of timestamp should be supported.
UaStatus IOManagerUaNode::startUpIO ( ServerManager pServerManager)
virtual

Starts and initalizes the IOManager.

Parameters
pServerManagerInterface to the central ServerManager object.
void IOManagerUaNode::variableCacheMonitoringChanged ( UaVariableCache pVariable,
TransactionType  transactionType 
)
virtual

Event that is called after the monitoring of a cache variable was changed.

This method needs to be overwritten by a derived class to get informed about monitoring changes for a cache variable. This can be used to start or stop the data acquisition if the values in the cache are only update when the variable is monitored.

It is not allowed to block this method since it is called from the network thread

Parameters
pVariable[in] UaVariableCache that was changed. The class UaVariableCache provides information about the number of subscribed monitored items (UaVariableCache::signalCount) and the smallest requrested sampling interval (UaVariableCache::getMinSamplingInterval).
transactionType[in] Type of transaction. Could be MONITOR_BEGIN, MONITOR_MODIFY or MONITOR_STOP
UaStatus IOManagerUaNode::writeValues ( const UaVariableArray arrUaVariables,
const PDataValueArray arrpDataValues,
UaStatusCodeArray arrStatusCodes 
)
virtual

Writes the value attributes for a list of UaVariables.

This method needs to be overwritten by a derived class if the value attribute should be written to an external data source.

This method is called for Write calls from OPC UA clients for Variables where the UaVariable::valueHandling is not set to UaVariable_Value_CacheIsSource.

Parameters
arrUaVariablesAn array of UaVariable interface pointers used to indicate which variables should be written. The implementation of the interface needs to have the necessary information to update the data in the external source.
arrpDataValuesArray of pointers to OpcUa_DataValue structures containing the data to write.
arrStatusCodesAn array of OpcUa_StatusCode values used to indicate if the write succeeds on a single variable base.
Returns
Error code

Reimplemented in NodeManagerRoot.


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