本文整理汇总了TypeScript中node-opcua-service-translate-browse-path.makeBrowsePath函数的典型用法代码示例。如果您正苦于以下问题:TypeScript makeBrowsePath函数的具体用法?TypeScript makeBrowsePath怎么用?TypeScript makeBrowsePath使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makeBrowsePath函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should browse MyEventType", () => {
let browsePath = makeBrowsePath("RootFolder", "/Types/EventTypes/BaseEventType<HasSubtype>1:MyEventType");
let result = addressSpace.browsePath(browsePath);
result.statusCode.should.eql(StatusCodes.Good);
result.targets!.length.should.eql(1);
if (doDebug) {
const opts = { addressSpace };
console.log("browsePath", browsePath.toString(opts));
console.log("result", result.toString(opts));
}
const node = addressSpace.findNode(result.targets![0].targetId)!
.browseName.toString().should.eql("1:MyEventType");
browsePath = makeBrowsePath("RootFolder", "/Types/EventTypes/BaseEventType<!HasSubtype>1:MyEventType");
result = addressSpace.browsePath(browsePath);
result.statusCode.should.eql(StatusCodes.BadNoMatch);
browsePath = makeBrowsePath("RootFolder", "/Types/EventTypes/BaseEventType<#HasSubtype>1:MyEventType");
result = addressSpace.browsePath(browsePath);
result.statusCode.should.eql(StatusCodes.Good);
const evType = addressSpace.findNode(result.targets![0].targetId);
// rowing upstream
browsePath = makeBrowsePath(evType, "<!HasSubtype>BaseEventType<!Organizes>EventTypes<!Organizes>Types<!Organizes>Root");
result = addressSpace.browsePath(browsePath);
result.statusCode.should.eql(StatusCodes.Good);
addressSpace.findNode(result.targets![0].targetId)!.browseName.toString().should.eql("Root");
});
示例2: function
ClientSessionImpl.prototype.findMethodId = function(
nodeId: NodeIdLike,
methodName: string,
callback: ResponseCallback<NodeId>,
) {
const browsePath = makeBrowsePath(nodeId, "/" + methodName);
let methodId: NodeId;
this.translateBrowsePath(browsePath, (err: Error | null, result?: BrowsePathResult) => {
if (err) {
return callback(err);
}
if (!result) {
return callback(new Error("Internal Error"));
}
result.targets = result.targets || [];
// istanbul ignore else
if (result.targets.length > 0) {
methodId = result.targets[0].targetId;
return callback(null, methodId);
} else {
// cannot find objectWithMethodNodeId
debugLog("cannot find " + methodName + " Method", result.toString());
err = new Error(" cannot find " + methodName + " Method");
}
callback(err);
});
};
示例3: makeBrowsePath
// find conditionRefreshId
(innerCallback: ErrorCallback ) => {
const browsePath = makeBrowsePath(conditionTypeNodeId, ".ConditionRefresh");
theSession.translateBrowsePath(browsePath, (err: Error | null, result?: BrowsePathResult) => {
if (!err) {
result = result!;
// istanbul ignore else
if (result.targets && result.targets.length > 0) {
conditionRefreshId = result.targets[0].targetId;
} else {
// cannot find conditionRefreshId
debugLog("cannot find conditionRefreshId", result.toString());
err = new Error(" cannot find conditionRefreshId");
}
}
innerCallback(err ? err : undefined);
});
},
示例4: makeBrowsePath
(prop: string) => makeBrowsePath(historyServerCapabilitiesNodeId, "." + prop));
示例5: readHistoryServerCapabilities
export function readHistoryServerCapabilities(
session: ClientSession,
callback?: (err: Error | null, capabilities?: HistoryServerCapabilities) => void
): any {
if (!callback) { throw new Error("Internal error"); }
// display HistoryCapabilities of server
const browsePath: BrowsePath = makeBrowsePath(
ObjectIds.ObjectsFolder,
"/Server/ServerCapabilities.HistoryServerCapabilities");
session.translateBrowsePath(browsePath, (err: Error | null, result?: BrowsePathResult) => {
if (err) {
return callback(err);
}
if (!result) {
return callback(new Error("Internal Error"));
}
if (result.statusCode !== StatusCodes.Good) {
return callback(new Error("StatusCode = " + result.statusCode.toString()));
}
result.targets = result.targets || [];
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",
"DeleteEventCapability",
"InsertAnnotationCapability",
"InsertDataCapability",
"InsertEventCapability",
"ReplaceDataCapability",
"ReplaceEventCapability",
"UpdateDataCapability",
"UpdateEventCapability",
"MaxReturnDataValues",
"MaxReturnEventValues",
"AggregateFunctions/AnnotationCount",
"AggregateFunctions/Average",
"AggregateFunctions/Count",
"AggregateFunctions/Delta",
"AggregateFunctions/DeltaBounds",
"AggregateFunctions/DurationBad",
"AggregateFunctions/DurationGood",
"AggregateFunctions/DurationStateNonZero",
// etc....
];
const browsePaths = properties.map(
(prop: string) => makeBrowsePath(historyServerCapabilitiesNodeId, "." + prop));
session.translateBrowsePath(browsePaths, (innerErr: Error | null, results?: BrowsePathResult[]) => {
if (innerErr) {
return callback(innerErr);
}
if (!results) {
return callback(new Error("Internal Error"));
}
const nodeIds = results.map(
(innerResult: BrowsePathResult) =>
(innerResult.statusCode === StatusCodes.Good && innerResult.targets)
? innerResult.targets[0].targetId
: NodeId.nullNodeId);
const nodesToRead: ReadValueIdOptions [] = nodeIds.map((nodeId: NodeId) => ({
attributeId: AttributeIds.Value,
nodeId/*: coerceNodeId(nodeId)*/}));
const data: HistoryServerCapabilities = {};
session.read(nodesToRead, (err2: Error | null, dataValues?: DataValue[]) => {
if (err2) {
return callback(err2);
}
if (!dataValues) {
return callback(new Error("Internal Error"));
}
for (let i = 0; i < dataValues.length; i++) {
const propName = lowerFirstLetter(properties[i]);
data[propName] = dataValues[i].value as Variant;
}
callback(null, data);
});
});
});
}