UAVariable Class
A OPCUA Variable Node
Constructor
UAVariable
        
                - 
                                options
Parameters:
- 
                                optionsObject- 
                                            value
- 
                                            browseNameString
- 
                                            dataTypeNodeId | String
- 
                                            valueRankInt32
- 
                                            arrayDimensionsNull | Array
- 
                                            accessLevelAccessLevel
- 
                                            userAccessLevelAccessLevel
- 
                                            [minimumSamplingInterval= -1]optional
- 
                                            [historizing= false]Boolean optional
- 
                                            [permissions]optional
- 
                                            parentNodeIdNodeIdThe AccessLevel Attribute is used to indicate how the Value of a Variable can be accessed (read/write) and if it contains current and/or historic data. The AccessLevel does not take any user access rights into account, i.e. although the Variable is writable this may be restricted to a certain user / user group. The AccessLevel is an 8-bit unsigned integer with the structure defined in the following table: Field Bit Description CurrentRead 0 Indicates if the current value is readable (0 means not readable, 1 means readable). CurrentWrite 1 Indicates if the current value is writable (0 means not writable, 1 means writable). HistoryRead 2 Indicates if the history of the value is readable (0 means not readable, 1 means readable). HistoryWrite 3 Indicates if the history of the value is writable (0 means not writable, 1 means writable). SemanticChange 4 Indicates if the Variable used as Property generates SemanticChangeEvents (see 9.31). Reserved 5:7 Reserved for future use. Shall always be zero. The first two bits also indicate if a current value of this Variable is available and the second two bits indicates if the history of the Variable is available via the OPC UA server. 
 
- 
                                            
Item Index
Methods
- _clone
- _clone_children_references
- addReference
- bindVariable
- browseNode
- browseNodeByTargetName
- dispose
- findReference
- findReferences
- full_name
- getAggregates
- getComponentByName
- getComponents
- getEventSourceOfs
- getEventSources
- getFalseSubStates
- getFolderElements
- getMethodById
- getMethodByName
- getMethods
- getNotifiers
- getProperties
- getPropertyByName
- getTrueSubStates
- normalize_referenceTypeId
- propagate_back_references
- readAttribute
- readValue
- readValueAsync
- resolveNodeId
- setValueFromSource
- unpropagate_back_references
- writeAttribute
- writeEnumValue
- writeValue
Properties
Methods
_clone
                    
                            - 
                                            Constructor
- 
                                            options
- 
                                            extraInfo
Parameters:
- 
                                            ConstructorFunction
- 
                                            optionsObject
- 
                                            extraInfoObject
Returns:
_clone_children_references
                    
                            - 
                                            newParent
- 
                                            [optionalFilter = null]
- 
                                            [extraInfo]
clone properties and methods
Parameters:
- 
                                            newParentObjectthe new parent object to which references of type HasChild will be attached 
- 
                                            [optionalFilter = null]Function optionala filter 
- 
                                            [extraInfo]Object optional
Returns:
addReference
                    
                            - 
                                            reference
Parameters:
- 
                                            referenceObject- 
                                                        referenceTypeString
- 
                                                        [isForward= true]Boolean optional
- 
                                                        nodeIdNode | NodeId | String
 
- 
                                                        
Example:
view.addReference({ referenceType: "Organizes", nodeId: myDevice });
                    or
myDevice1.addReference({ referenceType: "OrganizedBy", nodeId: view });bindVariable
                    
                            - 
                                            options
- 
                                            [overwrite = false]
bind a variable with a get and set functions.
Parameters:
- 
                                            optionsObject- 
                                                        [dataType=null]DataType optionalthe nodeId of the dataType 
- 
                                                        [accessLevel]Number optionalAccessLevelFlagItem 
- 
                                                        [userAccessLevel]Number optionalAccessLevelFlagItem 
- 
                                                        [set]Function optionalthe variable setter function 
- 
                                                        [get]Function optionalthe variable getter function. the function must return a Variant or a status code 
