Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Date and Time Function Blocks(Function blocks for accessing system date and time information)
Date and Time Function Blocks [message #1830025] Thu, 16 July 2020 02:40 Go to next message
NOJA Power is currently offline NOJA PowerFriend
Messages: 15
Registered: May 2020
Junior Member
Hi,

I downloaded the latest forte source and looked around in the function block modules but I didn't see anything in there for accessing system date and time information.

I'm wondering if you think it might be worth while adding some function blocks to the library to access system date and time information?

Use case examples:


  • Perform an operation every Monday between 9:00pm and 9:15pm local time
  • Latch unique monotonic time stamp with an operation
  • Change a setting based on season (Summer, Autumn, Winter, Spring)


Here are 3 function block examples that might address use cases.

Date/Time

The Date Time function block can represent current system date and time in 4DIAC data types.

The Date Time function block is subject to clock change by NTP, Daylight Savings Time, user or other updates. Where a monotonic time is required, refer to Monotonic Time function block.

index.php/fa/38589/0/

Local Time

The Local Time function block can represent current system date and time in broken down time components.

The Local Time function block is subject to clock change by NTP, Daylight Savings Time, user or other updates. Where a monotonic time is required, refer to Monotonic Time function block.

index.php/fa/38590/0/

Monotonic Time

Monotonic time can be described as:


  • Clock that cannot be set and represents monotonic time since some unspecified starting point.
  • A monotonic clock is a time source that will never jump forward or backward (due to NTP, Daylight Savings Time, user or other updates).


index.php/fa/38591/0/

Thank you
Re: Date and Time Function Blocks [message #1830060 is a reply to message #1830025] Thu, 16 July 2020 14:10 Go to previous messageGo to next message
Martin Melik-Merkumians is currently offline Martin Melik-MerkumiansFriend
Messages: 96
Registered: March 2016
Member
Hi,

this need is already addressed via the NOW and NOW_MONOTONIC functions available, which give you either the date and current time (as far as I remember in your current locale) or a monotonic time from a specified point of time (depending on OS and hardware) which has no direct correlation to the current time.

The idea of all these different time based data types are the use cases you mentioned. You can get the current date and time via the NOW function, returning a DATE_AND_TIME which can be explicitly cast into other data types which represent dates, i.e. DATE and TIME_OF_DAY
The TIME data type is not a specific date, but a time span, so the NOW_MONOTONIC returns a TIME with the time span since the starting point for the monotonic time start.

This also leads to a problem with your first FB_NOJA_DateTime, which returns a DATE, DATE_AND_TIME, TIME_OF_DAY, and TIME. The TIME type is incompatible with the other ones as it is a time span. Also, the other outputs can be generated via DT_TO_XXX cast FBs, so no need for providing all of them. As far as I see, it seems that no cast FBs are available right now, but can be easily created by wrapping a cast operator into a FB.
So if you are in need for such an FB, the best solution from my point of view would be to wrap the NOW function into an FB with a single DATE_AND_TIME output.

For monotonic time you can wrap the NOW_MONOTONIC function into an FB with a single TIME output (which replaces your third FB).

For your second FB, I do not see a use case, as you can compare two DATE_AND_TIME, DATE, and TIME_OF_DAY and you can also calculate the differences between dates, and most of the other information is included in the output of NOW or can easily calculated from it.

If you need time spans (TIME) as numbers (ANY_INT or ANY_REAL), there is a set of conversion FBs available in modules\IEC61131-3\Conversion\TIME, which clearly specify which time-base is used for the conversion.

Best regards,
Martin
Re: Date and Time Function Blocks [message #1830296 is a reply to message #1830060] Thu, 23 July 2020 00:44 Go to previous message
NOJA Power is currently offline NOJA PowerFriend
Messages: 15
Registered: May 2020
Junior Member
Hi,

Yes, I have seen the NOW and NOW_MONOTONIC functions. However, I cannot see a standard function block that provides this system time information to applications developed via IDE.

I'm wondering if you think it might be worth while adding some function blocks to the library to access system date and time information?

Thank you.
Previous Topic:freertos and socket
Next Topic:4diac Client and Python Server
Goto Forum:
  


Current Time: Wed Oct 28 14:02:37 GMT 2020

Powered by FUDForum. Page generated in 0.02104 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top