How to use the node-opcua-variant.DataType.StatusCode function in node-opcua-variant

To help you get started, we’ve selected a few node-opcua-variant 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_condition_base.ts View on Github external
public _assert_valid() {
        assert(this.receiveTime.readValue().value.dataType === DataType.DateTime);
        assert(this.receiveTime.readValue().value.value instanceof Date);

        assert(this.message.readValue().value.dataType === DataType.LocalizedText);
        assert(this.severity.readValue().value.dataType === DataType.UInt16);

        assert(this.time.readValue().value.dataType === DataType.DateTime);
        assert(this.time.readValue().value.value instanceof Date);

        assert(this.quality.readValue().value.dataType === DataType.StatusCode);
        assert(this.enabledState.readValue().value.dataType === DataType.LocalizedText);
        assert(this.branchId.readValue().value.dataType === DataType.NodeId);

        // note localTime has been made optional in 1.04
        assert(!this.localTime || this.localTime.readValue().value.dataType === DataType.ExtensionObject);

    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / shelving_state_machine.ts View on Github external
function _unShelveTimeFunc(
  shelvingState: ShelvingStateMachine
) {

    if (shelvingState.getCurrentState() === "Unshelved") {
        return new Variant({
            dataType: DataType.StatusCode,
            value: StatusCodes.BadConditionNotShelved
        });
    }

    if (!shelvingState._sheveldTime) {
        return new Variant({
            dataType: DataType.StatusCode,
            value: StatusCodes.BadConditionNotShelved
        });
    }
    if (shelvingState.getCurrentState() === "OneShotShelved" &&
      shelvingState._duration === UAAlarmConditionBase.MaxDuration) {
        return new Variant({
            dataType: DataType.Double,
            value: UAAlarmConditionBase.MaxDuration
        });
    }
    const now = new Date();

    let timeToAutomaticUnshelvedState =
      shelvingState._duration - (now.getTime() - shelvingState._sheveldTime.getTime());

    // timeToAutomaticUnshelvedState should always be greater than (or equal) zero
github node-opcua / node-opcua / packages / node-opcua-address-space / src / event_data.ts View on Github external
function prepare(dataValue: DataValue): Variant {
    if (dataValue.statusCode === StatusCodes.Good) {
        return dataValue.value;
    }
    return new Variant({dataType: DataType.StatusCode, value: dataValue.statusCode});
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / condition.js View on Github external
ConditionSnapshot.prototype.getQuality = function() {
    const self = this;
    return self._get_var("quality", DataType.StatusCode);
};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space_add_event_type.js View on Github external
function prepare(dataValue) {
    assert(dataValue instanceof DataValue);
    if(dataValue.statusCode === StatusCodes.Good) {
        return dataValue.value;
    }
    return new Variant({dataType: DataType.StatusCode, value: dataValue.statusCode});
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / condition.js View on Github external
UAConditionBase.prototype._assert_valid = function() {
    const self = this;
    assert(self.receiveTime.readValue().value.dataType === DataType.DateTime);
    assert(self.receiveTime.readValue().value.value instanceof Date);

    assert(self.localTime.readValue().value.dataType === DataType.ExtensionObject);
    assert(self.message.readValue().value.dataType === DataType.LocalizedText);
    assert(self.severity.readValue().value.dataType === DataType.UInt16);

    assert(self.time.readValue().value.dataType === DataType.DateTime);
    assert(self.time.readValue().value.value instanceof Date);

    assert(self.quality.readValue().value.dataType === DataType.StatusCode);
    assert(self.enabledState.readValue().value.dataType === DataType.LocalizedText);
    assert(self.branchId.readValue().value.dataType === DataType.NodeId);
};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / condition_snapshot.ts View on Github external
public setQuality(quality: StatusCode): void {
        this._set_var("quality", DataType.StatusCode, quality);
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / condition.js View on Github external
ConditionSnapshot.prototype.setQuality = function(quality) {
    const self = this;
    assert(quality instanceof StatusCode);
    assert(quality.hasOwnProperty("value") || "quality must be a StatusCode");
    self._set_var("quality", DataType.StatusCode, quality);
    /*
     * OPCUA Spec 1.0.3 - Part 9:
     * Comment, severity and quality are important elements of Conditions and any change
     * to them will cause Event Notifications.
     *
     */
    self._need_event_raise = true;
};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_acknowledgeable_condition_base.ts View on Github external
},
            clientUserId: {
                dataType: DataType.Null
            },
            comment: { dataType: DataType.LocalizedText, value: branch.getComment() },
            inputArguments: {
                dataType: DataType.Null
            },
            methodId: {
                dataType: DataType.Null
            },
            serverId: {
                dataType: DataType.Null
            },
            status: {
                dataType: DataType.StatusCode,
                value: StatusCodes.Good
            }
        };
        this.raiseEvent("AuditConditionConfirmEventType", eventData);

    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / alarm_condition.js View on Github external
function _unShelveTimeFunc(shelvingState) {


    if (shelvingState.getCurrentState() === "Unshelved") {
        return new Variant({
            dataType: DataType.StatusCode,
            value: StatusCodes.BadConditionNotShelved
        });
    }

    if (!shelvingState._sheveldTime) {
        return new Variant({
            dataType: DataType.StatusCode,
            value: StatusCodes.BadConditionNotShelved
        });
    }
    if (shelvingState.getCurrentState() === "OneShotShelved" && shelvingState._duration === UAAlarmConditionBase.MaxDuration) {
        return new Variant({
            dataType: DataType.Double,
            value: UAAlarmConditionBase.MaxDuration
        });
    }