Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const key = normalizeName(varName);
// istanbul ignore next
if (!self._map.hasOwnProperty(key)) {
if (doDebug) {
debugLog(" cannot find node ".white.bold.bgRed + varName.cyan);
debugLog(" map=", Object.keys(self._map).join(" "));
}
}
self._map[key] = new Variant({
dataType: dataType,
value: value
});
if (self._map[key + ".sourceTimestamp"]) {
self._map[key + ".sourceTimestamp"] = new Variant({
dataType: DataType.DateTime,
value: new Date()
});
}
const variant = self._map[key];
const node = self._node_index[key];
assert(node instanceof UAVariable);
self.emit("value_changed", node, variant);
};
const key = normalizeName(varName);
// istanbul ignore next
if (!this._map.hasOwnProperty(key)) {
if (doDebug) {
debugLog(" cannot find node " + varName);
debugLog(" map=", Object.keys(this._map).join(" "));
}
}
this._map[key] = new Variant({
dataType,
value
});
if (this._map[key + ".sourceTimestamp"]) {
this._map[key + ".sourceTimestamp"] = new Variant({
dataType: DataType.DateTime,
value: new Date()
});
}
const variant = this._map[key];
const node = this._node_index[key];
if (!node) {
// for instance localTime is optional
debugLog("Cannot serVar " + varName + " dataType " + DataType[dataType]);
return;
}
assert(node.nodeClass === NodeClass.Variable);
this.emit("value_changed", node, variant);
}
public _assert_valid() {
assert(this.receiveTime.readValue().value.dataType === DataType.DateTime);
assert(this.receiveTime.readValue().value.value instanceof Date);
assert(this.message.readValue().value.dataType === DataType.LocalizedText);
assert(this.severity.readValue().value.dataType === DataType.UInt16);
assert(this.time.readValue().value.dataType === DataType.DateTime);
assert(this.time.readValue().value.value instanceof Date);
assert(this.quality.readValue().value.dataType === DataType.StatusCode);
assert(this.enabledState.readValue().value.dataType === DataType.LocalizedText);
assert(this.branchId.readValue().value.dataType === DataType.NodeId);
// note localTime has been made optional in 1.04
assert(!this.localTime || this.localTime.readValue().value.dataType === DataType.ExtensionObject);
}
const sourceNode = addressSpace.findNode(data.sourceNode.value)!;
data.sourceName = data.sourceName || {
dataType: DataType.String,
value: sourceNode.getDisplayName("en")
};
const nowUTC = (new Date());
// time (UtcTime)
// TODO
data.time = data.time || { dataType: DataType.DateTime, value: nowUTC };
// receivedTime (UtcTime)
// TODO
data.receiveTime = data.receiveTime || { dataType: DataType.DateTime, value: nowUTC };
// localTime (UtcTime)
// TODO
data.localTime = data.localTime || { dataType: DataType.DateTime, value: nowUTC };
// message (LocalizedText)
data.message = data.message || { dataType: DataType.LocalizedText, value: { text: "" } };
// severity (UInt16)
data.severity = data.severity || { dataType: DataType.UInt16, value: 0 };
// xx // reminder : event type cannot be instantiated directly !
// xx assert(eventTypeNode.isAbstract);
const baseObjectType = addressSpace.findObjectType("BaseObjectType"); // i=58
/* istanbul ignore next */
UAAcknowledgeableConditionBase.prototype._raiseAuditConditionAcknowledgeEvent = function(branch) {
// raise the AuditConditionAcknowledgeEventType
const eventData = {
// EventType
eventId: { dataType: DataType.ByteString, value: branch.getEventId() },
//xx branchId: branch.branchId.readValue().value,
// AuditEventType
actionTimeStamp: { dataType: DataType.DateTime, value : new Date() },
status: { dataType: DataType.StatusCodes, value: StatusCodes.Good },
serverId: {},
clientAuditEntryId: {},
clientUserId: {},
methodId: {},
inputArguments: {},
comment: {dataType: DataType.LocalizedText, value: branch.getComment() }
};
this.raiseEvent("AuditConditionAcknowledgeEventType",eventData);
};
public _raiseAuditConditionAcknowledgeEvent(branch: ConditionSnapshot): void {
// raise the AuditConditionAcknowledgeEventType
const eventData: RaiseEventData = {
actionTimeStamp: { dataType: DataType.DateTime, value: new Date() },
// xx branchId: branch.branchId.readValue().value,
// AuditEventType
clientAuditEntryId: {
dataType: DataType.Null
},
clientUserId: {
dataType: DataType.Null
},
comment: { dataType: DataType.LocalizedText, value: branch.getComment() },
// EventType
eventId: { dataType: DataType.ByteString, value: branch.getEventId() },
inputArguments: {
public _assert_valid() {
assert(this.receiveTime.readValue().value.dataType === DataType.DateTime);
assert(this.receiveTime.readValue().value.value instanceof Date);
assert(this.message.readValue().value.dataType === DataType.LocalizedText);
assert(this.severity.readValue().value.dataType === DataType.UInt16);
assert(this.time.readValue().value.dataType === DataType.DateTime);
assert(this.time.readValue().value.value instanceof Date);
assert(this.quality.readValue().value.dataType === DataType.StatusCode);
assert(this.enabledState.readValue().value.dataType === DataType.LocalizedText);
assert(this.branchId.readValue().value.dataType === DataType.NodeId);
// note localTime has been made optional in 1.04
assert(!this.localTime || this.localTime.readValue().value.dataType === DataType.ExtensionObject);
}
// sourceNode
assert(data.hasOwnProperty("sourceNode"), "expecting a source node to be defined");
data.sourceNode = new Variant(data.sourceNode);
assert(data.sourceNode.dataType === DataType.NodeId);
// sourceName
const sourceNode = addressSpace.findNode(data.sourceNode.value);
data.sourceName = data.sourceName || { dataType: DataType.String, value: sourceNode.getDisplayName("en") };
const nowUTC = (new Date());
// time (UtcTime)
// TODO
data.time = data.time || { dataType: DataType.DateTime, value: nowUTC};
// receivedTime (UtcTime)
// TODO
data.receiveTime = data.receiveTime || { dataType: DataType.DateTime, value: nowUTC};
// localTime (UtcTime)
// TODO
data.localTime = data.localTime || { dataType: DataType.DateTime, value: nowUTC};
// message (LocalizedText)
data.message = data.message || { dataType: DataType.LocalizedText, value: { text: "" } };
// severity (UInt16)
data.severity = data.severity || { dataType: DataType.UInt16, value: 0 };
//xx // reminder : event type cannot be instantiated directly !
public setExpirationDate(value: Date) {
return this.expirationDate.setValueFromSource({
dataType: DataType.DateTime,
value
});
}
}
public setReceiveTime(time: UtcTime) {
assert(time instanceof Date);
return this._set_var("receiveTime", DataType.DateTime, time);
}