Alias¶
Introduction
An alias is a particular variable type that points to a source node indicated by its unique identifier (NodeId attribute). It links two areas of the project information model and makes it possible to set up dynamic links to create particular dynamic logics that would otherwise be impossible.
An alias is created in an object, or type of object, generically defined as parent node. The source node it points to identifies the source area, which includes the same source node and all its child nodes.
Note
typically aliases are created in graphical objects or in folders containing graphical objects, to create dynamic user interfaces (for example, when creating a widget that represents a motor type and that dynamically shows the values of different instances of the same type).
A short overview of how an alias works
This diagram summarizes how aliases work. In object A there is an alias that points to the source node B. From node A and/or any of its child nodes, dynamic links can be created with node B and/or any of its child nodes.
Dynamic links between aliases
When an alias is not exploited, a dynamic link is created via a relative reference/path from a parent node to the source node.
When an alias is present, stronger dynamic links can be created. In fact, thanks to its reference to the source node unique ID (NodeId attribute), the alias acts as an ”intermediary” between the parent node and source node,
Below is an example where we want to set the value of node C3 using the dynamic link to node B2. In the first case a dynamic link is used and the reference is ../../B/B2
. In the second case, thanks to the alias set on node C, the link is set up exploiting the alias and the reference is {B}/B2
.
When to use aliases
Aliases need to be used to set up dynamic links in the following cases:
When the dynamic link source node, and therefore its child nodes, exist only at runtime (e.g. the session nodes - see Session nodes). In this case, at design time a link is set up towards a node of the fictitious source area made available by the alias.
When the dynamic link source node, and therefore its child nodes, also exist at design time, but can change at runtime by effect of the set dynamic logics (e.g. in the case of widgets - see Aliases in widgets).
An alias is also useful as a ”shortcut” for creating dynamic links to recurrent nodes of interest, without therefore having to look for the same source node every time. At design time, in fact, the source nodes are grouped and easily accessible in the dynamic links window, while at runtime it is sufficient to know the name of an alias to access the node to which it points (see APIs for aliases).
Kind alias property
An alias always contains a Kind property, whose value is a reference node. More precisely, it is a reference to the object/variable type from which the source node derives, or, if the source node is not derived from a type, a reference to the same source node. The reference node is required to describe the source node information model. In fact, the alias displays the source area nodes to the parent node and to all its child nodes based on a known information model, which corresponds to the Kind node model.
When the source node of an alias is set, Q Studio automatically assigns a value to the Kind property. For example, if the source node is a Motor instance, the Kind property points to the Motor node.
However, when the source node of an alias is set at runtime only, e.g. in the case of widgets, the Kind node must be specified. Thus links can be created in the dynamic links window by exploiting the nodes of the Kind node information model, which at design time represent the actual project nodes at runtime.
Aliases in widgets
When designing a widget (see Reusable graphical objects: widget), it is always necessary to create an alias inside it. In fact, the reference node (e.g. Motor) is set using the Kind property of the alias, which represents the structure of nodes to be shown graphically in the widget. In this way, the properties and more generally the variables inside the widget can be set using dynamic links with the nodes of the reference node.
In every instance of a widget, the source node of the alias determines the actual source of the dynamic links. For example, MotorWidget1 might show the values of Motor1.
For a tutorial on the use of aliases in widgets see Design a widget to display the values of multiple motors.
Aliases generated automatically by UNIQO
At design time Q Studio automatically generates an alias for every Recipe Schema object and every Dynamic panel object in the project. These aliases are always accessible from any node and have the same BrowseName as the corresponding objects (for example, a PanelLoader1 alias is generated for a PanelLoader1 object).
Note
the aliases for Recipe Schema objects are created inside the project root node.
Also at runtime, the Presentation Engine makes an alias available at every interactive session (see Presentation engine) for every project Dynamic panel.
Session aliases
Q Studio provides the session alias Session, available in the dynamic links window only to set the property of the graphical objects and Report objects.
Q Studio provides the Session session alias. It is a system alias that points to the Session node, or the node of the current session that exists only at runtime and which contains several nodes assigned values based on the characteristics of the user and session locale (see Session nodes).
How aliases appear in the dynamic links window
In Q Studio, in the dynamic links window, the aliases are grouped in the Alias folder, except for the aliases for Dynamic panel objects generated automatically by Q Studio, which are grouped in a specific Dynamic panels folder.
In the window, each alias is identified by a node with icon and its name in curly brackets. The node can be expanded to navigate the information model of the node to which the alias points, and to select the source node of the dynamic link.
See also
Related procedures
Related APIs
Application examples