Search Results for

    Show / Hide Table of Contents

    Working with RAPID modules and programs

    Overview

    Using the Task object it is possible to load and save individual modules and programs. You can also unload programs, as well as reset the program pointer and start program execution.

    Note

    All these operations require mastership of the RAPID domain. For more information, see Accessing the controller.

    Load modules and programs

    To load a module or program file, you need the path to the file on the controller. While the file is loaded into memory the RapidLoadMode enumeration argument, add or Replace, specifies whether or not it should replace old modules or programs.

    If the file extension is not a valid module (mod or sys) or program (pgf) extension an ArgumentException is thrown.

    try
    {
        aTask.LoadProgramFromFile(aPrgFileName, RapidLoadMode.Replace);
        aTask.LoadModuleFromFile(aModFileName, RapidLoadMode.Add);
    }
    catch (ArgumentException ex)
    {
        return;
    }
    
    Note

    All program files must reside in the file system of the controller and not locally on the PC. In order to load a program from the PC, you must first download it to the controller by using the FileSystem.PutFile method. For more information, see File System domain.

    Note

    If the User Authorization System of the controller is used by the PC SDK application, it is required that the logged on user has the UAS grant UAS_RAPID_LOADPROGRAM to load and unload RAPID programs. For more information about which grants are necessary for a specific PC SDK method, see the API Reference.

    Save programs and modules

    You can save programs using the Task.SaveProgramToFile method and a single module by using the Module.SaveToFile method.

    To unload a program after it has been saved to file you can call DeleteProgram().

    Task[] taskCol = aController.Rapid.GetTasks();
    foreach (Task atask in taskCol)
    {
        atask.SaveProgramToFile(saveDir);
        atask.DeleteProgram();
    }
    

    In this example a module is saved to a file:

    Module aModule = aTask.GetModule("user");
    aModule.SaveToFile(aFilePathOnTheController);
    
    Note

    Please note that SaveToFile() is only intended for saving modules to the controller directory. If you intend to save it to a local disk on your PC, you need to use file transfer.

    ResetProgramPointer method

    Using ResetProgramPointer you can set the program pointer to the main entry point of the task.

    aTask.ResetProgramPointer();
    

    Start program

    Starting program execution in the robot controller can only be done in automatic operating mode. There are several overloaded Start methods to use, the simplest way to start RAPID execution of a controller task is:

    aTask.Start();
    
    Note

    If your application uses the User Authorization System of the controller (see User Authorization System), you should also check whether the current user has the grant UAS_RAPID_EXECUTE before calling the Start method.

    Execution change event

    It is possible to subscribe to events that occur when a RAPID program starts and stops. It is done like this:

    aController.Rapid.ExecutionStatusChanged +=
        new EventHandler<ExecutionStatusChangedEventArgs>(Rapid_ExecutionStatusChanged);
    

    For more information on how to write the event handler that is needed to update the GUI due to a controller event, see Avoiding threading conflicts and Letting the user know that RAPID data has changed.

    In This Article
    Back to top Copyright © 2025 ABB