loading
 
Locking Roborealm to get variables picture
aldofad from Italy  [3 posts]
13 year
Hi,
is there a way to consistently get some variables by locking Roborealm variables updates?

Example (wrong!)
RR_API.getVariable("NV_OBJECTS_TOTAL") = 2;
... wait some milliseconds ... but meanwhile internally in Roborealm NV_OBJECTS_TOTAL=1
//This array below only contains 1 value while I was expecting 2
RR_API.getVariable("NV_ARR_OBJ_SIM");

Is the problem clear?
I'm only asking if Roborealm is thread safe and provides locking through API

Many thanks, bye,
aldo
Anonymous 13 year
Aldo,

Yes, the problem is clear. It is a classic race condition.

We can provide a means to stop this from happening but want to just check first what language you are using and if you (for now) could skip the first getVariable and just get the length from the result of the second getVariable. As the value for an array will be a comma delimited string that you need to break into individual values you would know the length based on the number of commas.

Or is your situation a little different?

If so, we can introduce a locking mechanism that will stop variables from being updated while you access their values ... but note that this will stop the entire pipeline for as long as the read takes ... which may or may not be ideal depending on what you are doing. Let us know if this would be useful to you.

STeven.
aldofad from Italy  [3 posts] 13 year
Hi Steven,
I'm successfully using Java with Roborealm and I've no problems managing this situation from my side with or without any lock on Roborealm.

Your point of view is correct, however it should be ok to provide a .lock() method on the API even if it stops the main pipeline since the final Roborealm's purpose in my situation is to provide variables informations to the program I'm writing.

Many thanks,
aldo
Anonymous 13 year
Aldo,

We added a pause and resume function as part of the API. This is similar to a lock but is more appropriate to what is happening within RR. See the API.zip download at

http://www.roborealm.com/downloads/API.zip

to see these two new routines. You will also have to download 2.37.9 to have the updated API in RR.

Note that just in the same way as a unlock is needed you will have to ensure a resume is called before normal operation can continue.

Let us know if you need anything else.

STeven.
aldofad from Italy  [3 posts] 13 year
That's a very fast and good job Steven, thanks.
I imagine that the two new methods are relatively:

public boolean pause() {...<request><pause></pause></request>...}
public boolean resume() {...<request><resume></resume></request>...}

Thanks again,
aldo
Anonymous 13 year
That's correct!

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index