How to use the node-opcua-variant.DataType.Int32 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 / base_node.ts View on Github external
dataEncoding?: string
    ): DataValue {

        assert(!context || context instanceof SessionContext);
        const options: any = {};
        options.statusCode = StatusCodes.Good;

        switch (attributeId) {

            case AttributeIds.NodeId:  // NodeId
                options.value = { dataType: DataType.NodeId, value: this.nodeId };
                break;

            case AttributeIds.NodeClass: // NodeClass
                assert(_.isFinite(this.nodeClass));
                options.value = { dataType: DataType.Int32, value: this.nodeClass };
                break;

            case AttributeIds.BrowseName: // QualifiedName
                assert(this.browseName instanceof QualifiedName);
                options.value = { dataType: DataType.QualifiedName, value: this.browseName };
                break;

            case AttributeIds.DisplayName: // LocalizedText
                options.value = { dataType: DataType.LocalizedText, value: this.displayName[0] };
                break;

            case AttributeIds.Description: // LocalizedText
                options.value = { dataType: DataType.LocalizedText, value: this.description };
                break;

            case AttributeIds.WriteMask:
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space.ts View on Github external
/* istanbul ignore next */
        if (!(dataTypeNode instanceof UADataType)) {
            throw new Error("Expecting a UADataType" + _orig_dataTypeNode.toString());
        }
        dataTypeNode = dataTypeNode as UADataType;
        /* istanbul ignore next */
        if (typeof dataTypeNode!.nodeId!.value !== "number") {
            throw new Error("Internal Errror");
        }

        const id: number = dataTypeNode!.nodeId.value as number;
        assert(_.isFinite(id));

        const enumerationType = this.findDataType("Enumeration")!;
        if (sameNodeId(enumerationType.nodeId, dataTypeNode!.nodeId)) {
            return DataType.Int32;
        }

        if (dataTypeNode.nodeId.namespace === 0 && DataType[id]) {
            return id as DataType;
        }
        return this.findCorrespondingBasicDataType(dataTypeNode.subtypeOfObj as UADataType);
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / data_access / address_space_add_YArrayItem.js View on Github external
dataType: DataType.ExtensionObject, value: new Range(options.engineeringUnitsRange)
        }));

        if (options.hasOwnProperty("instrumentRange")) {
            variable.instrumentRange.setValueFromSource(new Variant({
                dataType: DataType.ExtensionObject, value: new Range(options.instrumentRange)
            }));
        }

        variable.title.setValueFromSource(new Variant({
            dataType: DataType.LocalizedText, value: coerceLocalizedText(options.title || "")
        }));

        // Linear/Log/Ln
        variable.axisScaleType.setValueFromSource(new Variant({
            dataType: DataType.Int32, value: coerceAxisScale(options.axisScaleType)
        }));

        variable.xAxisDefinition.setValueFromSource(new Variant({
            dataType: DataType.ExtensionObject, value: new AxisInformation(options.xAxisDefinition)
        }));

        return variable;


    };
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.ts View on Github external
function prepareVariantValue(dataType: DataType | string, value: VariantLike): VariantLike {
            if (typeof dataType === "string") {
                dataType = (DataType as any)[dataType];
            }
            if ((dataType === DataType.Int32 || dataType === DataType.UInt32) && value && (value as any).key) {
                value = value.value;
            }
            return value;
        }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.js View on Github external
function check_valid_array(dataType, array) {
    if (_.isArray(array)) {
        return true;
    }
    switch (dataType) {
        case DataType.Double:
            return array instanceof Float64Array;
        case DataType.Float:
            return array instanceof Float32Array;
        case DataType.Int32:
            return array instanceof Int32Array;
        case DataType.Int16:
            return array instanceof Int16Array;
        case DataType.SByte:
            return array instanceof Int8Array;
        case DataType.UInt32:
            return array instanceof Uint32Array;
        case DataType.UInt16:
            return array instanceof Uint16Array;
        case DataType.Byte:
            return array instanceof Uint8Array || array instanceof Buffer;
    }
    return false;
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable_type.js View on Github external
assert(this.value.schema.name === "Variant");
                options.value = this.value;
                options.statusCode = StatusCodes.Good;
            } else {
                debugLog(" warning Value not implemented");
                options.value = {dataType: DataType.UInt32, value: 0};
                options.statusCode = StatusCodes.BadAttributeIdInvalid;
            }
            break;
        case AttributeIds.DataType:
            assert(this.dataType instanceof NodeId);
            options.value = {dataType: DataType.NodeId, value: this.dataType};
            options.statusCode = StatusCodes.Good;
            break;
        case AttributeIds.ValueRank:
            options.value = {dataType: DataType.Int32, value: this.valueRank};
            options.statusCode = StatusCodes.Good;
            break;
        case AttributeIds.ArrayDimensions:
            assert(_.isArray(this.arrayDimensions) || this.arrayDimensions === null);
            options.value = {dataType: DataType.UInt32, arrayType: VariantArrayType.Array, value: this.arrayDimensions};
            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.ts View on Github external
private _readValueRank(): DataValue {
        assert(typeof this.valueRank === "number");
        const options = {
            statusCode: StatusCodes.Good,
            value: { dataType: DataType.Int32, value: this.valueRank }
        };
        return new DataValue(options);
    }