lib/address_space/ua_variable.js
/**
 * A OPCUA Variable Node
 *
 * @class UAVariable
 * @constructor
 * @extends  BaseNode
 * @param options  {Object}
 * @param options.value
 * @param options.browseName {string}
 * @param options.dataType   {NodeId|String}
 * @param options.valueRank  {Int32}
 * @param options.arrayDimensions {null|Array<Integer>}
 * @param options.accessLevel {AccessLevel}
 * @param options.userAccessLevel {AccessLevel}
 * @param [options.minimumSamplingInterval = -1]
 * @param [options.historizing = false] {Boolean}
 * @param [options.permissions]
 * @param options.parentNodeId {NodeId}
 *
 *  The 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.
 *
 */


The 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 .
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.
The 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 . 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 .
function UAVariable(options) {
    var self = this;
    BaseNode.apply(this, arguments);
    self.dataType = self.resolveNodeId(options.dataType);    
    assert(self.dataType instanceof NodeId);
    self.valueRank = options.valueRank || 0;  
    assert(typeof self.valueRank === "number");
    self.arrayDimensions = options.arrayDimensions || null;
    assert(_.isNull(self.arrayDimensions) || _.isArray(self.arrayDimensions));
    self.accessLevel = adjust_accessLevel(options.accessLevel);
    self.userAccessLevel = adjust_userAccessLevel(options.userAccessLevel);
    self.minimumSamplingInterval = adjust_samplingInterval(options.minimumSamplingInterval);
    self.parentNodeId = options.parentNodeId;
    self.historizing = !!options.historizing; 
    self._dataValue = new DataValue({statusCode: StatusCodes.BadWaitingForInitialData, value: {}});
    if (options.value) {
        self.bindVariable(options.value);
    }
    if (options.permissions) {
        self.setPermissions(options.permissions);
    }
    this.setMaxListeners(5000);
    self.semantic_version = 0;
    self.permission = null;
}
function UAVariable ( options ) { var self = this ; BaseNode . apply ( this , arguments ) ; self . dataType = self . resolveNodeId ( options . dataType ) ; assert ( self . dataType instanceof NodeId ) ; self . valueRank = options . valueRank || 0 ; assert ( typeof self . valueRank === "number" ) ; self . arrayDimensions = options . arrayDimensions || null ; assert ( _ . isNull ( self . arrayDimensions ) || _ . isArray ( self . arrayDimensions ) ) ; self . accessLevel = adjust_accessLevel ( options . accessLevel ) ; self . userAccessLevel = adjust_userAccessLevel ( options . userAccessLevel ) ; self . minimumSamplingInterval = adjust_samplingInterval ( options . minimumSamplingInterval ) ; self . parentNodeId = options . parentNodeId ; self . historizing = ! ! options . historizing ; self . _dataValue = new DataValue ( { statusCode : StatusCodes . BadWaitingForInitialData , value : { } } ) ; if ( options . value ) { self . bindVariable ( options . value ) ; } if ( options . permissions ) { self . setPermissions ( options . permissions ) ; } this . setMaxListeners ( 5000 ) ; self . semantic_version = 0 ; self . permission = null ; }
A OPCUA Variable Node
 @class UAVariable
 @constructor
 @extends  BaseNode
 @param options  {Object}
 @param options.value
 @param options.browseName {string}
 @param options.dataType   {NodeId|String}
 @param options.valueRank  {Int32}
 @param options.arrayDimensions {null|Array<Integer>}
 @param options.accessLevel {AccessLevel}
 @param options.userAccessLevel {AccessLevel}
 @param [options.minimumSamplingInterval = -1]
 @param [options.historizing = false] {Boolean}
 @param [options.permissions]
 @param options.parentNodeId {NodeId}
A OPCUA Variable Node @class UAVariable @constructor @extends BaseNode @param options { Object } @param options . value @param options . browseName { string } @param options . dataType { NodeId|String } @param options . valueRank { Int32 } @param options . arrayDimensions { null|Array<Integer > } @param options . accessLevel { AccessLevel } @param options . userAccessLevel { AccessLevel } @param [ options . minimumSamplingInterval = - 1 ] @param [ options . historizing = false ] { Boolean } @param [ options . permissions ] @param options . parentNodeId { NodeId }
// assert(self.typeDefinition.value === self.resolveNodeId("VariableTypeNode").value); /**
     * @property dataType
     * @type {NodeId}
     */ // DataType (NodeId) /**
     * @property valueRank
     * @type {number} UInt32
     * 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:
     *  n > 1:                      the Value is an array with the specified number of dimensions.
     *  OneDimension (1):           The value is an array with one dimension.
     *  OneOrMoreDimensions (0):    The value is an array with one or more dimensions.
     *  Scalar (?1):                The value is not an array.
     *  Any (?2):                   The value can be a scalar or an array with any number of dimensions.
     *  ScalarOrOneDimension (?3):  The value can be a scalar or a one dimensional array.
     *  NOTE All DataTypes are considered to be scalar, even if they have array-like semantics
     *  like ByteString and String.
     */ // UInt32 /**
     * This Attribute specifies the length of each dimension for an array value. T
     * @property arrayDimensions
     * @type {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 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.
     *     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.
     */ /**
     * @property accessLevel
     * @type {number}
     */ /**
     * @property userAccessLevel
     * @type {number}
     *
     */ /**
     * The MinimumSamplingInterval Attribute indicates how �current� the Value of the Variable will
     * be kept.
     * @property minimumSamplingInterval
     * @type {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 Historizing Attribute indicates whether the Server is actively collecting data for the
     * history of the Variable.
     * @property historizing
     * @type {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.
     */ // coerced to boolean