Home

mlamp

Download project

Object Oriented Programming

This example shows how object oriented programming can be used. It shows the implementation of
a building with different rooms. The visualization is used for a better demonstration.

Product description

This example displays a building with three different types of rooms. The first type has only one light.
The second one has an additional light, the third has two lights and additionally shows the temperature.
At daytime, all the lights are turned on and the temperature is set to 25. At nighttime all lights are
turned off and the temperature is set to 15. To show the conversion from an interface to a function block,
the temperature of room six is always set to 35.

More information

ILight: Interface for setting and getting the light value.

IRoom: Interface for doing some operations, when the daytime or nighttime comes up.

ITemp: Interface for setting and getting the temperature.

RoomType1: This function block implements the ILight and IRoom Interface. Therefore all
Interface methods need to be implemented. The function "Operation_Daytime" switches the lights on
and "Operation_Nighttime" switches the lights off.

RoomType2: This function block extends RoomType1 and inherits all methods. The method "SetLight"
is overridden, and extended for the additional light.

RoomType3: This function block extends RoomType2 and additionally implements the ITemp interface.
The methods "Operation_Daytime" and "Operation_Nighttime" are overridden and extended with the temperature.

CheckFB: Checks the time of the day. Each time period lasts five seconds.

BuildingManager: Depending on the time of day, the corresponding operations are done. Additionally a
conversion from the ITemp interface to the function block of RoomType3 is done with the function
"__QUERYINTERFACE".

Visualization: Displays eight rooms of three different types. The light bulbs are switched on at daytime
and switched off at nighttime. Two rooms also show the temperature. This value determines the size and color
of the bar.

System requirements and restrictions

System requirements and restrictions Info
Programming System CODESYS Development System Version 3.5.14.0 or higher
Runtime System CODESYS Control Version 3.5.14.0
Required Accessories -

Screenshot thumbnail
Screenshot of Visualization