APIs

Show:
// --------- This code has been automatically generated !!! 2017-12-15T21:14:01.357Z
"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/HistoryReadRequest_schema").HistoryReadRequest_Schema;
var getFactory = require("node-opcua-factory/src/factories_factories").getFactory;
var RequestHeader = getFactory("RequestHeader");
var HistoryReadValueId = require("./_auto_generated_HistoryReadValueId").HistoryReadValueId;
var BaseUAObject = require("node-opcua-factory/src/factories_baseobject").BaseUAObject;

/**
 * 
 * @class HistoryReadRequest
 * @constructor
 * @extends BaseUAObject
 * @param  options {Object}
 * @param  [options.requestHeader] {RequestHeader} 
 * @param  [options.historyReadDetails] {ExtensionObject} Maximum age of the value to be read in milliseconds
 * @param  [options.timestampsToReturn = 3] {TimestampsToReturn} An enumeration that specifies the Timestamps to be returned for each requested Variable Value Attribute.
 * @param  [options.releaseContinuationPoints] {Boolean} 
 * @param  [options.nodesToRead] {HistoryReadValueId[]} List of Nodes and their Attributes to read. For each entry in this list, a StatusCode is returned, and if it indicates success, the Attribute Value is also returned.
 */
function HistoryReadRequest(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);

    /**
      * 
      * @property requestHeader
      * @type {RequestHeader}
      */
    self.requestHeader =  new RequestHeader( options.requestHeader);

    /**
      * Maximum age of the value to be read in milliseconds
      * @property historyReadDetails
      * @type {ExtensionObject}
      */
    self.historyReadDetails = initialize_field(schema.fields[1], options.historyReadDetails);

    /**
      * An enumeration that specifies the Timestamps to be returned for each requested Variable Value Attribute.
      * @property timestampsToReturn
      * @type {TimestampsToReturn}
      * @default  3
      */
    self.setTimestampsToReturn(initialize_field(schema.fields[2], options.timestampsToReturn));

    /**
      * 
      * @property releaseContinuationPoints
      * @type {Boolean}
      */
    self.releaseContinuationPoints = initialize_field(schema.fields[3], options.releaseContinuationPoints);

    /**
      * List of Nodes and their Attributes to read. For each entry in this list, a StatusCode is returned, and if it indicates success, the Attribute Value is also returned.
      * @property nodesToRead
      * @type {HistoryReadValueId[]}
      */
    self.nodesToRead = [];
    if (options.nodesToRead) {
        assert(_.isArray(options.nodesToRead));
        self.nodesToRead = options.nodesToRead.map(function(e){ return new HistoryReadValueId(e); } );
    }

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

//## Define Enumeration setters
HistoryReadRequest.prototype.setTimestampsToReturn = function(value) {
   var coercedValue = _enumerations.TimestampsToReturn.typedEnum.get(value);
   /* istanbul ignore next */
   if (coercedValue === undefined || coercedValue === null) {
      throw new Error("value cannot be coerced to TimestampsToReturn: " + value);
   }
   this.timestampsToReturn = coercedValue;
};
HistoryReadRequest.prototype.encodingDefaultBinary = makeExpandedNodeId(664,0);
HistoryReadRequest.prototype.encodingDefaultXml = makeExpandedNodeId(663,0);
HistoryReadRequest.prototype._schema = schema;

var encode_ExtensionObject = _defaultTypeMap.ExtensionObject.encode;
var decode_ExtensionObject = _defaultTypeMap.ExtensionObject.decode;
var encode_TimestampsToReturn = _enumerations.TimestampsToReturn.encode;
var decode_TimestampsToReturn = _enumerations.TimestampsToReturn.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} 
 */
HistoryReadRequest.prototype.encode = function(stream,options) {
    // call base class implementation first
    BaseUAObject.prototype.encode.call(this,stream,options);
   this.requestHeader.encode(stream,options);
    encode_ExtensionObject(this.historyReadDetails,stream);
    encode_TimestampsToReturn(this.timestampsToReturn,stream);
    encode_Boolean(this.releaseContinuationPoints,stream);
    encodeArray(this.nodesToRead,stream,function(obj,stream){ obj.encode(stream,options); }); 
};
/**
 * decode the object from a binary stream
 * @method decode
 *
 * @param stream {BinaryStream} 
 * @param [option] {object} 
 */
HistoryReadRequest.prototype.decode = function(stream,options) {
    // call base class implementation first
    BaseUAObject.prototype.decode.call(this,stream,options);
    this.requestHeader.decode(stream,options);
    this.historyReadDetails = decode_ExtensionObject(stream,options);
    this.timestampsToReturn = decode_TimestampsToReturn(stream,options);
    this.releaseContinuationPoints = decode_Boolean(stream,options);
    this.nodesToRead = decodeArray(stream, function(stream) { 
       var obj = new HistoryReadValueId();
       obj.decode(stream,options);
       return obj; 
    });
};
HistoryReadRequest.possibleFields = [
  "requestHeader",
         "historyReadDetails",
         "timestampsToReturn",
         "releaseContinuationPoints",
         "nodesToRead"
];


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