How to use the node-opcua-service-subscription.MonitoringMode function in node-opcua-service-subscription

To help you get started, we’ve selected a few node-opcua-service-subscription 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 / test_to_fix / test_subscriptions.js View on Github external
it("server should create a monitored item  (CreateMonitoredItems)", function (done) {


        // CreateMonitoredItemsRequest
        var request = new subscription_service.CreateMonitoredItemsRequest({
            subscriptionId: subscriptionId,
            timestampsToReturn: read_service.TimestampsToReturn.Both,
            itemsToCreate: [
                {
                    itemToMonitor: {
                        nodeId: ec.makeNodeId(VariableIds.Server_ServerStatus_CurrentTime)
                    },
                    monitoringMode: subscription_service.MonitoringMode.Sampling,
                    requestedParameters: {
                        clientHandle: 26,
                        samplingInterval: 100,
                        filter: null,
                        queueSize: 100,
                        discardOldest: true
                    }
                }
            ]
        });
        g_session.createMonitoredItems(request, function (err, response) {
            if (!err) {
                response.should.be.instanceof(subscription_service.CreateMonitoredItemsResponse);
            }
            done(err);
        });
github node-opcua / node-opcua / packages / node-opcua-server / src / server_subscription.js View on Github external
"use strict";
/**
 * @module opcua.server
 */


const Dequeue = require("dequeue");

const subscription_service = require("node-opcua-service-subscription");
const DataChangeNotification = subscription_service.DataChangeNotification;
const EventNotificationList = subscription_service.EventNotificationList;
const NotificationMessage = subscription_service.NotificationMessage;
const StatusChangeNotification = subscription_service.StatusChangeNotification;
const MonitoringMode = subscription_service.MonitoringMode;
const NodeId = require("node-opcua-nodeid").NodeId;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const Enum = require("node-opcua-enum").Enum;
const assert = require("node-opcua-assert").assert;
const NodeClass = require("node-opcua-data-model").NodeClass;
const _ = require("underscore");

const AttributeIds = require("node-opcua-data-model").AttributeIds;

const SequenceNumberGenerator = require("node-opcua-secure-channel").SequenceNumberGenerator;

const EventEmitter = require("events").EventEmitter;
const util = require("util");

const SessionContext = require("node-opcua-address-space").SessionContext;
github node-opcua / node-opcua / packages / node-opcua-client / src / client_monitored_item_base.js View on Github external
function ClientMonitoredItemBase(subscription, itemToMonitor, monitoringParameters) {
    assert(subscription.constructor.name === "ClientSubscription");
    const self = this;
    self.itemToMonitor = new read_service.ReadValueId(itemToMonitor);
    self.monitoringParameters = new subscription_service.MonitoringParameters(monitoringParameters);
    self.subscription = subscription;
    self.monitoringMode = subscription_service.MonitoringMode.Reporting;
    assert(self.monitoringParameters.clientHandle === 4294967295, "should not have a client handle yet");
}
util.inherits(ClientMonitoredItemBase, EventEmitter);
github node-opcua / node-opcua / packages / node-opcua-server / src / monitored_item.js View on Github external
const subscription_service = require("node-opcua-service-subscription");
const read_service = require("node-opcua-service-read");

const DataValue = require("node-opcua-data-value").DataValue;
const Variant = require("node-opcua-variant").Variant;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const NodeClass = require("node-opcua-data-model").NodeClass;

const AttributeIds = require("node-opcua-data-model").AttributeIds;
const BaseNode = require("node-opcua-address-space").BaseNode;

const sameDataValue = require("node-opcua-data-value").sameDataValue;
const sameVariant = require("node-opcua-variant").sameVariant;
const isValidVariant = require("node-opcua-variant").isValidVariant;

const MonitoringMode = subscription_service.MonitoringMode;
const MonitoringParameters = subscription_service.MonitoringParameters;
const MonitoredItemModifyResult = subscription_service.MonitoredItemModifyResult;
const TimestampsToReturn = read_service.TimestampsToReturn;
const EventFilter = require("node-opcua-service-filter").EventFilter;
const apply_timestamps = require("node-opcua-data-value").apply_timestamps;

const UAVariable = require("node-opcua-address-space").UAVariable;

const defaultItemToMonitor = {indexRange: null, attributeId: read_service.AttributeIds.Value};

const SessionContext = require("node-opcua-address-space").SessionContext;
const NumericRange = require("node-opcua-numeric-range").NumericRange;



const debugLog = require("node-opcua-debug").make_debugLog(__filename);
github node-opcua / node-opcua / packages / node-opcua-server / src / opcua_server.js View on Github external
this._apply_on_Subscription(SetMonitoringModeResponse, message, channel, function (session, subscription, sendResponse, sendError) {

        if (!request.monitoredItemIds || request.monitoredItemIds.length === 0) {
            return sendError(StatusCodes.BadNothingToDo);
        }
        if (server.engine.serverCapabilities.operationLimits.maxMonitoredItemsPerCall > 0) {
            if (request.monitoredItemIds.length > server.engine.serverCapabilities.operationLimits.maxMonitoredItemsPerCall) {
                return sendError(StatusCodes.BadTooManyOperations);
            }
        }
        const monitoringMode = request.monitoringMode;

        if (monitoringMode === subscription_service.MonitoringMode.Invalid) {
            return sendError(StatusCodes.BadMonitoringModeInvalid);
        }

        const results = request.monitoredItemIds.map(function (monitoredItemId) {

            const monitoredItem = subscription.getMonitoredItem(monitoredItemId);
            if (!monitoredItem) {
                return StatusCodes.BadMonitoredItemIdInvalid;
            }
            monitoredItem.setMonitoringMode(monitoringMode);
            return StatusCodes.Good;
        });

        const response = new SetMonitoringModeResponse({
            results: results
        });