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


TypeScript node-opcua-service-translate-browse-path.makeBrowsePath函数代码示例

本文整理汇总了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");

    });
开发者ID:node-opcua,项目名称:node-opcua,代码行数:33,代码来源:test_address_space_browse_path.ts

示例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);
    });

};
开发者ID:node-opcua,项目名称:node-opcua,代码行数:31,代码来源:client_tools.ts

示例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);
            });
        },
开发者ID:node-opcua,项目名称:node-opcua,代码行数:19,代码来源:client_tools.ts

示例4: makeBrowsePath

 (prop: string) => makeBrowsePath(historyServerCapabilitiesNodeId, "." + prop));
开发者ID:node-opcua,项目名称:node-opcua,代码行数:1,代码来源:read_history_server_capabilities.ts

示例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);
            });
        });
    });
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:95,代码来源:read_history_server_capabilities.ts


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