Debugging an Add-In
This topic explains how to debug an Add-In. Debugging an Add-In can be very useful for understanding its behavior at runtime. As with other types of applications, Visual Studio can be used to obtain important information about the execution of the process.
Debugging an Add-In
Using Visual Studio, ensure that the Solution Configuration is set to Debug. Click the Start button. A RobotStudio instance gets executed.
Alternatively, select Start Debugging from the Debug menu (or press F5). This will start RobotStudio and auto-load your Add-in.
Note
Since the Add-in will load and execute directly when RobotStudio starts (even though there is not active station) it will probably throw an exception. Hence add a menu button to start your code, for more information, refer User Interface to create menus and buttons.
Visual Studio's default debugging controls allow the user to control the execution of the RobotStudio instance that is used for debugging purposes. When paused, the user can select the execution thread of the Add-In, and get information from it or from the RobotStudio process itself. The required process (RobotStudio instance), can be selected from the drop-down menu.
After selecting the required process and thread, refer to the Debugging tools window. This window shows a time lapse graph that shows performance metrics from the process, and a graphical log of the events triggered by RobotStudio and the Add-In. You can also see the Resource Utilization Analytics, and Event Logging in the Visual Studio's debugging tools. The Events, generated as part of RobotStudio's output, displays useful information about the debugged Add-In.
RobotStudio's Add-Ins are debugged with the standard Microsoft's .net libraries.
To call the debugging functionality, include the System.Diagnostics
library in the Add-In's code.
The following Add-In's code outputs a debug message as soon as it is loaded into RobotStudio:
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;
using System.Diagnostics;
// To activate this Add-in you have to copy RobotStudioEmptyAddin1.rsaddin to
// the Add-In directory, typically
// C:\Program Files (x86)\Common Files\ABB\RobotStudio\AddIns
namespace AddIn1
{
public class Class1
{
// This is the entry point which will be called when the Add-in is loaded
public static void AddinMain()
{
Debug.WriteLine("Hello RobotStudio, I am an Add-In!");
}
}
}