Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "node-opcua-date-time in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'node-opcua-date-time' 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.

public touchValue(optionalNow?: PreciseClock): void {
        const variable = this;
        const now = optionalNow || getCurrentClock();
        variable._dataValue.sourceTimestamp = now.timestamp;
        variable._dataValue.sourcePicoseconds = now.picoseconds;
        variable._dataValue.serverTimestamp = now.timestamp;
        variable._dataValue.serverPicoseconds = now.picoseconds;

        variable._dataValue.statusCode = StatusCodes.Good;

        if (variable.minimumSamplingInterval === 0) {
            // xx console.log("xxx touchValue = ",variable.browseName.toString(),variable._dataValue.value.value);
            if (variable.listenerCount("value_changed") > 0) {
                const clonedDataValue = variable.readValue();
                variable.emit("value_changed", clonedDataValue);
            }
        }
        if (variable.parent && variable.parent.nodeClass === NodeClass.Variable) {
            (variable.parent as UAVariable).touchValue(now);
assert(dataValue.hasOwnProperty("serverTimestamp"));
  assert(dataValue.hasOwnProperty("sourceTimestamp"));

  let cloneDataValue = null;
  let now = null;
  // apply timestamps
  switch (timestampsToReturn) {
    case TimestampsToReturn.Neither:
      cloneDataValue = cloneDataValue || _partial_clone(dataValue);
      break;
    case TimestampsToReturn.Server:
      cloneDataValue = cloneDataValue || _partial_clone(dataValue);
      cloneDataValue.serverTimestamp = dataValue.serverTimestamp;
      cloneDataValue.serverPicoseconds = dataValue.serverPicoseconds;
      if (!cloneDataValue.serverTimestamp) {
        now = now || getCurrentClock();
        cloneDataValue.serverTimestamp = now.timestamp as DateTime;
        cloneDataValue.serverPicoseconds = now.picoseconds;
      }
      break;
    case TimestampsToReturn.Source:
      cloneDataValue = cloneDataValue || _partial_clone(dataValue);
      cloneDataValue.sourceTimestamp = dataValue.sourceTimestamp;
      cloneDataValue.sourcePicoseconds = dataValue.sourcePicoseconds;
      break;
    default:
      assert(timestampsToReturn === TimestampsToReturn.Both);
      cloneDataValue = cloneDataValue || _partial_clone(dataValue);
      cloneDataValue.serverTimestamp = dataValue.serverTimestamp;
      cloneDataValue.serverPicoseconds = dataValue.serverPicoseconds;
      if (!cloneDataValue.serverTimestamp) {
        now = now || getCurrentClock();
function apply_timestamps2(
  dataValue: DataValue,
  timestampsToReturn: TimestampsToReturn,
  attributeId: AttributeIds
): DataValue {

  assert(attributeId > 0);
  assert(dataValue.hasOwnProperty("serverTimestamp"));
  assert(dataValue.hasOwnProperty("sourceTimestamp"));
  const cloneDataValue = new DataValue({});
  cloneDataValue.value = dataValue.value;
  cloneDataValue.statusCode = dataValue.statusCode;
  const now = getCurrentClock();
  // apply timestamps
  switch (timestampsToReturn) {
    case TimestampsToReturn.Server:
      cloneDataValue.serverTimestamp = dataValue.serverTimestamp;
      cloneDataValue.serverPicoseconds = dataValue.serverPicoseconds;
      cloneDataValue.serverTimestamp = now.timestamp as DateTime;
      cloneDataValue.serverPicoseconds = now.picoseconds;
      break;
    case TimestampsToReturn.Source:
      cloneDataValue.sourceTimestamp = dataValue.sourceTimestamp;
      cloneDataValue.sourcePicoseconds = dataValue.sourcePicoseconds;
      break;
    case TimestampsToReturn.Both:
      cloneDataValue.serverTimestamp = dataValue.serverTimestamp;
      cloneDataValue.serverPicoseconds = dataValue.serverPicoseconds;
      cloneDataValue.serverTimestamp = now.timestamp as DateTime;
UAVariable.prototype.writeValue = function (context, dataValue, indexRange, callback) {

    const self = this;
    if (!context) {
        context = SessionContext.defaultContext;
    }
    if (!dataValue.sourceTimestamp) {
        if (context.currentTime) {
            dataValue.sourceTimestamp = context.currentTime;
            dataValue.sourcePicoseconds = 0;
        } else {
            const clock = getCurrentClock();
            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();
function apply_timestamps2(dataValue, timestampsToReturn, attributeId) {

    assert(attributeId > 0);
    assert(timestampsToReturn.hasOwnProperty("key"));
    assert(dataValue instanceof DataValue);
    assert(dataValue.hasOwnProperty("serverTimestamp"));
    assert(dataValue.hasOwnProperty("sourceTimestamp"));

    const cloneDataValue = new DataValue({});
    cloneDataValue.value = dataValue.value;
    cloneDataValue.statusCode = dataValue.statusCode;

    const now = getCurrentClock();
    // apply timestamps
    switch (timestampsToReturn) {
        case TimestampsToReturn.Server:
            cloneDataValue.serverTimestamp = dataValue.serverTimestamp;
            cloneDataValue.serverPicoseconds = dataValue.serverPicoseconds;
            //xxif (true || !cloneDataValue.serverTimestamp) {
                cloneDataValue.serverTimestamp = now.timestamp;
                cloneDataValue.serverPicoseconds = now.picoseconds;
            //xx}
            break;
        case TimestampsToReturn.Source:
            cloneDataValue.sourceTimestamp = dataValue.sourceTimestamp;
            cloneDataValue.sourcePicoseconds = dataValue.sourcePicoseconds;
            break;
        case TimestampsToReturn.Both:
            cloneDataValue.serverTimestamp = dataValue.serverTimestamp;
historyData: new HistoryData({ dataValues }),
      statusCode: StatusCodes.Good
    });
    return callback(null, result2);
  }

  // todo add special treatment for when startTime > endTime
  // ( in this case series must be return in reverse order )

  let maxNumberToExtract = 0;
  let isReversed = false;
  let reverseDataValue = false;
  if (isMinDate(historyReadRawModifiedDetails.endTime!)) {
    // end time is not specified
    maxNumberToExtract = historyReadRawModifiedDetails.numValuesPerNode;
    if (isMinDate(historyReadRawModifiedDetails.startTime!)) {
      // end start and start time are not specified, this is invalid
      const result = new HistoryReadResult({
        statusCode: StatusCodes.BadHistoryOperationUnsupported // should be an error
      });
      return callback(null, result);
    }

  } else if (isMinDate(historyReadRawModifiedDetails.startTime!)) {
    // start time is not specified
    // end time is specified
    maxNumberToExtract = historyReadRawModifiedDetails.numValuesPerNode;
    isReversed = true;
    reverseDataValue = false;

    if (historyReadRawModifiedDetails.numValuesPerNode === 0) {
      // when start time is not specified
return callback(err);
      }

      // now make sure that only the requested number of value is returned
      if (historyReadRawModifiedDetails.numValuesPerNode >= 1) {
        if (dataValues.length === 0) {
          const result1 = new HistoryReadResult({
            historyData: new HistoryData({ dataValues: [] }),
            statusCode: StatusCodes.GoodNoData
          });
          return callback(null, result1);
        } else {
          const remaining = dataValues;
          dataValues = remaining.splice(0, historyReadRawModifiedDetails.numValuesPerNode);

          if (remaining.length > 0 && !isMinDate(historyReadRawModifiedDetails.endTime)) {
            continuationPoint = createContinuationPoint();
            context.continuationPoints = context.continuationPoints || {};
            context.continuationPoints[continuationPoint.toString("hex")] = {
              dataValues: remaining
            };
          }
        }
      }
      const result = new HistoryReadResult({
        continuationPoint: continuationPoint || undefined,
        historyData: new HistoryData({ dataValues }),
        statusCode: StatusCodes.Good
      });
      callback(null, result);
    });
if (!variant.dataType) {
            throw new Error("Variant must provide a valid dataType" + variant.toString());
        }
    }

    // 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 (variant.dataType === null || variant.dataType === undefined) {
                throw new Error("Variant must provide a valid dataType" + variant.toString());
            }
        }

        // 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({
            serverPicoseconds: now.picoseconds,
            serverTimestamp: now.timestamp,
            sourcePicoseconds: now.picoseconds,
            sourceTimestamp: now.timestamp,
            statusCode: statusCode || StatusCodes.Good
        });
        dataValue.value = variant as Variant;
        this._internal_set_dataValue(dataValue);
    }
UAVariable.prototype.touchValue = function (optionalNow) {
    const variable = this;
    const now = optionalNow || getCurrentClock();
    variable._dataValue.sourceTimestamp = now.timestamp;
    variable._dataValue.sourcePicoseconds = now.picoseconds;
    variable._dataValue.serverTimestamp = now.timestamp;
    variable._dataValue.serverPicoseconds = now.picoseconds;

    variable._dataValue.statusCode = StatusCodes.Good;

    if (variable.minimumSamplingInterval === 0) {
        //xx console.log("xxx touchValue = ",variable.browseName.toString(),variable._dataValue.value.value);
        if (variable.listenerCount("value_changed") > 0) {
            const clonedDataValue = variable.readValue();
            variable.emit("value_changed", clonedDataValue);
        }
    }
    if (variable.parent && variable.parent.nodeClass == NodeClass.Variable) {
        variable.parent.touchValue(now);

Is your System Free of Underlying Vulnerabilities?
Find Out Now