Convert

Symbol:

Description:

This function block is a converter for all the time based data types. It is possible to convert the data types OLEDATETIME, DT, DATE and TOD into each other and to their corresponding standard data types LONG and DOUBLE. Because the data type TIME represents a duration and not a point in time, it is only possible to convert it into and out of LONG.

This function block can be used to create a copy of time/date value by selecting the same time data type for input and output.

Parameter:

The parameter dialog can be used to select the data type of the input and of the output.

Signals:

Name

I/O

Type(s)

Function

Inp

I

OLEDATETIME, DT, DATE, TOD, TIME, DOUBLE, LONG

Input value

Out

O

OLEDATETIME, DT, DATE, TOD, TIME, DOUBLE, LONG

Converted output value

Visualisation:

The data type for input and output will be depicted at the function block.

Comments:

The data type can also be changed by connecting the input Inp. The connection of a supported data type will be denied, if the output is already connected and the input can't be converted to that data type.

The OLEDATETIME data type covers a much wider range of dates than the LONG based data types. For a conversion of that data type to such a LONG based type it is possible to have a date, that can't be handled by the result data type. In this case the minimum or maximum value of the result data type will be set.

The underlying data type for OLEDATETIME is DOUBLE, which has a broader data range than its defined period of time. The conversion from DOUBLE to OLEDATETIME may result in an outcome beyond/under the defined maximum/minimum. In this case the output will be set to that defined limits.


Get

Symbol:

Description:

This function block reads a subcomponent out of the time/date based data type connected to the input Inp and provides this component at the output Out.

Depending on the actual data type the following components can be selected: year, month, day, day of week, day of year, hour, minute, second, and millisecond.

The day of week is represented by a number between 1 (Sunday) and 7 (Saturday).

The data type TIME represents a duration, but will be interpreted as a structured time data type and its components can be read.

Parameter:

The parameter dialog can be used to select a data type and the component to get from it.

Signals:

Name

I/O

Type(s)

Function

Inp

I

TIME, DATE, TOD, DT, OLEDATETIME

Time/date value

Out

I

WORD

Subcomponent

Visualisation:

The current data type and the component to get will be depicted at the function block.

Comments:

The data type can also be set by connecting the input Inp. If the currently selected subcomponent is not supported by the new data type, the subcomponent will be changed, too.

The underlying data type for OLEDATETIME is DOUBLE, which has a broader data range than its defined period of time. So it is possible to have an invalid date (beyond the maximum or under the minimum) for that data type. In this case the output will be set to -1, regardless of the component to get.


Set date

Symbol:

Description:

This function block sets the components of a date for a data type connected to the input IO. The values of the subcomponents can be set via the input DD, MM, and YY.

For any component input containing a 0 or a negative value (or is not connected at all), this subcomponent will be taken directly out of the data type connected to IO.

The new date to set will always be a valid date, even if the values of the subcomponents are out of proper range. In this case a correct date will be calculated by adjusting the other components:

Day | Month | Year | Date
31 | 4 | 2009 | 01.05.2009
38 | 12 | 2009 | 07.01.2010
1 | 14 | 2009 | 01.02.2010

If the values of the component inputs can't combine directly into a valid date, the output Err will be set to HIGH.

Parameter:

The parameter dialog can be used to select a data type.

Signals:

Name

I/O

Type(s)

Function

IO

I/O

DATE, DT, OLEDATETIME

Date value

DD

I

WORD

Day

MM

I

WORD

Month

YY

I

WORD

Year

Err

O

BIT

Error indication

Visualisation:

The current data type will be depicted on the function block.

Comments:

The data type can also be changed by connecting the input IO.

For the LONG based data types 1970 is the smallest accepted and 2105 is the highest accepted value for the year. For the DOUBLE based data type 100 is the smallest possible and 9999 is the highest possible value for the year. A date beyond/under the defined maximum/minimum will be set to that limit.


Set time

Symbol:

Description:

This function block can set single subcomponents of a time foe the data type connected to the input IO. The value of that component will be set via the input InX.

Depending on the actual data type the following subcomponents can be set: hour, minute, second, millisecond, and day (only for TIME). The data type TIME represents a duration, but will be interpreted as a structured data type with subcomponents, which can be set.

If the value on the input InX is negative, the selected component of the data type will not changed.

The new time will be a valid time, even if the value of the component to set is out of range. In this case a correct time will be calculated by adjusting the other components. If this adjustment results in a point in time of another day, the corresponding date part will be changed, too:

Time | Input | Result
13:25:20 | 60 minutes | 14:00:20
10.07.2009 13:25:30 | 25 hours | 11.07.2009 01:25:20

If the value of the component input will not result directly in a valid time, the output Err will be set to HIGH.

Parameter:

The parameter dialog can be used to select a data type and the component to set.

Signals:

Name

I/O

Type(s)

Function

IO

I/O

TOD, DT, OLEDATETIME, TIME

Time value

InX

I

WORD

Subcomponent

Err

O

BIT

Error indication

Visualisation:

The current data type and the component to set will be depicted at the function block.

Comments:

The data type can also be changed by connecting the input IO.

Because the TIME data type is a LONG based duration in milliseconds, the largest duration is 49 days, 17 hours, 2 minutes, 47 seconds, and 295 milliseconds. The highest possible value to set for a day is therefore 49.

If the setting of a time for the OLEDATETIME data type will result in a date beyond/under the defined maximum/minimum, the output will be set to that limit.

An unconnected input InX will result in the value 0, which is a valid value for all components and will be set.