當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript AddressSpace.getNamespace方法代碼示例

本文整理匯總了TypeScript中node-opcua-address-space.AddressSpace.getNamespace方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AddressSpace.getNamespace方法的具體用法?TypeScript AddressSpace.getNamespace怎麽用?TypeScript AddressSpace.getNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在node-opcua-address-space.AddressSpace的用法示例。


在下文中一共展示了AddressSpace.getNamespace方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: addAggregateSupport

export function addAggregateSupport(addressSpace: AddressSpace) {
    const aggregateConfigurationType = addressSpace.getNamespace(0).findObjectType("AggregateConfigurationType");
    if (!aggregateConfigurationType) {
        throw new Error("addressSpace do not expose AggregateConfigurationType");
    }

    const aggregateFunctionType = addressSpace.getNamespace(0).findObjectType("AggregateFunctionType");
    if (!aggregateFunctionType) {
        throw new Error("addressSpace do not expose AggregateFunctionType");
    }

    const serverObject = addressSpace.rootFolder.objects.getFolderElementByName("Server");
    if (!serverObject) {
        throw new Error("addressSpace do not expose a ServerObject");
    }
    // xx serverObject.

    const serverCapabilities = serverObject.getChildByName("ServerCapabilities")! as UAServerCapabilities;

    // Let see if HistoryServer Capabilities object exists
    let historyServerCapabilities = serverCapabilities.getChildByName("HistoryServerCapabilities");
    if (!historyServerCapabilities) {
        historyServerCapabilities = createHistoryServerCapabilities(addressSpace, serverCapabilities);
    }

    setHistoricalServerCapabilities(historyServerCapabilities, historicalCapabilitiesDefaultProperties);

    addAggregateFunctionSupport(addressSpace, AggregateFunction.Interpolative);
    addAggregateFunctionSupport(addressSpace, AggregateFunction.Minimum);
    addAggregateFunctionSupport(addressSpace, AggregateFunction.Maximum);

}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:32,代碼來源:aggregates.ts

示例2: addAggregateFunctionSupport

function addAggregateFunctionSupport(
  addressSpace: AddressSpace, functionName: number): void {
    if (!functionName) {
        throw new Error("Invalid function name");
    }

    const serverCapabilities = addressSpace.rootFolder.objects.server.serverCapabilities;

    /* istanbul ignore next */
    if (!serverCapabilities.historyServerCapabilities) {
        throw new Error("missing serverCapabilities.historyServerCapabilities");
    }

    const aggregateFunctions = serverCapabilities.aggregateFunctions;

    const aggregateFunctionsInHist = serverCapabilities.historyServerCapabilities.aggregateFunctions;

    const functionNodeId = makeNodeId(functionName);
    const functionNode = addressSpace.getNamespace(0).findNode(functionNodeId);
    if (!functionNode) {
        throw new Error("Cannot find node " + functionName + " in addressSpace");
    }
    aggregateFunctions.addReference({
        nodeId: functionNode.nodeId,
        referenceType: "Organizes"
    });
    aggregateFunctionsInHist.addReference({
        nodeId: functionNode.nodeId,
        referenceType: "Organizes"
    });
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:31,代碼來源:aggregates.ts

示例3: createHistoryServerCapabilities

export function createHistoryServerCapabilities(
  addressSpace: AddressSpace,
  serverCapabilities: UAServerCapabilities
): UAObject {

    /* istanbul ignore next */
    if (serverCapabilities.browseName.toString() !== "ServerCapabilities") {
        throw new Error("Expecting server Capabilities");
    }

    const historyServerCapabilitiesType = addressSpace.getNamespace(0).findObjectType("HistoryServerCapabilitiesType")!;

    /* istanbul ignore next */
    if (!historyServerCapabilitiesType) {
        throw new Error("Cannot find HistoryServerCapabilitiesType");
    }
    const historyServerCapabilities = historyServerCapabilitiesType.instantiate({
        browseName: "HistoryServerCapabilities",
        componentOf: serverCapabilities
    });
    return historyServerCapabilities;
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:22,代碼來源:aggregates.ts


注:本文中的node-opcua-address-space.AddressSpace.getNamespace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。