How to use the node-opcua-service-write.WriteRequest function in node-opcua-service-write

To help you get started, we’ve selected a few node-opcua-service-write 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
ClientSession.prototype.write = function (nodesToWrite, callback) {

    const self = this;

    const isArray = _.isArray(nodesToWrite);
    if (!isArray) {
        nodesToWrite = [nodesToWrite];
    }

    assert(_.isFunction(callback));
    assert(_.isArray(nodesToWrite), "nodesToWrite must be an array");

    const request = new write_service.WriteRequest({nodesToWrite: nodesToWrite});

    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 write_service.WriteResponse);
        assert(nodesToWrite.length === response.results.length);
        callback(null, isArray ? response.results : response.results[0]);
    });
};

node-opcua-service-write

pure nodejs OPCUA SDK - module service-write

MIT
Latest version published 7 days ago

Package Health Score

86 / 100
Full package analysis