Step 4: Create Submodule "Light"
As it was done before for the Switch
and the SwitchSimple
, for the module Light
, a module declaration Light
, a function block Light
and an interface ILight
have to be created. The module shall be implemented by the function block, which itself shall implement the interface ILight
.
To be able to add the Light
module below our Room
module, the module declaration of Room
has to be extended with a Slots
section. In this section a subsection Slot_Multi
has to be created, which is called Lights
and will be able to hold modules of the type Light
. The number of lights, which can or have to be added to a room is defined by the parameter Cardinality
(in this case between 1 and 3 lights). Moreover two variables are declared: Variable
(pLights
, which will hold the function block instances of the Light modules added to the room) and Var_Count
(uiNumberOfLights
, which will be filled with the number of Light modules added to the room).
Slots

The variables pLights
and uiNumberOfLights
have to be added to the function block of the module "Lights", where uiNumberOfLights
is a UINT
and pLights
of type POINTER TO ILight
With this definition, only modules whose function blocks also implement the ILight
interface can be added to the Lights
slot.
Room
function block
The same slot concept that was used for the Room
modules is now used for the Light
module. As a result, the declaration of Light
includes a slot with a Switch
, which is why this slot is not a multi-slot, but a simple slot. Additional parameters of the Light
module are the speed of the dimmer rSpeed
and the maximum brightness uiMaxValue
. Finally, an output must be defined which represents the brightness of the associated light. All parameters, slots and outputs must also be added as variables to the function block of the Light
module.
Light

Light

