Variable.Connect(ConnectionType) Method

<< 点击显示目录 >>

主页  PVI通信 > PVI帮助信息 > PVI Services > BR.AN.Namespace > BR.AN.PviServices > Variable Class > Variable Methods > Connect Method >

Variable.Connect(ConnectionType) Method

BR.AN.PviServices .NET


Creates a connection of this instance to its processvariable.

[Visual Basic]

Public Overrides Overloads Sub Connect( _

  ByVal conType As ConnectionType _

)

[C#]

public override void Connect(

  ConnectionType conType

);

Parameters

conType

Defines the ConnectionType of this Variable object

Remarks

The Connected event notifies, that the connection was successfully created whereas the "Error" event notifies, that an error has occured. (e.g. task does not exist) It is also possible to connect the variable object, when its parent (cpu object) was not already connected. In that case the variable object store this "connect" action, to connect the variable object automatically when the cpu connectedevent received. For creating a link object to an existing variable object its needed to specify the LinkName property with the FullName property of the variable to link.

Example

// Creating service and cpu object
Service service = new Service("Service1");
service.Connect();
Cpu cpu = new Cpu(service,"Cpu1");
cpu.Connect();
..
..
// Creating connection to global Variable
Variable globVar = new Variable(cpu,"var1");
globVar.Connect();
globVar.Connected += new PviEventHandler(Var_Connected);
..
..
private void Var_Connected(object sender, PviEventArgs e)
{
    // Creating link connection to existing variable
    Variable linkToGlobVar = new Variable(cpuObj,"linkVar");
    linkToGlobVar.LinkName = "Service1.Cpu1.var1";    // or globVar.FullName;
    linkToGlobVar.Connect(ConnectionType.Link);
}

See Also

Variable Class | BR.AN.PviServices Namespace | Variable.Connect Overload List


Generated from assembly BR.AN.PviServices [8.1.0.4]