com.prosysopc.ua.client.nodes
Class UaVariableImpl

java.lang.Object
  extended by com.prosysopc.ua.nodes.AbstractUaNode
      extended by com.prosysopc.ua.client.nodes.UaNodeImpl
          extended by com.prosysopc.ua.client.nodes.UaInstanceImpl
              extended by com.prosysopc.ua.client.nodes.UaVariableImpl
All Implemented Interfaces:
UaInstance, UaNode, UaValueNode, UaVariable
Direct Known Subclasses:
BaseVariableTypeImpl, UaPropertyImpl

public class UaVariableImpl
extends UaInstanceImpl
implements UaVariable

Straight forward implementation of UaVariable.

It keeps all attributes in memory.


Field Summary
 
Fields inherited from class com.prosysopc.ua.client.nodes.UaNodeImpl
addressSpace, references, supportedAttributesMap
 
Constructor Summary
UaVariableImpl(AddressSpace addressSpace, org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.QualifiedName browseName, org.opcfoundation.ua.builtintypes.LocalizedText displayName)
          Create a new variable with dataTypeId initialized to BaseDataType.
UaVariableImpl(AddressSpace addressSpace, org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.QualifiedName browseName, org.opcfoundation.ua.builtintypes.LocalizedText displayName, org.opcfoundation.ua.builtintypes.LocalizedText description, EnumSet<WriteAccess> writeMask, EnumSet<WriteAccess> userWriteMask, UaClientReference[] references, UaProperty[] properties, org.opcfoundation.ua.builtintypes.NodeId dataTypeId, Integer valueRank, org.opcfoundation.ua.builtintypes.UnsignedInteger[] arrayDimensions, EnumSet<org.opcfoundation.ua.core.AccessLevel> accessLevel, EnumSet<org.opcfoundation.ua.core.AccessLevel> userAccessLevel, Double minimumSamplingInterval, Boolean historizing)
           
UaVariableImpl(AddressSpace addressSpace, org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.QualifiedName browseName, org.opcfoundation.ua.builtintypes.LocalizedText displayName, org.opcfoundation.ua.builtintypes.NodeId dataTypeId)
          Create a new variable with a specific data type.
UaVariableImpl(AddressSpace addressSpace, org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.QualifiedName browseName, org.opcfoundation.ua.builtintypes.LocalizedText displayName, UaType dataType)
          Create a new variable with a specific data type.
UaVariableImpl(AddressSpace addressSpace, org.opcfoundation.ua.builtintypes.NodeId nodeId, String name, Locale locale, org.opcfoundation.ua.builtintypes.NodeId dataTypeId)
          Create a new variable with a specific data type.
UaVariableImpl(AddressSpace addressSpace, org.opcfoundation.ua.builtintypes.NodeId nodeId, String name, Locale locale, UaType dataType)
          Create a new variable with a specific data type.
 
Method Summary
 void addDataChangeListener(DataChangeListener listener)
          Not supported at the moment.
 EnumSet<org.opcfoundation.ua.core.AccessLevel> getAccessLevel()
          Defines the global read/write access of the Value attribute for all users.
 org.opcfoundation.ua.builtintypes.UnsignedInteger[] getArrayDimensions()
          This Attribute specifies the length of each dimension for an array value.
 org.opcfoundation.ua.core.NodeAttributes getAttributes()
           
