Hi guys, got a new question for you..
I have written a module to query a bunch of points, all the points will have a tag, I use a neql query to look for all points with that tag.
String setQuery = "station:|slot:|neql:be:setpoint";
BOrd ord = BOrd.make(setQuery);
BITable resultSP = (BITable) ord.resolve().get();
I then pass my table to the findPoints method…
JSONArray resultSet = findPoints(resultSP);
if (!resultSet.isEmpty()) {
results.put("setpoints", resultSet);
}
This returns a JSON array …
public JSONArray findPoints(BITable result) {
try {
JSONArray sets = new JSONArray();
TableCursor<BNumericPoint> cursor = result.cursor();
while (cursor.next()) {
JSONObject set = new JSONObject();
BNumericPoint point = cursor.get();
String slots = point.getSlotPath().toString();
double val = point.getOut().getNumeric();
String ordinSes = point.getOrdInSession().toString();
BHistoryId historyId = findHistory(point);
set.put("ord", ordinSes);
set.put("path", slots);
set.put("value", Double.toString(val));
sets.put(set);
}
cursor.close();
return sets;
} catch (Exception e) {
System.out.println("Collect - Failed to find points: " + e.getMessage());
return null;
}
}
So this all works, however the values that get returned are not correct, they do not update from the previous values, if I Force Update the Driver points the query will update.
What I want to know is if there is a way for me in the code above force each point to subscribe before it returns it’s value, that way I get the most up to date value.
EDIT: I should mention that if I run the query again after a few seconds I get the correct and up to date values!
I have been reading about using .lease() and I have added some test code but it had no effect so I have removed it for clarity.
Thanks in advance for any help you can offer.