<< 点击显示目录 >> 主页 PVI通信 > PVI帮助信息 > PVI Services > BR.AN.Namespace > BR.AN.PviServices > Variable Class > Variable Constructor > Variable Constructor |
Initializes a new instance of the variable class to get connected to a global Variable on the plc.
[Visual Basic]
Public Overloads Sub New( _
ByVal cpu As Cpu, _
ByVal name As String _
)
[C#]
Cpu cpu,
string name
);
cpu
Cpu-object
name
variable name
This instance will be automatically added to the parents variable collection. For this reason its necessary to check this collection for already existing objects.
Exception Type |
Condition |
Variable object already exists. |
// CPU already connected
// Getting global variable list from the plc
cpu.Variables.Upload();
cpu.Variables.Uploaded += new PviEventHandler(Variables_Uploaded);
...
...
private void Variables_Uploaded(object sender, PviEventArgs e)
{
Variable myVar=null;
// Creating new variable "var_01" and get connected to it
if ( cpu.Variables.ContainsKey("var_01") )
myVar = cpu.Variables["var_01"]; // Variable already exists
else
myVar = new Variable(cpu,"var_01"); // Variable not exist -> create
myTask.Connect();
}
Variable Class | BR.AN.PviServices Namespace | Variable Constructor Overload List
Generated from assembly BR.AN.PviServices [8.1.0.4]