How to use the node-opcua-nodeid.coerceNodeId 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 / src / reference.ts View on Github external
constructor(options: AddReferenceOpts | Reference) {

        assert(options.referenceType instanceof NodeId);
        assert(options.nodeId instanceof NodeId);

        this.referenceType = coerceNodeId(options.referenceType);
        this.isForward = (options.isForward  === undefined ) ? true : !!options.isForward;
        this.nodeId = _localCoerceToNodeID(options.nodeId);

        // optional to speed up when AddReferenceOpts is in fact a Reference !
        this._referenceType = (options as any)._referenceType;
        this.node = (options as any).node;

        assert(is_valid_reference(this));
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_condition_base.ts View on Github external
if (conditionSourceNode) {

            conditionNode.sourceNode.setValueFromSource({
                dataType: DataType.NodeId,
                value: conditionSourceNode.nodeId
            });

            // conditionSourceNode node must be registered as a EventSource of an other node.
            // As per spec OPCUA 1.03 part 9 page 54:
            //   HasNotifier and HasEventSource References are used to expose the hierarchical organization
            //   of Event notifying Objects and ConditionSources. An Event notifying Object represents
            //   typically an area of Operator responsibility.  The definition of such an area configuration is
            //   outside the scope of this standard. If areas are available they shall be linked together and
            //   with the included ConditionSources using the HasNotifier and the HasEventSource Reference
            //   Types. The Server Object shall be the root of this hierarchy.
            if (!sameNodeId(conditionSourceNode.nodeId, coerceNodeId("ns=0;i=2253"))) { // server object
                /* istanbul ignore next */
                if (conditionSourceNode.getEventSourceOfs().length === 0) {
                    errorLog("conditionSourceNode = ", conditionSourceNode.browseName.toString());
                    errorLog("conditionSourceNode = ", conditionSourceNode.nodeId.toString());
                    throw new  Error("conditionSourceNode must be an event source " + conditionSourceNode.browseName.toString() + conditionSourceNode.nodeId.toString() ) ;
                }
            }

            const context = SessionContext.defaultContext;
            // set source Node (defined in UABaseEventType)
            conditionNode.sourceNode.setValueFromSource(
              conditionSourceNode.readAttribute(context, AttributeIds.NodeId).value
            );

            // set source Name (defined in UABaseEventType)
            conditionNode.sourceName.setValueFromSource(
github node-opcua / node-opcua / packages / node-opcua-address-space-for-conformance-testing / src / address_space_for_conformance_testing.js View on Github external
type: "NodeId", defaultValue: function() {
            return coerceNodeId("ns=" + 3 + ";g=00000000-0000-0000-0000-000000000023");
        }
    },
github node-opcua / node-opcua / packages / node-opcua-client / src / client_session_keepalive_manager.js View on Github external
const assert = require("node-opcua-assert").assert;
const EventEmitter = require("events").EventEmitter;
const util = require("util");

const coerceNodeId = require("node-opcua-nodeid").coerceNodeId;
const VariableIds = require("node-opcua-constants").VariableIds;

const serverStatus_State_Id = coerceNodeId(VariableIds.Server_ServerStatus_State);
const ServerState = require("node-opcua-common").ServerState;
const StatusCodes = require("node-opcua-status-code").StatusCodes;

const debugLog = require("node-opcua-debug").make_debugLog(__filename);
const doDebug = require("node-opcua-debug").checkDebugFlag(__filename);


function ClientSessionKeepAliveManager(session) {
    const self = this;
    self.session = session;
    self.timerId = 0;
}
util.inherits(ClientSessionKeepAliveManager, EventEmitter);
/**
 * @method ping_server
 *
github node-opcua / node-opcua / packages / node-opcua-generator / source / factory_code_generator.ts View on Github external
function getEncodingBinaryId(schema: StructuredTypeSchema): NodeId {
    const className = schema.name;
    const encodingBinarylId = (ObjectIds as any)[className + "_Encoding_DefaultBinary"];
    return coerceNodeId(encodingBinarylId);
}
github node-opcua / node-opcua / packages / node-opcua-generator / source / factory_code_generator.ts View on Github external
function getEncodingXmlId(schema: StructuredTypeSchema): NodeId {
    const className = schema.name;
    const encodingXmlId = (ObjectIds as any)[className + "_Encoding_DefaultXml"];
    return coerceNodeId(encodingXmlId);
}
github node-opcua / node-opcua / packages / node-opcua-client-proxy / src / proxy.js View on Github external
function getObject(proxyManager, nodeId, options, callback) {

    const session = proxyManager.session;

    nodeId = coerceNodeId(nodeId);

    if (nodeId.isEmpty()) {
        return setImmediate(function() {
            callback(new Error(" Invalid empty node in getObject"));
        });
    }

    const nodesToRead = [
        {
            nodeId: nodeId,
            attributeId: AttributeIds.BrowseName
        },
        {
            nodeId: nodeId,
            attributeId: AttributeIds.Description
        },