Universal Robots Forum

Using a singleton

Hi!

I want to connect my contributions.
And I saw on a forum post to use the singleton.
But how do I implement this into my urcap java code?
Many thanks!
I made the singleton class down here:
image

sth. like this (or your example above):

public class Singleton {

private Singleton() {

}

public static Singleton getInstance() {
    if (instance == null) {
        instance = new Singleton();
    }
    return instance;
}

and finally call Singleton singleton = Singleton.getInstance(); in your contributions

Thanks @m.birkholz !
I want to make multiple urcap nodes in the robot program and when I change the move speed of one, I want to change them all.
I use this config:


Do I need to place this in the singleton to make sure that every move changes?
This is the robot program: (If i change the move speed on one “Global weld”, I want to change both MoveL)
image