
The function block TIMESWITCH_ADD creates or modifies an event in a timer.
Note: The timer must be stored in the same element.
Tip: To modify an event, all values can be read using the function block TIMESWITCH_GET.
The input creates or modifies an event in the calendar on a positive edge. If the input is always true, the event will be created again as soon as it is deleted. Changes to an event are not detected.
Important: Creating and simultaneously deleting should be avoided as this can put a lot of strain on the SSD.
Here, the database of the timer is stored as a string. This must already exist as a function block TIMESWITCH. Also note the order of the program so that this function block is initialized correctly.
Defines the ID as a string for the event. This enables unique identification and prevents other events from causing conflicts. The ID should only consist of letters and numbers. Case sensitivity is observed.
Note: The ID should be uniquely defined for all calendars. An event can be copied by the user in the visualization to another calendar.
The title of the event as a string. This should not contain line breaks. If the input ADD is true, every change is immediately written to the calendar.
The start time of the event in the format DT#. If the input ADD is true, every change is immediately written to the calendar.
Tip: The switching times can be calculated with the function blocks MKTIME, STR2DT and EASTER_DATE.
The end time of the event in the format DT#. If the input ADD is true, every change is immediately written to the calendar. If the end time is less than DT_START, DT_END is defined as the start time.
If the input is not defined, the same value as DT_START is assumed and a pulse is generated for the event.
The input deactivates the event in the calendar. If the input ADD is true, every change is immediately written to the calendar.
At the input, the repetitions can be defined as a string. These can be generated with the helper functions REPEAT_YEARLY, REPEAT_MONTHLY, REPEAT_WEEKLY, REPEAT_DAILY and REPEAT_HOURLY or declared as described.
The string can be separated by a colon as follows:
w:2:4:135
The first digit (lowercase) defines the time interval of the repetition:
| Abbreviation | Time Interval |
|---|---|
| h | Hourly |
| d | Daily |
| w | Weekly |
| m | Monthly |
| y | Yearly |
The second digit defines the interval as an integer of the repetition. The smallest value is 1.
The third digit defines the end of the repetition. Here, three different formats can be defined:
The fourth digit defines the days of the week on which the repetition occurs. This digit is only used when defining weekly or monthly repetitions.
It is checked whether the current day of the week is present in the number. Multiple days can be specified one after the other. For example, 135 for Monday, Wednesday and Friday. If no value is specified (0 or an empty string), repetition does not occur on any day.
| Number | Day of the Week |
|---|---|
| 1 | Monday |
| 2 | Tuesday |
| 3 | Wednesday |
| 4 | Thursday |
| 5 | Friday |
| 6 | Saturday |
| 7 | Sunday |
Defines on which day of the week the event should be repeated. Numbers from -1 to 4 are supported. 0 or no declaration repeats monthly on the same day, regardless of the day of the week. The day of the week is taken from the first date.
| Value | Description |
|---|---|
| -1 | Repeats on the last day of the week. |
| 0 | Repeats on the same day. (Default) |
| 1 | Repeats on the first day of the week. |
| 2 | Repeats on the second day of the week. |
| 3 | Repeats on the third day of the week. |
| 4 | Repeats on the fourth day of the week. |
In case of an error, the output is set to true. This can be if the calendar does not exist or the ID was not defined or invalid.