How to use the node-opcua-status-code.StatusCodes.BadNodeIdInvalid function in node-opcua-status-code

To help you get started, we’ve selected a few node-opcua-status-code 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 / shelving_state_machine.ts View on Github external
assert(inputArguments.length === 1);

    const shelvingState = context.object as ShelvingStateMachine;

    if (shelvingState.getCurrentState() !== "Unshelved") {
        return callback(null, {
            statusCode: StatusCodes.BadConditionAlreadyShelved
        });
    }
    // checking duration ...
    const alarmNode = shelvingState.parent;

    // istanbul ignore next
    if (!(alarmNode instanceof UAAlarmConditionBase)) {
        return callback(null, {
            statusCode: StatusCodes.BadNodeIdInvalid
        });
    }
    const maxTimeShelved = alarmNode.getMaxTimeShelved();
    assert(_.isFinite(maxTimeShelved));

    assert(inputArguments[0].dataType === DataType.Double); // Duration
    assert(inputArguments[0] instanceof Variant);

    // xx console.log("inputArguments",inputArguments[0].toString());

    const proposedDuration = inputArguments[0].value; // as double (milliseconds)
    if (proposedDuration > maxTimeShelved) {
        return callback(null, {
            statusCode: StatusCodes.BadShelvingTimeOutOfRange
        });
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / argument_list.js View on Github external
function getMethodDeclaration_ArgumentList(addressSpace, objectId, methodId) {

    assert(objectId instanceof NodeId);
    assert(methodId instanceof NodeId);
    // find object in address space
    const obj = addressSpace.findNode(objectId);
    if (!obj) {

        // istanbul ignore next
        if(doDebug) {
            console.warn("cannot find node ",objectId.toString());
        }
        return {statusCode: StatusCodes.BadNodeIdUnknown};
    }
    if (!obj.hasMethods) {
        return {statusCode: StatusCodes.BadNodeIdInvalid};
    }
    let objectMethod = obj.getMethodById(methodId);
    if (!objectMethod) {

        // the method doesn't belong to the object, nevertheless
        // the method can be called
        objectMethod = addressSpace.findNode(methodId);
        if (!objectMethod || !(objectMethod instanceof UAMethod)) {
            return {statusCode: StatusCodes.BadMethodInvalid};
        }
    }

    const methodDeclarationId = objectMethod.methodDeclarationId;

    const methodDeclaration = addressSpace.findNode(methodDeclarationId);
    if (!methodDeclaration) {
github node-opcua / node-opcua / packages / node-opcua-server / source / validate_filter.ts View on Github external
function __validateDataChangeFilter(
  filter: DataChangeFilter,
  itemToMonitor: ReadValueIdOptions,
  node: UAVariable
): StatusCode {

    assert(itemToMonitor.attributeId === AttributeIds.Value);

    if ((node.nodeClass !== NodeClass.Variable)) {
        return StatusCodes.BadNodeIdInvalid;
    }

    assert(node.nodeClass === NodeClass.Variable);

    // if node is not Numerical=> DataChangeFilter
    assert(node.dataType instanceof NodeId);
    const dataType = node.addressSpace.findDataType(node.dataType)!;

    const dataTypeNumber = node.addressSpace.findDataType("Number")!;
    if (filter.deadbandType !== DeadbandType.None) {
        if (!dataType.isSupertypeOf(dataTypeNumber)) {
            return StatusCodes.BadFilterNotAllowed;
        }
    }

    if (filter.deadbandType === DeadbandType.Percent) {
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / alarm_condition.js View on Github external
function _oneShotShelve_method(inputArguments, context, callback) {

    assert(inputArguments.length === 0);
    const shelvingState = context.object;
    if (shelvingState.getCurrentState() === "OneShotShelved") {
        return callback(null, {
            statusCode: StatusCodes.BadConditionAlreadyShelved
        });
    }
    // checking duration ...
    const alarmNode = context.object.parent;

    // istanbul ignore next
    if (!(alarmNode instanceof UAAlarmConditionBase)) {
        return callback(null, {
            statusCode: StatusCodes.BadNodeIdInvalid
        });
    }


    const maxTimeShelved = alarmNode.getMaxTimeShelved();
    assert(_.isFinite(maxTimeShelved));
    assert(maxTimeShelved !== UAAlarmConditionBase.MaxDuration);

    // set automatic unshelving timer
    _clear_timer_if_any(shelvingState);
    shelvingState.setState("OneShotShelved");
    _start_timer_for_automatic_unshelve(shelvingState, maxTimeShelved);

    return callback(null, {
        statusCode: StatusCodes.Good
    });
github node-opcua / node-opcua / packages / node-opcua-address-space / source / helpers / call_helpers.ts View on Github external
if (response.statusCode !== StatusCodes.Good) {
        return callback(null, { statusCode: response.statusCode });
    }
    const methodDeclaration = response.methodDeclaration;

    // verify input Parameters
    const methodInputArguments = methodDeclaration.getInputArguments();

    response = verifyArguments_ArgumentList(addressSpace, methodInputArguments, inputArguments);
    if (response.statusCode !== StatusCodes.Good) {
        return callback(null, response);
    }

    const methodObj = addressSpace.findNode(methodId) as UAMethod;
    if (methodObj.nodeClass !== NodeClass.Method) {
        return callback(null, { statusCode: StatusCodes.BadNodeIdInvalid });
    }

    // invoke method on object
    const context = new SessionContext({
        object: addressSpace.findNode(objectId) as UAObject,
        server,
        session
    });

    let l_extraDataTypeManager: ExtraDataTypeManager;

    ensureDatatypeExtractedWithCallback(addressSpace, (err2: Error|null, extraDataTypeManager: ExtraDataTypeManager) => {

        l_extraDataTypeManager = extraDataTypeManager;

        // resolve opaque data structure from inputArguments
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_condition_base.ts View on Github external
function _enable_method(
  inputArguments: VariantLike[],
  context: SessionContext,
  callback: any
) {
    assert(inputArguments.length === 0);
    const conditionNode = context.object;
    assert(conditionNode);

    if (!(conditionNode instanceof UAConditionBase)) {
        return callback(null, {
            statusCode: StatusCodes.BadNodeIdInvalid
        });
    }
    const statusCode = conditionNode._setEnabledState(true);
    return callback(null, {
        statusCode
    });
}
github node-opcua / node-opcua / packages / node-opcua-server / src / monitored_item.js View on Github external
function _on_node_disposed(monitoredItem) {
    const node = this;
    monitoredItem._on_value_changed(new DataValue({sourceTimestamp: new Date(),statusCode: StatusCodes.BadNodeIdInvalid}));
    monitoredItem._stop_sampling();

}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / condition.js View on Github external
function _enable_method(inputArguments, context, callback) {
    assert(inputArguments.length === 0);
    const conditionNode = context.object;
    assert(conditionNode);

    if (!(conditionNode instanceof UAConditionBase)) {
        return callback(null, {
            statusCode: StatusCodes.BadNodeIdInvalid
        });
    }
    const statusCode = conditionNode._setEnabledState(true);
    return callback(null, {
        statusCode: statusCode
    });
}
github node-opcua / node-opcua / packages / node-opcua-server / source / monitored_item.ts View on Github external
private _on_node_disposed(node: BaseNode) {
    this._on_value_changed(new DataValue({
      sourceTimestamp: new Date(),
      statusCode: StatusCodes.BadNodeIdInvalid
    }));
    this._stop_sampling();
    node.removeListener("dispose", this._on_node_disposed_listener);
    this._on_node_disposed_listener = null;
  }