- 
                                                        [timestamped_get]Function optionalthe getter function. this function must return a object with the following 
- 
                                                        [historyRead]Function optionalproperties: - value: a Variant or a status code
- sourceTimestamp
- sourcePicoseconds
 
- 
                                                        [timestamped_set]Function optional
- 
                                                        [refreshFunc]Function optionalthe variable asynchronous getter function. 
 
- 
                                                        
- 
                                            [overwrite = false]Boolean optionalset overwrite to true to overwrite existing binding 
Returns:
void
Providing read access to the underlying value
Variation 1
In this variation, the user provides a function that returns a Variant with the current value.
The sourceTimestamp will be set automatically.
The get function is called synchronously.
Example:
    ...
                        var options =  {
                          get : function() {
                             return new Variant({...});
                          },
                          set : function(variant) {
                             // store the variant somewhere
                             return StatusCodes.Good;
                          }
                       };
                       ...
                       engine.bindVariable(nodeId,options):
                       ...
                    Variation 2:
This variation can be used when the user wants to specify a specific '''sourceTimestamp''' associated with the current value of the UAVariable.
The provided timestamped_get function should return an object with three properties:
- value: containing the variant value or a error StatusCode,
- sourceTimestamp
- sourcePicoseconds
...
                    var myDataValue = new DataValue({
                      value: {dataType: DataType.Double , value: 10.0},
                      sourceTimestamp : new Date(),
                      sourcePicoseconds: 0
                    });
                    ...
                    var options =  {
                      timestamped_get : function() { return myDataValue;  }
                    };
                    ...
                    engine.bindVariable(nodeId,options):
                    ...
                    // record a new value
                    myDataValue.value.value = 5.0;
                    myDataValue.sourceTimestamp = new Date();
                    ...
                    Variation 3:
This variation can be used when the value associated with the variables requires a asynchronous function call to be
                    extracted. In this case, the user should provide an async method refreshFunc.
The refreshFunc shall do whatever is necessary to fetch the most up to date version of the variable value, and
                    call the callback function when the data is ready.
The callback function follow the standard callback function signature:
- the first argument shall be null or Error, depending of the outcome of the fetch operation,
- the second argument shall be a DataValue with the new UAVariable Value, a StatusCode, and time stamps.
Optionally, it is possible to pass a sourceTimestamp and a sourcePicoseconds value as a third and fourth arguments of the callback. When sourceTimestamp and sourcePicoseconds are missing, the system will set their default value to the current time..
...
                    var options =  {
                       refreshFunc : function(callback) {
                         ... do_some_async_stuff_to_get_the_new_variable_value
                         var dataValue = new DataValue({
                             value: new Variant({...}),
                             statusCode: StatusCodes.Good,
                             sourceTimestamp: new Date()
                         });
                         callback(null,dataValue);
                       }
                    };
                    ...
                    variable.bindVariable(nodeId,options):
                    ...
                    Providing write access to the underlying value
Variation1 - provide a simple synchronous set function
Notes
to do : explain return StatusCodes.GoodCompletesAsynchronously;
browseNode
                    
                            - 
                                            browseDescription
- 
                                            session
browse the node to extract information requested in browseDescription
Parameters:
- 
                                            browseDescriptionBrowseDescription- 
                                                        referenceTypeIdNodeId
- 
                                                        browseDirectionBrowseDirection
- 
                                                        nodeClassMaskNodeClassMask
- 
                                                        resultMaskUInt32
 
- 
                                                        
- 
                                            sessionServerSession
Returns:
browseNodeByTargetName
                    
                            - 
                                            relativePathElement
Parameters:
- 
                                            relativePathElementRelativePathElement- 
                                                        targetNameQualifiedName- 
                                                                    nameString
- 
                                                                    namespaceIndexUInt32
 
- 
                                                                    
- 
                                                        referenceTypeIdNodeId
- 
                                                        isInverseBoolean
- 
                                                        includeSubtypesBoolean
 
