View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006218 | Compliance Test Tool (CTT) Unified Architecture | 3 - Feature Request | public | 2020-11-06 08:24 | 2022-08-05 15:46 |
Reporter | Thomas Reuther | Assigned To | Alexander Allmendinger | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | assigned | Resolution | open | ||
Platform | Windows 7 | OS | Windows 7 | OS Version | 6.1.7601 |
Product Version | 1.03.341.396 | ||||
Summary | 0006218: Unable to create UaDateTime object from Long value | ||||
Description | Hello, I want to create a deserializer for a custom data type (structure) which contains a DateTime. I want to use it in a custom test script. With the help of Part 6 document I could successfully decode the binary encoded ExtensionObject. Example: Part 6 says: "A DateTime value shall be encoded as a 64-bit signed integer (see Clause 5.2.2.2) which 119916288000000000 (100 ns) => 11991628800000 ms => 11991628800 s => 138792 days => 380 years My problem is to convert the Long value into a UaDateTime object. My plan is to create a UaDateTime of "1601-01-01" and add that number of nanoseconds. But however I create a UaDateTime object it is of "0001-01-01" istead: UaDateTime.fromString("1601-01-01T00:00:00.000Z") => "0001-01-01T00:00:00.000Z" Is this only a problem of "toString()" method of that object or is the year actually set to "0001"? var minDate = UaDateTime.fromString("1601-01-01T00:00:00.000Z") And actually: when I add the number 11991628800000 (ms) to minDate: minDate.addMilliSeconds( 11991628800000 ) I'll get "1601-01-01T22:15:09.568Z". I wonder how the year has changed from "0001" to "1601". But looking at the other parts of the date it seems that less than 24h were added. | ||||
Additional Information | Is there a problem with the UaDateTime class or do I used it in a wrong way? Is there a Calendar or other helper class? What is the recommend way to calculate a date from nanoseconds? | ||||
Tags | No tags attached. | ||||
Files Affected | |||||
|
Please attach the script code you are trying to use , we lack a point of reference. The CTT has no problems with UaDateTime as we use it. |
|
It is not about an existing script. I want to create a custom script using custom types. One of these types consists of strings and dates. I can successfully encode/decode strings by a look into part 6 "Mappings". I would like to know how I can decode a date. From specification I know a date is encoded as Long, as number of 100 nanos since 1601-01-01. And I know how to convert the byte string into a Long. But then I want to create a DateTime from this number. But I miss such a method. I expect something like: UaDateTime.fromLong(myLong) Is there such a method which I haven't found? What I tried so far (see my first posting) doesn't work. |
|
This is the definition of Part 6: What you are missing is these exception (limits) - so again I ask if you could provide a more concrete example of the structure you are trying to test and the tests you are trying to run for it. To generate an encode number from anything by a string representation of the a date does not make sense since the base time can vary on development platforms (and there are rules on how to handle that). Again we do not have any test cases that would need the functionality you are describing or any structure that would need to be tested that have this type of data. |
|
In a custom script I want to decode a custom data type, which is a structure of strings and a date. I successfully decoded the string part of it. The string can be decoded using UaByteSting.utf8ToString(). The length of a string can be decoded by UaByString.toUInt32(). But how to decode a date? For example I get "000006853A07AA01" (the date time fraction of the custom structure). I expect(ed) to find a helper function like UaByteString.toDateTime() which returns a UaDateTime object. But UaByteString only supports encoding/decoding of String and UInt32 by using get and set. So I started with my own decoder. At first I convert that hex string into a Long. The Long representation of that byte string above is 119916288000000000. Now I expect a helper function to convert this Long value into a UaDateTime, for example UaDateTime.fromLong() or UaDateTime.fromNanos(). There are some addXxx() functions, but no addNanos(). Then I tried this: var d = Constants.DateTime_Min(); But it doesn't work. My question: Is there anything available that helps me converting a Long (=Int64) into a UaDateTime? Our servers have a couple of custom structs which I want/need to use in custom scripts. |
|
So after a discussion in the cmp group - we think this might be what you are having an issue with: |
|
Yes, I can decode the datetime part to Int64. And yes, UA Expert can display values of such variables. I wasn't aware of platform dependent issues. I use the Windows platform. I was also using Linux, but there is not update since CTT version 1.02.x. It would be great when CTT becomes able to decode custom structs. At first I would like to have a Calendar class to calculate dates: '01.01.1601' + 119916288000000000 (nanos) = '01.01.1981' and vice versa for encoding. |
|
Updated the CTT to be able to decode custom structure in a future release (this will help with companion specification testing , not just vendor specific structures) |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-11-06 08:24 | Thomas Reuther | New Issue | |
2020-11-23 14:07 | Paul Hunkar | Status | new => feedback |
2020-11-23 14:07 | Paul Hunkar | Note Added: 0013284 | |
2020-11-24 11:02 | Thomas Reuther | Note Added: 0013293 | |
2020-11-24 11:02 | Thomas Reuther | Status | feedback => new |
2020-11-30 18:58 | Paul Hunkar | Assigned To | => Paul Hunkar |
2020-11-30 18:58 | Paul Hunkar | Status | new => feedback |
2020-11-30 18:58 | Paul Hunkar | Note Added: 0013317 | |
2020-12-01 11:52 | Thomas Reuther | Note Added: 0013319 | |
2020-12-01 11:52 | Thomas Reuther | Status | feedback => assigned |
2020-12-03 19:10 | Paul Hunkar | Status | assigned => feedback |
2020-12-03 19:10 | Paul Hunkar | Note Added: 0013370 | |
2020-12-07 12:43 | Thomas Reuther | Note Added: 0013377 | |
2020-12-07 12:43 | Thomas Reuther | Status | feedback => assigned |
2021-02-20 05:54 | Paul Hunkar | Category | 1 - Script Issue => 3 - Feature Request |
2021-02-20 05:55 | Paul Hunkar | Status | assigned => acknowledged |
2021-02-20 05:55 | Paul Hunkar | Note Added: 0013757 | |
2021-02-20 05:56 | Paul Hunkar | Assigned To | Paul Hunkar => |
2022-08-05 15:46 | Paul Hunkar | Assigned To | => Alexander Allmendinger |
2022-08-05 15:46 | Paul Hunkar | Status | acknowledged => assigned |