How to use the node-opcua-variant.DataType.LocalizedText 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 / test_helpers / add_event_generator_object.ts View on Github external
context: SessionContext,
      callback: MethodFunctorCallback) => {

        // xx console.log("In Event Generator Method");
        // xx console.log(this.toString());
        // xx console.log(context.object.toString());

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

        const message = inputArguments[0].value || "Hello from Event Generator Object";
        const severity = inputArguments[1].value || 0;

        const myEventType = namespace.addressSpace.findEventType("MyEventType", namespace.index);
        context.object.raiseEvent(myEventType, {
            message: {
                dataType: DataType.LocalizedText,
                value: { text: message }
            },
            severity: {
                dataType: DataType.UInt32,
                value: severity
            }

        });
        // console.log(require("util").inspect(context).toString());
        const callMethodResult = {
            outputArguments: [],
            statusCode: StatusCodes.Good
        };
        callback(null, callMethodResult);
    });
github node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / acknowledgeable_condition.js View on Github external
// raise the AuditConditionAcknowledgeEventType
    const eventData = {

        // EventType
        eventId:  { dataType: DataType.ByteString, value: branch.getEventId() },
        //xx branchId: branch.branchId.readValue().value,
        // AuditEventType
        actionTimeStamp: { dataType: DataType.DateTime, value : new Date() },
        status: { dataType: DataType.StatusCodes, value: StatusCodes.Good },
        serverId: {},
        clientAuditEntryId: {},
        clientUserId: {},
        methodId: {},
        inputArguments: {},
        comment:   {dataType: DataType.LocalizedText, value: branch.getComment() }
    };
    this.raiseEvent("AuditConditionAcknowledgeEventType",eventData);

};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / referenceType.js View on Github external
ReferenceType.prototype.readAttribute = function (context, attributeId, indexRange, dataEncoding) {

    assert(context instanceof SessionContext);

    const options = {};
    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 BaseNode.prototype.readAttribute.call(this, context, attributeId);
    }
    return new DataValue(options);
};
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space_add_enumeration_type.js View on Github external
definition: definition
        };

        const enumType = self._createNode(opts);

        enumType.propagate_back_references();

        if (_.isString(options.enumeration[0])) {

            // enumeration is a array of string
            definition = options.enumeration.map(function (str, index) {
                return coerceLocalizedText(str);
            });

            let value = new Variant({
                dataType: DataType.LocalizedText,
                arrayType: VariantArrayType.Array,
                value: definition
            });


            const enumStrings = self.addVariable({
                propertyOf: enumType,
                browseName: {name: "EnumStrings", namespaceIndex:0},
                modellingRule: "Mandatory",
                description: "",
                dataType: "LocalizedText",
                valueRank: 1,
                value: value
            });
            assert(enumStrings.browseName.toString() === "EnumStrings");
github node-opcua / node-opcua / packages / node-opcua-address-space / src / data_access / address_space_add_YArrayItem.js View on Github external
variable.setValueFromSource(options.value, StatusCodes.Good);


        variable.euRange.setValueFromSource(new Variant({
            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 / data_access / address_space_add_MultiStateDiscrete.js View on Github external
const enumStrings = options.enumStrings.map(function(value) {
            return coerceLocalizedText(value)
        });

        const enumStringsNode = namespace.addVariable({
            modellingRule: options.modellingRule ? "Mandatory" : undefined,
            propertyOf: variable,
            typeDefinition: "PropertyType",
            browseName: {name:"EnumStrings",namespaceIndex:0},
            dataType: "LocalizedText",
            accessLevel: "CurrentRead", //| CurrentWrite",
            userAccessLevel: "CurrentRead",// CurrentWrite",
            minimumSamplingInterval: 0,
            value:  new Variant({
                dataType: DataType.LocalizedText,
                arrayType: VariantArrayType.Array,
                value: enumStrings
            })
        });

        const handler = variable.handle_semantic_changed.bind(variable);
        enumStringsNode.on("value_changed",handler);

        variable.install_extra_properties();

        assert(variable.enumStrings.browseName.toString() === "EnumStrings");

        Object.setPrototypeOf(variable, UAMultiStateDiscreteType.prototype);

        return variable;
github node-opcua / node-opcua / packages / node-opcua-address-space / src / data_access / ua_mutlistate_value_discrete.ts View on Github external
public _findValueAsText(value?: number | Int64): Variant {
        const enumValueIndex = this._enumValueIndex();

        if (value === undefined) {
            throw new Error("Unexpected undefined value");
        }
        if (value instanceof Array) {
            value = value[1];
        }
        assert(!((value as any) instanceof Variant));
        let valueAsText1 = "Invalid";
        if (enumValueIndex[value]) {
            valueAsText1 = enumValueIndex[value].displayName;
        }
        const result = new Variant({
            dataType: DataType.LocalizedText,
            value: coerceLocalizedText(valueAsText1)
        });
        return result;
    }
    public _getDataType(): DataType {
github node-opcua / node-opcua / packages / node-opcua-address-space / src / data_access / address_space_add_TwoStateDiscrete.js View on Github external
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")
            })
        });

        trueStateNode.on("value_changed", handler);

        const falseStateNode =  namespace.addVariable({
            propertyOf: variable,
            typeDefinition: "PropertyType",
            browseName: {name: "FalseState", namespaceIndex: 0},
            dataType: "LocalizedText",
            minimumSamplingInterval: 0,
            value: new Variant({
                dataType: DataType.LocalizedText, value: coerceLocalizedText(options.falseState || "OFF")
            })
        });
github node-opcua / node-opcua / packages / node-opcua-address-space / src / namespace.ts View on Github external
typeDefinition: "PropertyType",
            value: new Variant({
                dataType: DataType.LocalizedText, value: coerceLocalizedText(options.trueState || "ON")
            })
        });

        trueStateNode.on("value_changed", handler);

        const falseStateNode = namespace.addVariable({
            browseName: { name: "FalseState", namespaceIndex: 0 },
            dataType: "LocalizedText",
            minimumSamplingInterval: 0,
            propertyOf: variable,
            typeDefinition: "PropertyType",
            value: new Variant({
                dataType: DataType.LocalizedText, value: coerceLocalizedText(options.falseState || "OFF")
            })
        });

        falseStateNode.on("value_changed", handler);

        variable.install_extra_properties();

        return variable;
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / loader / load_nodeset2.js View on Github external
finish: function () {
                    this.parent.parent.obj.value = {
                        dataType: DataType.LocalizedText,
                        arrayType: VariantArrayType.Array,
                        value: this.listData

                    };
                },
                endElement: function (/*element*/) {