Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (selectClause.typeDefinitionId.isEmpty()) {
return StatusCodes.Good;
}
const eventTypeNode = addressSpace.findEventType(selectClause.typeDefinitionId)!;
if (!eventTypeNode || !(eventTypeNode.nodeClass === NodeClass.ObjectType)) {
// xx console.log("eventTypeNode = ",selectClause.typeDefinitionId.toString());
// xx console.log("eventTypeNode = ",eventTypeNode);
// istanbul ignore next
if (eventTypeNode) {
console.log(eventTypeNode.toString());
}
}
// istanbul ignore next
if (eventTypeNode.nodeClass !== NodeClass.ObjectType) {
throw new Error("Expecting a ObjectType");
}
// navigate to the innerNode specified by the browsePath [ QualifiedName]
const browsePath = constructBrowsePathFromQualifiedName(eventTypeNode, selectClause.browsePath);
const browsePathResult = addressSpace.browsePath(browsePath);
return browsePathResult.statusCode;
}
// istanbul ignore next
if (!obj) {
throw new Error(" cannot find node with id " + reference.nodeId.toString());
}
if (_.isEqual(obj.browseName, relativePathElement.targetName)) { // compare QualifiedName
const key = obj.nodeId.toString();
if (!nodeIdsMap.hasOwnProperty(key)) {
nodeIds.push(obj.nodeId);
nodeIdsMap[key] = obj;
}
}
}
if (nodeIds.length === 0 && (this.nodeClass === NodeClass.ObjectType || this.nodeClass === NodeClass.VariableType)) {
const nodeType = this as any as UAVariableTypePublic;
if (nodeType.subtypeOf) {
// browsing also InstanceDeclarations included in base type
const baseType = this.addressSpace.findNode(nodeType.subtypeOf)! as BaseNode;
const n = baseType.browseNodeByTargetName(relativePathElement, isLast);
nodeIds = ([] as NodeId[]).concat(nodeIds, n);
}
}
return nodeIds;
}
const eventTypeFound = addressSpace.findEventType(eventType);
if (!eventTypeFound) {
throw new Error("raiseEvent: eventType cannot find event Type " + eventType.toString());
}
eventType = eventTypeFound;
if (! eventType || eventType.nodeClass !== NodeClass.ObjectType) {
throw new Error("eventType must exist and be an UAObjectType" + eventType!.toString());
}
} else if (eventType instanceof NodeId) {
const eventTypeFound = addressSpace.findNode(eventType) as BaseNode;
if (!eventTypeFound) {
throw new Error("raiseEvent: eventType cannot find event Type " + eventType.toString());
}
eventType = eventTypeFound!;
if (! eventType || eventType.nodeClass !== NodeClass.ObjectType) {
throw new Error("eventType must exist and be an UAObjectType" + eventType.toString());
}
}
eventType = eventType as UAObjectTypePublic;
let eventTypeNode = eventType;
// istanbul ignore next
if (!eventTypeNode) {
throw new Error("UAObject#raiseEventType : Cannot find event type :" + eventType.toString());
}
// coerce EventType
eventTypeNode = addressSpace.findEventType(eventType) as UAObjectTypePublic;
const baseEventType = addressSpace.findEventType("BaseEventType")!;
assert(eventTypeNode.isSupertypeOf(baseEventType));
const organizes = addReferenceType("Organizes/OrganizedBy", false, hierarchicalReferences);
}
{
const hasEventSource = addReferenceType("HasEventSource/EventSourceOf", false, hierarchicalReferences);
}
}
}
if (doDebug) {
dumpReferencesHierarchy(addressSpace);
}
const baseObjectType = namespace0._createNode({
browseName: "BaseObjectType",
isAbstract: true,
nodeClass: NodeClass.ObjectType,
nodeId: resolveNodeId(ObjectTypeIds.BaseObjectType)
});
const baseVariableType = namespace0._createNode({
browseName: "BaseVariableType",
isAbstract: true,
nodeClass: NodeClass.VariableType,
nodeId: resolveNodeId(VariableTypeIds.BaseVariableType)
}) as any as UAVariableType;
const propertyType = namespace0.addVariableType({
browseName: "PropertyType",
subtypeOf: baseVariableType
});
const baseDataVariableType = namespace0._createNode({
}
{
const organizes = addReferenceType("Organizes/OrganizedBy",false,hierarchicalReferences);
}
{
const hasEventSource = addReferenceType("HasEventSource/EventSourceOf",false,hierarchicalReferences);
}
}
}
dumpReferencesHierarchy(addressSpace);
const baseObjectType = namespace0._createNode({
browseName: "BaseObjectType",
nodeId: resolveNodeId(ObjectTypeIds.BaseObjectType),
nodeClass: NodeClass.ObjectType,
isAbstract: true
});
const baseVariableType = namespace0._createNode({
browseName: "BaseVariableType",
nodeId: resolveNodeId(VariableTypeIds.BaseVariableType),
nodeClass: NodeClass.VariableType,
isAbstract: true
});
const propertyType = namespace0.addVariableType({
browseName: "PropertyType",
subtypeOf: baseVariableType,
});
const baseDataVariableType = namespace0._createNode({
console.warn(" parents : ");
for (const parent of parents) {
console.log(" ",
parent.toString(),
addressSpace.findNode(parent.nodeId)!.browseName.toString()
);
}
return null;
}
assert(parents.length === 0 || parents.length === 1);
if (parents.length === 0) {
return null;
}
const theParent = addressSpace.findNode(parents[0]!.nodeId)!;
if (theParent && (theParent.nodeClass === NodeClass.VariableType || theParent.nodeClass === NodeClass.ObjectType)) {
return theParent as (UAVariableType | UAObjectType);
}
return null;
}
assert(node.nodeId instanceof NodeId, "Expecting a NodeId");
if (node.nodeId.namespace !== this.index) {
throw new Error("node must belongs to this namespace");
}
assert(node.nodeId.namespace === this.index && "node must belongs to this namespace");
assert(node.hasOwnProperty("browseName"), "Node must have a browseName");
//assert(node.browseName.namespaceIndex === this.index,"browseName must belongs to this namespace");
const indexName = node.nodeId.toString();
if (this._nodeid_index.hasOwnProperty(indexName)) {
throw new Error("nodeId " + node.nodeId.displayText() + " already registered " + node.nodeId.toString());
}
this._nodeid_index[indexName] = node;
if (node.nodeClass === NodeClass.ObjectType) {
_registerObjectType(this, node);
} else if (node.nodeClass === NodeClass.VariableType) {
_registerVariableType(this, node);
} else if (node.nodeClass === NodeClass.ReferenceType) {
_registerReferenceType(this, node);
} else if (node.nodeClass === NodeClass.DataType) {
_registerDataType(this, node);
} else if (node.nodeClass === NodeClass.Object) {
} else if (node.nodeClass === NodeClass.Variable) {
} else if (node.nodeClass === NodeClass.Method) {
} else if (node.nodeClass === NodeClass.View) {
} else {
console.log("Invalid class Name", node.nodeClass);
throw new Error("Invalid class name specified");
}
};
public addObjectType(options: AddObjectTypeOptions): UAObjectType {
assert(!options.hasOwnProperty("dataType"), "an objectType should not have a dataType");
assert(!options.hasOwnProperty("valueRank"), "an objectType should not have a valueRank");
assert(!options.hasOwnProperty("arrayDimensions"), "an objectType should not have a arrayDimensions");
return this._addObjectOrVariableType(
options,
"BaseObjectType",
NodeClass.ObjectType) as UAObjectType;
}