RobotStudio event

Exception when trying to load pgf

Options

I have a problem with the IRC5 communication. The main problem is that a functions returns before it actually is finished. For example:

<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

I call: Delete (program)

I will get from Delete() the result = true.

I then call LoadProgram(), but I will get an error that load program may not be executed (this is not completely the error, because I didn't know precisely the error anymore).

 

Situation

I've got the master rights to execute the function.

I'm using Robot Application Builder 5.10 (latest release), Visual Studio 2005.

 

This phenomenon also happens with other functions. I think that this is, because of the non-real-time operating system (a-synchroon).

I don't know how to solve this. I already tried to add Retry-cycle, but this did not solve the problem. Only a timeout between the delete- and load program resolves this, but this is unwanted as the time may vary. If the controller is very busy, the wait-time must be longer. This is not a solution for a production environment.

 

Comments

  • Hi,

    Take a look at my answer to Neil about loading a .pgf and then a .mod. The reason why you cannot load the program is the same, I think.

    When a program is deleted it executes some RAPID code before it is unloaded, and when you try to load the new program the reason it fails is that the program that you are unloading is still executing. So you need to be sure it has stopped executing. Try waiting for the event ExecutionStatusChanged when you delete the program, and load the new program when ExecutionStatus is 'Stopped'.

    (The DeleteProgram method does not return anything)

    Best regards,

    Ingela Brorsson
    Software Engineer
    ABB Robotics, Sweden
  • Thanks for your suggestion using the event ExecutionStatusChanged.

    It turns out that waiting for the event ExecutionStatusChanged doesn't work, because the event is not always triggered. I think that if the controller is too busy, the event ExecutionStatusChanged just is not send...

    <?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

    As an alternative, I have also made a piece of code that just waits until the ExecutionStatus is set to `Stopped' and then load the program into memory. With program I mean the *.PGF file.

     

    This results in the error: "Operation is illegal in current execution state".

    But the strange this is, that the ExecutionStatus was `Stopped'. So loading should not have been a problem.

     

    I think that the situation of Neil was different. He was loading a Program file and then also a module, but I'm only loading a program file.

     

    Any suggestions?

  • Hi,

    Whether you load or unload a pgf the execution state will change to 'running' a short while. If you then try to load a mod or a pgf you may therefore get the exception "Operation is illegal in current execution state". This happened when I tested Neil's code, and what you get as well.

    When a pgf is unloaded the predefined RAPID event routine SYS_RESET must execute.

    Unfortunately, now that I have investigated further I see that the event that I asked you to try does not miss any event from the controller, but there is an exception: "The subscription does not react to event routines.".Ouch

    This is something that needs to be improved (or at least documented)...  Thank's for drawing our attention to it. I hope you can make do with the workaround you figured out.

    Or maybe someone else on the Forum knows how to deal with it?

    Best regards,

    Ingela Brorsson
    Software Engineer
    ABB Robotics, Sweden
  • Hi,

    <?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

    Thanks for your reply, but I'm not heaving the same problem as Neil. I'll get the error: "Operation is illegal in current execution state" when I do the following:

     

    Pseudo code:

     

    Delete() //delete program

    While (Controller.Rapid.ExecutionStatus != Stopped)

    {

                 Sleep (100);     //wait a little bit.

    }

     

    //if I am here then ExecutionStatus should be stopped

     

    if (Controller.Rapid.ExecutionStatus != Stopped) //check again to be sure

    return;

     

    //if I am here now, then I can be sure that nothing is running anymore

    LoadProgramFromFile (Program, RapidLoadMode.Replace)

     

    //LoadProgramFromFile() will result in the error: Operation is illegal in current //execution state".

     

    So this is not the same problem as Neil has. If I put-in a time-delay just before LoadProgramFromFile then it works fine.

     

    My alternative doesn't work either, because of the problem above. And we don't want to put-in a time-delay.

     

    So I'm waiting for your response.

  • P.S. I'm loading only one *.PGF file, nothing else.
  • Hi,

    It seems that the property ExecutionStatus does not judge status to be 'running' when only the event routine SYS_RESET is executing. But still this is why you are not allowed to load the .pgf.

    So for 5.10, I do not see any alternative but to use a time delay.

    Best regards,

    Ingela Brorsson
    Software Engineer
    ABB Robotics, Sweden
  • Do you know when this is being solved?
  • RussD
    Options

    Maybe you can take advantage of some of the other events that are available such as ProgramChanged and ExecutionStateChanged or PPChanged to better control when you should start loading your new file.

    For instance, maybe the ProgramChangedEventArgs will change to Unknown when the new program is fully unloaded, or ExecutionState may change to Uninitialized when the process is complete? Perhaps by monitoring these states you can identify when it is safe to proceed.

    Russell Drown