Let us know
Creating UNIX timestamp as alarm data

This topic will show how to create UNIX timestamp as alarms text.

'11CV – ten thousands part of number of days since 1 January 1970 expressed in second
'12CV – thousands and hundreds part os number of days since 1 January 1970 expressed in second
'13CV – tens and ones part of number of days since 1 January 1970 expressed in second
'14CV – initial 4 digits of UNIX time
'15CV – today number of seconds
'16CV – initial number of seconds from number of days plus today
'17CV – adjusted 4 digits of UNIX time stamp using overflow from number of seconds
'18CV – adjusted 6 digits of UNIX time stamp

RA(DATA:10MB,ALARMS:W144)5S LOGONA

'Work out current days since 1/1/70 (unix 0)
'-------------------------------------------------
12SV(=10CV) 'days since 1/1/89
10CV=10CV+6940 'add difference between 1/1/89 and 1/1/70 (6940)

'Split number of days to keep within the DT number limit when processing
'-----------------------------------------------------------------------
11CV(W)=(10CV-(10CV%10000))*8.64        
12CV(W)=((10CV%10000)-(10CV%100))*864    
13CV(W)=((10CV%100)-(10CV%1))*86400    

'Build first 4 digits (subtotal)
'--------------------------------
14CV("Initial  4 digits",W)=(11CV/100)+((12CV-12CV%10000)/10000)+((13CV-13CV%1000000)/1000000)

'Build last 6 digits (subtotal)
'-------------------------------
T("Current Seconds",=15CV,W)            
16CV("Initial  last digits",W)=((12CV%10000)*100)+(13CV%1000000)+15CV

'Finalise both first 4 digits and last 6 digits
'----------------------------------------------
17CV("Adjusted  4 digits",W)=14CV+(16CV-16CV%1000000)/1000000                        
18CV("Adjusted  6 digits",W)=16CV%1000000

'Get padding for the middle of timestamp, if last 6 digits is small enough
'-------------------------------------------------------------------------
IF(18CV<10){11$="00000"}
IF(18CV><10,100){11$="0000"}
IF(18CV><100,1000){11$="000"}
IF(18CV><1000,10000){11$="00"}
IF(18CV><10000,100000){11$="0"}
IF(18CV><100000,1000000){11$=""}

'Alarm Construction
'--------------------- 
DO1"Timestamp = ?17F0?11$?18F0^M^J"

Notes:
The UNIX timestamp must be stored as alarm text.

Best regards,
Rudy Gunawan

This topic will show how to create UNIX timestamp as alarms text. ```` &#039;11CV &ndash; ten thousands part of number of days since 1 January 1970 expressed in second &#039;12CV &ndash; thousands and hundreds part os number of days since 1 January 1970 expressed in second &#039;13CV &ndash; tens and ones part of number of days since 1 January 1970 expressed in second &#039;14CV &ndash; initial 4 digits of UNIX time &#039;15CV &ndash; today number of seconds &#039;16CV &ndash; initial number of seconds from number of days plus today &#039;17CV &ndash; adjusted 4 digits of UNIX time stamp using overflow from number of seconds &#039;18CV &ndash; adjusted 6 digits of UNIX time stamp RA(DATA:10MB,ALARMS:W144)5S LOGONA &#039;Work out current days since 1/1/70 (unix 0) &#039;------------------------------------------------- 12SV(=10CV) &#039;days since 1/1/89 10CV=10CV+6940 &#039;add difference between 1/1/89 and 1/1/70 (6940) &#039;Split number of days to keep within the DT number limit when processing &#039;----------------------------------------------------------------------- 11CV(W)=(10CV-(10CV%10000))*8.64 12CV(W)=((10CV%10000)-(10CV%100))*864 13CV(W)=((10CV%100)-(10CV%1))*86400 &#039;Build first 4 digits (subtotal) &#039;-------------------------------- 14CV(&quot;Initial 4 digits&quot;,W)=(11CV/100)+((12CV-12CV%10000)/10000)+((13CV-13CV%1000000)/1000000) &#039;Build last 6 digits (subtotal) &#039;------------------------------- T(&quot;Current Seconds&quot;,=15CV,W) 16CV(&quot;Initial last digits&quot;,W)=((12CV%10000)*100)+(13CV%1000000)+15CV &#039;Finalise both first 4 digits and last 6 digits &#039;---------------------------------------------- 17CV(&quot;Adjusted 4 digits&quot;,W)=14CV+(16CV-16CV%1000000)/1000000 18CV(&quot;Adjusted 6 digits&quot;,W)=16CV%1000000 &#039;Get padding for the middle of timestamp, if last 6 digits is small enough &#039;------------------------------------------------------------------------- IF(18CV&lt;10){11$=&quot;00000&quot;} IF(18CV&gt;&lt;10,100){11$=&quot;0000&quot;} IF(18CV&gt;&lt;100,1000){11$=&quot;000&quot;} IF(18CV&gt;&lt;1000,10000){11$=&quot;00&quot;} IF(18CV&gt;&lt;10000,100000){11$=&quot;0&quot;} IF(18CV&gt;&lt;100000,1000000){11$=&quot;&quot;} &#039;Alarm Construction &#039;--------------------- DO1&quot;Timestamp = ?17F0?11$?18F0^M^J&quot; ```` Notes: The UNIX timestamp must be stored as alarm text. Best regards, Rudy Gunawan

Can the results of this calculation be sent using modbus tcp/ip ?

Can the results of this calculation be sent using modbus tcp/ip ?
57
1
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft