astime.fun 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. {REDUND_OK} FUNCTION_BLOCK DTExSetTime (*sets the current time using the DATE_AND_TIME data type*)
  2. VAR_INPUT
  3. enable :BOOL; (*enables execution*)
  4. DT1 :DATE_AND_TIME; (*date and time to be written*)
  5. Option :USINT; (*additional option: timEXSETTIME_NO_OPTION, timEXSETTIME_NO_LOGENTRY*)
  6. END_VAR
  7. VAR_OUTPUT
  8. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, 0xXXXX = see help*)
  9. END_VAR
  10. END_FUNCTION_BLOCK
  11. {REDUND_OK} FUNCTION_BLOCK DTSetTime (*sets current time in DATE_AND_TIME data type*)
  12. VAR_INPUT
  13. enable :BOOL; (*enables execution*)
  14. DT1 :DATE_AND_TIME; (*date and time to be written*)
  15. END_VAR
  16. VAR_OUTPUT
  17. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, 0xXXXX = see help*)
  18. END_VAR
  19. END_FUNCTION_BLOCK
  20. {REDUND_OK} FUNCTION_BLOCK DTGetTime (*reads the current time in the DATE_AND_TIME data type*)
  21. VAR_INPUT
  22. enable :BOOL; (*enables execution*)
  23. END_VAR
  24. VAR_OUTPUT
  25. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, 0xXXXX = see help*)
  26. DT1 :DATE_AND_TIME; (*date and time read*)
  27. END_VAR
  28. END_FUNCTION_BLOCK
  29. {REDUND_OK} FUNCTION clock_ms : TIME (*provides a continuous millisecond counter in the TIME data type*)
  30. END_FUNCTION
  31. {REDUND_OK} FUNCTION_BLOCK UtcDTGetTime (*reads the current UTC-time in the DATE_AND_TIME data type*)
  32. VAR_INPUT
  33. enable :BOOL; (*enables execution*)
  34. END_VAR
  35. VAR_OUTPUT
  36. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, 0xXXXX = see help*)
  37. DT1 :DATE_AND_TIME; (*UTC date and time read*)
  38. END_VAR
  39. END_FUNCTION_BLOCK
  40. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK UtcDTSetTime (*sets current UTC-time in DATE_AND_TIME data type*)
  41. VAR_INPUT
  42. enable :BOOL; (*enables execution*)
  43. DT1 :DATE_AND_TIME; (*UTC date and time to be written*)
  44. END_VAR
  45. VAR_OUTPUT
  46. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, ERR_FUB_BUSY, 0xXXXX = see help*)
  47. END_VAR
  48. VAR
  49. i_state : UINT; (*internal variable*)
  50. i_result : UINT; (*internal variable*)
  51. i_tmp : UDINT; (*internal variable*)
  52. END_VAR
  53. END_FUNCTION_BLOCK
  54. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK UtcDTExSetTime (*sets current UTC-time in DATE_AND_TIME data type*)
  55. VAR_INPUT
  56. enable :BOOL; (*enables execution*)
  57. DT1 :DATE_AND_TIME; (*UTC date and time to be written*)
  58. Option :USINT; (*additional option: timEXSETTIME_NO_OPTION, timEXSETTIME_NO_LOGENTRY*)
  59. END_VAR
  60. VAR_OUTPUT
  61. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, ERR_FUB_BUSY, 0xXXXX = see help*)
  62. END_VAR
  63. VAR
  64. i_state : UINT; (*internal variable*)
  65. i_result : UINT; (*internal variable*)
  66. i_tmp : UDINT; (*internal variable*)
  67. END_VAR
  68. END_FUNCTION_BLOCK
  69. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK DTStructureGetTime (*reads the current time in the calendar structure*)
  70. VAR_INPUT
  71. enable :BOOL; (*enables execution*)
  72. pDTStructure :UDINT; (*address of the calendar structure*)
  73. END_VAR
  74. VAR_OUTPUT
  75. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, 0xXXXX = see help*)
  76. END_VAR
  77. END_FUNCTION_BLOCK
  78. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK DTStructureSetTime (*sets current time in calendar structure*)
  79. VAR_INPUT
  80. enable :BOOL; (*enables execution*)
  81. pDTStructure :UDINT; (*address of the calendar structure*)
  82. END_VAR
  83. VAR_OUTPUT
  84. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, 0xXXXX = see help*)
  85. END_VAR
  86. END_FUNCTION_BLOCK
  87. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK DTStructureExSetTime (*sets current time in calendar structure*)
  88. VAR_INPUT
  89. enable :BOOL; (*enables execution*)
  90. pDTStructure :UDINT; (*address of the calendar structure*)
  91. Option :USINT; (*additional option: timEXSETTIME_NO_OPTION, timEXSETTIME_NO_LOGENTRY*)
  92. END_VAR
  93. VAR_OUTPUT
  94. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, 0xXXXX = see help*)
  95. END_VAR
  96. END_FUNCTION_BLOCK
  97. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK UtcDTStructureGetTime (*reads the UTC time in the calendar structure*)
  98. VAR_INPUT
  99. enable :BOOL; (*enables execution*)
  100. pDTStructure :UDINT; (*address of the calendar structure*)
  101. END_VAR
  102. VAR_OUTPUT
  103. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, 0xXXXX = see help*)
  104. END_VAR
  105. END_FUNCTION_BLOCK
  106. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK UtcDTStructureSetTime (*sets UTC time in calendar structure*)
  107. VAR_INPUT
  108. enable :BOOL; (*enables execution*)
  109. pDTStructure :UDINT; (*address of the calendar structure*)
  110. END_VAR
  111. VAR_OUTPUT
  112. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, ERR_FUB_BUSY, 0xXXXX = see help*)
  113. END_VAR
  114. VAR
  115. i_state : UINT; (*internal variable*)
  116. i_result : UINT; (*internal variable*)
  117. i_tmp : UDINT; (*internal variable*)
  118. END_VAR
  119. END_FUNCTION_BLOCK
  120. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK UtcDTStructureExSetTime (*sets UTC time in calendar structure*)
  121. VAR_INPUT
  122. enable :BOOL; (*enables execution*)
  123. pDTStructure :UDINT; (*address of the calendar structure*)
  124. Option :USINT; (*additional option: timEXSETTIME_NO_OPTION, timEXSETTIME_NO_LOGENTRY*)
  125. END_VAR
  126. VAR_OUTPUT
  127. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, ERR_FUB_BUSY, 0xXXXX = see help*)
  128. END_VAR
  129. VAR
  130. i_state : UINT; (*internal variable*)
  131. i_result : UINT; (*internal variable*)
  132. i_tmp : UDINT; (*internal variable*)
  133. END_VAR
  134. END_FUNCTION_BLOCK
  135. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK UtcDT_TO_LocalDTStructure (*sets current UTC-time in DATE_AND_TIME data type*)
  136. VAR_INPUT
  137. enable :BOOL; (*enables execution*)
  138. DT1 :DATE_AND_TIME; (*UTC date and time*)
  139. pDTStructure :UDINT; (*address of the calendar structure*)
  140. END_VAR
  141. VAR_OUTPUT
  142. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, ERR_FUB_BUSY, 0xXXXX = see help*)
  143. END_VAR
  144. VAR
  145. i_state : UINT; (*internal variable*)
  146. i_result : UINT; (*internal variable*)
  147. i_tmp : UDINT; (*internal variable*)
  148. END_VAR
  149. END_FUNCTION_BLOCK
  150. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK LocalDT_TO_UtcDTStructure (*sets current UTC-time in DATE_AND_TIME data type*)
  151. VAR_INPUT
  152. enable :BOOL; (*enables execution*)
  153. DT1 :DATE_AND_TIME; (*Local date and time*)
  154. pDTStructure :UDINT; (*address of the calendar structure*)
  155. END_VAR
  156. VAR_OUTPUT
  157. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, ERR_FUB_BUSY, 0xXXXX = see help*)
  158. END_VAR
  159. VAR
  160. i_state : UINT; (*internal variable*)
  161. i_result : UINT; (*internal variable*)
  162. i_tmp : UDINT; (*internal variable*)
  163. END_VAR
  164. END_FUNCTION_BLOCK
  165. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK UtcDTStructure_TO_LocalDT (*sets current UTC-time in DATE_AND_TIME data type*)
  166. VAR_INPUT
  167. enable :BOOL; (*enables execution*)
  168. pDTStructure :UDINT; (*address of the calendar structure*)
  169. END_VAR
  170. VAR_OUTPUT
  171. DT1 :DATE_AND_TIME; (*Local date and time*)
  172. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, ERR_FUB_BUSY, 0xXXXX = see help*)
  173. END_VAR
  174. VAR
  175. i_state : UINT; (*internal variable*)
  176. i_result : UINT; (*internal variable*)
  177. i_tmp : UDINT; (*internal variable*)
  178. END_VAR
  179. END_FUNCTION_BLOCK
  180. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK LocalDTStructure_TO_UtcDT (*sets current UTC-time in DATE_AND_TIME data type*)
  181. VAR_INPUT
  182. enable :BOOL; (*enables execution*)
  183. pDTStructure :UDINT; (*address of the calendar structure*)
  184. END_VAR
  185. VAR_OUTPUT
  186. DT1 :DATE_AND_TIME; (*UTC date and time*)
  187. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, ERR_FUB_BUSY, 0xXXXX = see help*)
  188. END_VAR
  189. VAR
  190. i_state : UINT; (*internal variable*)
  191. i_result : UINT; (*internal variable*)
  192. i_tmp : UDINT; (*internal variable*)
  193. END_VAR
  194. END_FUNCTION_BLOCK
  195. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION ascTIMEStructure : UDINT (*converts a "time" structure to a character string in the format "15:14:13\0"*)
  196. VAR_INPUT
  197. pTIMEStructure :UDINT; (*address of the time structure*)
  198. pStr :UDINT; (*address of the character field*)
  199. len :UDINT; (*length of the character field *)
  200. END_VAR
  201. END_FUNCTION
  202. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION ascDTStructure : UDINT (*converts a "date" structure to a character string in the format "Sun Jan 3 15:14:13 1988\0"*)
  203. VAR_INPUT
  204. pDTStructure :UDINT; (*address of the calendar structure *)
  205. pStr :UDINT; (*address of the character field*)
  206. len :UDINT; (*length of the character field*)
  207. END_VAR
  208. END_FUNCTION
  209. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION ascTIME : UDINT (*converts the TIME data type to a character string in the format "15:14:13\0"*)
  210. VAR_INPUT
  211. TIME1 :TIME; (*time*)
  212. pStr :UDINT; (*address of the character field*)
  213. len :UDINT; (*length of the character field*)
  214. END_VAR
  215. END_FUNCTION
  216. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION ascDT : UDINT (*converts the DATE_AND_TIME data type to character string in the format "Sun Jan 3 15:14:13 1988\0"*)
  217. VAR_INPUT
  218. DT1 :DATE_AND_TIME; (*date and time*)
  219. pStr :UDINT; (*address of the character field*)
  220. len :UDINT; (*length of the character field*)
  221. END_VAR
  222. END_FUNCTION
  223. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION TIMEStructure_TO_TIME : TIME (*converts a "time" structure to the TIME data type*)
  224. VAR_INPUT
  225. pTIMEStructure :UDINT; (*address of the time structure*)
  226. END_VAR
  227. END_FUNCTION
  228. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION TIME_TO_TIMEStructure : UDINT (*converts the TIME data type to a "time" structure*)
  229. VAR_INPUT
  230. TIME1 :TIME; (*time*)
  231. pTIMEStructure :UDINT; (*address of the calendar structure*)
  232. END_VAR
  233. END_FUNCTION
  234. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION DTStructure_TO_DT : DATE_AND_TIME (*converts a "date" structure to the DATE_AND_TIME data type*)
  235. VAR_INPUT
  236. pDTStructure :UDINT; (*address of the calendar structure*)
  237. END_VAR
  238. END_FUNCTION
  239. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION DT_TO_DTStructure : UDINT (*converts the DATE_AND_TIME data type to a "date" structure*)
  240. VAR_INPUT
  241. DT1 :DATE_AND_TIME; (*date and time*)
  242. pDTStructure :UDINT; (*address of the calendar structure*)
  243. END_VAR
  244. END_FUNCTION
  245. {REDUND_OK} FUNCTION DiffT : UDINT (*shows the difference between two times (TIME data type) expressed in milliseconds*)
  246. VAR_INPUT
  247. TIME2 :TIME; (*time 2*)
  248. TIME1 :TIME; (*time 1*)
  249. END_VAR
  250. END_FUNCTION
  251. {REDUND_OK} FUNCTION DiffDT : UDINT (*shows the difference between two times (DATE_AND_TIME data type) expressed in seconds*)
  252. VAR_INPUT
  253. DT2 :DATE_AND_TIME; (*date and time 2*)
  254. DT1 :DATE_AND_TIME; (*date and time 1*)
  255. END_VAR
  256. END_FUNCTION
  257. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK TimeDeviceGetInfo (*read information about time device*)
  258. VAR_INPUT
  259. enable :BOOL; (*enables execution*)
  260. pServer :UDINT; (*Pointer to string*)
  261. len :USINT; (*length of pServer*)
  262. END_VAR
  263. VAR_OUTPUT
  264. timeDevice :USINT; (*sntpREAL_TIME_CLOCK or sntpTIME_SERVER*)
  265. avgDeviation :REAL; (*average deviation between software time and time device*)
  266. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, ERR_FUB_BUSY, 0xXXXX = see help*)
  267. END_VAR
  268. VAR
  269. i_state :UINT; (*internal variable*)
  270. i_result :UINT; (*internal variable*)
  271. i_tmp :UDINT; (*internal variable*)
  272. END_VAR
  273. END_FUNCTION_BLOCK
  274. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK DstGetInfo (*read information about time device*)
  275. VAR_INPUT
  276. enable :BOOL; (*enables execution*)
  277. pDTStructure :UDINT; (*Pointer to DTStructure*)
  278. END_VAR
  279. VAR_OUTPUT
  280. dstState :USINT; (*timDAYLIGHT_SAVING_TIME, timNORMAL_TIME or timNO_DST*)
  281. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, ERR_FUB_BUSY, 0xXXXX = see help*)
  282. END_VAR
  283. VAR
  284. i_state :UINT; (*internal variable*)
  285. i_result :UINT; (*internal variable*)
  286. i_tmp :UDINT; (*internal variable*)
  287. END_VAR
  288. END_FUNCTION_BLOCK
  289. {REDUND_CONTEXT} {REDUND_UNREPLICABLE} FUNCTION_BLOCK DstGetInfoDT (*read information about time device*)
  290. VAR_INPUT
  291. enable :BOOL; (*enables execution*)
  292. DT1 :DATE_AND_TIME; (*date and time in UTC*)
  293. END_VAR
  294. VAR_OUTPUT
  295. dstState :USINT; (*timDAYLIGHT_SAVING_TIME, timNORMAL_TIME or timNO_DST*)
  296. status :UINT; (*execution status: ERR_OK, ERR_FUB_ENABLE_FALSE, ERR_FUB_BUSY, 0xXXXX = see help*)
  297. END_VAR
  298. VAR
  299. i_state :UINT; (*internal variable*)
  300. i_result :UINT; (*internal variable*)
  301. i_tmp :UDINT; (*internal variable*)
  302. END_VAR
  303. END_FUNCTION_BLOCK