How to use the node-opcua-numeric-range.NumericRange.coerce function in node-opcua-numeric-range

To help you get started, we’ve selected a few node-opcua-numeric-range 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-address-space / src / ua_variable.ts View on Github external
let indexRange: NumericRange | null = null;
        let callback: StatusCodeCallBack;
        if (args.length === 1) {
            indexRange = new NumericRange();
            callback = args[0];
        } else if (args.length === 2) {
            indexRange = args[0];
            callback = args[1];
        } else {
            throw new Error("Invalid Number of args");
        }

        assert(_.isFunction(callback));
        assert(dataValue instanceof DataValue);
        // index range could be string
        indexRange = NumericRange.coerce(indexRange);

        // test write permission
        if (!this.isWritable(context)) {
            return callback!(null, StatusCodes.BadNotWritable);
        }
        if (!this.isUserWritable(context)) {
            return callback!(null, StatusCodes.BadUserAccessDenied);
        }

        // adjust special case
        const variant = adjustVariant.call(this, dataValue.value);

        const statusCode = this.checkVariantCompatibility(variant);
        if (statusCode.isNot(StatusCodes.Good)) {
            return callback!(null, statusCode);
        }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.js View on Github external
if (context.currentTime && !dataValue.serverTimestamp) {
        dataValue.serverTimestamp = context.currentTime;
        dataValue.serverPicoseconds = 0;
    }

    assert(context instanceof SessionContext);

    // adjust arguments if optional indexRange Parameter is not given
    if (!_.isFunction(callback) && _.isFunction(indexRange)) {
        callback = indexRange;
        indexRange = new NumericRange();
    }
    assert(_.isFunction(callback));
    assert(dataValue instanceof DataValue);

    indexRange = NumericRange.coerce(indexRange);

    // test write permission
    if (!self.isWritable(context)) {
        return callback(null, StatusCodes.BadNotWritable);
    }
    if (!self.isUserWritable(context)) {
        return callback(null, StatusCodes.BadUserAccessDenied);
    }

    // adjust special case
    const variant = adjustVariant(self, dataValue.value);

    const statusCode = self.isValueInRange(variant);
    if (statusCode.isNot(StatusCodes.Good)) {
        return callback(null, statusCode);
    }

node-opcua-numeric-range

pure nodejs OPCUA SDK - module numeric-range

MIT
Latest version published 1 month ago

Package Health Score

84 / 100
Full package analysis