Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
public resolveSelectClause(selectClause: SimpleAttributeOperand) {
const self = this;
assert(selectClause instanceof SimpleAttributeOperand);
const addressSpace = self.$eventDataSource.addressSpace;
if (selectClause.browsePath!.length === 0 && selectClause.attributeId === AttributeIds.NodeId) {
assert(!"Cannot use resolveSelectClause on this selectClause as it has no browsePath");
}
// navigate to the innerNode specified by the browsePath [ QualifiedName]
const browsePath = constructBrowsePathFromQualifiedName(self.$eventDataSource, selectClause.browsePath);
// xx console.log(self.$eventDataSource.browseName.toString());
// xx console.log("xx browse Path", browsePath.toString());
const browsePathResult = addressSpace.browsePath(browsePath);
// xx console.log(" br",
// self.$eventDataSource.nodeId.toString(),
// selectClause.browsePath.toString(),
// browsePathResult.targets[0] ? browsePathResult.targets[0].targetId.toString() : "!!!NOT FOUND!!!"é)
if (browsePathResult.statusCode !== StatusCodes.Good) {
return null;
}
if (!browsePathResult.targets) {
return null;
EventData.prototype.resolveSelectClause = function(selectClause) {
const self = this;
assert(selectClause instanceof SimpleAttributeOperand);
const addressSpace = self.$eventDataSource.addressSpace;
if (selectClause.browsePath.length === 0 && selectClause.attributeId === AttributeIds.NodeId) {
assert(!"Cannot use resolveSelectClause on this selectClause as it has no browsePath");
}
// navigate to the innerNode specified by the browsePath [ QualifiedName]
const browsePath = constructBrowsePathFromQualifiedName(self.$eventDataSource, selectClause.browsePath);
//xx console.log(self.$eventDataSource.browseName.toString());
//xx console.log("xxxxxxxxxxxxx browse Pathx", browsePath.toString());
const browsePathResult = addressSpace.browsePath(browsePath);
//xx console.log(" br",self.$eventDataSource.nodeId.toString(),selectClause.browsePath.toString(),browsePathResult.targets[0] ? browsePathResult.targets[0].targetId.toString() : "!!!NOT FOUNF!!!".cyan)
if (browsePathResult.statusCode !== StatusCodes.Good) {
return null;
}
// istanbul ignore next
if (browsePathResult.targets.length !== 1) {
//xx console.log("selectClause ",selectClause.toString());
//xx console.log("browsePathResult ",browsePathResult.toString());
//xx throw new Error("browsePathResult.targets.length !== 1" + browsePathResult.targets.length);
function readHistoryServerCapabilities(the_session,callback) {
// display HistoryCapabilities of server
const browsePath = makeBrowsePath(ObjectIds.ObjectsFolder,"/Server/ServerCapabilities.HistoryServerCapabilities");
the_session.translateBrowsePath(browsePath,function(err,result) {
if (err) { return callback(err); }
if (result.statusCode !== StatusCodes.Good) {
return callback();
}
const historyServerCapabilitiesNodeId = result.targets[0].targetId;
// (should be ns=0;i=11192)
assert(historyServerCapabilitiesNodeId.toString() === "ns=0;i=11192");
// -------------------------
const properties = [
"AccessHistoryDataCapability",
"AccessHistoryEventsCapability",
"DeleteAtTimeCapability",
"DeleteRawCapability",
function browsePathPropertyRequest(nodeId: NodeIdLike, propertyName: string): BrowsePath {
return new BrowsePath({
relativePath: /* RelativePath */ {
elements: /* RelativePathElement */ [
{
includeSubtypes: false,
isInverse: false,
referenceTypeId: hasPropertyRefId,
targetName: {namespaceIndex: 0, name: propertyName}
}
]
},
startingNode: /* NodeId */ nodeId,
});
}
function explore_element(curNodeObject, elements, index) {
const element = elements[index];
assert(element instanceof translate_service.RelativePathElement);
const is_last = ( (index + 1) === elements.length);
const nodeIds = curNodeObject.browseNodeByTargetName(element,is_last);
const targets = nodeIds.map(function (nodeId) {
return {
targetId: nodeId,
remainingPathIndex: elements.length - index
};
});
if (!is_last) {
// explorer
for(let target of targets) {
const node = self.findNode(target.targetId);
self.performMessageTransaction(request, function (err, response) {
/* istanbul ignore next */
if (err) {
return callback(err, response);
}
assert(response instanceof translate_service.TranslateBrowsePathsToNodeIdsResponse);
callback(null, isArray ? response.results : response.results[0]);
});
ClientSession.prototype.translateBrowsePath = function (browsePath, callback) {
assert(_.isFunction(callback));
const self = this;
const isArray = _.isArray(browsePath);
browsePath = isArray ? browsePath :[browsePath];
const request = new translate_service.TranslateBrowsePathsToNodeIdsRequest({
browsePath: browsePath
});
self.performMessageTransaction(request, function (err, response) {
/* istanbul ignore next */
if (err) {
return callback(err, response);
}
assert(response instanceof translate_service.TranslateBrowsePathsToNodeIdsResponse);
callback(null, isArray ? response.results : response.results[0]);
});
};
private async extractMethodsIds(): Promise {
const browsePaths: BrowsePath[] = [
makeBrowsePath(this.fileNodeId, "/Open"),
makeBrowsePath(this.fileNodeId, "/Close"),
makeBrowsePath(this.fileNodeId, "/SetPosition"),
makeBrowsePath(this.fileNodeId, "/GetPosition"),
makeBrowsePath(this.fileNodeId, "/Write"),
makeBrowsePath(this.fileNodeId, "/Read"),
makeBrowsePath(this.fileNodeId, "/OpenCount"),
makeBrowsePath(this.fileNodeId, "/Size")
];
const results = await this.session.translateBrowsePath(browsePaths);
if (results[0].statusCode !== StatusCodes.Good) {
throw new Error("fileType object does not expose mandatory Open Method");
}
if (results[1].statusCode !== StatusCodes.Good) {
throw new Error("fileType object does not expose mandatory Close Method");
}
if (results[2].statusCode !== StatusCodes.Good) {
private async extractMethodsIds(): Promise {
const browsePaths: BrowsePath[] = [
makeBrowsePath(this.fileNodeId, "/Open"),
makeBrowsePath(this.fileNodeId, "/Close"),
makeBrowsePath(this.fileNodeId, "/SetPosition"),
makeBrowsePath(this.fileNodeId, "/GetPosition"),
makeBrowsePath(this.fileNodeId, "/Write"),
makeBrowsePath(this.fileNodeId, "/Read"),
makeBrowsePath(this.fileNodeId, "/OpenCount"),
makeBrowsePath(this.fileNodeId, "/Size")
];
const results = await this.session.translateBrowsePath(browsePaths);
if (results[0].statusCode !== StatusCodes.Good) {
throw new Error("fileType object does not expose mandatory Open Method");
}
if (results[1].statusCode !== StatusCodes.Good) {
throw new Error("fileType object does not expose mandatory Close Method");
}