Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// +->(hasSubtype) Aggregates/AggregatedBy
// +-> HasProperty/PropertyOf
// +-> HasComponent/ComponentOf
// +-> HasHistoricalConfiguration/HistoricalConfigurationOf
// +->(hasSubtype) HasSubtype/HasSupertype
// +->(hasSubtype) Organizes/OrganizedBy
// +->(hasSubtype) HasEventSource/EventSourceOf
let node;
if (isNodeIdString(refType)) {
refType = resolveNodeId(refType);
}
if (refType instanceof NodeId) {
node = this.findNode(refType);
// istanbul ignore next
if (!(node && (node.nodeClass === NodeClass.ReferenceType))) {
// throw new Error("cannot resolve referenceId "+ refType.toString());
return null;
}
} else {
assert(_.isString(refType));
node = this._findReferenceType(refType,namespace);
}
return node;
};
references = references.filter((reference: Reference) => {
const ref = resolveReferenceType(this.addressSpace, reference)!;
if (!ref) {
return false;
} // unknown type ... this may happen when the address space is not fully build
assert(ref.nodeClass === NodeClass.ReferenceType);
const is_of_type = ref.nodeId.toString() === referenceType.nodeId.toString();
if (is_of_type) {
return true;
}
if (browseDescription.includeSubtypes) {
return ref.isSupertypeOf(referenceType as UAReferenceTypePublic);
} else {
return false;
}
});
}
function addReferenceType(browseName,isAbstract,superType)
{
browseName = browseName.split("/");
let inverseName = browseName[1];
browseName = browseName[0];
const options = {
browseName: browseName,
inverseName: inverseName,
nodeId: resolveNodeId(ReferenceTypeIds[browseName]),
nodeClass: NodeClass.ReferenceType,
superType: superType,
isAbstract: isAbstract
};
options.references = [];
const hasSubType = resolveNodeId("HasSubtype");
if (superType) {
options.references.push({
referenceType: hasSubType, isForward: false, nodeId: superType.nodeId
});
}
const node = namespace0._createNode(options);
node.propagate_back_references();
return node;
}
init(this: any, name: string, attrs: XmlAttributes) {
this.obj = {};
this.obj.nodeClass = NodeClass.ReferenceType;
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
},
finish(this: any) {
UANamespace.prototype.addReferenceType = function (options) {
const namespace = this;
const addressSpace = namespace.addressSpace;
options.nodeClass = NodeClass.ReferenceType;
options.references = options.references || [];
if (options.subtypeOf) {
assert(options.subtypeOf);
const subtypeOfNodeId = addressSpace._coerceType(options.subtypeOf, "References", NodeClass.ReferenceType);
assert(subtypeOfNodeId);
console.log(subtypeOfNodeId.toString().cyan);
options.references.push({referenceType: "HasSubtype", isForward: false, nodeId: subtypeOfNodeId});
}
const node = namespace._createNode(options);
node.propagate_back_references();
return node;
UANamespace.prototype.findReferenceTypeFromInverseName = function (inverseName) {
assert(typeof inverseName === "string");
const node = this._referenceTypeMapInv[inverseName];
assert(!node || (node.nodeClass === NodeClass.ReferenceType && node.inverseName.text === inverseName));
return node ? node : null;
};
init: function (name, attrs) {
this.obj = {};
this.obj.nodeClass = NodeClass.ReferenceType;
this.obj.isAbstract = ec.coerceBoolean(attrs.IsAbstract);
this.obj.nodeId = convertToNodeId(attrs.NodeId) || null;
this.obj.browseName = convertQualifiedName(attrs.BrowseName);
},
finish: function () {
* @class ReferenceType
* @extends BaseNode
* @param options
* @constructor
*/
function ReferenceType(options) {
BaseNode.apply(this, arguments);
this.isAbstract = util.isNullOrUndefined(options.isAbstract) ? false : !!options.isAbstract;
this.symmetric = util.isNullOrUndefined(options.symmetric) ? false : !!options.symmetric;
this.inverseName = coerceLocalizedText(options.inverseName);
ReferenceTypeCounter +=1;
}
util.inherits(ReferenceType, BaseNode);
ReferenceType.prototype.nodeClass = NodeClass.ReferenceType;
/**
*
* @method readAttribute
* @param attributeId {AttributeIds}
* @param [indexRange {NumericalRange}]
* @param [dataEncoding {String}]
* @return {DataValue}
*/
ReferenceType.prototype.readAttribute = function (context, attributeId, indexRange, dataEncoding) {
assert(context instanceof SessionContext);
const options = {};
switch (attributeId) {
case AttributeIds.IsAbstract:
function _findAllSubType(referenceType) {
possibleReferenceTypes.push(referenceType);
assert(referenceType.nodeClass === NodeClass.ReferenceType);
const references = referenceType.findReferences(hasSubtypeReferenceType, true);
for(let _r of references) {
const subType = addressSpace.findNode(_r.nodeId);
_findAllSubType(subType);
}
}
_findAllSubType(referenceType);