Click or drag to resize

ControllerStateChanged Event

Occurs when the value of the controller State has changed.

Namespace:  ABB.Robotics.Controllers
Assembly:  ABB.Robotics.Controllers (in ABB.Robotics.Controllers.dll) Version: 6.5.129.0
Syntax
C#
public event StateChangedEventHandler StateChanged

Value

Type: ABB.Robotics.ControllersStateChangedEventHandler
Exceptions
ExceptionCondition
GeneralExceptionA General Exception has occurred.
Remarks
Any subscriber that wants to update their UI as a response to the event has to redirect the execution to the UI-thread, using the Invoke method. Note: You should not switch to the UI-thread if you do not need to update the UI, as a thread switch has an impact on performance.
Examples
This example creates a Controller instance and sets up a subscription to the StateChanged. The event handler redirects the execution to the UI-thread (see Invoke method on TpsControl), which add a the new State value to the list box.
bool ITpsViewSetup.Install(object sender,object data)
{
    bool result = true;
    try
    {
        // Create Controller
        c = new Controller();

        c.StateChanged += 
            new StateChangedEventHandler(c_StateChanged);
    }
    catch (System.Exception ee)
    {
        result = false;
    }

    return result;
}

// Event handler
private void c_StateChanged(object sender, StateChangedEventArgs e)
{
    // Redirect execution to UI-thread
    this.Invoke(new EventHandler(UpdateEventDataToListbox),sender,e);
}

// Update ListBox
private void UpdateEventDataToListbox(object sender, System.EventArgs e)
{
    listBox1.Items.Add(((StateChangedEventArgs) e).NewState.ToString());
}
See Also