RobotStudio event

How to load RAPID into VC with PC SDK

Dear All

According to PC SDK user manual v2, I wrote some codes by CAPI to connect virtual controller and load RAPID module as follows:
    ... ...
    m_controller = ControllerFactory.CreateFrom(controller); 
    m_controller.Logon(UserInfo.DefaultUser);
    if(m_controller.OperatingMode != ControllerOperatingMode.Auto)
    {
     //set to Auto mode
     VirtualPanel vp = VirtualPanel.Attach(m_controller);
     vp.ChangeMode(ControllerOperatingMode.Auto);
    }
    using(Mastership master = Mastership.Request(m_controller.Rapid))
    {
     try
     {
      Task taskMain = m_controller.Rapid.GetTask("T_ROB1");
      taskMain.LoadProgramFromFile("C:\Data\System1\HOME\MainMod.pgf", RapidLoadMode.Replace);
      master.Release();
     }
     catch(GeneralException)
     {
      master.Release();
      throw;
     }
    }

The code did work until calling LoadProgramFromFile/LoadModuleFromFile, which threw InternalException. "CDataSystem1Internal" is the directory of virtual controller.
Could you please tell me the correct way to use LoadProgramFromFile/LoadModuleFromFile? Thanks.

Willing to hear from you:) - Levy

Comments

  • Hi Levy,

    you should use FileSystem.RemoteDirectory+"rest of path". Observe that RemoteDirectory is RobotWare_xxxxx/vcbin if you use VIRC5, but System/HOME on the real controller. LocalDirectory is System/INTERNAL for VIRC5. Try to place your program file in one of these places.

    Reply if this works out. I'm interested in finding out why else it doesn't work. Please specify version 5.05 or 5.06 also.

    Urban Vikblom
    CONTAB