protected  org.opcfoundation.ua.core.VariableAttributes getAttributes(org.opcfoundation.ua.core.VariableAttributes attributes)
           
 UaType getDataType()
           
 org.opcfoundation.ua.builtintypes.NodeId getDataTypeId()
           
 Boolean getHistorizing()
           
 Double getMinimumSamplingInterval()
           
 org.opcfoundation.ua.core.NodeClass getNodeClass()
          The NodeClass Attribute identifies the NodeClass of a Node.
 EnumSet<org.opcfoundation.ua.core.AccessLevel> getUserAccessLevel()
          Defines the user specific read/write access of the Value attribute.
 org.opcfoundation.ua.builtintypes.DataValue getValue()
           
 Integer getValueRank()
          This Attribute indicates whether the Value Attribute of the Variable is an array and how many dimensions the array has.
 boolean hasUserWriteAccess(org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
          Overrides the default to check access to Value attribute from AccessLevel.
 boolean hasWriteAccess(org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
          Overrides the default to check access to Value attribute from AccessLevel.
protected  void initSupportedAttributes(List<org.opcfoundation.ua.builtintypes.UnsignedInteger> l)
           
protected  void readAttributeValue(org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.builtintypes.DataValue dataValue)
          Read the value of an attribute.
 org.opcfoundation.ua.builtintypes.DataValue readValue()
          Reads the current value of the variable from the server.
 void removeDataChangeListener(DataChangeListener listener)
          Not supported at the moment.
 void setAccessLevel(EnumSet<org.opcfoundation.ua.core.AccessLevel> accessLevel)
           
 void setArrayDimensions(org.opcfoundation.ua.builtintypes.UnsignedInteger[] arrayDimensions)
          This Attribute specifies the length of each dimension for an array value.
 void setAttribute(org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.builtintypes.DataValue dataValue)
          Unconditionally, set the value of the specified attribute.
 void setAttributes(org.opcfoundation.ua.core.VariableAttributes variableAttributes)
           
 void setDataType(UaType dataType)
          Set the Data Type node.
 void setDataTypeId(org.opcfoundation.ua.builtintypes.NodeId dataTypeId)
          Set the Data Type.
 void setHistorizing(Boolean historizing)
           
 void setMinimumSamplingInterval(Double minimumSamplingInterval)
           
 void setUserAccessLevel(EnumSet<org.opcfoundation.ua.core.AccessLevel> userAccessLevel)
           
 void setValue(org.opcfoundation.ua.builtintypes.DataValue value)
          The default Value for instances of this type.
 void setValue(Object value)
          Set value.
 void setValueRank(int valueRank)
          This Attribute indicates whether the Value Attribute of the VariableType is an array and how many dimensions the array has.
 String toString()
           
protected  void writeAttributeValue(org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, Object value, org.opcfoundation.ua.builtintypes.StatusCode statusCode, org.opcfoundation.ua.builtintypes.DateTime sourceTime, org.opcfoundation.ua.builtintypes.UnsignedShort sourcePicoseconds)
           
 boolean writeValue(Object value)
          Writes the value to the variable in the server.
 
Methods inherited from class com.prosysopc.ua.client.nodes.UaInstanceImpl
getTypeDefinition, getTypeDefinitionId, setTypeDefinition, setTypeDefinitionId, setTypeDefinitionId
 
Methods inherited from class com.prosysopc.ua.client.nodes.UaNodeImpl
addComponent, addProperties, addProperty, addReference, addReference, addReference, addReference, afterAddReference, afterDeleteReference, assertTypeSupport, assertTypeSupport, beforeAddReference, deleteReference, deleteReference, deleteReference, deleteReference, deleteReferences, doAddProperty, equals, findPlaceholders, getAddressSpace, getAttributes, getBrowseName, getComponent, getComponents, getDescription, getDescription, getDisplayName, getDisplayName, getMethod, getNodeId, getNodeVersion, getNodeVersionString, getProperties, getProperty, getPropertyValue, getReference, getReferenceList, getReferences, getSupportedAttributes, getUserWriteMask, getWriteMask, hashCode, hasProperty, hasTypeDefinition, readAttribute, readAttribute, referenceTypeInherits, removeComponent, removeProperty, setAttributes, setBrowseName, setDescription, setDisplayName, setNodeVersion, setPropertyValue, setReferences, setUserWriteMask, setWriteMask, supportsAttribute, writeAttribute
 
Methods inherited from class com.prosysopc.ua.nodes.AbstractUaNode
getForwardReferences, getInverseReferences, getReferences, getReferences, getReferencesAsList, referenceTypeInherits
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.prosysopc.ua.nodes.UaInstance
getTypeDefinition, getTypeDefinitionId, setTypeDefinition, setTypeDefinitionId, setTypeDefinitionId
 
Methods inherited from interface com.prosysopc.ua.nodes.UaNode
addComponent, addProperty, addReference, addReference, addReference, deleteReference, deleteReference, deleteReference, deleteReference, getAddressSpace, getBrowseName, getComponent, getComponents, getDescription, getDisplayName, getForwardReferences, getInverseReferences, getMethod, getNodeId, getNodeVersion, getProperties, getProperty, getReference, getReferences, getReferences, getSupportedAttributes, getUserWriteMask, getWriteMask, readAttribute, readAttribute, removeComponent, removeProperty, setAttributes, setBrowseName, setDescription, setDisplayName, setReferences, setUserWriteMask, setWriteMask, supportsAttribute, writeAttribute
 

Constructor Detail

UaVariableImpl

public UaVariableImpl(AddressSpace addressSpace,
                      org.opcfoundation.ua.builtintypes.NodeId nodeId,
                      org.opcfoundation.ua.builtintypes.QualifiedName browseName,
                      org.opcfoundation.ua.builtintypes.LocalizedText displayName)
Create a new variable with dataTypeId initialized to BaseDataType.

Parameters:
nodeId -
browseName -
displayName -

UaVariableImpl

public UaVariableImpl(AddressSpace addressSpace,
                      org.opcfoundation.ua.builtintypes.NodeId nodeId,
                      org.opcfoundation.ua.builtintypes.QualifiedName browseName,
                      org.opcfoundation.ua.builtintypes.LocalizedText displayName,
                      org.opcfoundation.ua.builtintypes.LocalizedText description,
                      EnumSet<WriteAccess> writeMask,
                      EnumSet<WriteAccess> userWriteMask,
                      UaClientReference[] references,
                      UaProperty[] properties,
                      org.opcfoundation.ua.builtintypes.NodeId dataTypeId,
                      Integer valueRank,
                      org.opcfoundation.ua.builtintypes.UnsignedInteger[] arrayDimensions,
                      EnumSet<org.opcfoundation.ua.core.AccessLevel> accessLevel,
                      EnumSet<org.opcfoundation.ua.core.AccessLevel> userAccessLevel,
                      Double minimumSamplingInterval,
                      Boolean historizing)

UaVariableImpl

public UaVariableImpl(AddressSpace addressSpace,
                      org.opcfoundation.ua.builtintypes.NodeId nodeId,
                      org.opcfoundation.ua.builtintypes.QualifiedName browseName,
                      org.opcfoundation.ua.builtintypes.LocalizedText displayName,
                      org.opcfoundation.ua.builtintypes.NodeId dataTypeId)
Create a new variable with a specific data type.

Parameters:
nodeId - The variable ID.
browseName - The name used for browseName
displayName - The name used for localized displayName
dataTypeId - The variable data type as a NodeId.

UaVariableImpl

public UaVariableImpl(AddressSpace addressSpace,
                      org.opcfoundation.ua.builtintypes.NodeId nodeId,
                      org.opcfoundation.ua.builtintypes.QualifiedName browseName,
                      org.opcfoundation.ua.builtintypes.LocalizedText displayName,
                      UaType dataType)
Create a new variable with a specific data type.

Parameters:
nodeId - The variable ID.
browseName - The name used for browseName
displayName - The name used for localized displayName
dataTypeId - The variable data type.

UaVariableImpl

public UaVariableImpl(AddressSpace addressSpace,
                      org.opcfoundation.ua.builtintypes.NodeId nodeId,
                      String name,
                      Locale locale,
                      org.opcfoundation.ua.builtintypes.NodeId dataTypeId)
Create a new variable with a specific data type.

Parameters:
nodeId - The variable ID.
name - The name used for browseName & displayName
locale - The locale of displayName
dataTypeId - The variable data type as a NodeId.

UaVariableImpl

public UaVariableImpl(AddressSpace addressSpace,
                      org.opcfoundation.ua.builtintypes.NodeId nodeId,
                      String name,
                      Locale locale,
                      UaType dataType)
Create a new variable with a specific data type.

Parameters:
nodeId - The variable ID.
name - The name used for browseName & displayName
locale - The locale of displayName
dataType - The variable data type.
Method Detail

addDataChangeListener

public void addDataChangeListener(DataChangeListener listener)
Not supported at the moment.

Specified by:
addDataChangeListener in interface UaVariable

getAccessLevel

public EnumSet<org.opcfoundation.ua.core.AccessLevel> getAccessLevel()
Description copied from interface: UaVariable
Defines the global read/write access of the Value attribute for all users.

In contrast to the WriteAccess this attribute only applies to the Value attribute.

Specified by:
getAccessLevel in interface UaVariable
Returns:
the current global access rights
See Also:
UaVariable.getUserAccessLevel()

getArrayDimensions

public org.opcfoundation.ua.builtintypes.UnsignedInteger[] getArrayDimensions()
Description copied from interface: UaValueNode
This Attribute specifies the length of each dimension for an array value. The Attribute is intended to describe the capability of the Variable, not the current size.

The number of elements shall be equal to the value of the ValueRank Attribute. Shall be null if ValueRank <= 0.

A value of 0 for an individual dimension indicates that the dimension has a variable length.

For example, if a Variable is defined by the following C array: Int32 myArray[346];

then this Variable's DataType would point to an Int32, the Variable's ValueRank has the value 1 and the ArrayDimensions is an array with one entry having the value 346.

Specified by:
getArrayDimensions in interface UaValueNode
Returns:
the array dimensions of the variable type or null if this is not a specific array type, i.e. ValueRank <= 0
See Also:
UaValueNode.setArrayDimensions(org.opcfoundation.ua.builtintypes.UnsignedInteger[])

getAttributes

public org.opcfoundation.ua.core.NodeAttributes getAttributes()
Specified by:
getAttributes in interface UaNode
Returns:
the current attribute values of the node in a NodeAttributes structure.

getDataType

public UaType getDataType()
Specified by:
getDataType in interface UaValueNode
Returns:
the DataType node, if set.
See Also:
UaValueNode.getDataTypeId()

getDataTypeId

public org.opcfoundation.ua.builtintypes.NodeId getDataTypeId()
Specified by:
getDataTypeId in interface UaValueNode
Returns:
NodeId of the data type definition for instances of this type.

getHistorizing

public Boolean getHistorizing()
Specified by:
getHistorizing in interface UaVariable
Returns:
whether the variable has history

getMinimumSamplingInterval

public Double getMinimumSamplingInterval()
Specified by:
getMinimumSamplingInterval in interface UaVariable
Returns:
the minimum sampling interval that the server supports for the variable

getNodeClass

public final org.opcfoundation.ua.core.NodeClass getNodeClass()
Description copied from interface: UaNode
The NodeClass Attribute identifies the NodeClass of a Node.

Specified by:
getNodeClass in interface UaNode
Overrides:
getNodeClass in class UaNodeImpl
Returns:
the Node Class of the node. This is hard-coded and cannot be changed.

getUserAccessLevel

public EnumSet<org.opcfoundation.ua.core.AccessLevel> getUserAccessLevel()
Description copied from interface: UaVariable
Defines the user specific read/write access of the Value attribute.

In contrast to the UserWriteAccess this attribute only applies to the Value attribute.

Specified by:
getUserAccessLevel in interface UaVariable
Returns:
the current access rights for the user that requested it
See Also:
UaVariable.getAccessLevel()

getValue

public org.opcfoundation.ua.builtintypes.DataValue getValue()
Specified by:
getValue in interface UaValueNode
Returns:
The default Value for instances of this type.

getValueRank

public Integer getValueRank()
Description copied from interface: UaValueNode
This Attribute indicates whether the Value Attribute of the Variable is an array and how many dimensions the array has.

It may have the following values:

Specified by:
getValueRank in interface UaValueNode
Returns:
the value rank
See Also:
UaValueNode.setValueRank(int)

hasUserWriteAccess

public boolean hasUserWriteAccess(org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
Overrides the default to check access to Value attribute from AccessLevel.

Specified by:
hasUserWriteAccess in interface UaNode
Overrides:
hasUserWriteAccess in class UaNodeImpl
Parameters:
attributeId -
Returns:

hasWriteAccess

public boolean hasWriteAccess(org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
Overrides the default to check access to Value attribute from AccessLevel.

Specified by:
hasWriteAccess in interface UaNode
Overrides:
hasWriteAccess in class UaNodeImpl
Parameters:
attributeId -
Returns:

readValue

public org.opcfoundation.ua.builtintypes.DataValue readValue()
                                                      throws StatusException,
                                                             ServiceException
Reads the current value of the variable from the server.

Returns:
the DataValue
Throws:
StatusException - if the read operation fails
ServiceException - if the service call to the server fails

removeDataChangeListener

public void removeDataChangeListener(DataChangeListener listener)
Not supported at the moment.

Specified by:
removeDataChangeListener in interface UaVariable

setAccessLevel

public void setAccessLevel(EnumSet<org.opcfoundation.ua.core.AccessLevel> accessLevel)
Specified by:
setAccessLevel in interface UaVariable
Parameters:
accessLevel - the access level to set
See Also:
UaVariable.getAccessLevel()

setArrayDimensions

public void setArrayDimensions(org.opcfoundation.ua.builtintypes.UnsignedInteger[] arrayDimensions)
Description copied from interface: UaValueNode
This Attribute specifies the length of each dimension for an array value. The Attribute is intended to describe the capability of the VariableType, not the current size.

The number of elements shall be equal to the value of the ValueRank Attribute. Shall be null if ValueRank <= 0.

A value of 0 for an individual dimension indicates that the dimension has a variable length.

For example, if a VariableType is defined by the following array:

Integer[] myArray = new Integer[346];

then this VariableType's DataType would point to the Int32 data type node, the VariableType's ValueRank has the value 1 and the ArrayDimensions is an array with one entry having the value 346.

Specified by:
setArrayDimensions in interface UaValueNode

setAttribute

public void setAttribute(org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                         org.opcfoundation.ua.builtintypes.DataValue dataValue)
                  throws StatusException
Description copied from class: UaNodeImpl
Unconditionally, set the value of the specified attribute. To check the access rights and that the attribute is supported by the node, use writeAttribute. The method calls the internal, overridable, writeAttributeValue.

Specified by:
setAttribute in interface UaNode
Overrides:
setAttribute in class UaNodeImpl
Throws:
StatusException

setAttributes

public void setAttributes(org.opcfoundation.ua.core.VariableAttributes variableAttributes)

setDataType

public void setDataType(UaType dataType)
Description copied from interface: UaValueNode
Set the Data Type node.

Specified by:
setDataType in interface UaValueNode
See Also:
UaValueNode.setDataTypeId(NodeId)

setDataTypeId

public void setDataTypeId(org.opcfoundation.ua.builtintypes.NodeId dataTypeId)
Description copied from interface: UaValueNode
Set the Data Type.

Specified by:
setDataTypeId in interface UaValueNode
See Also:
UaValueNode.setDataTypeId(NodeId)

setHistorizing

public void setHistorizing(Boolean historizing)
Specified by:
setHistorizing in interface UaVariable
Parameters:
historizing - define that the variable has history - or not

setMinimumSamplingInterval

public void setMinimumSamplingInterval(Double minimumSamplingInterval)
Specified by:
setMinimumSamplingInterval in interface UaVariable
Parameters:
minimumSamplingInterval - define the minimum sampling interval

setUserAccessLevel

public void setUserAccessLevel(EnumSet<org.opcfoundation.ua.core.AccessLevel> userAccessLevel)
Specified by:
setUserAccessLevel in interface UaVariable
Parameters:
userAccessLevel - the user access level to set
See Also:
UaVariable.getUserAccessLevel()

setValue

public void setValue(org.opcfoundation.ua.builtintypes.DataValue value)
              throws StatusException
Description copied from interface: UaValueNode
The default Value for instances of this type.

Specified by:
setValue in interface UaValueNode
Parameters:
value - the default value to set
Throws:
StatusException

setValue

public void setValue(Object value)
              throws StatusException
Set value.

Specified by:
setValue in interface UaValueNode
Parameters:
value - a new value. The value may be a DataValue, Variant or any "OPC UA compliant" value, i.e. value which can be used to initialize a Variant.
Throws:
StatusException - if the value is invalid for the Value attribute

setValueRank

public void setValueRank(int valueRank)
Description copied from interface: UaValueNode
This Attribute indicates whether the Value Attribute of the VariableType is an array and how many dimensions the array has.

It may have the following values:

Specified by:
setValueRank in interface UaValueNode
Parameters:
valueRank - the value rank to set

toString

public String toString()
Overrides:
toString in class UaInstanceImpl

writeValue

public boolean writeValue(Object value)
                   throws StatusException,
                          ServiceException
Writes the value to the variable in the server. If the value is written successfully, the current value is also changed to the variable immediately. If the write completes asynchronously, it must be read from the server later to get it updated to the variable.

Parameters:
value - the value to write to the server. The value may be a DataValue, Variant or any "OPC UA compliant" value, i.e. value which can be used to initialize a Variant.
Returns:
true if the value was written immediately; false, if the server returns Good_CompletesAsynchronously. In case the write fails, the method will throw an exception
Throws:
ServiceException - If the call fails. Expected ServiceResult codes are Bad_NothingToDo and Bad_TooManyOperations.
StatusException - If the server returns a bad status for the value. Read the exception for the error details and diagnostics. Expected bad status codes are Bad_NodeIdInvalid, Bad_NodeIdUnknown, Bad_AttributeIdInvalid, Bad_IndexRangeInvalid, Bad_IndexRangeNoData, Bad_WriteNotSupported, Bad_NotWritable, Bad_UserAccessDenied, Bad_OutOfRange, Bad_TypeMismatch
See Also:
readValue(), UaClient.writeValue(org.opcfoundation.ua.builtintypes.NodeId, java.lang.Object)

getAttributes

protected org.opcfoundation.ua.core.VariableAttributes getAttributes(org.opcfoundation.ua.core.VariableAttributes attributes)

initSupportedAttributes

protected void initSupportedAttributes(List<org.opcfoundation.ua.builtintypes.UnsignedInteger> l)
Overrides:
initSupportedAttributes in class UaNodeImpl

readAttributeValue

protected void readAttributeValue(org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                                  org.opcfoundation.ua.builtintypes.DataValue dataValue)
                           throws StatusException
Description copied from class: UaNodeImpl
Read the value of an attribute.

Overrides:
readAttributeValue in class UaNodeImpl
Parameters:
attributeId - the ID of the attribute to read.
dataValue - the DataValue structure in which the value is set.
Throws:
StatusException

writeAttributeValue

protected void writeAttributeValue(org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                                   Object value,
                                   org.opcfoundation.ua.builtintypes.StatusCode statusCode,
                                   org.opcfoundation.ua.builtintypes.DateTime sourceTime,
                                   org.opcfoundation.ua.builtintypes.UnsignedShort sourcePicoseconds)
                            throws StatusException
Overrides:
writeAttributeValue in class UaNodeImpl
Throws:
StatusException


Copyright © 2018. All rights reserved.