NEQL Query returns incorrect values

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.
:slightly_smiling_face:

1 Like

So your query is not updating even when you run it? (specifically when you run the query in quick succession)
Maybe its a synchronization issue. BQL and NEQL queries are inherently slow. It would help to know how the code is structured.

1 Like

I believe you are right - that a query returns current values and if the point hadn’t been otherwise subscribed then the value may be “old.” Temporarily leasing or otherwise making a proxy point update will bring timing issues into play. Do you get the same table returned when you run your query in the search service?

1 Like

Hi all,
Sorry for the late response, I have been away for a while.
I managed to get this to work by creating a topic pin on my module that I can fire when I need to update the driver points, I link this topic pin to the “Force Update Niagara Proxy Points” action pin and it works.
Interestingly I was manually firing this action when I first did this and despite the points updating the new values were not visible in my block, I am not sure why this is but I have it working, thanks for all the suggestions.