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: 346
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: 1919

Currently Online:
76 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 739

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1524

Posts: 6453

Newest Members:

shaylamaggard4, rickyjuarez140, jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1027, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1