How to use the node-opcua-service-read.TimestampsToReturn.Invalid function in node-opcua-service-read

To help you get started, we’ve selected a few node-opcua-service-read 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 / server_engine.ts View on Github external
private _readSingleNode(
    context: SessionContext,
    nodeToRead: ReadValueIdOptions,
    timestampsToReturn?: TimestampsToReturn
  ): DataValue {

    assert(context instanceof SessionContext);
    const engine = this;
    const nodeId = nodeToRead.nodeId!;
    const attributeId = nodeToRead.attributeId!;
    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