com.prosysopc.ua.server
Class IoManager

java.lang.Object
  extended by com.prosysopc.ua.server.ServiceManagerBase
      extended by com.prosysopc.ua.server.IoManager
Direct Known Subclasses:
IoManagerUaNode

public class IoManager
extends ServiceManagerBase

A base class for IO Manager implementations. Use this as a base to your custom IO Manager, if you do not wish to use UaNodes. If you use UaNodes, you had normally better simply use the IoManagerUaNode or inherit from it.

The base implementation defines the default constructor which requires a NodeManager, which the IO Manager will use to find the nodes that the operations refer to.

By default the operations just call the respective methods in IoManagerListeners. Node-specific listeners can be added with addNodeListener(org.opcfoundation.ua.builtintypes.NodeId, com.prosysopc.ua.server.io.UaNodeIoListener).


Constructor Summary
IoManager(NodeManager nodeManager)
          Default constructor.
 
Method Summary
 void addListeners(IoManagerListener... listeners)
          Add listeners to the IoManagerListenerChain.
 void addNodeListener(org.opcfoundation.ua.builtintypes.NodeId nodeId, UaNodeIoListener listener)
          Add UaNodeIoListener to the NodeIoManagerListener.
static void applyIndexRangeToReadValue(org.opcfoundation.ua.builtintypes.DataValue dataValue, org.opcfoundation.ua.utils.NumericRange indexRange)
          "Cuts" the specified indexRange out of the provided dataValue.
protected static Object applyIndexRangeToReadValue(Object value, org.opcfoundation.ua.utils.NumericRange indexRange, int d)
           
static org.opcfoundation.ua.builtintypes.DataValue applyIndexRangeToWriteValue(org.opcfoundation.ua.builtintypes.DataValue currentValue, org.opcfoundation.ua.builtintypes.DataValue newValue, org.opcfoundation.ua.utils.NumericRange indexRange)
          Writes the newValue to currentValue in the location specified by the indexRange.
 org.opcfoundation.ua.builtintypes.Variant autoConvert(org.opcfoundation.ua.builtintypes.Variant v, org.opcfoundation.ua.builtintypes.NodeId dataTypeId)
          Method for converting UA ByteString DataType to Java UnsignedByte[] type.
protected  Object beginRead(ServiceContext serviceContext, org.opcfoundation.ua.core.ReadValueId[] nodesToRead, org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn, org.opcfoundation.ua.builtintypes.DateTime minTimestamp, org.opcfoundation.ua.builtintypes.DataValue[] results, org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnosticInfos)
          Called to notify that a Read is beginning.
protected  Object beginWrite(ServiceContext serviceContext, org.opcfoundation.ua.core.WriteValue[] nodesToWrite, org.opcfoundation.ua.builtintypes.StatusCode[] results, org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnosticInfos)
          Called to notify that a Write is beginning.
protected  void checkAccessLevel(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaVariable variable, org.opcfoundation.ua.core.AccessLevel accessLevel)
          Validate that the node enables access for a certain accessLevel.
protected  void checkDataType(org.opcfoundation.ua.builtintypes.NodeId nodeId, UaValueNode valueNode, org.opcfoundation.ua.builtintypes.DataValue dataValue)
           
protected static void checkIndexRange(Object value, org.opcfoundation.ua.utils.NumericRange indexRange, int dimension)
           
