InformationModel.MakeVariable(browseName, dataTypeId, variableTypeId, arrayDimensions)
Create a project variable of the type indicated by the third argument, and which contains the data type indicated by the second argument. It returns a C# object of the IUAVariable
type corresponding to the project variable created. Using the fourth argument (optional), it is possible to create an array, specifying its type and size.
static IUAVariable MakeVariable(QualifiedName browseName, NodeId dataTypeId, NodeId variableTypeId, uint[] arrayDimensions);
Arguments
browseName
(QualifiedName)- The
BrowseName
of the new variable. -
dataTypeId
(NodeId) -
The Data type contained in the new variable.
Tip: A node inside theDataTypes
class represents the Data type. For example,OpcUa.DataTypes.Boolean
. variableTypeId
(NodeId)-
A Variable type from which the new variable is derived, represented by a node inside the
VariableTypes
classes (for example,FTOptix.CoDeSys.VariableTypes.Tag
). arrayDimensions
(uint[ ])- Optional. The size of the Array.
Returns
IUAVariable
- A C# object that corresponds to the project variable created.
Example
The following example shows an API that creates a Tag2
variable of the CoDeSysTag
predefined type, that contains one Int32 data:
var myVar = InformationModel.MakeVariable("Tag2", OpcUa.DataTypes.Int32, FTOptix.CoDeSys.VariableTypes.Tag);;
Owner.Add(myVar);