RobotStudio event

PCSDK / see Rapid code of running program

Hello everybody,

i need to know if there is any chance to read out the current program code?

By now i can see if there's are "UIMessageBoxEventArgs", "UITPReadNumEventArgs" and more... Tongue  But i want to see where the program pointer is (just in time)

For example, if nothing happens there is a white screen on my app. But if the programm is running, i want to see the programpointer (and the rapid code of course).

Just like the function in Robotstudio online when i open the Flexpendant screen. Approve

Has anyone an idea?  Lamp

Greetings "7seven"

Comments



  • Haven't tried it myself but..
    Declare a ProgramPointer on the right task, set up a subscription of the ProgramPointerChanged event and then use that event to read the Range property.
     
    Please let me know if that works out for you.
     
    However that is not similar to the RobotStudio feature to see a copy of the FlexPendant screen, that feature is on the wishlist but not available in PCSDK right now.
  • That's sounds not bad! Smile
    Is there anywhere an programm example for that?

    I'm not sure how i should realize that at this moment?Disapprove

    Greetings "7seven"

  • That's what i have right now...

    I can read out the Module, Routine & in which row i'll find the Program Pointer Big smile

    That's what i see in the "list_MessageBox" (example) : --> MainModule / main / 12
    But i want to see this  :  MoveJ myRobtarget ,v1000,z50,tool0WObj:=wobj0; Embarrassed

    Here's the code so far for reading out the RED stuff above:

    tasks[0].Start();
    tasks[0].ProgramPointerChanged += new EventHandler<ProgramPositionEventArgs>(ProgramPointer);  ....

    ... 
    private void ProgramPointer(object sender, ProgramPositionEventArgs ev)
            {
                InvokeIfRequired(list_MessageBox, (MethodInvoker)delegate()
                {
                    string _Module = ev.Position.Module.ToString();
                    string _Routine = ev.Position.Routine.ToString();
                    string _Range = ev.Position.Range.Begin.Row.ToString();
                    list_MessageBox.Items.Add(_Module + " / " + _Routine + " / " + _Range);
                });   
            }

    Anyone another idea how i can realize that QuestionQuestionQuestion



  • Hi,

    I have needed the same functionality and this is what I have ended up with - though it doesn't work that well yet, as the Simulator.Readystate is not necessarily fired the first time you run a simulation (atleast with MoveAlongPath).

    I use the Datarecorders event, as it is more reliable than the ProgrampointChanged event, since if the simulation is a full speed, the virtual controller sometimes go past certain lines, that it can execute really quickly.

    First event saves the module to a file, and afterwards reads into a streamreader where I add each line to a list.

    void Simulator_StateChanged(object sender, EventArgs e)
            {
                if (Simulator.State == SimulationState.Ready)
                {
                    SimulationState state = Simulator.State;
                    module = task0.GetModule(task0.ProgramPointer.Module);
                    module.SaveToFile("C:\");
                    lines.Clear();

                    using(StreamReader sr = new StreamReader("C:\" + module.ToString() + ".mod"))
                    {
                        string line;
                        while ((line = sr.ReadLine()) != null)
                        {
                            lines.Add(line);
                        }
                    }
                }
            }

    The second event is the Datarecorders tick event - this is a bit more reliable than Programpointer changed event.
    In this, I get the motionPointer, as this was what I needed, but I guess you should be able to use programpointer aswell.

    given the row line (begin), I can then extract the line from my list that included the module.

    void DataRecorder_Tick(object sender, DataRecorderTickEventArgs e)
            {
                ProgramPosition pos = task0.MotionPointer;
                int begin = pos.Range.Begin.Row;
                int end = pos.Range.End.Row;
                string module = pos.Module;

                if (begin != temp && begin != 0 && lines.Count() > 1 && begin < lines.Count())
                {
                temp = begin; // to avoid same lines multiply times.
                        Logger.AddMessage(new LogMessage(lines[begin-1], LogMessageSeverity.Warning));
                }

            }

    Some of this code is snippets that I copy/pasted and modified here in the post, so there might be a few errors/typos.

    Hopefully you can get something working :)

    Regards, Lars

    DanLars2013-03-15 09:49:07
    Lars Glud
    Danrob A/S