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
HIstoryReadRaw returning no response for a givven startTime endTime
February 7, 2022
10:00, EET
Avatar
aneeta.antony@bakerhughes.com
New Member
Members
Forum Posts: 2
Member Since:
October 18, 2021
sp_UserOfflineSmall Offline

Hello All,
Trying to gert History data for a NodeId form our OPCUA server form the client side and we are not getting proper response for the API.
The function we use is :-
DataValue[] dataValues = client.historyReadRaw(nodeId,startDateTime,endDateTime,
UnsignedInteger.MAX_VALUE, true, null, TimestampsToReturn.Server);

startTime: 02/04/22 05: 33: 43.7150000 GMT , endTime : 02/04/22 05: 38: 43.7150000

Response: obtained for a NodeId we are trying to read —->
[ DataValue(value=(null), statusCode=Bad_BoundNotFound (0x80D70000) “No data found to provide upper or lower bound value.”, sourceTimestamp=02/04/22 05: 33: 43.7150000 GMT, sourcePicoseconds=0, serverTimestamp=02/04/22 05: 33: 43.7150000 GMT, serverPicoseconds=0),
DataValue(value=(null), statusCode=Bad_BoundNotFound (0x80D70000) “No data found to provide upper or lower bound value.”, sourceTimestamp=02/04/22 05: 38: 43.7150000 GMT, sourcePicoseconds=0, serverTimestamp=02/04/22 05: 38: 43.7150000 GMT, serverPicoseconds=0) ]

For the given time frame , UAExpert UA client we verified to obtain response
Can you please suggest why this is happening?
I have doubts regarding the StartTime we pass in htis API , observing that GMT time is passed, could that be any issue of getting response form the server located in CST tiezone?
Another question is the prameter TimeStampToReturn.Server dosent seem to work , because i always get back GMT timezone.
any leads is appreciated.

Thanks in Advance
Aneeta Antony

February 8, 2022
11:11, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

There are 2 separate things I need to address.

1. There are no timezones “per se” in OPC UA. The OPC UA DateTime type is always in UTC, thus you must always give the data in UTC and handle it as UTC “SDK-wise”. How exactly that data is then visualized or constructed is up to you. Did you try with https://www.prosysopc.com/products/opc-ua-browser/ ? In general UIs typically might visualize the data in local timezone, but internally it is still UTC.

2. The com.prosysopc.ua.stack.builtintypes.DateTime class has a lot of … legacy, about 15 years I think. In my personal opinion, it is not very good in todays when compared to e.g. java.time.* APIs.

Longer explanations with a lot of personal opinions:

1.
DateTime is always transferred in UTC timezone: https://reference.opcfoundation.org/Core/docs/Part6/5.2.2/#5.2.2.5.

The com.prosysopc.ua.stack.builtintypes.DateTime holds the value also in UTC. “OPC UA Epoch” is “1601-01-01 12:00AM UTC” and the resoultion is 100s of nanoseconds from that. It is one of the things OPC UA “inherited” from OPC Classic. It is basically Windows FILETIME: https://docs.microsoft.com/en-us/previous-versions/aa915351(v=msdn.10)?redirectedfrom=MSDN.

The “Java Epoch” (or Unix Epoch https://en.wikipedia.org/wiki/Unix_time) is the more common in java based APIs. In java the resolution is typically milliseconds (or java.time.Instant has nanosecond resolution). Also, the data is “in UTC” or “timezoneless, but interpret as UTC” data, e.g. see System.currentTimeMillis.

2.
I would personally try to avoid using the com.prosysopc.ua.stack.builtintypes.DateTime directly, basically only use it if you do not have anything better (obiviously you need it to the API itself). If you are on Java8+ just use java.time.* in your application logic and just convert the data to DateTime whenever needed for SDK APIs. If you are on pre-Java-8 consider maybe consider https://www.joda.org/joda-time/ (though I have not personally used that, I believe it was what did lead to java.time being made).

Due to historical reasons, the DateTime class has APIs for both OPC UA and Java Epochs. Yes, it is a mess and can be very confusing. Anyway, regardless of which epoch, the data must always be given in UTC. In general, I would personally say it is a good idea in general to keep all “application data” in UTC and only visualize it in local timezones. The java.time.* has great tools for that (that is outside the scope of this answer however). One exception might be writing local-timezone-only-read files, but that is also outside of the scope.

If millisecond resolution is enough, you can use java.time.Instant.toEpochMilli() and static DateTime.fromMillis(long) + DateTime.getTimeInMillis().

Hopefully some day we can get rid of com.prosysopc.ua.stack.builtintypes.DateTime completely. Or just have conversion methods to/from Instant. In PubSubDataValue we used Instant, as it is in Java 8+ land, but the rest of the SDK is Java 6+ currently.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
28 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

TimK: 41

Member Stats:

Guest Posters: 0

Members: 681

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com

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

Administrators: admin: 1