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: 33
Member Since:
February 11, 2020
sp_UserOnlineSmall Online

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: 267

Currently Online: Matti Siponen, dreampangari
17 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 100

pramanj: 86

ibrahim: 70

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 38

Rainer Versteeg: 32

Thomas Reuther: 26

Member Stats:

Guest Posters: 0

Members: 1069

Moderators: 14

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 992

Posts: 4191

Newest Members:

carmellentz9, dreampangari, wdongjia, sheilalow452740, VivekRangi, mariannassaki, eugeniarobak, susannahmario, ahussnain, vla

Moderators: Jouni Aro: 846, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 540, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 20, Markus Johansson: 18, Matti Siponen: 33, Lusetti: 0

Administrators: admin: 0