> For the complete documentation index, see [llms.txt](https://support.powerio.com/hub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.powerio.com/hub/codesys-hvac/en/hvac-library/functionblocks/clock/switchtimes.md).

# SwitchTimeS

## `SwitchTimeS` (FB)

FUNCTION\_BLOCK SwitchTimeS

### Short description

> Time switch with 5 adjustable time periods and binary output.\
> Each time period is defined by an ON time / OFF time and a date.

### Representation

<figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-8e9b25951ebbfd7f18f5ba5857cec1591c4e886c%2FSwitchTimeS_FB.png?alt=media" alt=""><figcaption></figcaption></figure>

### Interfaces

#### Inputs

| Name  | Data type | Value range | Initial value | Function     |
| ----- | --------- | ----------- | ------------- | ------------ |
| *xEn* | BOOL      |             |               | Enable input |

#### Outputs

| Name               | Data type | Value range | Initial value | Function                                                          |
| ------------------ | --------- | ----------- | ------------- | ----------------------------------------------------------------- |
| *xActive*          | BOOL      |             |               | Display of active time periods                                    |
| *todActivatedFrom* | TOD       |             |               | Switch-on time of the last active time period of the current day  |
| *todActivatedTo*   | TOD       |             |               | Switch-off time of the last active time period of the current day |

#### Setpoints / Parameters

| Name                 | Data type | Value range | Initial value   | Function                         |
| -------------------- | --------- | ----------- | --------------- | -------------------------------- |
| **datCH1\_Date**     | DATE      |             | DATE#2022-01-01 | Date of time period 1            |
| **todCH1\_TimeFrom** | TOD       |             | TOD#07:00       | Switch-on time of time period 1  |
| **todCH1\_TimeTo**   | TOD       |             | TOD#12:00       | Switch-off time of time period 1 |
| **xCH1\_Mode**       | BOOL      |             | TRUE            | Display mode for time period 1   |
| **sCH1\_Notice**     | STRING    |             | ‘Notice’        | Text for time period 1           |
| **datCH2\_Date**     | DATE      |             | DATE#2022-01-01 | Date of time period 2            |
| **todCH2\_TimeFrom** | TOD       |             | TOD#07:00       | Switch-on time of time period 2  |
| **todCH2\_TimeTo**   | TOD       |             | TOD#12:00       | Switch-off time of time period 2 |
| **xCH2\_Mode**       | BOOL      |             | TRUE            | Display mode for time period 2   |
| **sCH2\_Notice**     | STRING    |             | ‘Notice’        | Text for time period 2           |
| **datCH3\_Date**     | DATE      |             | DATE#2022-01-01 | Date of time period 3            |
| **todCH3\_TimeFrom** | TOD       |             | TOD#07:00       | Switch-on time of time period 3  |
| **todCH3\_TimeTo**   | TOD       |             | TOD#12:00       | Switch-off time of time period 3 |
| **xCH3\_Mode**       | BOOL      |             | TRUE            | Display mode for time period 3   |
| **sCH3\_Notice**     | STRING    |             | ‘Notice’        | Text for time period 3           |
| **datCH4\_Date**     | DATE      |             | DATE#2022-01-01 | Date of time period 4            |
| **todCH4\_TimeFrom** | TOD       |             | TOD#07:00       | Switch-on time of time period 4  |
| **todCH4\_TimeTo**   | TOD       |             | TOD#12:00       | Switch-off time of time period 4 |
| **xCH4\_Mode**       | BOOL      |             | TRUE            | Display mode for time period 4   |
| **sCH4\_Notice**     | STRING    |             | ‘Notice’        | Text for time period 4           |
| **datCH5\_Date**     | DATE      |             | DATE#2022-01-01 | Date of time period 5            |
| **todCH5\_TimeFrom** | TOD       |             | TOD#07:00       | Switch-on time of time period 5  |
| **todCH5\_TimeTo**   | TOD       |             | TOD#12:00       | Switch-off time of time period 5 |
| **xCH5\_Mode**       | BOOL      |             | TRUE            | Display mode for time period 5   |
| **sCH5\_Notice**     | STRING    |             | ‘Notice’        | Text for time period 5           |

### Functional description

#### General

The current time (date / time) is permanently compared with the 5 defined time periods.\
The display output *xActive* takes the state TRUE if, when the enable input is active (*xEn* = TRUE), at least one of the 5 time periods is active.

> **Prerequisite for using the function block SwitchTimeS**
>
> For correct operation, the use of the TimeRead2 function block is required.

#### Enable input *xEn*

| *xEn* | *xActive*                             | *todActivatedFrom*                                               | *todActivatedTo*                                                  | Note           |
| ----- | ------------------------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------- | -------------- |
| FALSE | FALSE                                 | unchanged                                                        | unchanged                                                         | FB deactivated |
| TRUE  | State depending on the 5 time periods | Switch-on time of the last active time period of the current day | Switch-off time of the last active time period of the current day | FB activated   |

#### Display output *xActive*

The display output takes the state TRUE if, when the enable input is active (*xEn* = TRUE), at least one of the 5 time periods is active.

| *xActive* | *xEn* | Time period 1 | Time period 2 | Time period 3 | Time period 4 | Time period 5 | Note                            |
| --------- | ----- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------------------------- |
| FALSE     | FALSE | X             | X             | X             | X             | X             | FB deactivated                  |
| FALSE     | TRUE  | FALSE         | FALSE         | FALSE         | FALSE         | FALSE         | No time period active           |
| TRUE      | TRUE  | FALSE         | FALSE         | TRUE          | FALSE         | FALSE         | At least one time period active |

#### Switch-on time of the last active time period of the current day *todActivatedFrom*

This display output takes the value of the switch-on time of the last active time period if, when the enable input is active (*xEn* = TRUE), the date of the current time matches the date of the time period.\
In all other situations, it is not changed.

#### Switch-off time of the last active time period of the current day *todActivatedTo*

This display output takes the value of the switch-off time of the last active time period if, when the enable input is active (*xEn* = TRUE), the date of the current time matches the date of time period 5.\
In all other situations, it is not changed.

#### Time periods 1 - 5 (X = 1 .. 5)

Each time period is defined by adjustable data (switch-on time **todCHX\_TimeFrom**, switch-off time **todCHX\_TimeTo** and date **datCHX\_Date**)\
In addition, an operating mode (**xCHX\_Mode**) as well as a descriptive text (**sCHX\_Notice**) can be defined.\
If the switch-off time is before the switch-on time, then for the check the switch-off time is set to the value of the switch-on time.\
A time period is active if the current date matches the date of the time period and the time is within the time period (**xCHX\_Mode** = TRUE).\
A time period is active if the current date matches the date of the time period and the time is outside the time period (**xCHX\_Mode** = FALSE).

### Visualization

#### Representation

<figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-fe2a5f9d2d2f49634f47d1073a1bdf1e49cd02bc%2FSwitchTimeS.PNG?alt=media" alt=""><figcaption></figcaption></figure>

#### Interfaces visualization element

| Name                | Data type   | Type         | Initial value | Function                                                                                                                                                                                                                                                                                                     |
| ------------------- | ----------- | ------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **FB\_SwitchTimeS** | SwitchTimeS | VAR\_IN\_OUT |               | Enter FB SwitchTimeS here e.g. PRG.SwitchTimeS                                                                                                                                                                                                                                                               |
| **BMS\_Active**     | BOOL        | VAR\_INPUT   |               | BMS (Building Management System) GLT (building management technology). If BMS\_Active = TRUE, input / editing of the clocks is disabled, since they can then only be set via the BMS. Time values can then only be viewed.                                                                                   |
| **DisableInput**    | BOOL        | VAR\_INPUT   |               | DisableInpput = TRUE times of the weekly clocks can only be viewed and not edited./// - BMS (Building Management System) GLT (Building Management System). When BMS\_Active = TRUE the input/editing of the clocks is disabled because they can then only be set via the BMS. Times can then only be viewed. |

\
Note: VAR\_IN\_OUT interfaces must be assigned; VAR\_INPUT is optional.

### CODESYS

InOut:

| Scope       | Name               | Type     | Initial            |
| ----------- | ------------------ | -------- | ------------------ |
| Input       | `xEn`              | `BOOL`   |                    |
| Input Const | `datCH1_Date`      | `DATE`   | DATE#2022-1-1      |
| Input Const | `todCH1_TimeFrom`  | `TOD`    | TIME\_OF\_DAY#7:0  |
| Input Const | `todCH1_TimeTo`    | `TOD`    | TIME\_OF\_DAY#12:0 |
| Input Const | `xCH1_Mode`        | `BOOL`   | TRUE               |
| Input Const | `sCH1_Notice`      | `STRING` | ‘Notice’           |
| Input Const | `datCH2_Date`      | `DATE`   | DATE#2022-1-1      |
| Input Const | `todCH2_TimeFrom`  | `TOD`    | TIME\_OF\_DAY#7:0  |
| Input Const | `todCH2_TimeTo`    | `TOD`    | TIME\_OF\_DAY#12:0 |
| Input Const | `xCH2_Mode`        | `BOOL`   | TRUE               |
| Input Const | `sCH2_Notice`      | `STRING` | ‘Notice’           |
| Input Const | `datCH3_Date`      | `DATE`   | DATE#2022-1-1      |
| Input Const | `todCH3_TimeFrom`  | `TOD`    | TIME\_OF\_DAY#7:0  |
| Input Const | `todCH3_TimeTo`    | `TOD`    | TIME\_OF\_DAY#12:0 |
| Input Const | `xCH3_Mode`        | `BOOL`   | TRUE               |
| Input Const | `sCH3_Notice`      | `STRING` | ‘Notice’           |
| Input Const | `datCH4_Date`      | `DATE`   | DATE#2022-1-1      |
| Input Const | `todCH4_TimeFrom`  | `TOD`    | TIME\_OF\_DAY#7:0  |
| Input Const | `todCH4_TimeTo`    | `TOD`    | TIME\_OF\_DAY#12:0 |
| Input Const | `xCH4_Mode`        | `BOOL`   | TRUE               |
| Input Const | `sCH4_Notice`      | `STRING` | ‘Notice’           |
| Input Const | `datCH5_Date`      | `DATE`   | DATE#2022-1-1      |
| Input Const | `todCH5_TimeFrom`  | `TOD`    | TIME\_OF\_DAY#7:0  |
| Input Const | `todCH5_TimeTo`    | `TOD`    | TIME\_OF\_DAY#12:0 |
| Input Const | `xCH5_Mode`        | `BOOL`   | TRUE               |
| Input Const | `sCH5_Notice`      | `STRING` | ‘Notice’           |
| Output      | `xActive`          | `BOOL`   |                    |
| Output      | `todActivatedFrom` | `TOD`    |                    |
| Output      | `todActivatedTo`   | `TOD`    |                    |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://support.powerio.com/hub/codesys-hvac/en/hvac-library/functionblocks/clock/switchtimes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
