# ClockMaster32

## `ClockMaster32` (FB)

FUNCTION\_BLOCK ClockMaster32 EXTENDS LAT.Element IMPLEMENTS IUhrProtocol, IUhr

### Short description

> Master function block for a clock system with 32 weekly timers, 30 public holidays, 10 holiday periods and 5 special switching times.\
> The weekly timers each contain one on- and off-time per weekday (448 switching points).\
> Additionally, 30 public holidays (country-specific), 10 holiday periods (start and end date) and 5 special switching times (on- and off-time as well as date) can be defined.

### Representation

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

### Function description

#### General

This function block serves as the master function block for a clock system with 32 weekly timers, 30 public holidays, 10 holiday periods and 5 special switching times.\
It allows the user (visualization) to set the time and date values and, taking into account the current time and date, provides the resulting states (weekly timer channel 1 - 32, public holiday channel, holiday channel and special switching times channel) to up to 63 slave function blocks ClockSlave32.\
In the slave function blocks, the assignment to the channels (weekly timer channel 1 - 32, public holiday channel, holiday channel and special switching times channel) is then done via binary variables (FALSE = not assigned, TRUE = assigned).\
The connection between the master function block and the slave function blocks is made via the output *itfToClockSlave32* or the inputs \*itfFromClockMaster32 \*.\
The inputs *xAllOn* or *xAllOff* allow (input = TRUE) the central activation / deactivation of all outputs *xClockActive* of all connected slave function blocks.\
The input *xAllOff* is prioritized higher than the input *xAllOn* for setting the time and date values, the following function blocks are used:

Clock7d1Ch

PublicHoliday

Holiday

SwitchTimeS

Example representation in combination with slave clocks:

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

### Visualization

#### Representation

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

> The slave clocks are automatically appended in the order in which they are called in the program. The maximum number is limited to 144 slave clocks in the visualization element. In ClockMaster32 the maximum number can be adjusted via the library constant.

#### Visu-Element interfaces

| Name                  | Data type     | Type         | Initial value | Function                                                                                                                                                                                                      |
| --------------------- | ------------- | ------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **FB\_ClockMaster32** | ClockMaster32 | VAR\_IN\_OUT |               | Enter FB ClockMaster32 here e.g. PRG.ClockMaster32                                                                                                                                                            |
| **BMS\_Active**       | BOOL          | VAR\_INPUT   |               | BMS (Building Management System) GLT (building management). If 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. |
| **DisableInput**      | BOOL          | VAR\_INPUT   |               | DisableInput = TRUE weekly timer times can only be viewed and not edited.                                                                                                                                     |

\
Note: VAR\_IN\_OUT interfaces must be assigned, VAR\_INPUT are optional.

### CODESYS

InOut:

| Scope       | Name                | Type              | Initial                            |
| ----------- | ------------------- | ----------------- | ---------------------------------- |
| Input       | `xAllOn`            | `BOOL`            |                                    |
| Input       | `xAllOff`           | `BOOL`            |                                    |
| Input Const | `eCountry`          | eCountryList      | eCountryList.DE                    |
| Input Const | `ActiveClocksVisu`  | eActiveClocksVisu | eActiveClocksVisu.Activate16Clocks |
| Output      | `itfToClockSlave32` | `IUhrProtocol`    | THIS^                              |
| Output      | `ctClockSlave32`    | `CAA.COUNT`       |                                    |
