Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'node-opcua-service-filter' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
MonitoredItem.prototype._on_opcua_event = function (eventData) {
const self = this;
assert(!self.filter || self.filter instanceof EventFilter);
const selectClauses = self.filter ? self.filter.selectClauses : [];
const eventFields = extractEventFields(selectClauses, eventData);
// istanbul ignore next
if (doDebug) {
console.log(" RECEIVED INTERNAL EVENT THAT WE ARE MONITORING");
console.log(self.filter ? self.filter.toString() : "no filter");
eventFields.forEach(function (e) {
console.log(e.toString());
});
}
self._enqueue_event(eventFields);
};
// Release 1.04 8 OPC Unified Architecture, Part 9
// 4.5 Condition state synchronization
// To ensure a Client is always informed, the three special EventTypes
// (RefreshEndEventType, RefreshStartEventType and RefreshRequiredEventType)
// ignore the Event content filtering associated with a Subscription and will always be
// delivered to the Client.
if (!this.filter || !(this.filter instanceof EventFilter)) {
throw new Error("Internal Error");
}
const selectClauses = this.filter.selectClauses
? this.filter.selectClauses
: ([] as SimpleAttributeOperand[]);
const eventFields = extractEventFields(selectClauses, eventData);
// istanbul ignore next
if (doDebug) {
console.log(" RECEIVED INTERNAL EVENT THAT WE ARE MONITORING");
console.log(this.filter ? this.filter.toString() : "no filter");
eventFields.forEach((e: any) => {
console.log(e.toString());
});
}
this._enqueue_event(eventFields);
}
publishingEnabled: true,
requestedLifetimeCount: 1000,
requestedMaxKeepAliveCount: 100,
requestedPublishingInterval: 100,
};
const subscription = await session.createSubscription2(request);
const itemToMonitor: ReadValueIdOptions = {
attributeId: AttributeIds.EventNotifier,
nodeId: resolveNodeId("Server"), // i=2253
};
const fields = await extractConditionFields(session, "AcknowledgeableConditionType");
const eventFilter = constructEventFilter(fields, [resolveNodeId("AcknowledgeableConditionType")]);
const monitoringParameters: MonitoringParametersOptions = {
discardOldest: false,
filter: eventFilter,
queueSize: 100,
samplingInterval: 0,
};
const event_monitoringItem =
await subscription.monitor(itemToMonitor, monitoringParameters, TimestampsToReturn.Both);
const acknowledgeableConditions: EventStuff[] = [];
let refreshStartEventHasBeenReceived = false;
let RefreshEndEventHasBeenReceived = false;
publishingEnabled: true,
requestedLifetimeCount: 10000,
requestedMaxKeepAliveCount: 1000,
requestedPublishingInterval: 10,
};
const subscription = await session.createSubscription2(request);
_sessionPriv.$subscriptionforAlarmList = subscription;
const itemToMonitor: ReadValueIdOptions = {
attributeId: AttributeIds.EventNotifier,
nodeId: resolveNodeId("Server"), // i=2253
};
const fields = await extractConditionFields(session, "AlarmConditionType");
const eventFilter = constructEventFilter(fields, [resolveNodeId("AcknowledgeableConditionType")]);
const monitoringParameters: MonitoringParametersOptions = {
discardOldest: false,
filter: eventFilter,
queueSize: 10000,
samplingInterval: 0,
};
// now create a event monitored Item
const event_monitoringItem = ClientMonitoredItem.create(subscription, itemToMonitor, monitoringParameters, TimestampsToReturn.Both);
const RefreshStartEventType = resolveNodeId("RefreshStartEventType").toString();
const RefreshEndEventType = resolveNodeId("RefreshEndEventType").toString();
event_monitoringItem.on("changed", (eventFields: Variant[]) => {
const pojo = fieldsToJson(fields, eventFields) as EventStuff;
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;
const EventFilter = require("node-opcua-service-filter").EventFilter;
const DataChangeFilter = require("node-opcua-service-subscription").DataChangeFilter;
const AggregateFilter = require("node-opcua-service-subscription").AggregateFilter;
const UAVariable = require("node-opcua-address-space").UAVariable;
const validateFilter = require("./validate_filter").validateFilter;
const isValidDataEncoding = require("node-opcua-data-model").isValidDataEncoding;
const debugLog = require("node-opcua-debug").make_debugLog(__filename);
const doDebug = require("node-opcua-debug").checkDebugFlag(__filename);
const SubscriptionState = new Enum([
"CLOSED", // The Subscription has not yet been created or has terminated.
"CREATING", // The Subscription is being created
"NORMAL", // The Subscription is cyclically checking for Notifications from its MonitoredItems.
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);
const doDebug = require("node-opcua-debug").checkDebugFlag(__filename);
function _adjust_sampling_interval(samplingInterval,node_minimumSamplingInterval) {
const NodeId = require("node-opcua-nodeid").NodeId;
const sameNodeId = require("node-opcua-nodeid").sameNodeId;
const lowerFirstLetter = require("node-opcua-utils").lowerFirstLetter;
const doDebug = false;
const BaseNode = require("./base_node").BaseNode;
const UAVariable = require("./ua_variable").UAVariable;
const UAMethod = require("./ua_method").UAMethod;
const UAObjectType = require("./ua_object_type").UAObjectType;
const constructBrowsePathFromQualifiedName = require("node-opcua-service-translate-browse-path").constructBrowsePathFromQualifiedName;
const SimpleAttributeOperand = require("node-opcua-service-filter").SimpleAttributeOperand;
const AttributeIds = require("node-opcua-data-model").AttributeIds;
const context = require("./session_context").SessionContext.defaultContext;
const DataValue = require("node-opcua-data-value").DataValue;
const Namespace = require("./namespace").Namespace;
/**
* @class EventData
* @param eventTypeNode {BaseNode}
* @constructor
*/
function EventData(eventTypeNode) {
this.__nodes = {};
this.$eventDataSource = eventTypeNode;
assert(eventTypeNode instanceof BaseNode);