APIs for aliases

Introduction

The APIs described below are used to create, read or set project aliases.

The table below indicates the APIs to use for various purposes:

Purpose

API

Create an alias

InformationModel.MakeAlias(browseName)

Access the node to which a known alias points

LogicObject.GetAlias(string)

Set the node to which a known alias must point

LogicObject.SetAlias(string, IUANode)

Access to a known node of Dynamic panel type

LogicObject.GetPanelLoader(string)

InformationModel.MakeAlias(browseName)

Creates an alias and returns a corresponding IUAVariable C# object.

static IUAVariable MakeAlias(QualifiedName browseName);

Arguments

browseName QualifiedName

BrowseName of the new alias.

Returns

IUAVariable

C# object corresponding to the project object created.

Example

Below is an example in which an alias is created in the Panel1 object of the Q Studio project:

var modelFolder = Project.Current.Get("Model");
var alias = InformationModel.MakeAlias("CurrentMotor");
modelFolder.Add(alias);
modelFolder.SetAlias("Model", Project.Current.Find("Motor1"));

LogicObject.GetAlias(string)

Returns an IUANode C# object corresponding to the node pointed to by the alias indicated as argument.

static IUANode GetAlias(string aliasName);

Arguments

aliasName string

BrowseName of the alias.

Returns

IUANode

C# object corresponding to the node pointed to by the alias.

Example

Below is an example where the API returns a C# object corresponding to the node pointed to by the alias Motor, whose Speed property value is read and assigned to the myMotorSpeed variable.

Note

the (MotorType) cast operator changes the object type returned by the API from IUANode to MotorType. This is useful for directly accessing the Speed property of refMotor.

var refMotor = (MotorType)LogicObject.GetAlias("Motor");
var myMotorSpeed = refMotor.Speed;

LogicObject.SetAlias(string, IUANode)

Sets the value of an alias, or the node it points to.

void SetAlias(string aliasName, IUANode pointedNode);

Arguments

aliasName string

BrowseName of the alias to set.

pointedNode IUANode

Node to which the alias must point to.

Example

Below is an example where the MotorInstance alias points to the Motor1 node.

var myMotorInstance = Project.Current.FindObject("Motor1");
LogicObject.SetAlias("MotorInstance"), myMotorInstance);

LogicObject.GetPanelLoader(string)

Returns a PanelLoader C# object corresponding to the Dynamic panel object indicated in the argument.

Note

the API exploits the alias that the Presentation Engine automatically generates at runtime for the panel (see Aliases generated automatically by UNIQO).

PanelLoader GetPanelLoader(string panelLoaderName);

Arguments

panelLoaderName string

BrowseName of the Dynamic panel object.

Returns

PanelLoader

C# object corresponding to the Dynamic panel object.

Example

Below is an example where the API returns a C# object corresponding to the PanelLoader1 object, in which we want to create a Motor object.

var myPanel = LogicObject.GetPanelLoader("PanelLoader1");
var motor = InformationModel.MakeObject("Motor");
myPanel.ChangePanel("Panel1");

See also

Related concepts

Alias

Related procedures

Using aliases

Application examples

Design a widget to display the values of multiple motors