Show / Hide Table of Contents

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

  1. It is necessary that the main class of the Add-In inherits from the HostedAddInBase 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:

    public class Class1 : HostedAddInBase    
    {
        // content of the Powerpac
    }
    
  2. Write a public overriding method that follows the prototype of OnActivate , 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();
        }
    }
    
  3. Write a public overriding method that follows the prototype of OnDeactivate , 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();
        }
    }
}

See Also

  • Add-In OnLoad callback
  • Add-In Save and Close callbacks
  • Add-In File Options
  • Unload Callback
  • Creating a RobotStudio Add-In
  • Creating an Add-In File
In this article
Back to top Copyright © 2025 ABB