Synchronizing to Controller
This example provides information to synchronize Rs
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 :
Get virtual controller instance based on Rs
Irc5Controller object's SystemId .Request for RAPID Mastership from controller. If granted then call Sync
Path Instance method of RsProcedure(string, Sync Direction, Array List) Task type for synchronize to Controller.
Solution
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()));
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.
ABB.