Universal Robots Forum

Slow program page


I am experiencing slow reactivity of the interface on the program page of my URCaps

When my program page is displayed and I add a child (example: a passing point) the system calls 11 times the function “getTitle” and 11 times the function "IsDefined"
And if I add and I modify the position of a second point the system calls this time 22 times the function “getTitle” and 22 times “isDefined

Is there a way to limit the number of calls to these two functions?

Thank you

22 times seems a bit high, ut the amount of calls depend on interaction with eventual other nodes in the program.
And isDefined() is called every time a change is made anywhere in the program.

You should make the code in isDefined(), getTitle(), openView() etc. as lean as possible.
Preferably, these should only be depending on settings from the DataModel.
If depending on e.g. server calls or other external settings, this will dramatically affect user experience due to long loads and page changes.

I had a similar issue when I would try to receive data from a server when opening the installation screen. One way to resolve the issue was to use a timer and call the function a certain amount of time after the page has been open.

try this:

new java.util.Timer().schedule{
new java.util.TimerTask(){
public void run(){
}}, 100 (in miliseconds));

I know this doesn’t resolve the problem of calling a function 15 times on openview but this a good solution to server calls when the page is opened.

Thank you for the idea,

So I added a timer in the program class constructor.

My problem is that I can not stop the timer if I remove the node from the urcaps.

I declared the function “finalize ()” to stop the timer, but without success.

Is there another method?

Finalize probably won’t help you; I’ve never seen its call. You can stop it in the Activator stop function, but that one will be called only when the robot is shut down or if the URCap is removed from the system.
If this task has to be removed before shutting down the robot, you should keep its handler outside the program node, so that it’s still accessible from somewhere else even if you delete it.

Note that all events happinging within the URCap is happening in the same thread as the rest of the GUI.
Hence as discussed below, the generic functions like isDefined() and similar should be as lean as possible.

You can also consider using the EventQueue.invokeLater functionality from java.util.Timer, to load functionality that takes time, or should run in parallel.
This is shown by example in the MyDaemon sample, and is also mentioned in the URCap Tutorial document section “9.2 Interaction with the daemon”

Thank you for your reply,

It is precisely to lighten the functions “isDefined ()” and “getTitle ()” that I now use a “Timer”,

I understood the example of using the Timer, but in the example, the timer is started when opening the “OpenView ()” page and stops closing the page “CloseView ()”.

In my case I need to start my “Timer” when I add my urcaps node, so I start it with the constructor function. And I would like to find a solution to stop the timer when I remove the node.

Considering the previous answer of “jubeira”, it seems dificult?

thank you,

The timer in my previous post will delay a function call on “OpenView()” allowing the GUI to load and after a set time to make that function call. It seems to me that if you simply want to start a condition and stop it on “CloseView()” you could simply add a condition to make the function run on “OpenView()” and set to false on “CloseView().” If you’re trying to stop that delay timer for a function call I would do the condition statement inside your function to make the function not run unless true.

Hope this helps!