How to use the node-opcua-service-read.ReadRequest 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-client / src / client_session.js View on Github external
console.log("   session.read(nodesToRead,function(err,nodesToRead,results) {}".cyan);
            console.log("   with .... :".red);
            console.log("   session.read(nodesToRead,function(err,dataValues) {}".cyan);
            console.log("");
            console.log("please make sure to refactor your code and check that he second argument of your callback function is named".yellow,("dataValue" + (isArray?"s":"")).cyan);
            console.log("to make this exception disappear".yellow);
            throw new Error("ERROR ClientSession#read  API has changed !!, please fix the client code");
        }
    }

    // coerce nodeIds
    for (const node of nodesToRead) {
        node.nodeId = resolveNodeId(node.nodeId);
    }

    const request = new read_service.ReadRequest({
        nodesToRead: nodesToRead,
        maxAge: maxAge,
        timestampsToReturn: read_service.TimestampsToReturn.Both
    });

    self.performMessageTransaction(request, function (err, response) {

        /* istanbul ignore next */
        if (err) {
            return callback(err, response);
        }
        assert(response instanceof read_service.ReadResponse);

        const result =isArray? response.results : response.results[0];

        return callback(null,result);
github node-opcua / node-opcua / packages / node-opcua-client / src / client_session.js View on Github external
return new read_service.ReadValueId({
                nodeId: resolveNodeId(node),
                attributeId: read_service.AttributeIds.Value,
                indexRange: null,
                dataEncoding: {namespaceIndex: 0, name: null}
            });

        } else {
            assert(node instanceof Object);
            return new read_service.ReadValueId(node);
        }
    }

    const nodesToRead = nodes.map(coerceReadValueId);

    const request = new read_service.ReadRequest({
        nodesToRead: nodesToRead,
        timestampsToReturn: read_service.TimestampsToReturn.Neither
    });

    assert(nodes.length === request.nodesToRead.length);

    self.performMessageTransaction(request, function (err, response) {

        /* istanbul ignore next */
        if (err) {
            return callback(err, response);
        }
        if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
            return callback(new Error(response.responseHeader.serviceResult.toString()));
        }
        assert(response instanceof read_service.ReadResponse);