Universal Robots Forum

Code execution at the end of a parent node

My URCap is configured as parent node and i start a new thread in the beginning of the execution of the node (contribution class / generateScript() method). Now i like to kill the thread, when the Robot program has finished the last child node, respectively it leaves the parent node.

Do i have to implement a second method similar then generateScript()?

Any Idea? Thanks!

edit:
my code:

public class TestProgramNodeContribution implements ProgramNodeContribution{
...

    @Override
    public void generateScript(ScriptWriter writer){
        writer.defineThread("thread1");
            writer.whileTrue();
            writer.appendLine("textmsg(\"yo\")");
            writer.sleep(1.0);
        writer.end();
    writer.end();

    writer.runThread("thread1handle", "thread1()");
    }
...
}

Yo,

I‘m not sure if i understood this right but i think you simply need to insert writer.writeChildren() after running your thread and then kill it on the last line

I would also recommend to define threads in your installation node otherwise you will have issues with multiple definitions of your thread with the same name

3 Likes

Thanks i got it!
I have seen writeChildren() already in some samples but i had problems to adapt it. Now it works :slight_smile: