Click or drag to resize

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
C#
public event DataValueChangedEventHandler ValueChanged

Value

Type: ABB.Robotics.Controllers.RapidDomainDataValueChangedEventHandler
Exceptions
ExceptionCondition
InvalidOperationExceptionThe data is not declared as persistent.
GeneralExceptionA General Exception has occurred.
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
    {
        // Create instance if not done
        if (rdReg6 == null)
        {
            rdReg6 = c.Rapid.GetRapidData("T_ROB1","MyModule","reg6");

            rdReg6.ValueChanged += 
                new DataValueChangedEventHandler(rdReg6_ValueChanged);
        }
    }
    catch (System.Exception ee)
    {
        // TODO: Error handling

    }
}

// Event handler
private void rdReg6_ValueChanged(object sender,DataValueChangedEventArgs e)
{
    try
    {
        // Redirect execution to UI-thread
        this.Invoke(new EventHandler(UpdateUiOnRapidDataChanged),sender,e);
    }
    catch (GeneralException ee)
    {
        // TODO: Error handling
    }
    catch (System.Exception ee)
    {
        // TODO: Error handling
    }
}
// Update listbox
private void UpdateUiOnRapidDataChanged(object sender, EventArgs e)
{
    try
    {
        // Cast arguments
        IRapidData iVal = reg6.Value;

        // Update listbox
        listBox2.Items.Add(iVal.ToString());
    }
    catch (GeneralException ee)
    {
        // TODO: Error handling
    }
    catch (System.Exception ee)
    {
        // TODO: Error handling
    }
}
See Also