How to use the node-opcua.ClientSubscription function in node-opcua

To help you get started, we’ve selected a few node-opcua 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 coussej / node-opcua-logger / readpump.js View on Github external
ReadPump.prototype.StartMonitoring = function(callback) {
    let self = this;

    // create an OPCUA subscription
    self.uaSubscription = new opcua.ClientSubscription(self.uaSession, {
        requestedPublishingInterval: 1000,
        requestedLifetimeCount: 10,
        requestedMaxKeepAliveCount: 2,
        maxNotificationsPerPublish: 20,
        publishingEnabled: true,
        priority: 1
    });
    let sub = self.uaSubscription;
    sub.on("started", function() {
        console.log("subscription", sub.subscriptionId, "started");
    }).on("keepalive", function() {
        //console.log("subscription", sub.subscriptionId, "keepalive");
    }).on("terminated", function() {
        let err = "subscription" + sub.subscriptionId + "was terminated";
        console.log(err);
        callback(err);
github locka99 / opcua / 3rd-party / node-opcua / client.js View on Github external
callback => {
            the_subscription = new opcua.ClientSubscription(the_session, {
                requestedPublishingInterval: 1000,
                requestedLifetimeCount: 10,
                requestedMaxKeepAliveCount: 2,
                maxNotificationsPerPublish: 10,
                publishingEnabled: true,
                priority: 10
            });

            the_subscription.on("started", () => {
                console.log("subscription started for 2 seconds - subscriptionId=", the_subscription.subscriptionId);
            }).on("keepalive", () => {
                console.log("keepalive");
            }).on("terminated", () => {
                callback();
            });
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client.js View on Github external
function (callback) {

        const parameters = {
            requestedPublishingInterval: 100,
            requestedLifetimeCount: 1000,
            requestedMaxKeepAliveCount: 12,
            maxNotificationsPerPublish: 10,
            publishingEnabled: true,
            priority: 10
        };

        the_subscription = new opcua.ClientSubscription(the_session, parameters);

        function getTick() {
            return Date.now();
        }

        let t = getTick();

        the_subscription.on("started", function () {

            console.log("started subscription :", the_subscription.subscriptionId);

            console.log(" revised parameters ");
            console.log("  revised maxKeepAliveCount  ", the_subscription.maxKeepAliveCount, " ( requested ", parameters.requestedMaxKeepAliveCount + ")");
            console.log("  revised lifetimeCount      ", the_subscription.lifetimeCount, " ( requested ", parameters.requestedLifetimeCount + ")");
            console.log("  revised publishingInterval ", the_subscription.publishingInterval, " ( requested ", parameters.requestedPublishingInterval + ")");
            console.log("  suggested timeout hint     ", the_subscription.publish_engine.timeoutHint);
github PacktPublishing / Industrial-Internet-Application-Development / Chapter03 / opcua / hub / index.js View on Github external
function (cb) {
      subscription = new opcua.ClientSubscription(session, {
        maxNotificationsPerPublish: 5,
        priority: 5,
        publishingEnabled: true,
        requestedLifetimeCount: 5,
        requestedMaxKeepAliveCount: 3,
        requestedPublishingInterval: 500,
      });

      subscription.on("started", function () {
        console.log("subscription id: ", subscription.subscriptionId);
      }).on("terminated", function () {
        cb();
      });

      setTimeout(function () {
        subscription.terminate();