Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "node-opcua-data-value in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'node-opcua-data-value' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

value: number | boolean | null,
    statusCode: StatusCode
): DataValue {
    // setup data
    const sourceTimestamp = makeDate(time);

    if (value === undefined || value === null) {

        return new DataValue({
            sourceTimestamp,
            statusCode,
            value: undefined,
        });

    } else if (typeof value === "boolean") {
        return new DataValue({
            sourceTimestamp,
            statusCode,
            value: {dataType: DataType.Boolean, value},
        });

    } else {
        return new DataValue({
            sourceTimestamp,
            statusCode,
            value: {dataType: DataType.Float, value},
        });
    }
}
self._dataValue.statusCode = self._dataValue.statusCode || StatusCodes.Good;

    // repair missing timestamps
    if (!dataValue.serverTimestamp) {
        self._dataValue.serverTimestamp = old_dataValue.serverTimestamp;
        self._dataValue.serverPicoseconds = old_dataValue.serverPicoseconds;
    }
    if (!dataValue.sourceTimestamp) {
        self._dataValue.sourceTimestamp = old_dataValue.sourceTimestamp;
        self._dataValue.sourcePicoseconds = old_dataValue.sourcePicoseconds;
    }

    // if (dataValue.value.arrayType ===VariantArrayType.Array) {
    //     console.log("xxxx UAVariable emit value_changed ??".bgRed, old_dataValue.value.toString(),dataValue.value.toString());
    // }
    if (!sameDataValue(old_dataValue, dataValue)) {
        //xx if(this.nodeId.toString()=== "ns=2;s=Scalar_Static_Int32") {
        //xx     console.log("UAVariable emit value_changed");
        //xx }
        self.emit("value_changed", self._dataValue, indexRange);
    }
};
const indexRange = nodeToRead.indexRange;
    const dataEncoding = nodeToRead.dataEncoding;

    if (timestampsToReturn === TimestampsToReturn.Invalid) {
      return new DataValue({ statusCode: StatusCodes.BadTimestampsToReturnInvalid });
    }

    timestampsToReturn = (timestampsToReturn !== undefined) ? timestampsToReturn : TimestampsToReturn.Neither;

    const obj = engine.__findObject(nodeId!);

    let dataValue;
    if (!obj) {
      // may be return BadNodeIdUnknown in dataValue instead ?
      // Object Not Found
      return new DataValue({ statusCode: StatusCodes.BadNodeIdUnknown });
    } else {

      // check access
      //    BadUserAccessDenied
      //    BadNotReadable
      //    invalid attributes : BadNodeAttributesInvalid
      //    invalid range      : BadIndexRangeInvalid
      try {
        dataValue = obj.readAttribute(context, attributeId, indexRange, dataEncoding);
        assert(dataValue.statusCode instanceof StatusCode);
        if (!dataValue.isValid()) {
          console.log("Invalid value for node ", obj.nodeId.toString(), obj.browseName.toString());
        }

      } catch (err) {
        console.log(" Internal error reading  NodeId       ", obj.nodeId.toString());
const old_dataValue = this._dataValue;

        this._dataValue = dataValue;
        this._dataValue.statusCode = this._dataValue.statusCode || StatusCodes.Good;

        // repair missing timestamps
        if (!dataValue.serverTimestamp) {
            this._dataValue.serverTimestamp = old_dataValue.serverTimestamp;
            this._dataValue.serverPicoseconds = old_dataValue.serverPicoseconds;
        }
        if (!dataValue.sourceTimestamp) {
            this._dataValue.sourceTimestamp = old_dataValue.sourceTimestamp;
            this._dataValue.sourcePicoseconds = old_dataValue.sourcePicoseconds;
        }

        if (!sameDataValue(old_dataValue, dataValue)) {
            this.emit("value_changed", this._dataValue, indexRange);
        }
    }
assert(dataValue.statusCode instanceof StatusCode);
        if (!dataValue.isValid()) {
          console.log("Invalid value for node ", obj.nodeId.toString(), obj.browseName.toString());
        }

      } catch (err) {
        console.log(" Internal error reading  NodeId       ", obj.nodeId.toString());
        console.log("                         AttributeId  ", attributeId.toString());
        console.log("                        ", err.message);
        console.log("                        ", err.stack);
        return new DataValue({ statusCode: StatusCodes.BadInternalError });
      }

      // Xx console.log(dataValue.toString());

      dataValue = apply_timestamps(dataValue, timestampsToReturn, attributeId);

      return dataValue;
    }
  }
//             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) {
//             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) {
}
    }

    // if (variant.hasOwnProperty("value")) {
    //     if (variant.dataType === DataType.UInt32) {
    //         if (!_.isFinite(variant.value)) {
    //             throw new Error("Expecting an number");
    //         }
    //     }
    // }

    variant = Variant.coerce(variant);

    const now = coerceClock(sourceTimestamp, 0);

    const dataValue = new DataValue({
        sourceTimestamp: now.timestamp,
        sourcePicoseconds: now.picoseconds,
        serverTimestamp: now.timestamp,
        serverPicoseconds: now.picoseconds,
        statusCode: statusCode || StatusCodes.Good
    });
    dataValue.value = variant;
    self._internal_set_dataValue(dataValue, null);
};
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) {
            return;
        }
    }
// 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) {
      const hasChanged = !sameDataValue(dataValue, this.oldDataValue!);
      if (!hasChanged) {
        return;
      }
    }

    if (!apply_filter.call(this, dataValue)) {
      debugLog("filter did not pass");
      return;
    }

    if (useIndexRange) {
      // when an indexRange is provided , make sure that no record happens unless
      // extracted variant in the selected range  has really changed.

      // istanbul ignore next
      if (doDebug) {

Is your System Free of Underlying Vulnerabilities?
Find Out Now