Synchronizing to Station
This example provides information to synchronize data from virtual controller into RobotStudio Station. 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 data appears in RobotStudio Home tab.
Use this procedure to Synchronize to Station :
Get virtual controller Instance based on Rs
Irc5Controller object's SystemId .Request for RAPID Mastership from controller.
If RAPID Mastership is granted then call Sync
Path in the direction of Station.Procedure(string, Sync Direction, Array List)
Solution
Get virtual controller Instance based on RsIrc5Controller object's SystemId.
RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)task.Parent; //Get Controller object ABB.Robotics.Controllers.Controller controller = new ABB.Robotics.Controllers.Controller(new Guid(rsIrc5Controller.SystemId.ToString()));
Request for RAPID Mastership from controller.
using (ABB.Robotics.Controllers.Mastership m = ABB.Robotics.Controllers.Mastership.Request(controller.Rapid))
If RAPID Mastership is granted then call SyncPathProcedure in the direction of Station.
result = task.SyncPathProcedure(path.ModuleName + "/" + path.Name, SyncDirection.ToStation, messages);
Example
This example provides information to synchronize data from virtual controller into RobotStudio Station.
private static bool SynchronizeToStation(RsPathProcedure path, RsTask task)
{
Project.UndoContext.BeginUndoStep("SynchronizeToStation");
bool result = false;
try
{
//Get RobotStudio Controller
RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)task.Parent;
//Get Controller object
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();
//Synchronization to Station
result = task.SyncPathProcedure(path.ModuleName + "/" + path.Name,
SyncDirection.ToStation,
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.