- 
                                                        
Returns:
dispose
                    
                            ()
                    
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        the dispose method should be called when the node is no longer used, to release back pointer to the address space and clear caches.
findReference
                    
                            - 
                                            strReference
- 
                                            [isForward]
- 
                                            [optionalSymbolicName]
Parameters:
- 
                                            strReferenceStringthe referenceType as a string. 
- 
                                            [isForward]Boolean | Null optional
- 
                                            [optionalSymbolicName]String optional
Returns:
findReferences
                    
                            - 
                                            strReference
- 
                                            [isForward=true]
Parameters:
- 
                                            strReferenceStringthe referenceType as a string. 
- 
                                            [isForward=true]Boolean optional
Returns:
full_name
                    
                            ()
                    
                            
                                String
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        Returns:
the full path name of the node
getAggregates
                    
                            ()
                    
                            
                                BaseNode[]
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        Returns:
return an array with the Aggregates of this object.
getComponentByName
                    
                            - 
                                            browseName
retrieve a component by name
Parameters:
- 
                                            browseNameObject
Returns:
getComponents
                    
                            ()
                    
                            
                                BaseNode[]
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        Returns:
return an array with the components of this object.
getEventSourceOfs
                    
                            ()
                    
                            
                                BaseNode[]
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        Returns:
return a array of the objects for which this node is an EventSource
getEventSources
                    
                            ()
                    
                            
                                BaseNode[]
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        Returns:
return a array with the event source of this object.
getFalseSubStates
                    
                            ()
                    
                            
                                BaseNode[]
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        Returns:
return an array with the SubStates of this object.
getFolderElements
                    
                            ()
                    
                            
                                Arrayreturns the list of nodes that this folder object organizes
Returns:
getMethodById
                    
                            - 
                                            nodeId
Parameters:
- 
                                            nodeIdObject
Returns:
getMethodByName
                    
                            - 
                                            browseName
Parameters:
- 
                                            browseNameObject
Returns:
getMethods
                    
                            ()
                    
                            
                                Arrayreturns the list of methods that this object provides
Returns:
returns an array wit"h Method objects.
Note: internally, methods are special types of components
getPropertyByName
                    
                            - 
                                            browseName
retrieve a property by name
Parameters:
- 
                                            browseNameObject
Returns:
getTrueSubStates
                    
                            ()
                    
                            
                                BaseNode[]
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        Returns:
return an array with the SubStates of this object.
normalize_referenceTypeId
                    
                            - 
                                            addressSpace
- 
                                            referenceTypeId
Parameters:
- 
                                            addressSpaceAddressSpace
- 
                                            referenceTypeIdString | NodeId | Null: the referenceType either as a string or a nodeId 
Returns:
propagate_back_references
                    
                            ()
                    
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        this methods propagates the forward references to the pointed node by inserting backward references to the counter part node
readAttribute
                    
                            - 
                                            context
- 
                                            attributeId
- 
                                            indexRange
- 
                                            dataEncoding
Parameters:
- 
                                            contextSessionContext
- 
                                            attributeIdAttributeIdsthe attributeId to read 
- 
                                            indexRangeNumericRange | | null
- 
                                            dataEncodingString
Returns:
readValue
                    
                            - 
                                            [context]
- 
                                            [indexRange]
- 
                                            [dataEncoding]
Parameters:
- 
                                            [context]SessionContext optional
- 
                                            [indexRange]NumericRange | Null optional
- 
                                            [dataEncoding]String optional
