TimerSwitch

A timer switch is a clock that switches a number of outputs on or off at set times. The switching times are individually configurable.

The following snippet exposes the definition of a specific TimeZone.

Example

The main islands of New Zealand use New Zealand Standard Time (NZST), 12 hours in advance of UTC. During summer months — from the last Sunday in September until the first Sunday in April — daylight saving time (NZDT) is observed and clocks are advanced one hour.

See: https://en.wikipedia.org/wiki/Time_in_New_Zealand

tzTimeZoneNZST : TimeZone :=
(
    iBias := 12*60 (* T#1M *),
    asgPeriod := [
    ( (* (NZDT -> NZST) - First Sunday in April at 03:00:00.000 (NZDT) *)
        sName:='NZST',
        dtDate := (uiMonth := 4, eWeekday := WEEKDAY.SUNDAY, uiDay := 1, uiHour := 3)
    ),( (* (NZST -> NZDT) - Last Sunday in September at 02:00:00.000 (NZST) *)
        sName := 'NZDT',
        dtDate := (uiMonth := 9, eWeekday := WEEKDAY.SUNDAY, uiDay := 5, uiHour := 2),
        iBias := 60 (* T#1M *)
    )]
);

Bemerkung

Due to current deficiencies in the compiler, no constants can be used for the tzTimeZone input of the TimerSwitch block. It is therefore necessary to declare a variable of type TimeZone and then assign the values of the predefined constants (e.g. TSW.gc_tzTimeZoneCET or TSW.gc_tzTimeZoneUTC) to this variable.

tzTimeZoneUTC : TimeZone := TSW.gc_tzTimeZoneUTC;
myTimerSwitch : TimerSwitch := (tzTimeZone := tzTimeZoneUTC);

Due to another deficiencies in the compiler, the data type of the input aslSchedule of the TimerSwitch block is displayed wrongly. The following would be correct:

FUNCTION_BLOCK PUBLIC FINAL TimerSwitch EXTENDS CBML.LConC IMPLEMENTS ITimeSwitch, IDateTimeProvider
VAR_INPUT CONSTANT
    /// Source for the current date and time information in milliseconds since 1.1.1970 00:00:00.000
    itfDateTimeProvider : IDateTimeProvider := Globals.g_dtpDateTimeProvider;
    /// Compensation speed [ms/h] for the transition from one time zone period to another.
    tCompensationSpeed : TIME;
END_VAR
VAR_IN_OUT (* CONSTANT *)
    /// Switching Schedule
    aslSchedule : ARRAY[*] OF Schedule;
END_VAR

[...]