protected  void checkSupportsAttribute(ServiceContext serviceContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaNode node, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
           
protected  void checkWriteMask(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaNode node, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
           
protected  void endRead(ServiceContext serviceContext, Object object, org.opcfoundation.ua.core.ReadValueId[] nodesToRead, org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn, org.opcfoundation.ua.builtintypes.DateTime minTimestamp, org.opcfoundation.ua.builtintypes.DataValue[] results, org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnosticInfos)
          Called to notify the end of a Read.
protected  void endWrite(ServiceContext serviceContext, Object object, org.opcfoundation.ua.core.WriteValue[] nodesToWrite, org.opcfoundation.ua.builtintypes.StatusCode[] results, org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnosticInfos)
          Called to notify the end of a Write.
protected  EnumSet<org.opcfoundation.ua.core.AccessLevel> getAccessLevel(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaVariable variable)
           
 IoManagerListener getDefaultListener()
          Get the default IoManagerListener.
protected  boolean getExecutable(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaMethod node)
           
 IoManagerListener getNodeListener()
          Get NodeIoManagerListener.
 NodeManager getNodeManager()
           
protected  EnumSet<org.opcfoundation.ua.core.AccessLevel> getUserAccessLevel(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaVariable node)
           
protected  boolean getUserExecutable(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaMethod node)
           
protected  EnumSet<WriteAccess> getUserWriteMask(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaNode node)
           
protected  org.opcfoundation.ua.builtintypes.NodeId getVariableDataType(org.opcfoundation.ua.builtintypes.NodeId nodeId, UaValueNode valueNode)
           
protected  EnumSet<WriteAccess> getWriteMask(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaNode node)
           
protected  void initializeMonitoredDataItem(ServiceContext serviceContext, MonitoredDataItem monitoredItem, org.opcfoundation.ua.builtintypes.DataValue dataValue)
          Get the initial value for a new MonitoredDataItem.
 org.opcfoundation.ua.builtintypes.DataValue readAttribute(org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.utils.NumericRange indexRange, org.opcfoundation.ua.builtintypes.DateTime minTimestamp)
          Read attribute directly from this IoManager
protected  void readAttribute(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.utils.NumericRange indexRange, org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn, org.opcfoundation.ua.builtintypes.DateTime minTimestamp, org.opcfoundation.ua.builtintypes.DataValue dataValue)
          Read the value of a single node attribute.
protected  void readNonValue(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaNode node, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.builtintypes.DataValue dataValue)
          Read the value of a node attribute, except for the Value of a variable node.
protected  void readValue(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaValueNode variable, org.opcfoundation.ua.utils.NumericRange indexRange, org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn, org.opcfoundation.ua.builtintypes.DateTime minTimestamp, org.opcfoundation.ua.builtintypes.DataValue dataValue)
          Read the Value attribute of a Variable node.
 void removeListeners(IoManagerListener... listeners)
          Remove given listeners from the IoManagerListenerChain.
 void setListeners(IoManagerListener... listeners)
          Set the listeners of the IoManagerListenerChain.
protected static void validateIndexRange(int dim, int length, org.opcfoundation.ua.utils.NumericRange indexRange)
           
 void writeAttribute(org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.utils.NumericRange indexRange, org.opcfoundation.ua.builtintypes.DataValue dataValue)
          Write the value of a single node attribute.
protected  boolean writeAttribute(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.utils.NumericRange indexRange, org.opcfoundation.ua.builtintypes.DataValue dataValue)
          Write the value of a single node attribute.
protected  boolean writeNonValue(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaNode node, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.builtintypes.DataValue dataValue)
          Write the value of a single node attribute, except for the Value of a variable node.
protected  boolean writeValue(ServiceContext serviceContext, Object operationContext, org.opcfoundation.ua.builtintypes.NodeId nodeId, UaValueNode valueNode, org.opcfoundation.ua.utils.NumericRange indexRange, org.opcfoundation.ua.builtintypes.DataValue dataValue)
          Write the Value attribute of a Variable node.
 
Methods inherited from class com.prosysopc.ua.server.ServiceManagerBase
arrayDimensionsMatch, checkIsMethod, checkIsValueNode, checkIsVariable, checkIsVariableOrVariableType, dataTypeEquals, getNode, getNode, getNode, getNode, getNodeManagerTable, getServer, getSubscriptionManager, isValueNode, isVariable, listenerError, requireUaNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IoManager

public IoManager(NodeManager nodeManager)
Default constructor.

Parameters:
nodeManager - the NodeManager to which this IO Manager is attached to.
Method Detail

applyIndexRangeToReadValue

public static void applyIndexRangeToReadValue(org.opcfoundation.ua.builtintypes.DataValue dataValue,
                                              org.opcfoundation.ua.utils.NumericRange indexRange)
                                       throws StatusException
"Cuts" the specified indexRange out of the provided dataValue.

Parameters:
dataValue - the original value, which is modified by the method, unless the status is bad, in which case the range is ignored
indexRange - the index range to cut out of the value: if null or empty, the method will not modify the value
Throws:
StatusException - Bad_IndexRangeNoData, if the index range cannot be applied to the value

applyIndexRangeToWriteValue

public static org.opcfoundation.ua.builtintypes.DataValue applyIndexRangeToWriteValue(org.opcfoundation.ua.builtintypes.DataValue currentValue,
                                                                                      org.opcfoundation.ua.builtintypes.DataValue newValue,
                                                                                      org.opcfoundation.ua.utils.NumericRange indexRange)
                                                                               throws StatusException
Writes the newValue to currentValue in the location specified by the indexRange.

Parameters:
currentValue - the current value to modify.
newValue - the new value to write: if not a string or array, the method will return the value unmodified
indexRange - the range where to write the newValue: if null or empty, the method will return the value unmodified
Returns:
the modified value
Throws:
StatusException - Bad_IndexRangeNoData if the range cannot be applied to currentValue

applyIndexRangeToReadValue

protected static Object applyIndexRangeToReadValue(Object value,
                                                   org.opcfoundation.ua.utils.NumericRange indexRange,
                                                   int d)
                                            throws StatusException
Throws:
StatusException

checkIndexRange

protected static void checkIndexRange(Object value,
                                      org.opcfoundation.ua.utils.NumericRange indexRange,
                                      int dimension)
                               throws StatusException
Throws:
StatusException

validateIndexRange

protected static void validateIndexRange(int dim,
                                         int length,
                                         org.opcfoundation.ua.utils.NumericRange indexRange)
                                  throws StatusException
Throws:
StatusException

addListeners

public void addListeners(IoManagerListener... listeners)
Add listeners to the IoManagerListenerChain.


addNodeListener

public void addNodeListener(org.opcfoundation.ua.builtintypes.NodeId nodeId,
                            UaNodeIoListener listener)
Add UaNodeIoListener to the NodeIoManagerListener.


autoConvert

public final org.opcfoundation.ua.builtintypes.Variant autoConvert(org.opcfoundation.ua.builtintypes.Variant v,
                                                                   org.opcfoundation.ua.builtintypes.NodeId dataTypeId)
Method for converting UA ByteString DataType to Java UnsignedByte[] type.

Parameters:
dv -
dataTypeId -
Returns:
the converted value, or original if no conversion is needed

getDefaultListener

public IoManagerListener getDefaultListener()
Get the default IoManagerListener. This should be the last listener in the IoManagerListenerChain to provide default return values.


getNodeListener

public IoManagerListener getNodeListener()
Get NodeIoManagerListener.


getNodeManager

public NodeManager getNodeManager()
Returns:
the nodeManager which the IoManager is using

readAttribute

public org.opcfoundation.ua.builtintypes.DataValue readAttribute(org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                                                 org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                                                                 org.opcfoundation.ua.utils.NumericRange indexRange,
                                                                 org.opcfoundation.ua.builtintypes.DateTime minTimestamp)
                                                          throws StatusException
Read attribute directly from this IoManager

Parameters:
nodeId - The node to read.
attributeId - The attribute to read.
indexRange - The requested index range for an array value. May be null.
minTimestamp - Minimum value of the ServerTimestamp of the value to be read. If there is no value available that is new enough already available (in the server cache), the server should attempt to read a new value from the actual data source, instead of using the cached value. If a new value cannot be read, the best value available is returned. If minTimestamp == DateTime.MAX_VALUE a new value should be read from the source.
Returns:
The data value of the attribute
Throws:
StatusException - If the read fails. Expected result codes: Bad_NodeIdInvalid, Bad_NodeIdUnknown, Bad_AttributeIdInvalid, Bad_IndexRangeInvalid, Bad_IndexRangeNoData, Bad_NotReadable, Bad_UserAccessDenied

removeListeners

public void removeListeners(IoManagerListener... listeners)
Remove given listeners from the IoManagerListenerChain.


setListeners

public void setListeners(IoManagerListener... listeners)
Set the listeners of the IoManagerListenerChain. Typically the last one is the default getDefaultListener(). Node-specific listener getNodeListener() and type-specific listener IoManagerUaNode.getTypeListener() can be used too.


writeAttribute

public void writeAttribute(org.opcfoundation.ua.builtintypes.NodeId nodeId,
                           org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                           org.opcfoundation.ua.utils.NumericRange indexRange,
                           org.opcfoundation.ua.builtintypes.DataValue dataValue)
                    throws StatusException
Write the value of a single node attribute.

Parameters:
nodeId - The node to write.
attributeId - The attribute to write.
indexRange - The index range to set for an array value. May be null.
dataValue - The data value to write.
Throws:
StatusException - If the write fails. Expected result codes: Bad_NodeIdInvalid, Bad_NodeIdUnknown, Bad_AttributeIdInvalid, Bad_IndexRangeInvalid, Bad_IndexRangeNoData, Bad_DataEncodingInvalid, Bad_DataEncodingUnsupported, Bad_NotWriteable, Bad_UserAccessDenied, Bad_TypeMismatch

beginRead

protected Object beginRead(ServiceContext serviceContext,
                           org.opcfoundation.ua.core.ReadValueId[] nodesToRead,
                           org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn,
                           org.opcfoundation.ua.builtintypes.DateTime minTimestamp,
                           org.opcfoundation.ua.builtintypes.DataValue[] results,
                           org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnosticInfos)
                    throws ServiceException
Called to notify that a Read is beginning. You can prepare a context object corresponding to the specified nodesToRead. The results are typically handled in the readValue(com.prosysopc.ua.server.ServiceContext, java.lang.Object, org.opcfoundation.ua.builtintypes.NodeId, com.prosysopc.ua.nodes.UaValueNode, org.opcfoundation.ua.utils.NumericRange, org.opcfoundation.ua.core.TimestampsToReturn, org.opcfoundation.ua.builtintypes.DateTime, org.opcfoundation.ua.builtintypes.DataValue) and readNonValue(com.prosysopc.ua.server.ServiceContext, java.lang.Object, org.opcfoundation.ua.builtintypes.NodeId, com.prosysopc.ua.nodes.UaNode, org.opcfoundation.ua.builtintypes.UnsignedInteger, org.opcfoundation.ua.builtintypes.DataValue) handlers. Alternatively, you may define all the results here.

If you return a result object, it will be provided in endRead(com.prosysopc.ua.server.ServiceContext, java.lang.Object, org.opcfoundation.ua.core.ReadValueId[], org.opcfoundation.ua.core.TimestampsToReturn, org.opcfoundation.ua.builtintypes.DateTime, org.opcfoundation.ua.builtintypes.DataValue[], org.opcfoundation.ua.builtintypes.DiagnosticInfo[]), where you can dispose it.

Parameters:
serviceContext - the client service call context
nodesToRead - the nodes to be read. Note: The call may contain read requests for several node managers, so if you handle the nodes here, check the namespace of the requested items.
timestampsToReturn - defines whether Server, Source or Both timestamps should be returned with every value. Neither is not a valid value (checked already before calling the method)
minTimestamp - Minimum value of the ServerTimestamp of the value to be read. If there is no value available that is new enough already available (in the server cache), the server should attempt to read a new value from the actual data source, instead of using the cached value. If a new value cannot be read, the best value available is returned. If minTimestamp == DateTime.MAX_VALUE a new value should be read from the source.
results - the array of results, which you may fill here or later in the specific read methods
diagnosticInfos - possible error diagnostics
Returns:
a handle to your context object. Return null, if you do not need to refer to the context later on.
Throws:
ServiceException - if you need to return a service call error

beginWrite

protected Object beginWrite(ServiceContext serviceContext,
                            org.opcfoundation.ua.core.WriteValue[] nodesToWrite,
                            org.opcfoundation.ua.builtintypes.StatusCode[] results,
                            org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnosticInfos)
                     throws ServiceException
Called to notify that a Write is beginning. You can prepare a context object corresponding to the specified nodesToWrite. The results are typically handled in the writeValue(com.prosysopc.ua.server.ServiceContext, java.lang.Object, org.opcfoundation.ua.builtintypes.NodeId, com.prosysopc.ua.nodes.UaValueNode, org.opcfoundation.ua.utils.NumericRange, org.opcfoundation.ua.builtintypes.DataValue) and writeNonValue(com.prosysopc.ua.server.ServiceContext, java.lang.Object, org.opcfoundation.ua.builtintypes.NodeId, com.prosysopc.ua.nodes.UaNode, org.opcfoundation.ua.builtintypes.UnsignedInteger, org.opcfoundation.ua.builtintypes.DataValue) handlers. Alternatively, you may define all the results here and ignore them in the specific methods.

If you return a result object, it will be provided in endWrite(com.prosysopc.ua.server.ServiceContext, java.lang.Object, org.opcfoundation.ua.core.WriteValue[], org.opcfoundation.ua.builtintypes.StatusCode[], org.opcfoundation.ua.builtintypes.DiagnosticInfo[]), where you can dispose it.

Parameters:
serviceContext - the client service call context
nodesToWrite - the nodes to be read. Note: The call may contain read requests for several node managers, so if you handle the nodes here, check the namespace of the requested items.
results - the array of results, which you may fill here or later in the specific write methods
diagnosticInfos - possible error diagnostics
Returns:
a handle to your context object. Return null, if you do not need to refer to the context later on.
Throws:
ServiceException - if you need to return a service call error

checkAccessLevel

protected void checkAccessLevel(ServiceContext serviceContext,
                                Object operationContext,
                                org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                UaVariable variable,
                                org.opcfoundation.ua.core.AccessLevel accessLevel)
                         throws StatusException
Validate that the node enables access for a certain accessLevel. Will check both AccessLevel and UserAccessLevel.

Parameters:
serviceContext -
nodeId -
variable -
accessLevel -
Throws:
StatusException

checkDataType

protected void checkDataType(org.opcfoundation.ua.builtintypes.NodeId nodeId,
                             UaValueNode valueNode,
                             org.opcfoundation.ua.builtintypes.DataValue dataValue)
                      throws StatusException
Parameters:
nodeId -
valueNode -
dataValue -
Throws:
StatusException

checkSupportsAttribute

protected void checkSupportsAttribute(ServiceContext serviceContext,
                                      org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                      UaNode node,
                                      org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
                               throws StatusException
Parameters:
serviceContext -
nodeId -
node -
attributeId -
Throws:
StatusException

checkWriteMask

protected void checkWriteMask(ServiceContext serviceContext,
                              Object operationContext,
                              org.opcfoundation.ua.builtintypes.NodeId nodeId,
                              UaNode node,
                              org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
                       throws StatusException
Parameters:
serviceContext -
operationContext -
nodeId -
node -
Throws:
StatusException

endRead

protected void endRead(ServiceContext serviceContext,
                       Object object,
                       org.opcfoundation.ua.core.ReadValueId[] nodesToRead,
                       org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn,
                       org.opcfoundation.ua.builtintypes.DateTime minTimestamp,
                       org.opcfoundation.ua.builtintypes.DataValue[] results,
                       org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnosticInfos)
                throws ServiceException
Called to notify the end of a Read. You can finalize the context prepared in beginRead(com.prosysopc.ua.server.ServiceContext, org.opcfoundation.ua.core.ReadValueId[], org.opcfoundation.ua.core.TimestampsToReturn, org.opcfoundation.ua.builtintypes.DateTime, org.opcfoundation.ua.builtintypes.DataValue[], org.opcfoundation.ua.builtintypes.DiagnosticInfo[]) here.

Parameters:
serviceContext - the client service call context
nodesToRead - the nodes to be read
timestampsToReturn - defines whether Server, Source or Both timestamps should be returned with every value. Neither is not a valid value (checked already before calling the method)
minTimestamp - Minimum value of the ServerTimestamp of the value to be read. If there is no value available that is new enough already available (in the server cache), the server should attempt to read a new value from the actual data source, instead of using the cached value. If a new value cannot be read, the best value available is returned. If minTimestamp == DateTime.MAX_VALUE a new value should be read from the source.
results - the array of results
diagnosticInfos - possible error diagnostics
Throws:
ServiceException - if you need to return a service call error

endWrite

protected void endWrite(ServiceContext serviceContext,
                        Object object,
                        org.opcfoundation.ua.core.WriteValue[] nodesToWrite,
                        org.opcfoundation.ua.builtintypes.StatusCode[] results,
                        org.opcfoundation.ua.builtintypes.DiagnosticInfo[] diagnosticInfos)
                 throws ServiceException
Called to notify the end of a Write. You can finalize the context prepared in beginWrite(com.prosysopc.ua.server.ServiceContext, org.opcfoundation.ua.core.WriteValue[], org.opcfoundation.ua.builtintypes.StatusCode[], org.opcfoundation.ua.builtintypes.DiagnosticInfo[]) here.

Parameters:
serviceContext - the client service call context
nodesToWrite - the nodes to be written
results - the array of results
diagnosticInfos - possible error diagnostics
Throws:
ServiceException - if you need to return a service call error

getAccessLevel

protected EnumSet<org.opcfoundation.ua.core.AccessLevel> getAccessLevel(ServiceContext serviceContext,
                                                                        Object operationContext,
                                                                        org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                                                        UaVariable variable)
                                                                 throws StatusException
Parameters:
variable -
nodeId -
serviceContext -
operationContext -
Returns:
Throws:
StatusException

getExecutable

protected boolean getExecutable(ServiceContext serviceContext,
                                Object operationContext,
                                org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                UaMethod node)
                         throws StatusException
Parameters:
serviceContext -
operationContext -
nodeId -
node -
Returns:
Throws:
StatusException

getUserAccessLevel

protected EnumSet<org.opcfoundation.ua.core.AccessLevel> getUserAccessLevel(ServiceContext serviceContext,
                                                                            Object operationContext,
                                                                            org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                                                            UaVariable node)
Parameters:
serviceContext -
operationContext -
nodeId -
node -
Returns:

getUserExecutable

protected boolean getUserExecutable(ServiceContext serviceContext,
                                    Object operationContext,
                                    org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                    UaMethod node)
Parameters:
serviceContext -
operationContext -
nodeId -
node -
Returns:

getUserWriteMask

protected EnumSet<WriteAccess> getUserWriteMask(ServiceContext serviceContext,
                                                Object operationContext,
                                                org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                                UaNode node)
Parameters:
serviceContext -
operationContext -
nodeId -
node -
Returns:

getVariableDataType

protected org.opcfoundation.ua.builtintypes.NodeId getVariableDataType(org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                                                       UaValueNode valueNode)
                                                                throws StatusException
Parameters:
nodeId -
valueNode -
valueNode -
Returns:
Throws:
StatusException

getWriteMask

protected EnumSet<WriteAccess> getWriteMask(ServiceContext serviceContext,
                                            Object operationContext,
                                            org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                            UaNode node)
                                     throws StatusException
Parameters:
serviceContext -
operationContext -
nodeId -
node -
Returns:
Throws:
StatusException

initializeMonitoredDataItem

protected void initializeMonitoredDataItem(ServiceContext serviceContext,
                                           MonitoredDataItem monitoredItem,
                                           org.opcfoundation.ua.builtintypes.DataValue dataValue)
                                    throws StatusException
Get the initial value for a new MonitoredDataItem. By default the value is fetched from readAttribute, but you may override it as necessary.

The initial value is required for CreateMonitoredItem, ModifyMonitoredItem or TransferSubscription.

Parameters:
serviceContext - The serviceContext of the client connection used to call the CreateMonitoredItem, ModifyMonitoredItem or TransferSubscription service that initiates the call. Note that the RequestHeader part of the ServiceContext may be set to null in the object.
monitoredItem - The new monitoredItem that needs the initial value
dataValue - The value that should be initialized to the initial value of the item. The value is by default Bad_WaitingForInitialData, unless changed here.
Throws:
StatusException - If the value is not available or may not be read due to access level restrictions, for example.

readAttribute

protected void readAttribute(ServiceContext serviceContext,
                             Object operationContext,
                             org.opcfoundation.ua.builtintypes.NodeId nodeId,
                             org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                             org.opcfoundation.ua.utils.NumericRange indexRange,
                             org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn,
                             org.opcfoundation.ua.builtintypes.DateTime minTimestamp,
                             org.opcfoundation.ua.builtintypes.DataValue dataValue)
                      throws StatusException
Read the value of a single node attribute.

If the Value attribute is to be read, the method uses #checkAccessLevel(ServiceContext, NodeId, UaVariable, AccessLevel) to validate that the user has read access to the value. If the read is acceptable, it will call #readValue(ServiceContext, NodeId, UaVariable, NumericRange, TimestampsToReturn, DateTime, DataValue) to do the read and finally, it will trigger the onRead event in the listener.

For other attributes, #readNonValue(ServiceContext, NodeId, UaNode, UnsignedInteger, DataValue) is used to read the attribute value, except for the User-attributes for which #getUserAccessLevel(ServiceContext, NodeId, UaVariable), #getUserExecutable(ServiceContext, NodeId, UaMethod) or #getUserWriteMask(ServiceContext, NodeId, UaNode) are used, respectively, to define the correct value. By default, these methods just ask the value from the listener.

Typically, you will just need to override readValue and readNonValue to create your custom IoManager. If you use IoManagerUaNode, it will simply read the attributes from the node objects, by default.

Parameters:
serviceContext - The serviceContext of the client connection used to call this service.
operationContext - the possible operationContext prepared in beginRead(com.prosysopc.ua.server.ServiceContext, org.opcfoundation.ua.core.ReadValueId[], org.opcfoundation.ua.core.TimestampsToReturn, org.opcfoundation.ua.builtintypes.DateTime, org.opcfoundation.ua.builtintypes.DataValue[], org.opcfoundation.ua.builtintypes.DiagnosticInfo[])
nodeId - The node to read.
attributeId - The attribute to read.
indexRange - The requested index range for an array value. May be null.
timestampsToReturn - Which timestamps were requested by the client.
minTimestamp - Minimum value of the ServerTimestamp of the value to be read. If there is no value available that is new enough already available (in the server cache), the server should attempt to read a new value from the actual data source, instead of using the cached value. If a new value cannot be read, the best value available is returned. If minTimestamp == DateTime.MAX_VALUE a new value should be read from the source.
dataValue - The data value to return. Set Value, and for Value attribute also StatusCode and the Timestamps.
Throws:
StatusException - If the read fails. Expected result codes: Bad_NodeIdInvalid, Bad_NodeIdUnknown, Bad_AttributeIdInvalid, Bad_IndexRangeInvalid, Bad_IndexRangeNoData, Bad_NotReadable, Bad_UserAccessDenied

readNonValue

protected void readNonValue(ServiceContext serviceContext,
                            Object operationContext,
                            org.opcfoundation.ua.builtintypes.NodeId nodeId,
                            UaNode node,
                            org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                            org.opcfoundation.ua.builtintypes.DataValue dataValue)
                     throws StatusException
Read the value of a node attribute, except for the Value of a variable node.

Parameters:
serviceContext - The serviceContext of the client connection used to call this service.
operationContext - the possible operationContext prepared in beginRead(com.prosysopc.ua.server.ServiceContext, org.opcfoundation.ua.core.ReadValueId[], org.opcfoundation.ua.core.TimestampsToReturn, org.opcfoundation.ua.builtintypes.DateTime, org.opcfoundation.ua.builtintypes.DataValue[], org.opcfoundation.ua.builtintypes.DiagnosticInfo[])
nodeId - The node to read.
node - The node object to read. If the node is not available this may be null.
attributeId - The attribute to read.
dataValue - The data value to return. You only need to set Value of the DataValue.
Throws:
StatusException - If the read fails. Expected result codes: Bad_NodeIdInvalid, Bad_NodeIdUnknown, Bad_AttributeIdInvalid, Bad_NotReadable, Bad_UserAccessDenied

readValue

protected void readValue(ServiceContext serviceContext,
                         Object operationContext,
                         org.opcfoundation.ua.builtintypes.NodeId nodeId,
                         UaValueNode variable,
                         org.opcfoundation.ua.utils.NumericRange indexRange,
                         org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn,
                         org.opcfoundation.ua.builtintypes.DateTime minTimestamp,
                         org.opcfoundation.ua.builtintypes.DataValue dataValue)
                  throws StatusException
Read the Value attribute of a Variable node.

Parameters:
serviceContext - The serviceContext of the client connection used to call this service.
operationContext - the possible operationContext prepared in beginRead(com.prosysopc.ua.server.ServiceContext, org.opcfoundation.ua.core.ReadValueId[], org.opcfoundation.ua.core.TimestampsToReturn, org.opcfoundation.ua.builtintypes.DateTime, org.opcfoundation.ua.builtintypes.DataValue[], org.opcfoundation.ua.builtintypes.DiagnosticInfo[])
nodeId - The node to read.
variable - The node object to read. If the node is not available this may be null.
indexRange - The requested index range for an array value. May be null.
timestampsToReturn - Which timestamps were requested by the client.
minTimestamp - Minimum value of the ServerTimestamp of the value to be read. If there is no value available that is new enough already available (in the server cache), the server should attempt to read a new value from the actual data source, instead of using the cached value. If a new value cannot be read, the best value available is returned. If minTimestamp == DateTime.MAX_VALUE a new value should be read from the source.
dataValue - The data value to return. Set Value, and for Value attribute also StatusCode and the Timestamps.
Throws:
StatusException - If the read fails. Expected result codes: Bad_NodeIdInvalid, Bad_NodeIdUnknown, Bad_IndexRangeInvalid, Bad_IndexRangeNoData, Bad_NotReadable, Bad_UserAccessDenied

writeAttribute

protected boolean writeAttribute(ServiceContext serviceContext,
                                 Object operationContext,
                                 org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                 org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                                 org.opcfoundation.ua.utils.NumericRange indexRange,
                                 org.opcfoundation.ua.builtintypes.DataValue dataValue)
                          throws StatusException
Write the value of a single node attribute.

The method uses #checkAccessLevel(ServiceContext, NodeId, UaVariable, AccessLevel) , checkSupportsAttribute(ServiceContext, NodeId, UaNode, UnsignedInteger) and #checkWriteMask(ServiceContext, NodeId, UaNode, UnsignedInteger) methods to validate if write is accepted. Override these methods, instead of this method, to provide your custom checks.

If write is acceptable, it will also notify the listener about the write. Unless the listener cancels the write, it will finally call #writeValue(ServiceContext, NodeId, UaVariable, NumericRange, DataValue) or #writeNonValue(ServiceContext, NodeId, UaNode, UnsignedInteger, DataValue) to do the actual write. The default implementation does nothing, so you must override that. Or if you are actually using IoManagerUaNode, it will write the attribute value to a UaNode object.

Parameters:
serviceContext - The serviceContext of the client connection used to call this service.
operationContext - the possible operationContext prepared in beginWrite(com.prosysopc.ua.server.ServiceContext, org.opcfoundation.ua.core.WriteValue[], org.opcfoundation.ua.builtintypes.StatusCode[], org.opcfoundation.ua.builtintypes.DiagnosticInfo[])
nodeId - The node to write.
attributeId - The attribute to write.
indexRange - The index range to set for an array value. May be null.
dataValue - The data value to write.
Throws:
StatusException - If the write fails. Expected result codes: Bad_NodeIdInvalid, Bad_NodeIdUnknown, Bad_AttributeIdInvalid, Bad_IndexRangeInvalid, Bad_IndexRangeNoData, Bad_DataEncodingInvalid, Bad_DataEncodingUnsupported, Bad_NotWriteable, Bad_UserAccessDenied, Bad_TypeMismatch

writeNonValue

protected boolean writeNonValue(ServiceContext serviceContext,
                                Object operationContext,
                                org.opcfoundation.ua.builtintypes.NodeId nodeId,
                                UaNode node,
                                org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                                org.opcfoundation.ua.builtintypes.DataValue dataValue)
                         throws StatusException
Write the value of a single node attribute, except for the Value of a variable node.

Parameters:
serviceContext - The serviceContext of the client connection used to call this service.
operationContext -
nodeId - The node to write.
node - The node object to write. If the node is not available this may be null.
attributeId - The attribute to write.
dataValue - The data value to write.
Throws:
StatusException - If the write fails. Expected result codes: Bad_NodeIdInvalid, Bad_NodeIdUnknown, Bad_AttributeIdInvalid, Bad_IndexRangeInvalid, Bad_IndexRangeNoData, Bad_DataEncodingInvalid, Bad_DataEncodingUnsupported, Bad_NotWriteable, Bad_UserAccessDenied, Bad_TypeMismatch

writeValue

protected boolean writeValue(ServiceContext serviceContext,
                             Object operationContext,
                             org.opcfoundation.ua.builtintypes.NodeId nodeId,
                             UaValueNode valueNode,
                             org.opcfoundation.ua.utils.NumericRange indexRange,
                             org.opcfoundation.ua.builtintypes.DataValue dataValue)
                      throws StatusException
Write the Value attribute of a Variable node.

Parameters:
serviceContext - The serviceContext of the client connection used to call this service.
operationContext - the possible operationContext prepared in beginWrite(com.prosysopc.ua.server.ServiceContext, org.opcfoundation.ua.core.WriteValue[], org.opcfoundation.ua.builtintypes.StatusCode[], org.opcfoundation.ua.builtintypes.DiagnosticInfo[])
nodeId - The node to write.
valueNode - The node object to write. If the node is not available this may be null.
indexRange - The index range to set for an array value. May be null.
dataValue - The data value to write.
Throws:
StatusException - If the write fails. Expected result codes: Bad_NodeIdInvalid, Bad_NodeIdUnknown, Bad_AttributeIdInvalid, Bad_IndexRangeInvalid, Bad_IndexRangeNoData, Bad_DataEncodingInvalid, Bad_DataEncodingUnsupported, Bad_NotWriteable, Bad_UserAccessDenied, Bad_OutOfRange, Bad_TypeMismatch, Bad_WriteNotSupported


Copyright © 2018. All rights reserved.