RobotStudio event

Load a program by broswing disk controller

Options
Hi,
i have build a win32 application in C# with some methods that allow me to perform many operations on a controller. But i have a problem about implement a method that can load a RAPID program that stored on hardisk device on robot controller.
I know and i think that i must use "Task[].LoadProgramFromFile(string Path, RapidLoadMode)" of PC SDK, but for use this method i must to know previos the name of my RAPID program and where it is located on controller hardisk. So i would to do a broswing of hardisk, select a program and load it.
I know that we can only access on controler hardisk by FTP protocol so i builded a method using this:

...
using (Mastership mc = Mastership.Request(controller.Configuration),
          mr = mastership.Request(controller.Rapid))
          {
                     Task[] tasks = controller.Rapid.GetTasks();

                     System.Windows.Forms.OpenFileDialog file = new OpenFileDialog();

                     file.Filter = "Old stile (*.prg)|*.prg|IRC5|*.pgf|All File |*.*";
                     file.Title = "Load Robot Program from robot";
                     file.CheckPathExists = false;
                     file.ValidateNames = false;
                     file.CheckFileExists = false;
                     file.RestoreDirectory = true;  
                     file.InitialDirectory = "ftp://" + controller.FileSystem.RemoteDirectory;
                    
                     if(file.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {                               
                                string s = file.FileName;
                                int pos = s.LastIndexOf('/');
                                s = s.Remove(0, pos + 1);

                                try
                                {
                                    tasks[0].LoadProgramFromFile(file.FileName, RapidLoadMode.Replace);
                                }
                                catch(System.Exception ex)
                                {
                                    MessageBox.Show(ex.Message, "Error 0018:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    mr.Release();
                                    mc.Release();
                                }
                            }
                            mr.Release();
                            mc.Release();
                        }
             }  
.....
           
Now when i start this method it's all ok, i can broswe into controller hardisk and select the file that i want, but when i click on "Open" button of  this "OpenFileDialog" it don't work also in the near tetxbox appear my selected file... Cry

What is the problem?? is maybe .net?? somebody can help me??
How i can load a RAPID program directly on controller without must know the file name?? is it possibile to do a file broswing into controller hardisk without ftp or http protocol??

best regard Emanuele

Comments

  • a note:
    ...
    file.InitialDirectory = "ftp://" + controller.FileSystem.RemoteDirectory;
                        
                         if(file.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    ....

    work under Windows 7 32bit under Win XP don't work (open win default directory)..

    some ideas??



  • A bit strange...I have Win7 32 installed on my machine and for me it doesn't work. Same behaviour as you get using XP i.e initial directory is set to win default directory....I test some more this morning and see if I can figure it out.
     
    Lennart H
  • just a question: but do you have tried on real controller??
  • Yes, I'm connected to a real controller. Got it working by the following assignment:

    file.InitialDirectory =
    "ftp://192.168.125.1" + controller.FileSystem.RemoteDirectory;
    But now I stuck in the same way as you are. Nothing happens when I click the open-button.

    Best is perhaps to write your own dialog using the methods that are available in the FileSystem class. There's no open file dialog included in the PC-SDK today.
    Lennart H
  • ok tank you very much!!

    but the another last question: isn't possible to share (maybe with credential) a folder of controller hardisk into lan?? this would be the better and fast solution for my problem...
    There is some process into controller S.O. or into Windows CE of FlexPendant about it??
  • It's not possible to share directories, at least as far as I know...Perhaps someone else out there knows better. The public interface to the controller disk using the LAN is basically the same as when using the service port: FTP implemented in the FileSystem class.

    Lennart H
  • ECapitanio
    Options
    Tanks for your help, i have done by implementing a FTP client custom control (with treeview and listview, etc...) Wink has been a long way but I got a good result ... maybe want you that i attach here my custom control that I created so I can be of help to others people???

    bye ema