How to use the node-opcua-numeric-range.NumericRange 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
}
                        }
                        */
        }

        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
        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);
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.js View on Github external
dataValue.sourceTimestamp = clock.timestamp;
            dataValue.sourcePicoseconds = clock.picoseconds;
        }
    }

    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);
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_data_type.ts View on Github external
public get binaryEncodingDefinition(): string {
        const indexRange = new NumericRange();
        const descriptionNode = this.binaryEncoding.findReferencesAsObject("HasDescription")[0];
        const structureVar = descriptionNode.findReferencesAsObject(
          "HasComponent", false)[0] as any as UAVariable;
        const dataValue = structureVar.readValue(SessionContext.defaultContext, indexRange);
        // xx if (!dataValue || !dataValue.value || !dataValue.value.value) { return "empty";}
        return dataValue.value.value.toString();
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_data_type.ts View on Github external
public get xmlEncodingDefinition(): string {
        const indexRange = new NumericRange();
        const descriptionNode = this.xmlEncoding.findReferencesAsObject("HasDescription")[0];
        const structureVar = descriptionNode.findReferencesAsObject(
          "HasComponent", false)[0] as any as UAVariable;
        const dataValue = structureVar.readValue(SessionContext.defaultContext, indexRange);
        if (!dataValue || !dataValue.value || !dataValue.value.value) {
            return "empty";
        }
        return dataValue.value.value.toString();
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_data_type.js View on Github external
UADataType.prototype.__defineGetter__("xmlEncodingDefinition", function () {
    const indexRange = new NumericRange();
    const descriptionNode = this.xmlEncoding.findReferencesAsObject("HasDescription")[0];
    const structureVar    = descriptionNode.findReferencesAsObject("HasComponent",false)[0];
    const dataValue = structureVar.readValue(SessionContext.defaultContext, indexRange);
    if (!dataValue || !dataValue.value || !dataValue.value.value) {
        return "empty";
    }
    return dataValue.value.value.toString();
});

node-opcua-numeric-range

pure nodejs OPCUA SDK - module numeric-range

MIT
Latest version published 3 months ago

Package Health Score

86 / 100
Full package analysis