How to use the node-opcua-status-code.StatusCodes.BadDataEncodingInvalid function in node-opcua-status-code

To help you get started, we’ve selected a few node-opcua-status-code 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 / src / server_subscription.js View on Github external
// AttributeIds.Value is only valid for monitoring value of UAVariables.
        return handle_error(StatusCodes.BadAttributeIdInvalid);
    }


    if (itemToMonitor.attributeId === AttributeIds.INVALID) {
        return handle_error(StatusCodes.BadAttributeIdInvalid);
    }

    if (!itemToMonitor.indexRange.isValid()) {
        return handle_error(StatusCodes.BadIndexRangeInvalid);
    }

    // check dataEncoding applies only on Values
    if (itemToMonitor.dataEncoding.name && itemToMonitor.attributeId !== AttributeIds.Value) {
        return handle_error(StatusCodes.BadDataEncodingInvalid);
    }

    // check dataEncoding
    if (!isValidDataEncoding(itemToMonitor.dataEncoding)) {
        return handle_error(StatusCodes.BadDataEncodingUnsupported);
    }

    // check that item can be read by current user session

    // filter
    const requestedParameters = monitoredItemCreateRequest.requestedParameters;
    const filter = requestedParameters.filter;
    const statusCodeFilter = validateFilter(filter, itemToMonitor, node);
    if (statusCodeFilter !== StatusCodes.Good) {
        return handle_error(statusCodeFilter);
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.js View on Github external
UAVariable.prototype.readValue = function (context, indexRange, dataEncoding) {

    if (!context) {
        context = SessionContext.defaultContext;
    }
    const self = this;

    if (!self.isReadable(context)) {
        return new DataValue({statusCode: StatusCodes.BadNotReadable});
    }
    if (!self.isUserReadable(context)) {
        return new DataValue({statusCode: StatusCodes.BadUserAccessDenied});
    }
    if (!is_valid_dataEncoding(dataEncoding)) {
        return new DataValue({statusCode: StatusCodes.BadDataEncodingInvalid});
    }

    if (self._timestamped_get_func) {
        assert(self._timestamped_get_func.length === 0);
        self._dataValue = self._timestamped_get_func();
    }

    let dataValue = self._dataValue;

    if (isGoodish(dataValue.statusCode)) {

        dataValue = extractRange(dataValue, indexRange);
    }

    /* istanbul ignore next */
    if (dataValue.statusCode.equals(StatusCodes.BadWaitingForInitialData)) {
github node-opcua / node-opcua / packages / node-opcua-server / source / server_subscription.ts View on Github external
if (itemToMonitor.attributeId === AttributeIds.Value && !(node.nodeClass === NodeClass.Variable)) {
      // AttributeIds.Value is only valid for monitoring value of UAVariables.
      return handle_error(StatusCodes.BadAttributeIdInvalid);
    }

    if (itemToMonitor.attributeId === AttributeIds.INVALID) {
      return handle_error(StatusCodes.BadAttributeIdInvalid);
    }

    if (!itemToMonitor.indexRange.isValid()) {
      return handle_error(StatusCodes.BadIndexRangeInvalid);
    }

    // check dataEncoding applies only on Values
    if (itemToMonitor.dataEncoding.name && itemToMonitor.attributeId !== AttributeIds.Value) {
      return handle_error(StatusCodes.BadDataEncodingInvalid);
    }

    // check dataEncoding
    if (!isValidDataEncoding(itemToMonitor.dataEncoding)) {
      return handle_error(StatusCodes.BadDataEncodingUnsupported);
    }

    // check that item can be read by current user session

    // filter
    const requestedParameters = monitoredItemCreateRequest.requestedParameters;
    const filter = requestedParameters.filter;
    const statusCodeFilter = validateFilter(filter, itemToMonitor, node);
    if (statusCodeFilter !== StatusCodes.Good) {
      return handle_error(statusCodeFilter);
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.ts View on Github external
public readValue(context?: SessionContext | null, indexRange?: NumericRange, dataEncoding?: string) {

        if (!context) {
            context = SessionContext.defaultContext;
        }

        if (!this.isReadable(context)) {
            return new DataValue({ statusCode: StatusCodes.BadNotReadable });
        }
        if (!this.isUserReadable(context)) {
            return new DataValue({ statusCode: StatusCodes.BadUserAccessDenied });
        }
        if (!isValidDataEncoding(dataEncoding)) {
            return new DataValue({ statusCode: StatusCodes.BadDataEncodingInvalid });
        }

        if (this._timestamped_get_func) {
            assert(this._timestamped_get_func.length === 0);
            this._dataValue = this._timestamped_get_func();
        }

        let dataValue = this._dataValue;

        if (isGoodish(dataValue.statusCode)) {
            // note : extractRange will clone the dataValue
            dataValue = extractRange(dataValue, indexRange);
        }

        /* istanbul ignore next */
        if (dataValue.statusCode.equals(StatusCodes.BadWaitingForInitialData)
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.ts View on Github external
): DataValue {

        if (!context) {
            context = SessionContext.defaultContext;
        }
        assert(context instanceof SessionContext);

        const options: DataValueLike = {};

        if (attributeId !== AttributeIds.Value) {
            if (indexRange && indexRange.isDefined()) {
                options.statusCode = StatusCodes.BadIndexRangeNoData;
                return new DataValue(options);
            }
            if (isDataEncoding(dataEncoding)) {
                options.statusCode = StatusCodes.BadDataEncodingInvalid;
                return new DataValue(options);
            }
        }

        switch (attributeId) {
            case AttributeIds.Value:
                return this.readValue(context, indexRange, dataEncoding);

            case AttributeIds.DataType:
                return this._readDataType();

            case AttributeIds.ValueRank:
                return this._readValueRank();

            case AttributeIds.ArrayDimensions:
                return this._readArrayDimensions();
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.js View on Github external
UAVariable.prototype.readAttribute = function (context, attributeId, indexRange, dataEncoding) {

    if (!context) {
        context = SessionContext.defaultContext;
    }
    assert(context instanceof SessionContext);

    const options = {};

    if (attributeId !== AttributeIds.Value) {
        if (indexRange && indexRange.isDefined()) {
            options.statusCode = StatusCodes.BadIndexRangeNoData;
            return new DataValue(options);
        }
        if (is_dataEncoding(dataEncoding)) {
            options.statusCode = StatusCodes.BadDataEncodingInvalid;
            return new DataValue(options);
        }
    }

    switch (attributeId) {
        case AttributeIds.Value:
            return this.readValue(context, indexRange, dataEncoding);

        case AttributeIds.DataType:
            return this._readDataType();

        case AttributeIds.ValueRank:
            return this._readValueRank();

        case AttributeIds.ArrayDimensions:
            return this._readArrayDimensions();