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


TypeScript node-opcua-nodeid.resolveNodeId函數代碼示例

本文整理匯總了TypeScript中node-opcua-nodeid.resolveNodeId函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript resolveNodeId函數的具體用法?TypeScript resolveNodeId怎麽用?TypeScript resolveNodeId使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: it

    it(" AddressSpace#findCorrespondingBasicDataType  i=13 => DataType.String", () => {

        const dataType = addressSpace.findDataType(resolveNodeId("i=12"))!;
        dataType.browseName.toString().should.eql("String");
        addressSpace.findCorrespondingBasicDataType(dataType).should.eql(DataType.String);

    });
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:7,代碼來源:test_address_space.ts

示例2: browse

    public browse(nodesToBrowse: BrowseDescriptionLike | BrowseDescriptionLike[], callback?: ResponseCallback<any>): any {

        const isArray = _.isArray(nodesToBrowse);
        if (!isArray) {
            nodesToBrowse = [nodesToBrowse as BrowseDescriptionLike];
        }
        const results: BrowseResult[] = [];
        for (let browseDescription of nodesToBrowse as any[]) {
            browseDescription.referenceTypeId = resolveNodeId(browseDescription.referenceTypeId);
            browseDescription = new BrowseDescription(browseDescription);
            const nodeId = resolveNodeId(browseDescription.nodeId);
            const r = this.addressSpace.browseSingleNode(nodeId, browseDescription);
            results.push(r);
        }
        callback!(null, isArray ? results : results[0]);
    }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:16,代碼來源:pseudo_session.ts

示例3: constructHookArgument

