Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.node.nodeId.toString(), this.node.browseName.toString());
}
// we are monitoring OPCUA Event
this._on_opcua_event_received_callback = this._on_opcua_event.bind(this);
this.node.on("event", this._on_opcua_event_received_callback);
return;
}
if (this.itemToMonitor.attributeId !== AttributeIds.Value) {
// sampling interval only applies to Value Attributes.
this.samplingInterval = 0; // turned to exception-based regardless of requested sampling interval
// non value attribute only react on value change
this._attribute_changed_callback = this._on_value_changed.bind(this);
const event_name = makeAttributeEventName(this.itemToMonitor.attributeId);
this.node.on(event_name, this._attribute_changed_callback);
if (recordInitialValue) {
// read initial value
const dataValue = this.node.readAttribute(context, this.itemToMonitor.attributeId);
this.recordValue(dataValue, true);
}
return;
}
if (this.samplingInterval === 0) {
// we have a exception-based dataItem : event based model, so we do not need a timer
// rather , we setup the "value_changed_event";
private _stop_sampling() {
// debugLog("MonitoredItem#_stop_sampling");
if (!this.node) {
throw new Error("Internal Error");
}
if (this._on_opcua_event_received_callback) {
assert(_.isFunction(this._on_opcua_event_received_callback));
this.node.removeListener("event", this._on_opcua_event_received_callback);
this._on_opcua_event_received_callback = null;
}
if (this._attribute_changed_callback) {
assert(_.isFunction(this._attribute_changed_callback));
const event_name = makeAttributeEventName(this.itemToMonitor.attributeId);
this.node.removeListener(event_name, this._attribute_changed_callback);
this._attribute_changed_callback = null;
}
if (this._value_changed_callback) {
// samplingInterval was 0 for a exception-based data Item
// we setup a event listener that we need to unwind here
assert(_.isFunction(this._value_changed_callback));
assert(!this._samplingId);
this.node.removeListener("value_changed", this._value_changed_callback);
this._value_changed_callback = null;
}
if (this._semantic_changed_callback) {
assert(_.isFunction(this._semantic_changed_callback));