RobotStudio event

S4Backup [WebWare SDK]

I'm trying to perform a backup of a robot using a Helper control and the S4Backup method.

The manual says the following:

This method is used create a backup of the robot controller files. It saves system parameters and modules in a new directory on a memory device.

On a memory device: Does this mean that I can perform the backup directly to my PC? Or do I have to do the backup on the robot?

I've tried both, but I get the error -5108 General error for log. in either case.

In Interlink Configuration I've configured the robot for standard backup. What am I doing wrong?

Comments

  • The memory device in this case is the memory device on the robot (flashdisk/harddrive). The directory you enter as a string value when calling the method, will be therefore be created on the robot.

    If you want to transfer files from the robot to/from a PC, there are other methods that can be used, such as S4FileCopy.

    In order to help you with the -5108 error you are experiencing, it would be helpful if you could provide the following information:

    1. Which WebWare SDK build version, for instance 3.02.0317, is in use?
    2. Are you using long file names on the robot (longer than 8+3 characters) ?
    3. What are your settings for the following Interlink Configuration properties:
       a. Alias name
       b. TCP/IP node and IP address
       c. Profile name
       d. Please send screenshots/info of all tabs in the profile editor.
    4. Describe the configuration of robot, i.e. BaseWare version, software options, robot type, etc.
    5. If possible, send some code.

    ______________________________
    Anders Dannberg
    ABB Automation Technologies
    Support Engineer - WebWare Team

  • The problem is solved, I used the path HOME:/BACKUP instead of the complete search path.

    Two more questions though:

    1. Is there a built in way to get to know the system name for the current machine in order to be able to generate a complete search path?

    2. Is there a built in way to copy a directory including all of it's subdirs?

  • Q1:

    I think that the ControlID property of the Helper control will return the current system name.

    Q2:

    There is no support in the RAP protocol for directory recursion, so the user must implement their own recursion method. One approach is to build a collection using the values returned from successive calls to the S4Dir method of the Helper control.

    Russell Drown
  • Backup and directory structure.

    I'm struggling a bit with recursion here. Trying to build the complete directory structure on local PC which is identical with the backup last run on the robot. I understand that I should use the S4Dir method in recursion but I just can't get it to work. It just falls out when it reaches the first bottom in the filetree (syspar), where it should back up.

    Would appreciate some samles on this.

    /S 

  • I am assuming you want to accomplish this using the Helper control (and not the FileManager control, which automatically displays and let you browse robot systems, including subdirectories).

    Unfortunately, the S4Dir method does not support directory recursion.
    This means you would have to implement this in your code. One solution would be using S4Dir and S4Dirlist.

    To simply list the directories in the hd0a/temp folder:
    ===========================================

            intResult = Helper1.S4Dir("/hd0a/", " emp", 0, 3, lngResult)

            For i = 0 To Helper1.DirListCount - 1
                MsgBox (Helper1.DirList(i))
            Next

            ' ... add code here that allows you to select  a directory

            ' ... then you would have to set the Helper1.S4Dir properties 
              to the newly selected directoryname, and re-list the
              directories here. Obviously you would probably want to handle
              this in functions or similar, to manage your code.

    ===========================================

    ______________________________
    Anders Dannberg
    ABB Automation Technologies
    Support Engineer

  • You say s4dir doesn't support recursion.. hmmmm.. so I can't do things like ....(using c#)? Which doesn't work

    private void CopyBackupToPC(string strDir)
      {
    //remove device from dir   

    strDir = strDir.Substring(5,strDir.Length - 5);
     
       AddDirectory(strDir);
       
      }


      private void AddDirectory(string strDir)
      {
       int intResultID_A = 0;   short shRetval_A;   
       shRetval_A = AxHelper1.S4Dir("/hd0a/",strDir,0,3,ref intResultID_A);
       
       if(shRetval_A == 0)
       {
        //the first two directories is "." and ".." so start at index 2
        for(short i = 2; i < AxHelper1.DirListCount -1; i++)
        {
         string strPath = "/Blaa/Backup/RobOne" + strDir + "/" + AxHelper1.get_DirList(i) + "/";
         shRetval_A  = AxHelper1.S4MkDir("C:", strPath,3,ref intResultID_A);
        
         if(AxHelper1.FileListCount > 0)
         {
          AddFiles(strDir + "/" + AxHelper1.get_DirList(i)+ "/");
         }
         
         AddDirectory(strDir + "/" + AxHelper1.get_DirList(i));
        }
       }
      }

     

  • S4Dir will not retrieve a complete directory structure of all subdirectories. It will however return a list of the directories for a selected path (set by S4Dir). You would have to create a function and/or loop, until you have retrieved all subdirectories based on your starting path.

    I don't have code samples for this functionality right now. Time allowing, we could perhaps create such a sample project and post here. 

    Maybe someone else out there has already created one and would like to share it?

    ______________________________
    Anders Dannberg
    ABB Automation Technologies
    Support Engineer

  • I took a simple but inelegant approach to this by using the collection object. Someone could take this pseudocode and simplify it and post it if they would like; I just did enough with this to get it working for what I needed.

    What I do first is use S4Dir to get the properties of the root of my target. Once I know how many directories there are, I loop through and add the root folders to the collection (I assume that there are no files in the root):

    If dirCount > 0 then

                For i = 0 to dirCount -1

                            Add Helper.DirList(i) to the collection

                Next i

    End If


    Next, I build the root directory structure on the PC for each item in the collection, and at the same time copy any files I find in these dirs to the PC as well.

    If CollectionCount > 0 Then  //if any are found create them on the pc<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

            For i = 1 To CollectionCount  //collections are 1-based

        MkLocalDir(the current Dir Name) //create the dir

                    call S4Dir to get the file count for the current dir

                    If intFileCount > 0 Then // there are files present

                            For j = 0 To intFileCount - 1

                                        Copy each file to PC

                            Next j

                    End If

             Next i

     End If

    Next, I go through and build the sub directories by operating on the topmost item in the collection until there are no more items left (I am adding sub-dirs to the end of the collection and deleting the topmost item at the end of this loop)

    While CollectionCount > 0 //as long as there are items left in the collection

             Get the name of the first item in the collection

             call S4Dir on this item to get its dir count

             If intDirCount > 0 Then  //if it has sub-dirs

                     For each sub-dir in the current dir

    add the sub-dir to the end of the collection

    MkLocalDir(the current sub-dir Name)

                            call S4Dir to get the file count for the current sub-dir

                            If intFileCount > 0 Then //there are files present

                                        For j = 0 To intFileCount - 1

                                                    Copy each file to PC

                            Next j

                            End If

                      Next sub-dir

             Remove the first item in the collection

             End If

    End While

    RussD38392,7000578704
    Russell Drown