How to use the node-opcua-data-value.extractRange function in node-opcua-data-value

To help you get started, we’ve selected a few node-opcua-data-value 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
//             this.node.listenerCount("value_changed"),this.node.nodeId.toString());
    // xx   console.log("events ---- ",this.node.eventNames().join("-"));
    // xx    console.log("indexRange = ",indexRange ? indexRange.toString() :"");
    // xx    console.log("this.itemToMonitor.indexRange = ",this.itemToMonitor.indexRange.toString());

    if (!hasSemanticChanged && indexRange && this.itemToMonitor.indexRange) {
      // we just ignore changes that do not fall within our range
      // ( unless semantic bit has changed )
      if (!NumericRange.overlap(indexRange as NumericalRange0, this.itemToMonitor.indexRange)) {
        return; // no overlap !
      }
    }

    assert(this.itemToMonitor, "must have a valid itemToMonitor(have this monitoredItem been disposed already ?");
    // extract the range that we are interested with
    dataValue = extractRange(dataValue, this.itemToMonitor.indexRange);

    // istanbul ignore next
    if (doDebug) {
      debugLog("MonitoredItem#recordValue",
        this.node!.nodeId.toString(),
        this.node!.browseName.toString(), " has Changed = ", !sameDataValue(dataValue, this.oldDataValue!));
    }

    // if semantic has changed, value need to be enqueued regardless of other assumptions
    if (hasSemanticChanged) {
      return this._enqueue_value(dataValue);
    }

    const useIndexRange = this.itemToMonitor.indexRange && !this.itemToMonitor.indexRange.isEmpty();

    if (!skipChangeTest) {
github node-opcua / node-opcua / packages / node-opcua-server / src / monitored_item.js View on Github external
//             self.node.listenerCount("value_changed"),self.node.nodeId.toString());
    //xx   console.log("events ---- ",self.node.eventNames().join("-"));
    //xx    console.log("indexRange = ",indexRange ? indexRange.toString() :"");
    //xx    console.log("self.itemToMonitor.indexRange = ",self.itemToMonitor.indexRange.toString());

    if (!hasSemanticChanged && indexRange && self.itemToMonitor.indexRange) {
        // we just ignore changes that do not fall within our range
        // ( unless semantic bit has changed )
        if (!NumericRange.overlap(indexRange,self.itemToMonitor.indexRange)) {
            return; // no overlap !
        }
    }

    assert( self.itemToMonitor,"must have a valid itemToMonitor(have this monitoredItem been disposed already ?");
    // extract the range that we are interested with
    dataValue = extractRange(dataValue, self.itemToMonitor.indexRange);

    // istanbul ignore next
    if (doDebug) {
        debugLog("MonitoredItem#recordValue", self.node.nodeId.toString(), self.node.browseName.toString(), " has Changed = ", !sameDataValue(dataValue, self.oldDataValue));
    }

    // if semantic has changed, value need to be enqueued regardless of other assumptions
    if (hasSemanticChanged) {
        return self._enqueue_value(dataValue);
    }

    const useIndexRange = self.itemToMonitor.indexRange && !self.itemToMonitor.indexRange.isEmpty();

    if (!skipChangeTest) {
        const hasChanged = !sameDataValue(dataValue, self.oldDataValue);
        if (!hasChanged) {
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.js View on Github external
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)) {
        debugLog(" Warning:  UAVariable#readValue ".red + self.browseName.toString().cyan + " (" + self.nodeId.toString().yellow + ") exists but dataValue has not been defined");
    }
    return dataValue;
};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.ts View on Github external
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)
            || dataValue.statusCode.equals(StatusCodes.UncertainInitialValue)
        ) {
            debugLog(chalk.red(" Warning:  UAVariable#readValue ")
                + chalk.cyan(this.browseName.toString()) +
                " (" + chalk.yellow(this.nodeId.toString()) + ") exists but dataValue has not been defined");
        }
        return dataValue;
    }