How to use the node-opcua-variant.DataType.Byte 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-server / source / server_engine.ts View on Github external
// TimeZoneDataType
      const timeZoneDataType = addressSpace.findDataType(resolveNodeId(DataTypeIds.TimeZoneDataType))!;
      // xx console.log(timeZoneDataType.toString());

      const timeZone = new TimeZoneDataType({
        daylightSavingInOffset: /* boolean*/ false,
        offset: /* int16 */ 0
      });
      bindStandardScalar(VariableIds.Server_LocalTime,
        DataType.ExtensionObject, () => {
          return timeZone;
        });

      bindStandardScalar(VariableIds.Server_ServiceLevel,
        DataType.Byte, () => {
          return 255;
        });

      bindStandardScalar(VariableIds.Server_Auditing,
        DataType.Boolean, () => {
          return engine.isAuditing;
        });

      function bindServerDiagnostics() {

        bindStandardScalar(VariableIds.Server_ServerDiagnostics_EnabledFlag,
          DataType.Boolean, () => {
            return engine.serverDiagnosticsEnabled;
          }, (newFlag: boolean) => {
            engine.serverDiagnosticsEnabled = newFlag;
          });
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.js View on Github external
function adjustVariant(uaVariable, variant) {

    const self = uaVariable;

    // convert Variant( Scalar|ByteString) =>  Variant(Array|ByteArray)
    const addressSpace = self.addressSpace;

    const basicType = addressSpace.findCorrespondingBasicDataType(uaVariable.dataType);

    if (basicType === DataType.Byte && uaVariable.valueRank === 1) {
        if (variant.arrayType === VariantArrayType.Scalar && variant.dataType === DataType.ByteString) {

            if ((uaVariable.dataType.value === DataType.Byte.value) && (self.dataType.namespace === 0)) { // Byte
                variant.arrayType = VariantArrayType.Array;
                variant.dataType = DataType.Byte;
                assert(variant.dataType === DataType.Byte);
                assert(!variant.value || variant.value instanceof Buffer);
            }
        }
    }
    if (basicType === DataType.ByteString && uaVariable.valueRank === -1 /* Scalar*/) {

        if (variant.arrayType === VariantArrayType.Array && variant.dataType === DataType.Byte) {
            if ((self.dataType.value === DataType.ByteString.value) && (self.dataType.namespace === 0)) { // Byte
                variant.arrayType = VariantArrayType.Scalar;
                variant.dataType = DataType.ByteString;
                assert(variant.dataType === DataType.ByteString);
                assert(!variant.value || variant.value instanceof Buffer);
            }
        }
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.js View on Github external
function adjustVariant(uaVariable, variant) {

    const self = uaVariable;

    // convert Variant( Scalar|ByteString) =>  Variant(Array|ByteArray)
    const addressSpace = self.addressSpace;

    const basicType = addressSpace.findCorrespondingBasicDataType(uaVariable.dataType);

    if (basicType === DataType.Byte && uaVariable.valueRank === 1) {
        if (variant.arrayType === VariantArrayType.Scalar && variant.dataType === DataType.ByteString) {

            if ((uaVariable.dataType.value === DataType.Byte.value) && (self.dataType.namespace === 0)) { // Byte
                variant.arrayType = VariantArrayType.Array;
                variant.dataType = DataType.Byte;
                assert(variant.dataType === DataType.Byte);
                assert(!variant.value || variant.value instanceof Buffer);
            }
        }
    }
    if (basicType === DataType.ByteString && uaVariable.valueRank === -1 /* Scalar*/) {

        if (variant.arrayType === VariantArrayType.Array && variant.dataType === DataType.Byte) {
            if ((self.dataType.value === DataType.ByteString.value) && (self.dataType.namespace === 0)) { // Byte
                variant.arrayType = VariantArrayType.Scalar;
                variant.dataType = DataType.ByteString;
github node-opcua / node-opcua / packages / node-opcua-server / src / server_engine.js View on Github external
bindVariableIfPresent(nodeId, {
                get: function () {
                    const value = func();
                    assert(_.isArray(value));
                    return new Variant({
                        dataType: variantDataType,
                        arrayType: VariantArrayType.Array,
                        value: value
                    });
                },
                set: null // read only
            });
        }

        bindStandardScalar(VariableIds.Server_ServiceLevel,
            DataType.Byte, function () {
                return 255;
            });

        bindStandardScalar(VariableIds.Server_Auditing,
            DataType.Boolean, function () {
                return engine.isAuditing;
            });


        function bindServerDiagnostics() {

            bindStandardScalar(VariableIds.Server_ServerDiagnostics_EnabledFlag,
                DataType.Boolean, function () {
                    return engine.serverDiagnosticsEnabled;
                }, function (newFlag) {
                    engine.serverDiagnosticsEnabled = newFlag;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.ts View on Github external
function adjustVariant(this: UAVariable, variant: Variant): Variant {

    // convert Variant( Scalar|ByteString) =>  Variant(Array|ByteArray)
    const addressSpace = this.addressSpace;

    const basicType = addressSpace.findCorrespondingBasicDataType(this.dataType);

    if (basicType === DataType.Byte && this.valueRank === 1) {
        if (variant.arrayType === VariantArrayType.Scalar && variant.dataType === DataType.ByteString) {

            if ((this.dataType.value === DataType.Byte) && (this.dataType.namespace === 0)) { // Byte
                variant.arrayType = VariantArrayType.Array;
                variant.dataType = DataType.Byte;
                assert(variant.dataType === DataType.Byte);
                assert(!variant.value || variant.value instanceof Buffer);
            }
        }
    }
    if (basicType === DataType.ByteString && this.valueRank === -1 /* Scalar*/) {

        if (variant.arrayType === VariantArrayType.Array && variant.dataType === DataType.Byte) {
            if ((this.dataType.value === DataType.ByteString) && (this.dataType.namespace === 0)) { // Byte
                variant.arrayType = VariantArrayType.Scalar;
                variant.dataType = DataType.ByteString;
github node-opcua / node-opcua / packages / node-opcua-address-space-for-conformance-testing / src / address_space_for_conformance_testing.js View on Github external
function makeRange(dataTypeStr) {
        assert(typeof dataTypeStr === "string");
        const dataType = DataType[dataTypeStr];
        let engineeringUnitsRange = { low: -200, high: 200 };
        let instrumentRange = { low: -200, high: 200 };
        if (DataType[dataType][0] === "U" || dataType === DataType.Byte) {
            engineeringUnitsRange = { low: 10, high: 250 };
            instrumentRange = { low: 10, high: 250 };
        }
        return { engineeringUnitsRange, instrumentRange };
    }
    function _addAnalogDataItem(localParentFolder, dataType, initialValue) {
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_object.js View on Github external
UAObject.prototype.readAttribute = function (context, attributeId) {

    assert(context instanceof SessionContext);

    const now = getCurrentClock();
    const options = {};
    switch (attributeId) {
        case AttributeIds.EventNotifier:
            assert(ec.isValidByte(this.eventNotifier));
            options.value = {dataType: DataType.Byte, value: this.eventNotifier};
            options.serverTimestamp = now.timestamp;
            options.serverPicoseconds = now.picoseconds;
            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-address-space / src / ua_variable.js View on Github external
UAVariable.prototype._readAccessLevel = function (context) {
    assert(context instanceof SessionContext);
    const options = {
        value: {dataType: DataType.Byte, value: AccessLevelFlag.toByte(this.accessLevel)},
        statusCode: StatusCodes.Good
    };
    return new DataValue(options);
};
github node-opcua / node-opcua / packages / node-opcua-file-transfer / source / client / client_file.ts View on Github external
public async open(mode: OpenFileMode): Promise {

        if (mode === null || mode === undefined) {
            throw new Error("expecting a validMode " + OpenFileMode[mode]);
        }
        if (this.fileHandle) {
            throw new Error("File has already be opened");
        }
        await this.ensureInitialized();

        const result = await this.session.call({
            inputArguments: [
                { dataType: DataType.Byte, value: mode as Byte }
            ],
            methodId: this.openMethodNodeId,
            objectId: this.fileNodeId
        });
        if (result.statusCode !== StatusCodes.Good) {
            debugLog("Cannot open file : ");
            throw new Error("cannot open file statusCode = " + result.statusCode.toString() + "mode = " + OpenFileMode[mode]);
        }

        this.fileHandle = result.outputArguments![0].value;

        return this.fileHandle;
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.ts View on Github external
private _readUserAccessLevel(context: SessionContext): DataValue {

        assert(context instanceof SessionContext);

        const effectiveUserAccessLevel = _calculateEffectiveUserAccessLevelFromPermission(
            this,
            context,
            this.userAccessLevel
        );

        const options = {
            value: {
                dataType: DataType.Byte,
                statusCode: StatusCodes.Good,
                value: convertAccessLevelFlagToByte(effectiveUserAccessLevel)
            }
        };
        return new DataValue(options);
    }