How to use node-opcua-nodeid - 10 common examples

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-for-conformance-testing / src / address_space_for_conformance_testing.js View on Github external
function add_ObjectWithMethod(namespace, parentFolder) {


    const myObject = namespace.addObject({
        nodeId: "s=ObjectWithMethods",
        organizedBy: parentFolder,
        browseName: "ObjectWithMethods"
    });

    const methodNoArgs = namespace.addMethod(myObject, {
        browseName: "MethodNoArgs",
        nodeId: "s=MethodNoArgs",
        //xx inputArguments: [],
        //xx outputArguments: []
    });
    assert(makeNodeId("MethodNoArgs", namespace.index).toString().match(/s=MethodNoArgs/));
    assert(methodNoArgs.nodeId.toString().match(/s=MethodNoArgs/));

    methodNoArgs.bindMethod(function(inputArguments, context, callback) {
        // console.log(require("util").inspect(context).toString());
        const callMethodResult = {
            statusCode: StatusCodes.Good,
            outputArguments: []
        };
        callback(null, callMethodResult);
    });


    const methodIO = namespace.addMethod(myObject, {

        ///xx modellingRule: "Mandatory",
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-end2end-test / _test_generated / _auto_generated_ServerSideUnimplementedRequest.js View on Github external
assert(this instanceof BaseUAObject); //  ' keyword "new" is required for constructor call')
    resolve_schema_field_types(schema);

    BaseUAObject.call(this,options);

    /**
      * 
      * @property requestHeader
      * @type {RequestHeader}
      */
    self.requestHeader =  new RequestHeader( options.requestHeader);

   // Object.preventExtensions(self);
}
util.inherits(ServerSideUnimplementedRequest,BaseUAObject);
ServerSideUnimplementedRequest.prototype.encodingDefaultBinary = makeExpandedNodeId(892,0);
ServerSideUnimplementedRequest.prototype._schema = schema;

/**
 * encode the object into a binary stream
 * @method encode
 *
 * @param stream {BinaryStream} 
 */
ServerSideUnimplementedRequest.prototype.encode = function(stream,options) {
    // call base class implementation first
    BaseUAObject.prototype.encode.call(this,stream,options);
   this.requestHeader.encode(stream,options);
};
/**
 * decode the object from a binary stream
 * @method decode
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-server / source / server_engine.ts View on Github external
if (doDebug) {
        console.warn("ServerEngine#_getServerSubscriptionDiagnosticsArray : no addressSpace");
      }
      return null; // no addressSpace
    }
    const subscriptionDiagnosticsType = this.addressSpace.findVariableType("SubscriptionDiagnosticsType");
    if (!subscriptionDiagnosticsType) {
      if (doDebug) {
        console.warn("ServerEngine#_getServerSubscriptionDiagnosticsArray " +
          ": cannot find SubscriptionDiagnosticsType");
      }
    }

    // SubscriptionDiagnosticsArray = i=2290
    const subscriptionDiagnosticsArray = this.addressSpace.findNode(
      makeNodeId(VariableIds.Server_ServerDiagnostics_SubscriptionDiagnosticsArray))!;

    return subscriptionDiagnosticsArray as UADynamicVariableArray;
  }
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / base_node.js View on Github external
// ignore propagation on back reference to UAVariableType or UAObject Type reference
    // because there are too many !
    if (!referenceType || _is_massively_used_reference(referenceType)) {
        //xx &&(referenceNode.constructor.name === "UAVariableType" || referenceNode.constructor.name  === "UAObjectType")
        // console.log(referenceType.browseName.toString() ,referenceNode.browseName.toString(), "on ",self.browseName.toString());
        return;
    }
    // ------------------------------- EXPERIMENT


    //xx if (!referenceType.isSupertypeOf(hierarchicalReferencesId)) { return; }
    const related_node = _resolveReferenceNode(addressSpace, reference);
    if (related_node) {

        // verify that reference doesn't point to object itself (see mantis 3099)
        if (sameNodeId(reference.nodeId, self.nodeId)) {

            // istanbul ignore next
            if (displayWarningReferencePointingToItsef) {
                // this could happen with method
                console.warn("  Warning: a Reference is pointing to itself ", self.nodeId.toString(), self.browseName.toString());
                displayWarningReferencePointingToItsef = false;
            }

        }
        //xx ignore this assert(reference.nodeId.toString() !== self.nodeId.toString());
        //function w(s,l) { return (s+"                                                          ").substr(0,l);}
        //if (reference.isForward) {
        //    console.log("  CHILD => ",w(related_node.browseName   + " " + related_node.nodeId.toString(),30),
        //        "  PARENT   ",w(self.browseName + " " + self.nodeId.toString(),30) , reference.toString());
        //} else {
        //    console.log("  CHILD => ",w(self.browseName   + " " + self.nodeId.toString(),30),