How to use the node-opcua-nodeid.resolveNodeId function in node-opcua-nodeid

To help you get started, we’ve selected a few node-opcua-nodeid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-address-space / test_helpers / create_minimalist_address_space_nodeset.ts View on Github external
browseName: "BaseVariableType",
        isAbstract: true,
        nodeClass: NodeClass.VariableType,
        nodeId: resolveNodeId(VariableTypeIds.BaseVariableType)
    }) as any as UAVariableType;

    const propertyType = namespace0.addVariableType({
        browseName: "PropertyType",
        subtypeOf: baseVariableType
    });

    const baseDataVariableType = namespace0._createNode({
        browseName: "BaseDataVariableType",
        isAbstract: true,
        nodeClass: NodeClass.VariableType,
        nodeId: resolveNodeId(VariableTypeIds.BaseDataVariableType),
        subtypeOf: baseVariableType.nodeId
    }) as any as UAVariableType;

    const modellingRule_Optional = namespace0._createNode({
        browseName: "Optional",
        nodeClass: NodeClass.Object,
        nodeId: resolveNodeId(ObjectIds.ModellingRule_Optional),
    }) as any as UAObject;

    const modellingRule_Mandatory = namespace0._createNode({
        browseName: "Mandatory",
        nodeClass: NodeClass.Object,
        nodeId: resolveNodeId(ObjectIds.ModellingRule_Mandatory),
    }) as any as UAObject;

    // add the root folder
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space.ts View on Github external
}
        }
        assert(params.referenceType instanceof NodeId);

        // ----------- now resolve target NodeId;
        if (params.nodeId instanceof BaseNode) {
            assert(!params.hasOwnProperty("node"));
            params.node = params.nodeId as BaseNode;
            params.nodeId = params.node.nodeId;
        } else {
            let _nodeId = params.nodeId! as NodeId;
            assert(!!_nodeId, "missing 'nodeId' in reference");
            if (_nodeId && (_nodeId as any).nodeId) {
                _nodeId = (_nodeId as any).nodeId as NodeId;
            }
            _nodeId = resolveNodeId(_nodeId);
            /* istanbul ignore next */
            if (!(_nodeId instanceof NodeId) || _nodeId.isEmpty()) {
                // tslint:disable:no-console
                console.log("xx =>", JSON.stringify(params, null, " "));
                throw new Error(" Invalid reference nodeId " + _nodeId.toString());
            }
            params.nodeId = _nodeId;
        }
        return new Reference(params);
    }
