RapidDataValueChanged Event |
This event occurs when the value of the
RapidData
has changed. It's only possible to get events from Rapid data
declared
persistent.
Namespace:
ABB.Robotics.Controllers.RapidDomain
Assembly:
ABB.Robotics.Controllers (in ABB.Robotics.Controllers.dll) Version: 6.5.129.0
Syntax Exceptions Remarks Note: It's only possible to get events from Rapid data
declared as persistent.
Any subscriber that wants to update their UI as response to
the event has to redirect the execution to the UI-thread, using an
Invoke method.
Note: You should not switch execution to the UI-thread unless absolutely necessary, since
it could impact the performance significantly.
Examples This example creates a
RapidData instance and adds a subscription to its
ValueChanged event.
As the event handler isn't called on the UI-thread, you must redirect execution to the UI-thread before any update of the User Interface.
private void btnDataSubcribe_Click(object sender,EventArgs e)
{
try
{
if (rdReg6 == null)
{
rdReg6 = c.Rapid.GetRapidData("T_ROB1","MyModule","reg6");
rdReg6.ValueChanged +=
new DataValueChangedEventHandler(rdReg6_ValueChanged);
}
}
catch (System.Exception ee)
{
}
}
private void rdReg6_ValueChanged(object sender,DataValueChangedEventArgs e)
{
try
{
this.Invoke(new EventHandler(UpdateUiOnRapidDataChanged),sender,e);
}
catch (GeneralException ee)
{
}
catch (System.Exception ee)
{
}
}
private void UpdateUiOnRapidDataChanged(object sender, EventArgs e)
{
try
{
IRapidData iVal = reg6.Value;
listBox2.Items.Add(iVal.ToString());
}
catch (GeneralException ee)
{
}
catch (System.Exception ee)
{
}
}
See Also