Universal Robots Forum

Interact in Java with variables assigned/created in PolyScope/URScript

Hi everyone,

thanks for reading and your time first!!

I am struggled developing my URCap.

My idea consists of creating a HMI screen for a palletizing project, where I have buttons and different combo boxes to change between programs when palletizing or to change some important values for a chosen program.

I have all this info stored in variables created either with PolyScope or URScript lines, like the number of the layers, current box number, etc.

Therefore, I thought that the best option was to create an Installation Node URCap. The thing is, I do not need to use the generateScript() method since this adds the code in the preamble and I want to update the variables in “real-time”/runtime (exactly when pressing the button or changing the value in a text field).

For now, when using buttons to update a variable, this is working well inside the action listener (sending a socket throught the port 30001):

                  "sec progSec():\nwrite_output_boolean_register(2,True)\nend\n"

But when it comes to i.e. showing the variables values in a text field/pane/label, where I need to read also the value set in the variable, I see no way of achieving this.

I have gone through all these posts and the CycleCounter example (here it is updating a variable but for a Program Node development):




And I am afraid that using the DataModel I can get only the names of the variables and I cannot update the values. It is not possible to communicate directly Java with the URControl that is using the variables in runtime, or am I mistaken? Can I use the scriptwriter anywhere?

Any help/clarification would be really useful. I am considering using daemon, but I am a newby with daemons.

Do not hesitate to ask if anything is not clear…

Thanks in advance and kind regards!!