How to use node-opcua-assert - 10 common examples

To help you get started, we’ve selected a few node-opcua-assert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-server / source / monitored_item.ts View on Github external
private _set_timer() {

    assert(this.samplingInterval >= MonitoredItem.minimumSamplingInterval);
    assert(!this._samplingId);

    if (useCommonTimer) {
      this._samplingId = appendToTimer(this);
    } else {
      // settle periodic sampling
      this._samplingId = setInterval(() => {
        this._on_sampling_timer();
      }, this.samplingInterval);
    }
    // xx console.log("MonitoredItem#_set_timer",this._samplingId);
  }
github node-opcua / node-opcua / packages / node-opcua-server / source / server_session.ts View on Github external
private _getSubscriptionDiagnosticsArray() {

        if (!this.addressSpace) {
            if (doDebug) {
                console.warn("ServerSession#_getSubscriptionDiagnosticsArray : no addressSpace");
            }
            return null; // no addressSpace
        }

        const subscriptionDiagnosticsArray = this.subscriptionDiagnosticsArray;
        if (!subscriptionDiagnosticsArray) {
            return null; // no subscriptionDiagnosticsArray
        }
        assert(subscriptionDiagnosticsArray.browseName.toString() === "SubscriptionDiagnosticsArray");
        return subscriptionDiagnosticsArray;
    }
github node-opcua / node-opcua / packages / node-opcua-server / source / server_end_point.ts View on Github external
private _preregisterChannel(channel: ServerSecureChannelLayer) {
        // _preregisterChannel is used to keep track of channel for which
        // that are in early stage of the hand shaking process.
        // e.g HEL/ACK and OpenSecureChannel may not have been received yet
        // as they will need to be interrupted when OPCUAServerEndPoint is closed
        assert(this._started, "OPCUAServerEndPoint must be started");

        assert(!this._channels.hasOwnProperty(channel.hashKey), " channel already preregistered!");

        this._channels[channel.hashKey] = channel;

        (channel as any)._unpreregisterChannelEvent = () => {
            debugLog("Channel received an abort event during the preregistration phase");
            this._un_pre_registerChannel(channel);
            channel.dispose();
        };
        channel.on("abort", (channel as any)._unpreregisterChannelEvent);
    }
