How to use the node-opcua-data-model.NodeClass.Variable function in node-opcua-data-model

To help you get started, we’ve selected a few node-opcua-data-model 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 / alarms_and_conditions / ua_limit_alarm.ts View on Github external
alarmNode.setHighLimit(options.highLimit);
        }
        if (options.hasOwnProperty("lowLimit")) {
            alarmNode.setLowLimit(options.lowLimit);
        }
        if (options.hasOwnProperty("lowLowLimit")) {
            alarmNode.setLowLowLimit(options.lowLowLimit);
        }

        /*
         * The InputNode Property provides the NodeId of the Variable the Value of which is used as
         * primary input in the calculation of the Alarm state. If this Variable is not in the AddressSpace,
         * a Null NodeId shall be provided. In some systems, an Alarm may be calculated based on
         * multiple Variables Values; it is up to the system to determine which Variable’s NodeId is used.
         */
        assert(alarmNode.inputNode.nodeClass === NodeClass.Variable);
        alarmNode.inputNode.setValueFromSource({ dataType: "NodeId", value: inputNode.nodeId });

        // install inputNode monitoring for change
        alarmNode._installInputNodeMonitoring(options.inputNode);
        alarmNode._watchLimits();

        return alarmNode;
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.ts View on Github external
assert(_.isArray(options.arrayDimensions) || options.arrayDimensions === null);
        // -----------------------------------------------------

        options.minimumSamplingInterval = +options.minimumSamplingInterval || 0;
        let references = options.references || ([] as AddReferenceOpts[]);

        references = ([] as AddReferenceOpts[]).concat(references, [
            {
                isForward: true,
                nodeId: typeDefinition,
                referenceType: "HasTypeDefinition"
            }
        ]);

        assert(!options.nodeClass || options.nodeClass === NodeClass.Variable);
        options.nodeClass = NodeClass.Variable;

        options.references = references;

        const variable = this.createNode(options) as UAVariable;
        assert(variable instanceof UAVariable);
        return variable;
    }
github node-opcua / node-opcua / packages / node-opcua-server / src / server_subscription.js View on Github external
assert(monitoredItemCreateRequest instanceof MonitoredItemCreateRequest);


    function handle_error(statusCode) {
        return new subscription_service.MonitoredItemCreateResult({statusCode: statusCode});
    }

    const itemToMonitor = monitoredItemCreateRequest.itemToMonitor;

    const node = addressSpace.findNode(itemToMonitor.nodeId);
    if (!node) {
        return handle_error(StatusCodes.BadNodeIdUnknown);
    }


    if (itemToMonitor.attributeId === AttributeIds.Value && !(node.nodeClass === NodeClass.Variable)) {
        // AttributeIds.Value is only valid for monitoring value of UAVariables.
        return handle_error(StatusCodes.BadAttributeIdInvalid);
    }


    if (itemToMonitor.attributeId === AttributeIds.INVALID) {
        return handle_error(StatusCodes.BadAttributeIdInvalid);
    }

    if (!itemToMonitor.indexRange.isValid()) {
        return handle_error(StatusCodes.BadIndexRangeInvalid);
    }

    // check dataEncoding applies only on Values
    if (itemToMonitor.dataEncoding.name && itemToMonitor.attributeId !== AttributeIds.Value) {
        return handle_error(StatusCodes.BadDataEncodingInvalid);
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.js View on Github external
if (this._nodeid_index.hasOwnProperty(indexName)) {
        throw new Error("nodeId " + node.nodeId.displayText() + " already registered " + node.nodeId.toString());
    }

    this._nodeid_index[indexName] = node;

    if (node.nodeClass === NodeClass.ObjectType) {
        _registerObjectType(this, node);
    } else if (node.nodeClass === NodeClass.VariableType) {
        _registerVariableType(this, node);
    } else if (node.nodeClass === NodeClass.ReferenceType) {
        _registerReferenceType(this, node);
    } else if (node.nodeClass === NodeClass.DataType) {
        _registerDataType(this, node);
    } else if (node.nodeClass === NodeClass.Object) {
    } else if (node.nodeClass === NodeClass.Variable) {
    } else if (node.nodeClass === NodeClass.Method) {
    } else if (node.nodeClass === NodeClass.View) {
    } else {
        console.log("Invalid class Name", node.nodeClass);
        throw new Error("Invalid class name specified");
    }
};
github node-opcua / node-opcua / packages / node-opcua-client-crawler / source / node_crawler.ts View on Github external
task5: (callback: ErrorCallback) => {
                    if (cacheNode.nodeClass !== NodeClass.Variable) {
                        return callback();
                    }
                    this._defer_readNode(cacheNode.nodeId, AttributeIds.MinimumSamplingInterval, (err, value) => {
                        cacheNode.minimumSamplingInterval = value;
                        callback();
                    });
                },
github node-opcua / node-opcua / packages / node-opcua-client-proxy / source / proxy_variable.ts View on Github external
constructor(proxyManager: UAProxyManager, nodeId: NodeId, reference: ReferenceDescription) {
        super(proxyManager, nodeId, NodeClass.Variable);
    }
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space_change_event_tools.ts View on Github external
function _getTypeDef(node: BaseNode) {
                if (node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable) {
                    return node.typeDefinitionObj.nodeId;
                }
                return null;
            }
github node-opcua / node-opcua / packages / node-opcua-address-space / source / loader / load_nodeset2.ts View on Github external
const task = async (addressSpace2: AddressSpace) => {
                            data.variant.value = data.postponedExtensionObject;
                            assert(data.nodeId, "expecting a nodeid");
                            const node = addressSpace.findNode(data.nodeId)!;
                            if (node.nodeClass === NodeClass.Variable) {
                                const v = node as UAVariable;
                                v.setValueFromSource(data.variant);
                            }
                            if (node.nodeClass === NodeClass.VariableType) {
                                const v = node as UAVariableType;
                                v.value.value = data.variant.value;
                            }

                        };
                        postTasks.push(task);
github node-opcua / node-opcua / packages / node-opcua-address-space / src / base_node_private.ts View on Github external
this: UAVariableType | UAVariable,
    options: ToStringOption
) {
    assert(options);

    const _private = BaseNode_getPrivate(this);

    if (this.dataType) {

        const addressSpace = this.addressSpace;
        const d = addressSpace.findNode(this.dataType);
        const n = d ? "(" + d.browseName.toString() + ")" : " (???)";
        options.add(options.padding + chalk.yellow("          dataType            : ") + this.dataType + "  " + n);
    }

    if (this.nodeClass === NodeClass.Variable) {
        if (this._dataValue) {
            options.add(options.padding + chalk.yellow("          value               : ") + "\n" +
                options.indent(this._dataValue.toString(), options.padding + "                        | "));
        }
    }

    if (this.accessLevel) {
        options.add(options.padding + chalk.yellow("          accessLevel         : ") + " " +
            accessLevelFlagToString(this.accessLevel));
    }
    if (this.userAccessLevel) {
        options.add(options.padding + chalk.yellow("          userAccessLevel     : ") + " " +
            accessLevelFlagToString(this.userAccessLevel));
    }
    if (this.hasOwnProperty("valueRank")) {
        options.add(options.padding + chalk.yellow("          valueRank           : ") + " " +