github node-opcua / node-opcua / packages / node-opcua-client / source / alarms_and_conditions / client_alarm_tools_acknowledge_all_conditions.ts View on Github external
discardOldest: false,
        filter: eventFilter,
        queueSize: 100,
        samplingInterval: 0,
    };

    const event_monitoringItem =
        await subscription.monitor(itemToMonitor, monitoringParameters, TimestampsToReturn.Both);

    const acknowledgeableConditions: EventStuff[] = [];

    let refreshStartEventHasBeenReceived = false;
    let RefreshEndEventHasBeenReceived = false;

    const RefreshStartEventType = resolveNodeId("RefreshStartEventType").toString();
    const RefreshEndEventType = resolveNodeId("RefreshEndEventType").toString();

    const promise = new Promise((resolve, reject) => {

        // now create a event monitored Item
        event_monitoringItem.on("changed", (_eventFields: any) => {
            const eventFields = _eventFields as Variant[];
            try {

                if (RefreshEndEventHasBeenReceived) {
                    return;
                }
                // dumpEvent(session, fields, eventFields);
                const pojo = fieldsToJson(fields, eventFields) as any;
                // console.log(pojo.eventType.value.toString(), RefreshEndEventType, RefreshStartEventType);

                // make sure we only start recording event after the RefreshStartEvent has been received
github node-opcua / node-opcua / packages / node-opcua-address-space / src / loader / load_nodeset2.js View on Github external
finish: function () {

                        const typeId = this.text.trim();
                        //xx console.log("typeId = ",typeId);
                        this.parent.parent.typeId = resolveNodeId(typeId);

                        switch (typeId) {
                            case "i=297":  // Argument
                            case "ns=0;i=297":  // Argument
                                break;
                            case "ns=0;i=7616": // EnumValueType
                            case "i=7616": // EnumValueType
                                break;
                            case "ns=0;i=888": // EnumValueType
                            case "i=888":  // EUInformation
                                break;
                            case "ns=0;i=885":  // Range
                            case "i=885":  // Range
                                break;
                            default:
                                console.warn("loadnodeset2 ( checking identifier type) : unsupported typeId in ExtensionObject " + typeId);
github node-opcua / node-opcua / packages / node-opcua-convert-nodeset-to-javascript / src / convert_nodeset_to_types.js View on Github external
dataType.definition.forEach(function(pair) {
        const dataTypeId = resolveNodeId(pair.dataType);

        const fieldDataType = addressSpace.findNode(dataTypeId);

        if (!fieldDataType) {
            throw new Error(
                " cannot find description for object " +
                    dataTypeId +
                    ". Check that this node exists in the nodeset.xml file"
            );
        }

        //xx console.log("xxxxx dataType",dataType.toString());

        // check if  dataType is an enumeration or a structure or  a basic type
        if (fieldDataType.isSupertypeOf(enumeration)) {
            makeEnumeration(fieldDataType);
github node-opcua / node-opcua / packages / node-opcua-server / source / server_engine.ts View on Github external
assert(_.isArray(value));
            return new Variant({
              arrayType: VariantArrayType.Array,
              dataType: variantDataType,
              value
            });
          },
          set: null // read only
        });
      }

      bindStandardScalar(VariableIds.Server_EstimatedReturnTime,
        DataType.DateTime, () => minOPCUADate);

      // TimeZoneDataType
      const timeZoneDataType = addressSpace.findDataType(resolveNodeId(DataTypeIds.TimeZoneDataType))!;
      // xx console.log(timeZoneDataType.toString());

      const timeZone = new TimeZoneDataType({
        daylightSavingInOffset: /* boolean*/ false,
        offset: /* int16 */ 0
      });
      bindStandardScalar(VariableIds.Server_LocalTime,
        DataType.ExtensionObject, () => {
          return timeZone;
        });

      bindStandardScalar(VariableIds.Server_ServiceLevel,
        DataType.Byte, () => {
          return 255;
        });
github node-opcua / node-opcua / packages / node-opcua-client-dynamic-extension-object / source / client_dynamic_extension_object.ts View on Github external
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 && dataValueNamespaceArray.value.value.length > 0) {
        dataTypeManager.setNamespaceArray(dataValueNamespaceArray.value.value as string[]);
    }

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

    // let find all DataType dictionary node corresponding to a given namespace
    // (have DataTypeDictionaryType)
    const nodeToBrowse: BrowseDescriptionLike = {
        browseDirection: BrowseDirection.Forward,
        includeSubtypes: false,
        nodeClassMask: makeNodeClassMask("Variable"),
        nodeId: opcBinaryNodeId,
github node-opcua / node-opcua / packages / node-opcua-client-crawler / source / node_crawler.ts View on Github external
private _createCacheNode(nodeId: NodeId) {
        const key = resolveNodeId(nodeId).toString();
        let cacheNode = this._objectCache[key];
        if (cacheNode) {
            throw new Error("NodeCrawler#_createCacheNode :" +
                " cache node should not exist already : " + nodeId.toString());
        }
        cacheNode = new CacheNode(nodeId);
        assert(!this._objectCache.hasOwnProperty(key));
        this._objectCache[key] = cacheNode;
        return cacheNode;
    }
github node-opcua / node-opcua / packages / node-opcua-client-crawler / source / node_crawler.ts View on Github external
private _getCacheNode(nodeId: NodeIdLike): CacheNode {
        const key = resolveNodeId(nodeId).toString();
        return this._objectCache[key];
    }
github node-opcua / node-opcua / packages / node-opcua-client-dynamic-extension-object / source / client_dynamic_extension_object.ts View on Github external
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")
        };
    });
    const results2 = await session.browse(nodesToBrowse2);