Activate/Deactivate callbacks
A Powerpac deployed in RobotStudio can use callback functions when it is activated or deactivated. This topic shows how to use these callback functions.
Note
You can try out this example using the RobotStudio Empty Add-in template from Visual Studio.
OnActivate and OnDeactivate functions
It is necessary that the main class of the Add-In inherits from the Hosted
Add class to be recognized as a Powerpac, and for using the function callbacks. To achieve this, write the main class as shown in this snippet:In Base public class Class1 : HostedAddInBase { // content of the Powerpac }
Write a public overriding method that follows the prototype of On
Activate , which receives no arguments and returns a bool.public class Class1 : HostedAddInBase { public override bool OnActivate() { // Statements to execute when the Powerpac is activated... return base.OnActivate(); } }
Write a public overriding method that follows the prototype of On
Deactivate , which receives no arguments and returns a bool.public class Class1 : HostedAddInBase { public override bool OnActivate() { // Statements to execute when the Powerpac is activated... return base.OnActivate(); } public override bool OnDeactivate() { // Statements to execute when the Powerpac is deactivated... return base.OnDeactivate(); } }
Important
Remember to comply with the stipulated Requirements for hosting an Add-In as a Powerpac.
The complete code for this example is:
using System;
using System.Collections.Generic;
using System.Text;
using ABB.Robotics.Math;
using ABB.Robotics.RobotStudio;
using ABB.Robotics.RobotStudio.Environment;
using ABB.Robotics.RobotStudio.Stations;
namespace Powerpac
{
public class Class1 : HostedAddInBase
{
public override bool OnActivate()
{
// Statements to execute when the Powerpac is activated...
return base.OnActivate();
}
public override bool OnDeactivate()
{
// Statements to execute when the Powerpac is deactivated...
return base.OnDeactivate();
}
}
}