Universal Robots Forum

Run script before program tree

In my URCap, I need the script, generated by the URCap to run, before the robot starts to execute what is in the program tree inside the URCap. How do I get it to do that? As it is right now, it first want to execute the program tree, then the script.

Any script code contributed from an installation node is added before the main program tree executes… can you add it from there?

I got a lot of variables from input fields, is there a way to get them from the Program Node to the Installation Node?

One way that should work is to pass Installation Node reference to the constructor of Program Node. This way you could use data model from Installation in Program Node.

I need the program node in the installation node, do you have an example of doing that? I am not sure how I would do something like that.

Not exactly the same thing, but look at MyDaemon sample. Daemon service reference is passed to Installation Node service and saved there. I think, that something similar would work between Installation and Program node.

Create a singleton that adds the program nodes to a list or a map or some collection whenever a new program node is constructed.
Then, from the installation node you can get access to that collection and do whatever you want with it.