How to use the node-opcua-status-code.StatusCodes.BadIndexRangeInvalid 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-data-value / source / datavalue.ts View on Github external
export function extractRange(dataValue: DataValue, indexRange: NumericalRange): DataValue {

  const variant = dataValue.value;
  if (indexRange && canRange(dataValue)) {
    if (!indexRange.isValid()) {
      return new DataValue({ statusCode: StatusCodes.BadIndexRangeInvalid });
    }
    // let's extract an array of elements corresponding to the indexRange
    const result = indexRange.extract_values(variant.value, variant.dimensions);
    dataValue = _clone_with_array_replacement(dataValue, result);
  } else {
    // clone the whole data Value
    dataValue = dataValue.clone();
  }
  return dataValue;
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.ts View on Github external
write_func.call(this, dataValue, indexRange, (
            err: Error | null,
            statusCode1: StatusCode,
            correctedDataValue: DataValue) => {

            if (!err) {

                correctedDataValue = correctedDataValue || dataValue;
                assert(correctedDataValue instanceof DataValue);
                // xx assert(correctedDataValue.serverTimestamp);

                if (indexRange && !indexRange.isEmpty()) {

                    if (!indexRange.isValid()) {
                        return callback!(null, StatusCodes.BadIndexRangeInvalid);
                    }

                    const newArr = correctedDataValue.value.value;
                    // check that source data is an array
                    if (correctedDataValue.value.arrayType !== VariantArrayType.Array) {
                        return callback!(null, StatusCodes.BadTypeMismatch);
                    }

                    // check that destination data is also an array
                    assert(check_valid_array(this._dataValue.value.dataType, this._dataValue.value.value));
                    const destArr = this._dataValue.value.value;
                    const result = indexRange.set_values(destArr, newArr);

                    if (result.statusCode.isNot(StatusCodes.Good)) {
                        return callback!(null, result.statusCode);
                    }
github node-opcua / node-opcua / packages / node-opcua-numeric-range / source / numeric_range.ts View on Github external
low_index = 0;
        high_index = arrayToAlter.length - 1;
        break;
      case NumericRangeType.SingleValue:
        low_index = self.value;
        high_index = self.value;
        break;
      case NumericRangeType.ArrayRange:
        low_index = self.value[0];
        high_index = self.value[1];
        break;
      case NumericRangeType.MatrixRange:
        // for the time being MatrixRange is not supported
        return { array: arrayToAlter, statusCode: StatusCodes.BadIndexRangeNoData };
      default:
        return { array: [], statusCode: StatusCodes.BadIndexRangeInvalid };
    }

    if (high_index >= arrayToAlter.length || low_index >= arrayToAlter.length) {
      return { array: [], statusCode: StatusCodes.BadIndexRangeNoData };
    }
    if ((this.type !== NumericRangeType.Empty) && newValues.length !== (high_index - low_index + 1)) {
      return { array: [], statusCode: StatusCodes.BadIndexRangeInvalid };
    }
    const insertInPlace = (_.isArray(arrayToAlter)
      ? insertInPlaceStandardArray
      : (arrayToAlter instanceof Buffer ? insertInPlaceBuffer : insertInPlaceTypedArray));
    return {
      array: insertInPlace(arrayToAlter, low_index, high_index, newValues),
      statusCode: StatusCodes.Good
    };
  }
github node-opcua / node-opcua / packages / node-opcua-server / source / server_subscription.ts View on Github external
const node = addressSpace.findNode(itemToMonitor.nodeId);
    if (!node) {
      return handle_error(StatusCodes.BadNodeIdUnknown);
    }

    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;
github node-opcua / node-opcua / packages / node-opcua-server / src / server_subscription.js View on Github external
return handle_error(StatusCodes.BadNodeIdUnknown);
    }


    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;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.js View on Github external
self._timestamped_set_func(dataValue, indexRange, function (err, statusCode, correctedDataValue) {

        if (!err) {

            correctedDataValue = correctedDataValue || dataValue;
            assert(correctedDataValue instanceof DataValue);
            //xx assert(correctedDataValue.serverTimestamp);

            if (indexRange && !indexRange.isEmpty()) {

                if (!indexRange.isValid()) {
                    return callback(null, StatusCodes.BadIndexRangeInvalid);
                }

                const newArr = correctedDataValue.value.value;
                // check that source data is an array
                if (correctedDataValue.value.arrayType !== VariantArrayType.Array) {
                    return callback(null, StatusCodes.BadTypeMismatch);
                }

                // check that destination data is also an array
                assert(check_valid_array(self._dataValue.value.dataType, self._dataValue.value.value));
                const destArr = self._dataValue.value.value;
                const result = indexRange.set_values(destArr, newArr);

                if (result.statusCode.isNot(StatusCodes.Good)) {
                    return callback(null, result.statusCode);
                }