github node-opcua / node-opcua / packages / node-opcua-server / src / monitored_item.js View on Github external
// DeadbandType = PercentDeadband
            // For this type of deadband the deadbandValue is defined as the percentage of the EURange. That is,
            // it applies only to AnalogItems with an EURange Property that defines the typical value range for the
            // item. This range shall be multiplied with the deadbandValue and then compared to the actual value change
            // to determine the need for a data change notification. The following pseudo code shows how the deadband
            // is calculated:
            //      DataChange if (absolute value of (last cached value - current value) >
            //                                          (deadbandValue/100.0) * ((high-low) of EURange)))
            //
            // Specifying a deadbandValue outside of this range will be rejected and reported with the
            // StatusCode Bad_DeadbandFilterInvalid (see Table 27).
            // If the Value of the MonitoredItem is an array, then the deadband calculation logic shall be applied to
            // each element of the array. If an element that requires a DataChange is found, then no further
            // deadband checking is necessary and the entire array shall be returned.
            assert(self.node !== null, "expecting a valid address_space object here to get access the the EURange");

            if (self.node.euRange) {
                // double,double
                const rangeVariant = self.node.euRange.readValue().value;
                const range = rangeVariant.value.high - rangeVariant.value.high;
                assert(_.isFinite(range));
                return checkDeadBand(oldDataValue.value, newDataValue.value, DeadbandType.Percent, deadbandValue, range);

            }
            return true;
    }
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.js View on Github external
function _Variable_bind_with_simple_set(options) {
    /* jshint validthis: true */
    const self = this;
    assert(self instanceof UAVariable);
    assert(_.isFunction(options.set), "should specify set function");
    assert(!options.timestamped_set, "should not specify a timestamped_set function");

    assert(!self._timestamped_set_func);
    assert(!self._set_func);

    self._set_func = turn_sync_to_async(options.set, 1);
    assert(self._set_func.length === 2, " set function must have 2 arguments ( variant, callback)");

    self._timestamped_set_func = function (timestamped_value, indexRange, callback) {
        assert(timestamped_value instanceof DataValue);
        self._set_func(timestamped_value.value, function (err, statusCode) {
            callback(err, statusCode, timestamped_value);
        });
    };
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.js View on Github external
const self = this;
    assert(!options.hasOwnProperty("arrayDimension"), "Do you mean ArrayDimensions ?");

    // dataType
    options.dataType = options.dataType || "Int32";
    options.dataType = self.addressSpace._coerce_DataType(options.dataType);

    // valueRank
    options.valueRank = utils.isNullOrUndefined(options.valueRank) ? -1 : options.valueRank;
    assert(_.isFinite(options.valueRank));
    assert(typeof options.valueRank === "number");

    // arrayDimensions
    options.arrayDimensions = options.arrayDimensions || null;
    assert(_.isArray(options.arrayDimensions) || options.arrayDimensions === null);

    const variableType = self._addObjectOrVariableType(options, "BaseVariableType", NodeClass.VariableType);

    variableType.dataType = options.dataType;
    variableType.valueRank = options.valueRank;
    variableType.arrayDimensions = options.arrayDimensions;

    return variableType;
};
github node-opcua / node-opcua / packages / node-opcua-client-dynamic-extension-object / source / extra_data_type_manager.ts View on Github external
public registerTypeDictionary(nodeId: NodeId, typeDictionary: TypeDictionary) {
        /* istanbul ignore next */
        if (this.hasDataTypeDictionary(nodeId)) {
            throw new Error("Dictionary already registered");
        }

        this.typeDictionaries[this.makeKey(nodeId)] = typeDictionary;
        assert(nodeId.namespace !== 0,
            "registerTypeDictionary cannot be used for namespace 0");
        assert(!this.typeDictionariesByNamespace.hasOwnProperty(nodeId.namespace),
            "already registered");
        this.typeDictionariesByNamespace[nodeId.namespace] = typeDictionary;
    }
github node-opcua / node-opcua / packages / node-opcua-client-dynamic-extension-object / source / extra_data_type_manager.ts View on Github external
public registerTypeDictionary(nodeId: NodeId, typeDictionary: TypeDictionary) {
        /* istanbul ignore next */
        if (this.hasDataTypeDictionary(nodeId)) {
            throw new Error("Dictionary already registered");
        }

        this.typeDictionaries[this.makeKey(nodeId)] = typeDictionary;
        assert(nodeId.namespace !== 0,
            "registerTypeDictionary cannot be used for namespace 0");
        assert(!this.typeDictionariesByNamespace.hasOwnProperty(nodeId.namespace),
            "already registered");
        this.typeDictionariesByNamespace[nodeId.namespace] = typeDictionary;
    }
github node-opcua / node-opcua / packages / node-opcua-address-space-for-conformance-testing / src / address_space_for_conformance_testing.js View on Github external
function getRandomFuncForType(dataType) {

    assert(dataType);
    const dataTypeName = DataType[dataType];

    const f = ec["random" + dataTypeName];

    if (f) {
        return f;
    }

    //xx console.log("xxxx dataType  ",dataType);
    switch (dataTypeName) {
        case "Variant":
            return function() {
                return new Variant();
            };
        case "QualifiedName":
            return function() {
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.js View on Github external
addressSpace.modelChangeTransaction(function () {

        assert(isNonEmptyQualifiedName(options.browseName));
        //xx assert(options.hasOwnProperty("browseName") && options.browseName.length > 0);

        assert(options.hasOwnProperty("nodeClass"));
        options.references = addressSpace.normalizeReferenceTypes(options.references);

        const references = _copy_references(options.references);

        _handle_hierarchy_parent(addressSpace, references, options);

        _handle_event_hierarchy_parent(addressSpace, references, options);

        UANamespace._process_modelling_rule(references, options.modellingRule);

        options.references = references;

        node = self._createNode(options);
        assert(node.nodeId instanceof NodeId);

        node.propagate_back_references();

node-opcua-assert

pure nodejs OPCUA SDK - module assert

MIT
Latest version published 3 months ago

Package Health Score

86 / 100
Full package analysis

Popular node-opcua-assert functions