APIs

Show:
// --------- This code has been automatically generated !!! 2017-12-21T20:31:15.266Z
"use strict";
/**
 * @module opcua.address_space.types
 */
var assert = require("node-opcua-assert");
var util = require("util");
var _  = require("underscore");
var makeNodeId = require("node-opcua-nodeid").makeNodeId;
var schema_helpers =  require("node-opcua-factory/src/factories_schema_helpers");
var extract_all_fields                       = schema_helpers.extract_all_fields;
var resolve_schema_field_types               = schema_helpers.resolve_schema_field_types;
var initialize_field                         = schema_helpers.initialize_field;
var initialize_field_array                   = schema_helpers.initialize_field_array;
var check_options_correctness_against_schema = schema_helpers.check_options_correctness_against_schema;
var _defaultTypeMap = require("node-opcua-factory/src/factories_builtin_types")._defaultTypeMap;
var ec = require("node-opcua-basic-types");
var encodeArray = ec.encodeArray;
var decodeArray = ec.decodeArray;
var makeExpandedNodeId = require("node-opcua-nodeid/src/expanded_nodeid").makeExpandedNodeId;
var generate_new_id = require("node-opcua-factory").generate_new_id;
var _enumerations = require("node-opcua-factory/src/factories_enumerations")._private._enumerations;
var schema = require("../schemas/Variant_schema").Variant_Schema;
var getFactory = require("node-opcua-factory/src/factories_factories").getFactory;
var BaseUAObject = require("node-opcua-factory/src/factories_baseobject").BaseUAObject;

/**
 * 
 * @class Variant
 * @constructor
 * @extends BaseUAObject
 * @param  options {Object}
 * @param  [options.dataType = 0] {DataType} the variant type.
 * @param  [options.arrayType = 0] {VariantArrayType} 
 * @param  [options.value = null] {Any} 
 * @param  [options.dimensions = null] {UInt32[]} the matrix dimensions
 */
function Variant(options)
{
    options = options || {};
    /* istanbul ignore next */
    if (schema_helpers.doDebug) { check_options_correctness_against_schema(this,schema,options); }
    var self = this;
    assert(this instanceof BaseUAObject); //  ' keyword "new" is required for constructor call')
    resolve_schema_field_types(schema);

    //construction hook
    options = schema.construct_hook(options); 
    BaseUAObject.call(this,options);

    /**
      * the variant type.
      * @property dataType
      * @type {DataType}
      * @default  0
      */
    self.setDataType(initialize_field(schema.fields[0], options.dataType));

    /**
      * 
      * @property arrayType
      * @type {VariantArrayType}
      * @default  0
      */
    self.setArrayType(initialize_field(schema.fields[1], options.arrayType));

    /**
      * 
      * @property value
      * @type {Any}
      * @default  null
      */
    self.value = initialize_field(schema.fields[2], options.value);

    /**
      * the matrix dimensions
      * @property dimensions
      * @type {UInt32[]}
      * @default  null
      */
    self.dimensions = initialize_field_array(schema.fields[3], options.dimensions);

   // Object.preventExtensions(self);
}
util.inherits(Variant,BaseUAObject);

//## Define Enumeration setters
Variant.prototype.setDataType = function(value) {
   var coercedValue = _enumerations.DataType.typedEnum.get(value);
   /* istanbul ignore next */
   if (coercedValue === undefined || coercedValue === null) {
      throw new Error("value cannot be coerced to DataType: " + value);
   }
   this.dataType = coercedValue;
};
Variant.prototype.setArrayType = function(value) {
   var coercedValue = _enumerations.VariantArrayType.typedEnum.get(value);
   /* istanbul ignore next */
   if (coercedValue === undefined || coercedValue === null) {
      throw new Error("value cannot be coerced to VariantArrayType: " + value);
   }
   this.arrayType = coercedValue;
};
schema.id = generate_new_id();
Variant.prototype.encodingDefaultBinary = makeExpandedNodeId(schema.id);
Variant.prototype._schema = schema;

var encode_DataType = _enumerations.DataType.encode;
var decode_DataType = _enumerations.DataType.decode;
var encode_VariantArrayType = _enumerations.VariantArrayType.encode;
var decode_VariantArrayType = _enumerations.VariantArrayType.decode;
var encode_Any = _defaultTypeMap.Any.encode;
var decode_Any = _defaultTypeMap.Any.decode;
var encode_UInt32 = _defaultTypeMap.UInt32.encode;
var decode_UInt32 = _defaultTypeMap.UInt32.decode;
Variant.prototype.encode = function(stream,options) {
   schema.encode(this,stream,options); 
};
/**
 * decode the object from a binary stream
 * @method decode
 *
 * @param stream {BinaryStream} 
 * @param [option] {object} 
 */
Variant.prototype.decode = function(stream,options) {
   schema.decode(this,stream,options); 
};
Variant.prototype.decode_debug = function(stream,options) {
   schema.decode_debug(this,stream,options); 
};
/**
 *
 * verify that all object attributes values are valid according to schema
 * @method isValid
 * @return {Boolean}
 */
Variant.prototype.isValid = function() { return schema.isValid(this); };
Variant.possibleFields = [
  "dataType",
         "arrayType",
         "value",
         "dimensions"
];


exports.Variant = Variant;
var register_class_definition = require("node-opcua-factory/src/factories_factories").register_class_definition;
register_class_definition("Variant",Variant);