How to handle timestamps?

HaMo

How to handle timestamps?

Post by HaMo » Wed Oct 22, 2014 9:20 am

Hi all,
try to handle timestamps out of an opc signal.
Result 1413961997087 looks like seconds since 1970 (unix timestamp) or since 1904 Labview time?
Any hints, how to interpred the result?

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: How to handle timestamps?

Post by Marco Grawunder » Wed Oct 22, 2014 9:39 am

Code: Select all

Date date = new Date(1413961997087L);
System.out.println(date);
Wed Oct 22 09:13:17 CEST 2014

It this is from today, these are unix timestamps (i.e. milliseconds since then)

If you want to display in another way, use MAP and corresponding MEP functions:

http://wiki.odysseus.offis.uni-oldenbur ... +Functions

eg. toDate()

HaMo

Re: How to handle timestamps?

Post by HaMo » Tue Nov 18, 2014 10:26 am

And what do I have to do, for instance to write the OPC-DA transmitted timestamp, together with the Odysseus internal timestamp (starttimestamp / endtimestamp) to a datasink (for instance MySQL). Does a join help ?

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: How to handle timestamps?

Post by Marco Grawunder » Tue Nov 18, 2014 10:50 am

If you want to write an OPC timestamp you have to use the map operator timestamp(opcvalue).

If you want to syncronize the Odysseus timestamp with the OPC timestamp then you have to use the TIMESTAMP operator after the map operation.

Code: Select all

mapped = MAP({Expressions=[['timestamp(opcalue)*1000','ts'],['value(opcvalue)','value']]}, opcsource)
stamped = TIMESTAMP({start = 'ts'},mapped)

HaMo

Re: How to handle timestamps?

Post by HaMo » Tue Nov 18, 2014 11:05 am

Sorry, but thats not what I'm searching for.
I don't want to synchronize the both timestamps
I have to add the Odysseus timestamp, as an additonal value, to the MySQL tuple.
Sorry for being not clear enough.

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: How to handle timestamps?

Post by Marco Grawunder » Tue Nov 18, 2014 11:20 am

Ah ok. This can be done with TimestampToPayload

http://wiki.odysseus.offis.uni-oldenbur ... d+operator

HaMo

Re: How to handle timestamps?

Post by HaMo » Tue Nov 18, 2014 12:28 pm

OK, that's what I need,

tried:

Code: Select all

MySQL_Datastream := TIMESTAMPTOPAYLOAD(ModBus_Values)
results in:
Wert1|Wert2|Wert3|meta_valid_start|meta_valid_end|
248| 0| 49|1416305832822| -1 |

Don't need meta_valid_end, for now.
How can I switch it off ?

User avatar
ckuka
Posts: 35
Joined: Tue Jul 29, 2014 10:55 am
Location: Shanghai, P.R. China/中国上海
Contact:

Re: How to handle timestamps?

Post by ckuka » Tue Nov 18, 2014 12:39 pm

Easiest way is a Project operator.

Code: Select all

output = PROJECT({
                  attributes = ['Wert1','Wert2','Wert3','meta_valid_start']
                 }, input)
kind regards / 祝好
Christian Kuka

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: How to handle timestamps?

Post by Marco Grawunder » Tue Nov 18, 2014 12:42 pm

Currently, both values are written. Restriction can be done by an following Project operator.

http://odysseus.offis.uni-oldenburg.de: ... t+operator

If you need only one timestamp you can also use: StreamDate() in a MAP-Function.

HaMo

Re: How to handle timestamps?

Post by HaMo » Tue Nov 18, 2014 12:57 pm

OK, will try this possibilities.
thanks to all

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest