<< 点击显示目录 >> 主页 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 local variable on the plc.
[Visual Basic]
Public Overloads Sub New( _
ByVal task As Task, _
ByVal name As String _
)
[C#]
Task task,
string name
);
task
Task-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. |
// Task already connected
// Getting local variable list from the task on the plc
task.Variables.Upload();
task.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 = task.Variables["var_01"]; // Variable already exists
else
myVar = new Variable(task,"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]