///
function constructHookArgument(options?: { dataType: any, valueRank?: number, arrayDimensions?: any }): any {

    options = options || {dataType: DataType.Null};

    let dataType = options.dataType;
    if (dataType) {
        if (typeof dataType === "string") {
            dataType = resolveNodeId(dataType);
        } else if (dataType instanceof NodeId) {
            // nothing
        } else if (dataType.value) {
            assert(dataType.hasOwnProperty("namespace"));
            dataType = coerceNodeId(dataType.value, dataType.namespace);
        } else {
            assert(typeof dataType === "number");
        }
        options.dataType = dataType;
    }
    if (options.valueRank === undefined) {
        options.valueRank = -1;
    }
    // fix missing ArrayDimension (The value is an array with one dimension.)
    if (options.valueRank !== 1 || !options.arrayDimensions) {
        options.arrayDimensions = [0];
    }

    return options;

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

示例4: it

    it("AddressSpace#addObject should create a 'hasTypeDefinition' reference on node", () => {

        const nbReferencesBefore = baseObjectType.findReferencesEx(
          "HasTypeDefinition", BrowseDirection.Inverse).length;

        const node1 = namespace.addObject({
            browseName: "Node1",
            typeDefinition: "BaseObjectType"
        });

        // xx node1.findReferencesEx("References", BrowseDirection.Forward).forEach(dump);

        const forwardReferences = node1.findReferencesEx("References", BrowseDirection.Forward);
        forwardReferences.length.should.eql(1);

        forwardReferences[0].referenceType.should.eql(resolveNodeId("HasTypeDefinition"));
        forwardReferences[0].isForward.should.eql(true);
        forwardReferences[0].nodeId.should.eql(baseObjectType.nodeId);

        const inverseReferences = node1.findReferencesEx("References", BrowseDirection.Inverse);
        inverseReferences.length.should.eql(0);

        const nbReferencesAfter = baseObjectType.findReferencesEx("HasTypeDefinition", BrowseDirection.Inverse).length;
        // xx console.log("",nbReferencesBefore,nbReferencesAfter);

        nbReferencesAfter.should.eql(nbReferencesBefore,
          "we should have no more inverse references on the BaseObjectType because we " +
          "do not add backward reference when reference is HasTypeDefinition");

        should(node1.parent).eql(null, "node1 should have no parent");
    });
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:31,代碼來源:test_base_node.ts

示例5: it

        it("should add a YArrayItem", () => {

            const yArrayItem = namespace.addYArrayItem({

                organizedBy: objectsFolder,

                browseName: "MyYArrayItem",

                title: "My Little YArray Item",

                engineeringUnits: standardUnits.degree_celsius,
                engineeringUnitsRange: { low: 100, high: 200 },

                axisScaleType: "Log",

                xAxisDefinition: {
                    axisScaleType: AxisScaleEnumeration.Linear,
                    axisSteps: [0, 25, 50, 75, 100],
                    engineeringUnits: standardUnits.second,
                    euRange: { low: -10, high: 100 },
                    title: coerceLocalizedText("the X axis legend"),
                },

                value: new Variant({
                    arrayType: VariantArrayType.Array,
                    dataType: DataType.Float,
                    value: [1, 2, 3, 2]
                })
            });

            yArrayItem.browseName.toString().should.eql("1:MyYArrayItem");

            yArrayItem.dataType.should.eql(resolveNodeId("Float"));

            yArrayItem.readValue().value.value.length.should.eql(4);
            yArrayItem.readValue().value.value[0].should.eql(1);
            yArrayItem.readValue().value.value[1].should.eql(2);
            yArrayItem.readValue().value.value[2].should.eql(3);
            yArrayItem.readValue().value.value[3].should.eql(2);

            yArrayItem.hasOwnProperty("instrumentRange").should.eql(false, "optional instrument Range not expected");

            yArrayItem.euRange.readValue().value.value.low.should.eql(100);
            yArrayItem.euRange.readValue().value.value.high.should.eql(200);

            yArrayItem.title.readValue().value.value.text.should.eql("My Little YArray Item");

            // access xAxisDefinition from extension object
            const x = yArrayItem.xAxisDefinition.readValue().value.value as AxisInformation;

            x.engineeringUnits.should.eql(standardUnits.second);
            x.title!.text!.should.eql("the X axis legend");
            x.euRange.low.should.eql(-10);
            x.euRange.high.should.eql(100);

            // xx console.log("xxxx ",yArrayItem.xAxisDefinition.toString())
            // xx yArrayItem.xAxisDefinition.euRange.readValue().value.value.should.eql(standardUnits.second);
            // xx yArrayItem.xAxisDefinition.engineeringUnits.readValue().value.value.should.eql(standardUnits.second);

        });
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:60,代碼來源:subtest_Y_array_item_type.ts

示例6: extractNamespaceDataType

export async function extractNamespaceDataType(
  session: IBasicSession,
  dataTypeManager: ExtraDataTypeManager
) {

    // read namespace array
    const dataValueNamespaceArray = await session.read({
        attributeId: AttributeIds.Value,
        nodeId: resolveNodeId("Server_NamespaceArray")
    });

    if (dataValueNamespaceArray.statusCode === StatusCodes.Good) {
        dataTypeManager.setNamespaceArray(dataValueNamespaceArray.value.value as string[]);
    }

    // DatType/OPCBinary => i=93 [OPCBinarySchema_TypeSystem]
    const opcBinaryNodeId = resolveNodeId("OPCBinarySchema_TypeSystem");

    const nodeToBrowse = {
        browseDirection: BrowseDirection.Forward,
        includeSubtypes: false,
        nodeClassMask: makeNodeClassMask("Variable"),
        nodeId: opcBinaryNodeId,
        referenceTypeId: resolveNodeId("HasComponent"),
        resultMask: makeResultMask("ReferenceType | IsForward | BrowseName | NodeClass | TypeDefinition")
    };
    const result = await session.browse(nodeToBrowse);

    // filter nodes that have the expected namespace Index
    const references = result.references!.filter(
      (e: ReferenceDescription) => e.nodeId.namespace !== 0);

    /* istanbul ignore next */
    if (references.length === 0) {
        return;
    }
    for (const ref of references) {
        const typeDictionary = await extractSchema(session, ref.nodeId);
        await exploreDataTypeDefinition(session, ref.nodeId, typeDictionary, dataTypeManager.namespaceArray);
        dataTypeManager.registerTypeDictionary(ref.nodeId, typeDictionary);
    }

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

示例7: makeNodeClassMask

 const nodesToBrowse2 = references.map((ref: ReferenceDescription) => {
     return {
         browseDirection: BrowseDirection.Inverse,
         includeSubtypes: false,
         nodeClassMask: makeNodeClassMask("Object | Variable"),
         nodeId: ref.nodeId,
         referenceTypeId: resolveNodeId("HasDescription"),
         resultMask: makeResultMask("NodeId | ReferenceType | BrowseName | NodeClass | TypeDefinition")
     };
 });
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:10,代碼來源:client_dynamic_extension_object.ts

示例8: _translateNodeId

 function _translateNodeId(nodeId: string): NodeId {
     if (alias_map[nodeId]) {
         return alias_map[nodeId];
     }
     const m = nodeId.match(reg);
     if (m) {
         const namespaceIndex = _translateNamespaceIndex(parseInt(m[1], 10));
         nodeId = "ns=" + namespaceIndex + ";" + m[2];
     }
     return resolveNodeId(nodeId);
 }
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:11,代碼來源:load_nodeset2.ts

示例9: extractEventField

/**
 *
 * @method extractEventField
 * extract a eventField from a event node, matching the given selectClause
 * @param eventData
 * @param selectClause
 */
function extractEventField(eventData: any, selectClause: SimpleAttributeOperand): Variant {

    assert_valid_event_data(eventData);
    assert(selectClause instanceof SimpleAttributeOperand);

    selectClause.browsePath = selectClause.browsePath || [];

    if (selectClause.browsePath.length === 0 && selectClause.attributeId === AttributeIds.NodeId) {

        // "ns=0;i=2782" => ConditionType
        // "ns=0;i=2041" => BaseEventType
        if (selectClause.typeDefinitionId.toString() !== "ns=0;i=2782") {
            // not ConditionType
            // tslint:disable-next-line:no-console
            console.warn("this case is not handled yet : selectClause.typeDefinitionId = " + selectClause.typeDefinitionId.toString());
            const eventSource1 = eventData.$eventDataSource;
            return new Variant({ dataType: DataType.NodeId, value: eventSource1.nodeId });
        }
        const conditionTypeNodeId = resolveNodeId("ConditionType");
        assert(sameNodeId(selectClause.typeDefinitionId, conditionTypeNodeId));

        const eventSource = eventData.$eventDataSource;
        const eventSourceTypeDefinition = eventSource.typeDefinitionObj;
        if (!eventSourceTypeDefinition) {
            // eventSource is a EventType class
            return new Variant();
        }
        const addressSpace = eventSource.addressSpace;
        const conditionType = addressSpace.findObjectType(conditionTypeNodeId);

        if (!eventSourceTypeDefinition.isSupertypeOf(conditionType)) {
            return new Variant();
        }
        // Yeh : our EventType is a Condition Type !
        return new Variant({ dataType: DataType.NodeId, value: eventSource.nodeId });
    }

    const handle = eventData.resolveSelectClause(selectClause);

    if (handle !== null) {
        const value = eventData.readValue(handle, selectClause);
        assert(value instanceof Variant);
        return value;

    } else {

        // Part 4 - 7.17.3
        // A null value is returned in the corresponding event field in the Publish response if the selected
        // field is not part of the Event or an error was returned in the selectClauseResults of the EventFilterResult.
        // return new Variant({dataType: DataType.StatusCode, value: browsePathResult.statusCode});
        return new Variant();
    }
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:60,代碼來源:tools_event_filter.ts

示例10: it

    it("should dump a browseDescription", (done: any) => {

        const browseDescription: BrowseDescriptionOptions = {
            browseDirection: BrowseDirection.Both,
            includeSubtypes: true,
            nodeClassMask: 0, // 0 = all nodes
            referenceTypeId: resolveNodeId("HierarchicalReferences"),
            resultMask: 0x3F
        };

        const hr = addressSpace.findReferenceType("HierarchicalReferences")!;

        redirectToFile("dumpBrowseDescription.log", () => {
            dumpBrowseDescription(hr, browseDescription);
        }, done);

    });
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:17,代碼來源:test_browse_node.ts


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