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?

Comments

  • 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:
    http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/e73d2cb4-1974-f850-471f-52abe9951166.htm

    For another routine, you have to use the method "SetProgramPointer", see
    http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/edd35108-78a7-01de-a154-186d03d0226d.htm

    Afterward, you have to "Start" the program, see
    http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/4dc4d703-0b11-363a-31bf-674cacd97b5e.htm

    Please have also a look into the manual "Working with RAPID modules and programs"
    http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/847d1dda-5ab5-4fec-a238-9e5d34115938.htm

    I hope I could help you.

    Best regards
    Micky

  • 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,
    Eugene
  • Micky
    Micky ✭✭✭
    Hello Eugene,

    you could stop the program as follows:
    1. Starting the cycle once with the following method: 
      task.Start(RegainMode.Continue,ExecutionMode.Continuous,ExecutionCycle.Once)
      (See http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/d53ae203-12ad-821c-f1e9-54a8f1886bf4.htm)

    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:
    http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/847d1dda-5ab5-4fec-a238-9e5d34115938.htm

    Deleting a module:
    http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/97b412d4-b9ef-9b7d-9345-120ca6b2587a.htm

    Chapter "File system domain" of the manual
    http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/45d2b326-dd15-4d8d-93b0-b752bac5b149.htm

    Best regards
    Micky
  • 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.

    /BR
    Micky
  • Hi Micky,
    Yes, you right. And I can set something like:
    pseudocode:
    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;
                try
                {
                    
                    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,
    Eugene

  • 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.

    Thanks,
  • 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);
    fs.PutFile(fileName);
    
    // Load module ftom (TEMP)$/mTest_01.mod
    
    fs.RemoveFile(fileName);
    

    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.
    Eugene

  • (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