當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。