10:00, EET
October 18, 2021
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
11:11, EET
April 3, 2012
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.
Most Users Ever Online: 1919
Currently Online:
12 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: 728
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1