APIs

Show:
// --------- This code has been automatically generated !!! 2017-12-15T21:13:58.903Z
"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/RegisteredServer_schema").RegisteredServer_Schema;
var getFactory = require("node-opcua-factory/src/factories_factories").getFactory;
var LocalizedText = getFactory("LocalizedText");
var BaseUAObject = require("node-opcua-factory/src/factories_baseobject").BaseUAObject;

/**
 * The information required to register a server with a discovery server.
 * 
 * @class RegisteredServer
 * @constructor
 * @extends BaseUAObject
 * @param  options {Object}
 * @param  [options.serverUri] {String} The globally unique identifier for the server.
 * @param  [options.productUri] {String} The globally unique identifier for the product.
 * @param  [options.serverNames] {LocalizedText[]} The name of server in multiple lcoales.
 * @param  [options.serverType] {ApplicationType} The type of server.
 * @param  [options.gatewayServerUri] {String} The globally unique identifier for the server that is acting as a gateway for the server.
 * @param  [options.discoveryUrls] {String[]} The URLs for the server's discovery endpoints.
 * @param  [options.semaphoreFilePath] {String} A path to a file that is deleted when the server is no longer accepting connections.
 * @param  [options.isOnline] {Boolean} If FALSE the server will save the registration information to a persistent datastore.
 */
function RegisteredServer(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);

    BaseUAObject.call(this,options);

    /**
      * The globally unique identifier for the server.
      * @property serverUri
      * @type {String}
      */
    self.serverUri = initialize_field(schema.fields[0], options.serverUri);

    /**
      * The globally unique identifier for the product.
      * @property productUri
      * @type {String}
      */
    self.productUri = initialize_field(schema.fields[1], options.productUri);

    /**
      * The name of server in multiple lcoales.
      * @property serverNames
      * @type {LocalizedText[]}
      */
    self.serverNames = [];
    if (options.serverNames) {
        assert(_.isArray(options.serverNames));
        self.serverNames = options.serverNames.map(function(e){ return new LocalizedText(e); } );
    }

    /**
      * The type of server.
      * @property serverType
      * @type {ApplicationType}
      */
    self.setServerType(initialize_field(schema.fields[3], options.serverType));

    /**
      * The globally unique identifier for the server that is acting as a gateway for the server.
      * @property gatewayServerUri
      * @type {String}
      */
    self.gatewayServerUri = initialize_field(schema.fields[4], options.gatewayServerUri);

    /**
      * The URLs for the server's discovery endpoints.
      * @property discoveryUrls
      * @type {String[]}
      */
    self.discoveryUrls = initialize_field_array(schema.fields[5], options.discoveryUrls);

    /**
      * A path to a file that is deleted when the server is no longer accepting connections.
      * @property semaphoreFilePath
      * @type {String}
      */
    self.semaphoreFilePath = initialize_field(schema.fields[6], options.semaphoreFilePath);

    /**
      * If FALSE the server will save the registration information to a persistent datastore.
      * @property isOnline
      * @type {Boolean}
      */
    self.isOnline = initialize_field(schema.fields[7], options.isOnline);

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

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

var encode_String = _defaultTypeMap.String.encode;
var decode_String = _defaultTypeMap.String.decode;
var encode_ApplicationType = _enumerations.ApplicationType.encode;
var decode_ApplicationType = _enumerations.ApplicationType.decode;
var encode_Boolean = _defaultTypeMap.Boolean.encode;
var decode_Boolean = _defaultTypeMap.Boolean.decode;
/**
 * encode the object into a binary stream
 * @method encode
 *
 * @param stream {BinaryStream} 
 */
RegisteredServer.prototype.encode = function(stream,options) {
    // call base class implementation first
    BaseUAObject.prototype.encode.call(this,stream,options);
    encode_String(this.serverUri,stream);
    encode_String(this.productUri,stream);
    encodeArray(this.serverNames,stream,function(obj,stream){ obj.encode(stream,options); }); 
    encode_ApplicationType(this.serverType,stream);
    encode_String(this.gatewayServerUri,stream);
    encodeArray(this.discoveryUrls, stream, encode_String);
    encode_String(this.semaphoreFilePath,stream);
    encode_Boolean(this.isOnline,stream);
};
/**
 * decode the object from a binary stream
 * @method decode
 *
 * @param stream {BinaryStream} 
 * @param [option] {object} 
 */
RegisteredServer.prototype.decode = function(stream,options) {
    // call base class implementation first
    BaseUAObject.prototype.decode.call(this,stream,options);
    this.serverUri = decode_String(stream,options);
    this.productUri = decode_String(stream,options);
    this.serverNames = decodeArray(stream, function(stream) { 
       var obj = new LocalizedText();
       obj.decode(stream,options);
       return obj; 
    });
    this.serverType = decode_ApplicationType(stream,options);
    this.gatewayServerUri = decode_String(stream,options);
    this.discoveryUrls = decodeArray(stream, decode_String);
    this.semaphoreFilePath = decode_String(stream,options);
    this.isOnline = decode_Boolean(stream,options);
};
RegisteredServer.possibleFields = [
  "serverUri",
         "productUri",
         "serverNames",
         "serverType",
         "gatewayServerUri",
         "discoveryUrls",
         "semaphoreFilePath",
         "isOnline"
];


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