RobotStudio event

Start controller with Loaded module - LoadModuleFromFile function was used.

Hi everyone,
How can I start the controller with the loaded module inside? I'm using pc sdk application. Using LoadModuleFromFile function and now I would like to start the controller. How can I trigger the execution of that module?

Thank you?


  • Micky
    Micky ✭✭✭
    Hello Eugene,

    after loading the module you have to set the program pointer to a routine:

    For routine "main" you can use the method "ResetProgramPointer", see:

    For another routine, you have to use the method "SetProgramPointer", see

    Afterward, you have to "Start" the program, see

    Please have also a look into the manual "Working with RAPID modules and programs"

    I hope I could help you.

    Best regards

  • Thanks Micky,
    I have one more question. I load the module from external hard drive, set program pointer to sequence routine inside that module, finished running that module. The controller will continue to go through that module over and over, right? How can I stop the controller at the end of my module/sequence, resave that module back to my external hard drive and delete that module? I know the delete method is exist, but I need to re-save that module back to the external hard drive. Basically same procedure as from the production manager but only from my application and with external/network hard drive (not from the controller ).

    Thanks for your help,
  • Micky
    Micky ✭✭✭
    Hello Eugene,

    you could stop the program as follows:
    1. Starting the cycle once with the following method: 

    2. or add the instruction "Stop" or "Exit" at the end of your RAPID routine

    Observe the execution state and as soon as the program stops you save and delete the module.
    //Load module 
    //start robot program
    aController.Rapid.ExecutionStatusChanged += ExecutionStatusChanged;
    private void ExecutionStatusChanged(object sender, ExecutionStatusChangedEventArgs e)
       if (e.Status == ExecutionStatus.Stopped)
           aController.Rapid.ExecutionStatusChanged -= ExecutionStatusChanged;
           //Save module
           //Delete module

    In case it not possible to save the module directly on your computer, you have to save it first onto the controller (maybe in the TEMP directory) and copy it later to your PC.

    See also the following links:

    Working with RAPID modules and programs:

    Deleting a module:

    Chapter "File system domain" of the manual

    Best regards
  • How can I copy it from the controller (temp folder)? What kind of method should I use?
  • You included the link for the file system domain. 
    Thank you Micky for all your help.
  • Micky
    Micky ✭✭✭
    Hello Eugene,

    Maybe you should set an additional signal or a persistent at the end of the program so that you know for sure that the program has really quit and not just stopped. 
    If only the program stop is monitored, your PC program will delete the current robot module and the robot can no longer continue its program.
    This means that in addition to the program stop you would also have to check the current value of the persistent or the signal and only then save and delete the module if this is the case.

  • Hi Micky,
    Yes, you right. And I can set something like:
    public void .... (objec sender, Signal state change)
        Save module;
        Copy module;
        Delete module;
  • Hi Micky,
    Maybe you will be able to help me out.?
    I having a problem with aFileSystem.Localderectory and Remotedirectory. It throws an exception - {"The given path's format is not supported."}.
    I'm trying to load the module from a predefined location to the controller. This is code example:

                // I tred this whay to
                // string remoteFl = "C:/Test/mTest_01.mod";
                aFileSystem = cp.Cntr.FileSystem; // Cntr - it's a controller.
                aFileSystem.LocalDirectory = "C:/Test/mTest_01.mod";
                string remoteFl = aFileSystem.RemoteDirectory;
                string localDir = aFileSystem.LocalDirectory;
                    aFileSystem.PutFile(localDir, remoteFl, true);
                catch (Exception c)
                    MessageBox.Show($"{c.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

    I think I'm missing something. Not sure what..

    Thank you,

  • I know I need to grant UAS_RAPID_LOADPROGRAM to load and unload rapid program.
    This what I have: 
    var rgName = Grant.LoadRapidProgram.Name;
    Now how can I use that grant? How can I assign this grant? On Mastership m = Mastership, or in Cntr.Logon(UserInfo.DefaultUser);?

    I little lost. Not enough information/documentation.
    I will appreciate any help.

  • Hi,

    To upload a file to the controller you should do something like this:
    string localPath = @C:\Test\mTest_01.mod;
    var fs = controller.FileSystem;
    fs.LocalDirectory = Path.GetDirectory(localPath);
    fs.RemoteDirectory = "(TEMP)$";
    string fileName = Path.GetFileName(localPath);
    // Load module ftom (TEMP)$/mTest_01.mod

    Any operation that requires UAS grants will work as long as the logged in user has those grant(s).
    You can check for grants via controller.AuthenticationSystem, but you cannot assign grants to a user as far as I know. That must be done in RobotStudio.
    Johannes Weiman
    Software Engineer
    RobotStudio Team, ABB Robotics
  • Thank you Johannes for your respond.
    I would like to load the module inside of the controller PARTMODULE folder. It's located in HOME folder. How can I provide that directory? I tried "(HOME/PARTMODULE)$", "(PARTMODULE)$"  not working. I will have to provide a full path?
    fs.RemoteDirectory = ??

    Thank you for your help.

  • (HOME)$/PARTMODULE should work. 
    Johannes Weiman
    Software Engineer
    RobotStudio Team, ABB Robotics
  • It worked. Thank you.
    It's the same procedure with a real controller as with virtual - correct? Or I will have to do some different approaches?
  • I'm not 100% sure, but I think so. If you use environment variables like (HOME)$ and (TEMP)$, the same code should work for RC and VC.
    Johannes Weiman
    Software Engineer
    RobotStudio Team, ABB Robotics