Step 6: Implementation
Switches
For the implementation of the functionality of the module Switch
we use the method CallPrioMediumStart
from Module
by overriding it with our own implementation. We choose this function, because the module Room
declared a MEDIUM
task, which implies that the method CallPrioMediumStart
of the function block Switch
will be called each cycle of a medium task. The detailed information can be seen in example project itself. However, the main functionality of the switch is to differ between the tap and dim function. After pushing the switch, a timer will start with the given time from the user parameter. When the timer is finished and the switch not released the dim function is used, indicated by the variable xPushLong
. The variable xPush
is TRUE
, if the switch is just tapped. For both xPushLong
and xPush
properties are added to both the function block Switch
and the interface ISwitch
, so that they can be used from the parent light function block.
Light
Again, the Light
function block overrides the method CallPrioMediumStart
. Depending on the input variables of the underlying switch, the light is dimmed to "on" or "off" or only toggled. For the dimmer, the speed value of the declared parameter rSpeed
is used. After reaching the maximum or minimum dim value, the dimming is stopped. If the light is in a dimmed state and the switch is tapped, the light is switched on. (The detailed implementation is given in the corresponding example project.)
Check the code
After implementation, the declarations should be checked by use of the command Build. If no error is displayed the declarations is alright.