Temperature management

Exercise 1: Writing the temperature Controller

In this exercise, you will learn how to write a basic temperature Controller that will adjust the temperature in a given room to a targeted temperature. In that purpose, you will use the following simulated devices:

fr.liglab.adele.icasa.device.temperature.Cooler
fr.liglab.adele.icasa.device.temperature.Thermometer
fr.liglab.adele.icasa.device.temperature.Heater

The devices interfaces is described in the iCASA Heater/Cooler documentation.

Question 1 – Component: Create a new component nammed “TemperatureController”. Use “TemperatureControllerImpl” as your implementation class. The package will be “org.example.temperature.Controller”.

Using the temperature measured by thermometers (you can use the average value when more than one thermometer is available), try to adjust the wattage of Coolers and Heaters to reach a given temperature (say 25°C/77°F/293.15K) into the flat.

You will have to use a consistent unit for temperature (°C/°F or Kelvin). We recommand you to use Kelvin.

We assume you have no idea of the simulated physical temperature model. So you will have to base your system on a test and try approach. To implement such approach, you will probably need to implement and provide as service the PeriodicRunnable interface that will check the temperature periodically (every 10s for instance):
scheduling
Question 2 – Scripts: Write a script to check your application is working.

Here are some command you should use:

<behavior startdate="25/12/2012-00:00:00" factor="1440">
 
    <!-- Create the different zones -->
    <create-zone id="kitchen"  leftX="410" topY="370" X-lenght="245" Y-lenght="210" />   
    <create-zone id="livingroom" leftX="410" topY="28" X-lenght="245" Y-lenght="350" />
    <create-zone id="bedroom"  leftX="55" topY="370" X-lenght="259" Y-lenght="210" />   
    <create-zone id="bathroom"  leftX="55" topY="20" X-lenght="260" Y-lenght="350" />
 
    <!-- Creating a Thermometer, a Heater and a Cooler-->
    <create-device id="Ther-A3654Q-S" type="iCasa.Thermometer" />
    <create-device id="Heat-A4894S-S" type="iCasa.Heater" />
    <create-device id="Cool-A7496W-S" type="iCasa.Cooler" />
 
    <!-- Moving the devices to a given room-->
    <move-device-zone deviceId="Heat-A4894S-S" zoneId="livingroom" />
    <move-device-zone deviceId="Ther-A3654Q-S" zoneId="livingroom" />
    <move-device-zone deviceId="Cool-A7496W-S" zoneId="livingroom" />
 

 
    //.. 
 
</behavior>

Try to configure different temperatures for the different rooms (higher, lower or equal than/to 25°C).

Run the script and check that the application is working as expected.

Question 3 – Configuring the temperature per room: Change your implementation to allow the configuration of the temperature for each room.

You can use the following targeted temperatures:

  • 15°C for the Kitchen
  • 18°C for the Living room
  • 20°C for the Bedroom
  • 23°C for the Bathroom

Check that your application is working as expected.