当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript NodeId.map方法代码示例

本文整理汇总了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;
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:96,代码来源:tools_event_filter.ts


注:本文中的node-opcua-nodeid.NodeId.map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。