本文整理匯總了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;
}