Show / Hide Table of Contents

Synchronizing to Controller

This example provides information to synchronize RsPathProcedure to virtual controller.

An active Station and Controller is required for this example. RsTask and RsPathProcedure are passed as parameters. To check the result of the addin, ensure that the module appears in the offline tab

Use this procedure to Synchronize to Controller :

  1. Get virtual controller instance based on RsIrc5Controller object's SystemId .

  2. Request for RAPID Mastership from controller. If granted then call SyncPathProcedure(string, SyncDirection, ArrayList) Instance method of RsTask type for synchronize to Controller.

Solution

  1. Get virtual controller instance based on RsIrc5Controller object's SystemId.

    RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)task.Parent;
    //Get virtual controller instance from RsIrc5Controller instance
    ABB.Robotics.Controllers.Controller controller =
        new ABB.Robotics.Controllers.Controller(new Guid(rsIrc5Controller.SystemId.ToString()));
    
  2. Request for RAPID Mastership from controller. If granted then call SyncPathProcedure Instance method of RsTask type for synchronize to Controller.

    using (ABB.Robotics.Controllers.Mastership m = 
        ABB.Robotics.Controllers.Mastership.Request(controller.Rapid))
    {
        try
        {
            ArrayList messages = new ArrayList();
            result = task.SyncPathProcedure(path.ModuleName + "/" + path.Name,
                SyncDirection.ToController,
                messages);
    
        }
        catch (Exception)
        {
            result = false;
        }
    }
    

Example

This example provides information to synchronize RsPathProcedure to virtual controller.

private static bool SynchronizeToRapid(RsPathProcedure path,RsTask task)
{
    bool result = false;
    Project.UndoContext.BeginUndoStep("SynchronizeToRapid");
    try
    {
        path.Synchronize = true;
        //Get reference to instance of RsIrc5Controller   
        RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)task.Parent;
        //Get virtual controller instance from RsIrc5Controller instance
        ABB.Robotics.Controllers.Controller controller =
            new ABB.Robotics.Controllers.Controller(new Guid(rsIrc5Controller.SystemId.ToString()));

        //Request for Mastership from controller 
        //If granted then call SyncPathProcedure instance method of RsTask   
        using (ABB.Robotics.Controllers.Mastership m = 
            ABB.Robotics.Controllers.Mastership.Request(controller.Rapid))
        {
            try
            {
                ArrayList messages = new ArrayList();
                result = task.SyncPathProcedure(path.ModuleName + "/" + path.Name,
                    SyncDirection.ToController,
                    messages);

            }
            catch (Exception)
            {
                result = false;
            }
        }
    }
    catch (Exception ex)
    {
        Logger.AddMessage(new LogMessage(ex.Message.ToString()));
        Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
    }
    finally
    {
        Project.UndoContext.EndUndoStep();
    }
    
    return result;
}

Required Namespaces

ABB.Robotics.RobotStudio.Environment

ABB.Robotics.Controllers.RapidDomain

See Also

  • Importing MoveInstruction
  • Loading Module
  • Saving Program
In this article
Back to top Copyright © 2024 ABB