Returns:
from OPC.UA.Spec 1.02 part 4 5.10.2.4 StatusCodes Table 51 defines values for the operation level statusCode contained in the DataValue structure of each values element. Common StatusCodes are defined in Table 166. Table 51 Read Operation Level Result Codes Symbolic Id Description BadNodeIdInvalid The syntax of the node id is not valid. BadNodeIdUnknown The node id refers to a node that does not exist in the server address space. BadAttributeIdInvalid Bad_AttributeIdInvalid The attribute is not supported for the specified node. BadIndexRangeInvalid The syntax of the index range parameter is invalid. BadIndexRangeNoData No data exists within the range of indexes specified. BadDataEncodingInvalid The data encoding is invalid. This result is used if no dataEncoding can be applied because an Attribute other than Value was requested or the DataType of the Value Attribute is not a subtype of the Structure DataType. BadDataEncodingUnsupported The server does not support the requested data encoding for the node. This result is used if a dataEncoding can be applied but the passed data encoding is not known to the Server. BadNotReadable The access level does not allow reading or subscribing to the Node. BadUserAccessDenied User does not have permission to perform the requested operation. (table 165)
readValueAsync
                    
                            - 
                                            context
- 
                                            callback
Parameters:
- 
                                            contextSessionContext
- 
                                            callbackFunction- 
                                                        errNull | Error
- 
                                                        dataValueDataValue | Nullthe value read 
 
- 
                                                        
setValueFromSource
                    
                            - 
                                            variant
- 
                                            [statusCode ]
- 
                                            [sourceTimestamp= Now]
setValueFromSource is used to let the device sets the variable values this method also records the current time as sourceTimestamp and serverTimestamp. the method broadcasts an "value_changed" event
Parameters:
- 
                                            variantVariant
- 
                                            [statusCode ]StatusCode optional
- 
                                            [sourceTimestamp= Now]Object optional
unpropagate_back_references
                    
                            ()
                    
                    
                    
                            private
                    
                    
                    
                    
                    
                        
                    
                        Undo the effect of propagate_back_references
writeAttribute
                    
                            - 
                                            context
- 
                                            writeValue
- 
                                            callback
Parameters:
- 
                                            contextSessionContext
- 
                                            writeValueWriteValue
- 
                                            callbackFunction- 
                                                        errError | Null
- 
                                                        statusCodeStatusCode
 
- 
                                                        
writeEnumValue
                    
                            - 
                                            value
Parameters:
- 
                                            valueString | Number
writeValue
                    
                            - 
                                            context
- 
                                            dataValue
- 
                                            [indexRange]
- 
                                            callback
Parameters:
- 
                                            contextSessionContext
- 
                                            dataValueDataValue
- 
                                            [indexRange]NumericRange optional
- 
                                            callbackFunction- 
                                                        errError | Null
- 
                                                        statusCodeStatusCode
 
- 
                                                        
Properties
accessLevel
                        Number
                    
                    
                    
                    
                    
                        
                    
                        arrayDimensions
                        number UInt32
                    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 Variables 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.
                        Note that the maximum length of an array transferred on the wire is 2147483647 (max Int32)
                        and a multidimentional array is encoded as a one dimensional array.
                    
                    
                    
                    
                    
                        
                    
                        This Attribute specifies the length of each dimension for an array value. T
hasMethods
                        Boolean
                    
                    
                    
                    
                    
                        
                    
                        returns true if the object has some opcua methods
historizing
                        Boolean
                     This differs from the AccessLevel Attribute which identifies if the
                    Variable has any historical data. A value of TRUE indicates that the Server is actively
                    collecting data. A value of FALSE indicates the Server is not actively collecting data.
                    Default value is FALSE.
                    
                    
                    
                    
                    
                        
                    
                        The Historizing Attribute indicates whether the Server is actively collecting data for the history of the Variable.
minimumSamplingInterval
                        number Optional
                     It specifies (in milliseconds) how fast the Server can reasonably sample the value
                    for changes (see Part 4 for a detailed description of sampling interval).
                    A MinimumSamplingInterval of 0 indicates that the Server is to monitor the item continuously.
                    A MinimumSamplingInterval of -1 means indeterminate.
                    
                    
                    
                    
                    
                        
                    
                        The MinimumSamplingInterval Attribute indicates how 'current' the Value of the Variable will be kept.
 The NodeOPCUA API
            The NodeOPCUA API