Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
read VS readValues ---> Not able to read multiple Data onDataChange without cached Values
July 1, 2020
10:38, EEST
Avatar
Ron Hoppe
New Member
Members
Forum Posts: 1
Member Since:
July 1, 2020
sp_UserOfflineSmall Offline

Hallo,

I’m having trouble reading Data from the OPC UA Server. I have a subscription which gets triggered every minute and is supposed to
read Data from the OPC UA Server. For this action I tried to use the following two methods. (readValues(List) and readAttribute(NodeId, UnsignedInteger).

The first Method uses the Method “readValues” of the UaClient. This Methods reads alle the Values from all the Nodes I need at once and is very fast.
It is exactly what I need, but the is ONE BIG PROBLEM. If the Data I read every Minute changes, the “readValues” Method will not read the changed
new values und just reads the old values. It seems like this methods caches the old value in some way and just retruns me the old values instead of reading
the current values of the nodeId.

Because of this Issue I was forced to use the second Method “readAttribute” which uses the Method “read” of the UaClient. I have to call this Method for every single
Node I want to read the Value from. It does the job an gives me the current Values of the Node. The only problem here is that I now have a single reading request
for every Node and this slows down the reading quit a lot. In my case it takes about 10 times longer than the first Method.

It would be perfect beeing able to disable to caching for the “readValues” Method. This would give me the current Data of the Node in very little time. Please can
someone give me a hint how I can achive this 🙂

protected UaClient client;

public DataValue[] readValues(List nodeids){
NodeId[] nodes= new NodeId[nodeids.size()];
try {
DataValue[] values= client.readValues(nodeids.toArray(nodes));
return values;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}

public DataValue readAttribute(NodeId nodeId, UnsignedInteger attributeId){
ReadResponse response = null;
ReadValueId readValue = new ReadValueId(nodeId, attributeId, null, null);
try {
response= client.read(0.0, TimestampsToReturn.Both, readValue);
DataValue[] values = response.getResults();
return values[0];
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}

July 1, 2020
15:12, EEST
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 319
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

I would first like to ask which version of the Prosys OPC UA SDK for Java you are using? In versions older than 3.2.0, the default value for maximum accepted age of the Value is non-zero, which means caching is used by default when reading Values from a Server. In newer versions, the default value is zero and thus caching isn’t used by default.

By calling UaClient.readValues(NodeId[] nodeIds, NumericRange[] indexRanges, TimestampsToReturn timestamps, Double maxCacheAge) instead of UaClient.readValues(NodeId[] nodeIds), you can use 0 as the value of maxCacheAge to request the Server to return the newest Value instead of a cached Value. You can set timestamps to TimestampsToReturn.Both and indexRanges to null.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
16 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

ibrahim: 75

rocket science: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

TimK: 41

Member Stats:

Guest Posters: 0

Members: 708

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1465

Posts: 6252

Newest Members:

christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer, shanonhumphreys, KupimotoblokfuB, tamhollander5, paulinafcf, bridgette18l

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 982, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 319, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1