TimerSwitch (FB) ¶ FUNCTION_BLOCK PUBLIC FINAL TimerSwitch EXTENDS CBML.LConC IMPLEMENTS ITimeSwitch, IDateTimeProvider InOut: Scope Name Type Initial Comment Inherited from Input xEnable BOOL TRUE : Activates the defined operation FALSE : Aborts/resets the defined operation LConC Output xBusy BOOL TRUE : Operation is running LConC xError BOOL TRUE : Error condition reached LConC Input Const itfDateTimeProvider IDateTimeProvider Globals.g_dtpDateTimeProvider Source for the current date and time information in milliseconds since 1.1.1970 00:00:00.000 tCompensationSpeed TIME Compensation speed [ms/h] for the transition from one time zone period to another. e.g. t#5000ms => 30d <= 1/(30 × 24) × 60 × 60 × 1000 e.g. t#150000ms => 24h <= 1/24 × 60 × 60 × 1000 Input aslSchedule POINTER TO Schedule Switching Schedule tzTimeZone REFERENCE TO TimeZone Current time zone (Optional - Default: |gc_tzTimeZoneCET| ) Output eErrorID ERROR liClockDiff LINT After switching the time zone, a continuously decreasing difference between the current local time and the current time within the TimeSwitch is displayed. eWeekDay WEEKDAY Current day of the week datToday DATE Current date todNow TOD Current time of the day sTimeZone TZ_NAME Name of the current time zone ePeriod PERIOD Current period of the time zone dwSwitches DWORD Status of the 32 switches. Bit 0 => switch 1, … Methods: GetDateTime Structure: IDateTimeProvider GetDateTime (Method)
IDateTimeProvider ¶ GetDateTime (Method)
Functions ¶ CombineDateTime (Function) DateTimeFromWeek (Function) DayOfWeek (Function) GetDateTime (Function) GetLocalDateTime (Function) GetTimeStampsDifference (Function) IsLeapYear (Function) JoinDateTime (Function) LocalDateTime (Function) SeparateDateTime (Function) SplitDateTime (Function) WeekOfYear (Function)
CombineDateTime (FUN) ¶ FUNCTION CombineDateTime : ULINT Combines the IEC data typed parts to a timestamp. InOut: Scope Name Type Initial Comment Return CombineDateTime ULINT date and time in milliseconds since 1.1.1970 00:00:00.000 Input datDate DATE todTime TOD Output eErrorID ERROR ERROR.NO_ERROR
DateTimeFromWeek (FUN) ¶ FUNCTION DateTimeFromWeek : ULINT Combines the ISO week date parts to a timestamp uiYear := 2009 uiWeek :=1 eWeekday:=WEEKDAY.MONDAY => 29.12.2008 uiYear := 2009 uiWeek :=53 eWeekday:=WEEKDAY.SUNDAY => 03.01.2010 See: https://en.wikipedia.org/wiki/ISO_week_date InOut: Scope Name Type Comment Return DateTimeFromWeek ULINT date and time in milliseconds since 1.1.1970 00:00:00.000 Input uiYear YEAR uiWeek WEEK eWeekday WEEKDAY Output eErrorID ERROR
DayOfWeek (FUN) ¶ FUNCTION DayOfWeek : WEEKDAY Calculates the appropriate value of the WEEKDAY enum that matches the parameter datDate . InOut: Scope Name Type Initial Return DayOfWeek WEEKDAY Input datDate DATE Output eErrorID ERROR ERROR.NO_ERROR
GetDateTime (FUN) ¶ FUNCTION GetDateTime : ULINT Related to UTC this function returns the current date and time in milliseconds since Thursday, 1.1.1970 00:00:00.000, managed in a 64 Bit data type The default IDateTimeProvider implementation ( DateTimeProvider ) is in use InOut: Scope Name Type Comment Return GetDateTime ULINT The current UTC date and time in milliseconds since 1.1.1970 00:00:00.000 Output eErrorID ERROR
GetLocalDateTime (FUN) ¶ FUNCTION GetLocalDateTime : ULINT Related to TimeZone in tzTimeZone this function returns the current date and time in milliseconds since Thursday, 1.1.1970 00:00:00.000, managed in a 64 Bit data type The default IDateTimeProvider implementation ( DateTimeProvider ) is in use InOut: Scope Name Type Comment Return GetLocalDateTime ULINT The current local date and time in milliseconds since 1.1.1970 00:00:00.000 Inout Const tzTimeZone TimeZone Time zone as base for caclulating local time Output eErrorID ERROR
GetTimeStampsDifference (FUN) ¶ FUNCTION GetTimeStampsDifference : ERROR InOut: Scope Name Type Comment Return GetTimeStampsDifference ERROR Input uliDateTimeFirst ULINT First timestamp in milliseconds since 1.1.1970 00:00:00.000 uliDateTimeSecond ULINT Second timestamp in milliseconds since 1.1.1970 00:00:00.000 Output uliDays ULINT Differece of the timestamps in day, hour, minute, second and millisecond uiHours HOUR uiMinutes MINUTE uiSeconds SECOND uiMilliseconds MILLISECOND
IsLeapYear (FUN) ¶ FUNCTION IsLeapYear : BOOL Checks whether the year (uiYear) passed represents a leap year. InOut: Scope Name Type Initial Return IsLeapYear BOOL Input uiYear YEAR Output eErrorID ERROR ERROR.NO_ERROR