Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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();
});
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);
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();