Variables

What is a Variable

A variable is an element that in the project represents a figure, a characteristic of an object, and specifies its value. For example, a variable can represent functional characteristics of a physical object (a Speed variable), style characteristics of graphical interface objects (for example the color of a text), or characteristics of other specific objects (for example the properties of a recipe configuration).

A variable has the following characteristics:

  • can contain other variables (in this case it is defined as a structured variable)

  • contains only one data type (DataType)

  • cannot contain objects

  • has attributes that describe it

Example

To represent the speed of a motor (in the example the Motor object), a numeric variable can be used (Speed, of type Int32). For example purposes its value is 100. Below is how it is displayed in Q Studio:

../_images/2c7058a579ed831156e727ea143937276077fb1a.png

Properties

We define as property the non-detachable variables of a node.

For example, Text is a property of the Label native object, as there can be no Label object without the Text property.

Attributes

A variable always has the following attributes:

Attribute

Description

BrowseName

Name of the variable in the project

DataType

Data type that the variable can contain

Description

Description of the variable

DisplayName

Name of the variable, translatable and usually used to be displayed in the interface at runtime

NodeId

Unique identifier, assigned automatically by UNIQO

Value

Value of the data

Variable types and instances

A VariableType is a “model” variable from which similar variables will be derived, called instances. However, instances can contain other specific variables.

Creating instances is advantageous in terms of speed and consistency, as any changes made to the type are automatically made to the instances.

Important

if a variable type is deleted, the instances are also deleted.

Native and custom variable types

The UNIQO default types are defined as native types. These are always available regardless of the project.

The types created within a project by users or by the application logic created are defined as custom types. These types are only available in the project in which they were created.

Native variable types

Type

Description

Variable

Base variable, which contains a value.

Analog Variable

Structured variable, used for representing physical sizes (see Properties of an analog variable).

Node Pointer

Variable whose value is a reference to a project node (see Property of a Node pointer variable).

Set the value of the variables

The value of a variable can be set at design time in different ways:

  • with a fixed value set manually (usually to set graphical properties or properties of non-physical objects such as recipes, loggers etc.)

  • inherited from the variable type or object type (usually to set graphic properties or properties of non-physical objects)

  • based on the value of another variable (see Dynamic Links).

The value of the field variables, for example a temperature, depends instead on the values read by the PLC (see Field variables).

Field variables

To use and display values from the field/from a PLC, UNIQO imports the tags/variables into the project and keeps them synchronized.

These variables are special tag variables. Below is an example in Q Studio:

../_images/6955f7f0a37ea7a02a7858caf01161730476d271.png

For details on the use of these variables see Import tags from the PLCs.

Unit of measurement and limits for numerical variables

For numeric variables, the unit of measure with which the value is expressed can be set using the EngineeringUnits property. Using the EURange property, it is possible to set the minimum and maximum values of the variable.

These properties are always present in the analog variables, while it is possible to add them manually in the base variables (see Setting the Unit of Measure for a Variable and Add the minimum and maximum limits of a variable).

Properties of an analog variable

Properties

Properties

Data type

Description

EngineeringUnits

Description

Localized text

Extended description of the unit of measurement

DisplayName

Localized text

Text trimming of the unit of measurement

UnitId

Int32

Identifier of the unit of measurement (see Unit of measurement supported by variables)

EURange

Lower limit

Double

Lower limit of the range of values that the variable can have

High Limit

Double

Upper limit of the range of values that the variable can have

Constrain

Boolean

True: if the user enters a value out of range, returns the value to the previous value.

False: if the user enters a value out of range, the value is still accepted.

Note

in Q Studio, the EngineeringUnits variable and its properties can only be displayed in the dynamic links window (see Dynamic Link Window).

Property of a Node pointer variable

A variable of the Node Pointer type is a special variable whose value is a reference to a project node (see Nodes and information model). The referenced node must be of the type and class defined by the following properties:

Properties

Data type

Description

Kind

NodeId

Object type or variable type from which the node is derived

NodeClass

NodePointerNodeClass

Node class. Instance = the node can only be an instance; Type = the node can only be a type; Either = the node can be an instance or a type.

Example

The Data logger object has among its properties a Store node pointer, through which it is possible to select one database from all the databases in the project in which to store the recorded data.

../_images/95e0ab359a991e0c06068cc69574220ccd0f87e9.png

To do this, the Store node pointer is set as follows:

  • Kind is set on the Store object type

  • NodeClass is set on Instance

See also

Related procedures

Variables and Variable Types

References

API to create variables