Skip to main content

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).

Figure 54. Definition of section Slots
Definition of section 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.

Figure 55. Declaration in the Room function block
Declaration in the Room function block


The same slot concept that was used for the Roommodules 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.

Figure 56. Declaration of module Light
Declaration of module Light


Figure 57. Declaration of the function block Light
Declaration of the function block Light


Figure 58. Text list and image pool
Text list and image pool


Step 5: Create Submodule "Light simple"