<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to real number to Timestamp</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3ce7a6cf83/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3ce7a6cf83/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/3ce7a6cf83/</id><updated>2021-10-28T13:52:27.365000Z</updated><subtitle>Recent posts to real number to Timestamp</subtitle><entry><title>real number to Timestamp</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3ce7a6cf83/?limit=25#e297" rel="alternate"/><published>2021-10-28T13:52:27.365000Z</published><updated>2021-10-28T13:52:27.365000Z</updated><author><name>Inna</name><uri>https://forge.codesys.com/u/inna/</uri></author><id>https://forge.codesys.comf252ba5c379c3affbed88f93f512d48701b14cde</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks.&lt;br/&gt;
I'll try it.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>real number to Timestamp</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3ce7a6cf83/?limit=50#2ecc" rel="alternate"/><published>2021-10-28T12:31:21.262000Z</published><updated>2021-10-28T12:31:21.262000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.com0f19b1bb5d50ea11d5d5cc22f683119a1e708af6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;What about this?&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;TYPE&lt;/span&gt; &lt;span class="nt"&gt;TIMESTAMP_UNION&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="nt"&gt;UNION&lt;/span&gt;
    &lt;span class="nt"&gt;As2RealS&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;       &lt;span class="nt"&gt;TIMESTAMPASREAL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;AsTimeStamp&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="nt"&gt;TIMESTAMP&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;AsHex&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;          &lt;span class="nt"&gt;TIMESTAMPASHEX&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_UNION&lt;/span&gt;
&lt;span class="nt"&gt;END_TYPE&lt;/span&gt;

&lt;span class="nt"&gt;TYPE&lt;/span&gt; &lt;span class="nt"&gt;TIMESTAMPASREAL&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="nt"&gt;STRUCT&lt;/span&gt;
    &lt;span class="nt"&gt;Real1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;REAL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;Real2&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;REAL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_STRUCT&lt;/span&gt;
&lt;span class="nt"&gt;END_TYPE&lt;/span&gt;

&lt;span class="nt"&gt;TYPE&lt;/span&gt; &lt;span class="nt"&gt;TIMESTAMPASHEX&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="nt"&gt;STRUCT&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;attribute&lt;/span&gt; &lt;span class="err"&gt;'displaymode':='hex'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;Byte1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;attribute&lt;/span&gt; &lt;span class="err"&gt;'displaymode':='hex'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;Byte2&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;attribute&lt;/span&gt; &lt;span class="err"&gt;'displaymode':='hex'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;Byte3&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;attribute&lt;/span&gt; &lt;span class="err"&gt;'displaymode':='hex'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;Byte4&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;attribute&lt;/span&gt; &lt;span class="err"&gt;'displaymode':='hex'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;Byte5&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;attribute&lt;/span&gt; &lt;span class="err"&gt;'displaymode':='hex'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;Byte6&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;attribute&lt;/span&gt; &lt;span class="err"&gt;'displaymode':='hex'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;Byte7&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;attribute&lt;/span&gt; &lt;span class="err"&gt;'displaymode':='hex'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;Byte8&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_STRUCT&lt;/span&gt;
&lt;span class="nt"&gt;END_TYPE&lt;/span&gt;

&lt;span class="nt"&gt;TYPE&lt;/span&gt; &lt;span class="nt"&gt;TIMESTAMP&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="nt"&gt;STRUCT&lt;/span&gt;
    &lt;span class="nt"&gt;Hour&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;       &lt;span class="nt"&gt;USINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  
    &lt;span class="nt"&gt;Year&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;       &lt;span class="nt"&gt;USINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;Month&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;USINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  
    &lt;span class="nt"&gt;Day&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;        &lt;span class="nt"&gt;USINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;mSec&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;       &lt;span class="nt"&gt;UINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;   
    &lt;span class="nt"&gt;Second&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;     &lt;span class="nt"&gt;USINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  
    &lt;span class="nt"&gt;Minute&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;     &lt;span class="nt"&gt;USINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_STRUCT&lt;/span&gt;
&lt;span class="nt"&gt;END_TYPE&lt;/span&gt;

&lt;span class="nt"&gt;PROGRAM&lt;/span&gt; &lt;span class="nt"&gt;Test_PRG&lt;/span&gt;
&lt;span class="nt"&gt;VAR&lt;/span&gt;
    &lt;span class="nt"&gt;TestTimestamp&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="nt"&gt;TIMESTAMP_UNION&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;As2Reals&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt; 
        &lt;span class="nt"&gt;Real1&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;4&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;14855132E-28&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="nt"&gt;Real2&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;0501924E-25&lt;/span&gt;
    &lt;span class="o"&gt;));&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I had to play around with the byte order in the TIMESTAMP structure, depending on your platform, it might be different, I don't know.  And the TIMESTAMPASHEX struct was just for information, you wouldn't really need it.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>real number to Timestamp</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3ce7a6cf83/?limit=25#c36e" rel="alternate"/><published>2021-10-27T07:27:20.063000Z</published><updated>2021-10-27T07:27:20.063000Z</updated><author><name>Inna</name><uri>https://forge.codesys.com/u/inna/</uri></author><id>https://forge.codesys.com2759190630d5b17337fe9085b5fabf7730b3ab0d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
I have two real numbers that represent timestamp - see the attached screenshot. Is there codesys function or structure that converts 2 real numbers into appropriate timestamp in a resolution of mSec. If codesys has no build-in support for this, what is the better way to perform it in ST?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>