How to use the node-opcua-variant.DataType.Boolean 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 / test / helpers / helpers.ts View on Github external
// setup data
    const sourceTimestamp = makeDate(time);

    if (value === undefined || value === null) {

        return new DataValue({
            sourceTimestamp,
            statusCode,
            value: undefined,
        });

    } else if (typeof value === "boolean") {
        return new DataValue({
            sourceTimestamp,
            statusCode,
            value: {dataType: DataType.Boolean, value},
        });

    } else {
        return new DataValue({
            sourceTimestamp,
            statusCode,
            value: {dataType: DataType.Float, value},
        });
    }
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / data_access / address_space_add_TwoStateDiscrete.js View on Github external
const twoStateDiscreteType = addressSpace.findVariableType("TwoStateDiscreteType");
        assert(twoStateDiscreteType, "expecting TwoStateDiscreteType to be defined , check nodeset xml file");


        // todo : if options.typeDefinition is specified,

        const variable = namespace.addVariable({
            componentOf: options.componentOf,
            browseName: options.browseName,
            nodeId: options.nodeId,
            typeDefinition: twoStateDiscreteType.nodeId,
            dataType: "Boolean",
            accessLevel: options.accessLevel,
            userAccessLevel: options.userAccessLevel,
            value: new Variant({dataType: DataType.Boolean, value: !!options.value})
        });

        const handler = variable.handle_semantic_changed.bind(variable);

        add_dataItem_stuff(variable, options);

        const trueStateNode = namespace.addVariable({
            propertyOf: variable,
            typeDefinition: "PropertyType",
            browseName: {name: "TrueState", namespaceIndex: 0},
            dataType: "LocalizedText",
            minimumSamplingInterval: 0,
            value: new Variant({
                dataType: DataType.LocalizedText, value: coerceLocalizedText(options.trueState || "ON")
            })
        });
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_reference_type.ts View on Github external
public readAttribute(context: SessionContext  | null, attributeId: AttributeIds): DataValue {

        assert(!context || context instanceof SessionContext);

        const options: DataValueLike = {};
        switch (attributeId) {
            case AttributeIds.IsAbstract:
                options.value = { dataType: DataType.Boolean, value: !!this.isAbstract };
                options.statusCode = StatusCodes.Good;
                break;
            case AttributeIds.Symmetric:
                options.value = { dataType: DataType.Boolean, value: !!this.symmetric };
                options.statusCode = StatusCodes.Good;
                break;
            case AttributeIds.InverseName: // LocalizedText
                options.value = { dataType: DataType.LocalizedText, value: this.inverseName };
                options.statusCode = StatusCodes.Good;
                break;
            default:
                return super.readAttribute(context, attributeId);
        }
        return new DataValue(options);
    }
github node-opcua / node-opcua / packages / node-opcua-address-space-for-conformance-testing / src / address_space_for_conformance_testing.js View on Github external
const variant = dataValue.value;
        assert(variant instanceof Variant);
        assert(ec.isValidUInt16(variant.value) && " value must be valid for dataType");
        interval = variant.value;
        install_Timer();
    });


    const enabledVariable = namespace.addVariable({
        componentOf: simulation,
        browseName: "Enabled",
        description: { locale: "en", text: "Enabled" },
        nodeId: "s=Scalar_Simulation_Enabled",
        dataType: "Boolean",
        value: new Variant({
            dataType: DataType.Boolean,
            arrayType: VariantArrayType.Scalar,
            value: enabled
        })
    });
    enabledVariable.on("value_changed", function(dataValue/*,indexRange*/) {
        const variant = dataValue.value;
        assert(variant instanceof Variant);
        assert(ec.isValidBoolean(variant.value) && " value must be valid for dataType");
        enabled = variant.value;
        install_Timer();
    });
    install_Timer();

    const addressSpace = namespace.addressSpace;
    addressSpace.registerShutdownTask(tearDown_Timer);
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.ts View on Github external
private _readHistorizing(): DataValue {
        assert(typeof (this.historizing) === "boolean");
        const options = {
            statusCode: StatusCodes.Good,
            value: { dataType: DataType.Boolean, value: !!this.historizing }
        };
        return new DataValue(options);
    }
}
github node-opcua / node-opcua / packages / node-opcua-server / source / server_engine.ts View on Github external
});

        bindStandardScalar(VariableIds.HistoryServerCapabilities_AccessHistoryDataCapability,
          DataType.Boolean, () => {
            return engine.historyServerCapabilities.accessHistoryDataCapability;
          });
        bindStandardScalar(VariableIds.HistoryServerCapabilities_AccessHistoryEventsCapability,
          DataType.Boolean, () => {
            return engine.historyServerCapabilities.accessHistoryEventsCapability;
          });
        bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertDataCapability,
          DataType.Boolean, () => {
            return engine.historyServerCapabilities.insertDataCapability;
          });
        bindStandardScalar(VariableIds.HistoryServerCapabilities_ReplaceDataCapability,
          DataType.Boolean, () => {
            return engine.historyServerCapabilities.replaceDataCapability;
          });
        bindStandardScalar(VariableIds.HistoryServerCapabilities_UpdateDataCapability,
          DataType.Boolean, () => {
            return engine.historyServerCapabilities.updateDataCapability;
          });

        bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertEventCapability,
          DataType.Boolean, () => {
            return engine.historyServerCapabilities.insertEventCapability;
          });

        bindStandardScalar(VariableIds.HistoryServerCapabilities_ReplaceEventCapability,
          DataType.Boolean, () => {
            return engine.historyServerCapabilities.replaceEventCapability;
          });
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_method.js View on Github external
UAMethod.prototype.readAttribute = function (context, attributeId) {

    assert(context instanceof SessionContext);

    const self = this;
    const options = {};
    switch (attributeId) {
        case AttributeIds.Executable:
            options.value = {dataType: DataType.Boolean, value: self.getExecutableFlag(context)};
            options.statusCode = StatusCodes.Good;
            break;
        case AttributeIds.UserExecutable:
            options.value = {dataType: DataType.Boolean, value: self.getExecutableFlag(context)};
            options.statusCode = StatusCodes.Good;
            break;
        default:
            return BaseNode.prototype.readAttribute.call(this, context, attributeId);
    }
    return new DataValue(options);
};
github node-opcua / node-opcua / packages / node-opcua-server-configuration / source / push_certificate_manager_helpers.ts View on Github external
const certificateGroupIdVariant = inputArguments[0];
    const certificateTypeIdVariant = inputArguments[1];
    const subjectNameVariant = inputArguments[2];
    const regeneratePrivateKeyVariant = inputArguments[3];
    const nonceVariant = inputArguments[4];

    if (!expected(certificateGroupIdVariant, DataType.NodeId, VariantArrayType.Scalar)) {
        return { statusCode: StatusCodes.BadInvalidArgument };
    }
    if (!expected(certificateTypeIdVariant, DataType.NodeId, VariantArrayType.Scalar)) {
        return { statusCode: StatusCodes.BadInvalidArgument };
    }
    if (!expected(subjectNameVariant, DataType.String, VariantArrayType.Scalar)) {
        return { statusCode: StatusCodes.BadInvalidArgument };
    }
    if (!expected(regeneratePrivateKeyVariant, DataType.Boolean, VariantArrayType.Scalar)) {
        return { statusCode: StatusCodes.BadInvalidArgument };
    }
    if (!expected(regeneratePrivateKeyVariant, DataType.Boolean, VariantArrayType.Scalar)) {
        return { statusCode: StatusCodes.BadInvalidArgument };
    }

    if (!hasEncryptedChannel(context)) {
        return { statusCode: StatusCodes.BadSecurityModeInsufficient };
    }

    if (!hasExpectedUserAccess(context)) {
        return { statusCode: StatusCodes.BadUserAccessDenied };
    }

    const certificateGroupId = certificateGroupIdVariant.value as NodeId;
    const certificateTypeId = certificateTypeIdVariant.value as NodeId;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / alarm_condition.js View on Github external
function _update_suppressedOrShelved(alarmNode) {

    alarmNode.suppressedOrShelved.setValueFromSource({
        dataType: DataType.Boolean,
        value: alarmNode.isSuppressedOrShelved()
    });
}
github node-opcua / node-opcua / packages / node-opcua-server / src / server_engine.js View on Github external
DataType.Boolean, function () {
                    return engine.historyServerCapabilities.updateDataCapability;
                });

            bindStandardScalar(VariableIds.HistoryServerCapabilities_InsertEventCapability,
                DataType.Boolean, function () {
                    return engine.historyServerCapabilities.insertEventCapability;
                });

            bindStandardScalar(VariableIds.HistoryServerCapabilities_ReplaceEventCapability,
                DataType.Boolean, function () {
                    return engine.historyServerCapabilities.replaceEventCapability;
                });

            bindStandardScalar(VariableIds.HistoryServerCapabilities_UpdateEventCapability,
                DataType.Boolean, function () {
                    return engine.historyServerCapabilities.updateEventCapability;
                });

            bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteEventCapability,
                DataType.Boolean, function () {
                    return engine.historyServerCapabilities.deleteEventCapability;
                });


            bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteRawCapability,
                DataType.Boolean, function () {
                    return engine.historyServerCapabilities.deleteRawCapability;
                });

            bindStandardScalar(VariableIds.HistoryServerCapabilities_DeleteAtTimeCapability,
                DataType.Boolean, function () {