How to use the node-opcua-data-model.coerceLocalizedText function in node-opcua-data-model

To help you get started, we’ve selected a few node-opcua-data-model 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 / state_machine / finite_state_machine.js View on Github external
const state = self.getStateByName(toStateNode);
        // istanbul ignore next
        if (!state) {
            throw new Error("Cannot find state with name " + toStateNode);
        }
        assert(state.browseName.toString() === toStateNode);
        toStateNode = state;
    }
    const fromStateNode = self.currentStateNode;

    toStateNode = self._coerceNode(toStateNode);
    assert(toStateNode instanceof UAObject);

    self.currentState.setValueFromSource({
        dataType: DataType.LocalizedText,
        value: coerceLocalizedText(toStateNode.browseName.toString())
    }, StatusCodes.Good);

    self.currentStateNode = toStateNode;

    const transitionNode = self.findTransitionNode(fromStateNode, toStateNode);

    if (transitionNode) {

        //xx console.log("transitionNode ",transitionNode.toString());
        // The inherited Property SourceNode shall be filled with the NodeId of the StateMachine instance where the
        // Transition occurs. If the Transition occurs in a SubStateMachine, then the NodeId of the SubStateMachine
        // has to be used. If the Transition occurs between a StateMachine and a SubStateMachine, then the NodeId of
        // the StateMachine has to be used, independent of the direction of the Transition.
        // Transition identifies the Transition that triggered the Event.
        // FromState identifies the State before the Transition.
        // ToState identifies the State after the Transition.
github node-opcua / node-opcua / packages / node-opcua-address-space / src / base_node_private.ts View on Github external
let data: any = {};

    if (!obj) {
        // cannot find reference node
        data = {
            isForward,
            nodeId: reference.nodeId,
            referenceTypeId: (resultMask & ResultMask.ReferenceType) ? referenceTypeId : null,
            typeDefinition: null
        };
    } else {
        assert(reference.nodeId, " obj.nodeId");
        data = {
            browseName: (resultMask & ResultMask.BrowseName) ? coerceQualifiedName(obj.browseName) : null,
            displayName: (resultMask & ResultMask.DisplayName) ? coerceLocalizedText(obj.displayName[0]) : null,
            isForward: (resultMask & ResultMask.IsForward) ? isForward : false,
            nodeClass: (resultMask & ResultMask.NodeClass) ? obj.nodeClass : NodeClass.Unspecified,
            nodeId: obj.nodeId,
            referenceTypeId: (resultMask & ResultMask.ReferenceType) ? referenceTypeId : null,
            typeDefinition: (resultMask & ResultMask.TypeDefinition) ? obj.typeDefinition : null
        };
    }
    if (data.typeDefinition === null) {
        data.typeDefinition = NodeId.nullNodeId;
    }
    const referenceDescription = new ReferenceDescription(data);
    return referenceDescription;
}
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 / namespace.ts View on Github external
userAccessLevel: options.userAccessLevel,
            value: new Variant({ dataType: DataType.Boolean, value: !!options.value })
        }) as UAVariable;

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

        add_dataItem_stuff(variable, options);

        const trueStateNode = namespace.addVariable({
            browseName: { name: "TrueState", namespaceIndex: 0 },
            dataType: "LocalizedText",
            minimumSamplingInterval: 0,
            propertyOf: variable,
            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")
            })
        });
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 / data_access / address_space_add_MultiStateValueDiscrete.js View on Github external
return coerceEnumValues(_.map(enumValues, function (value, key) {

            return new EnumValueType({
                value: value,
                displayName: coerceLocalizedText(key),
                description: coerceLocalizedText(key)
            });
        }));
    }
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 / base_node.ts View on Github external
private _setDescription(description: LocalizedTextLike | null): void {
        const __description = coerceLocalizedText(description);
        const _private = BaseNode_getPrivate(this);
        _private._description = __description!;
    }
github node-opcua / node-opcua / packages / node-opcua-address-space / src / data_access / address_space_add_MultiStateValueDiscrete.js View on Github external
return _.map(enumValues, function (en) {
            assert(en.hasOwnProperty("value"));
            assert(en.hasOwnProperty("displayName"));
            return new EnumValueType({
                value: en.value,
                displayName: coerceLocalizedText(en.displayName)
            });
        })
    } else {
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)
        });