本文整理汇总了TypeScript中node-opcua-nodeid.NodeId.map方法的典型用法代码示例。如果您正苦于以下问题:TypeScript NodeId.map方法的具体用法?TypeScript NodeId.map怎么用?TypeScript NodeId.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node-opcua-nodeid.NodeId
的用法示例。
在下文中一共展示了NodeId.map方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructEventFilter
export function constructEventFilter(
arrayOfNames: string[] | string,
conditionTypes?: NodeId[] | NodeId
): EventFilter {
if (!_.isArray(arrayOfNames)) {
return constructEventFilter([arrayOfNames], conditionTypes);
}
if (conditionTypes && !_.isArray(conditionTypes)) {
return constructEventFilter(arrayOfNames, [conditionTypes]);
}
if (!(arrayOfNames instanceof Array)) {
throw new Error("internal error");
}
// replace "string" element in the form A.B.C into [ "A","B","C"]
const arrayOfNames2 = arrayOfNames.map((path) => {
if (typeof path !== "string") {
return path;
}
return path.split(".");
});
const arrayOfNames3 = arrayOfNames2.map((path) => {
if (_.isArray(path)) {
return path.map(stringToQualifiedName);
}
return path;
});
// replace "string" elements in arrayOfName with QualifiedName in namespace 0
const arrayOfNames4 = arrayOfNames3.map((s) => {
return (typeof s === "string") ? stringToQualifiedName(s) : s;
});
// construct browse paths array
const browsePaths = arrayOfNames4.map((s) => {
return _.isArray(s) ? s : [s];
});
// Part 4 page 127:
// In some cases the same BrowsePath will apply to multiple EventTypes. If the Client specifies the BaseEventType
// in the SimpleAttributeOperand then the Server shall evaluate the BrowsePath without considering the Type.
// [..]
// The SimpleAttributeOperand structure allows the Client to specify any Attribute, however, the Server is only
// required to support the Value Attribute for Variable Nodes and the NodeId Attribute for Object Nodes.
// That said, profiles defined in Part 7 may make support for additional Attributes mandatory.
let selectClauses = browsePaths.map((browsePath) => {
return new SimpleAttributeOperand({
attributeId: AttributeIds.Value,
browsePath,
indexRange: undefined, // NumericRange
typeDefinitionId: makeNodeId(ObjectTypeIds.BaseEventType) // i=2041
});
});
if (conditionTypes && conditionTypes instanceof Array) {
const extraSelectClauses = conditionTypes.map((nodeId) => {
return new SimpleAttributeOperand({
attributeId: AttributeIds.NodeId,
browsePath: undefined,
indexRange: undefined, // NumericRange
typeDefinitionId: nodeId // conditionType for instance
});
});
selectClauses = selectClauses.concat(extraSelectClauses);
}
const filter = new EventFilter({
selectClauses: selectClauses,
whereClause: { // ContentFilter
elements: [ // ContentFilterElement
// {
// filterOperator: FilterOperator.IsNull,
// filterOperands: [ //
// new ElementOperand({
// index: 123
// }),
// new AttributeOperand({
// nodeId: "i=10",
// alias: "someText",
// browsePath: { //RelativePath
//
// },
// attributeId: AttributeIds.Value
// })
// ]
// }
]
}
});
return filter;
}