In this exercise you will build a RoomOccupancy service that computes statics on room occupancy. You will then use this service to tune the manager behavior.
Question 1 – RoomOccupancy service: Create a new component called “RoomOccupancy” and implement the following service :
package org.example.occupancy; public interface RoomOccupancy { /** * Gets the probability (between 0 and 1) that the given room is occupied * at the given moment of the day. * * @param minuteOfTheDay * a specific time in the day in minute (between 0 (=00:00) and * 1439 (=23:59)) * @param minuteOfTheDay * the room name where the occupancy value is required. * @return the room occupancy is a value between 0 and 1 where 0 indicates * that there the room is always empty and 1 indicates that the room * is always occupied at the given moment of the day. */ public double getRoomOccupancy(int minuteOfTheDay, String room); }
The package “org.example.occupancy” must be provided by your component.
The idea is to check periodically (using a PeriodicRunnable) if a room is occupied or not and adjust the
At the beginning, the default value of room occupancy is 0.
Question 3 – Script and command: Create a script using the command describe in iCASA documentation that move one or more users in the different rooms of the flat during 2 days.
Question 4 – Test: Based on the script you have written, test that your RoomOccupancy service is working as expected. For this purpose you can write a command (provided by the “Room Occupancy” component).
Question 5 – TemperatureConfiguration: Change the TemperatureConfiguration service so that the temperature management can be turn on/off in a given room:
package org.example.temperature; /** * The TemperatureConfiguration service allows one to configure the temperature * controller. */ public interface TemperatureConfiguration { //... /** * Turn on the temperature management in the given room * * @param room * the given room */ public void turnOn(String room); /** * Turn off the temperature management in the given room * * @param room * the given room */ public void turnOff(String room); }
Question 6 – Energy management: Now you will try to manage the energy.
Your manager will depend on the room occupancy component:
Add an energy mode to your manager:
/** * This interface allows to configure the temperature manager responsible for * configuring the temperature controller. */ public interface TemperatureManagerAdministration { //... /** * Enable the energy saving mode. */ public void turnOnEnergySavingMode(); /** * Disable the energy saving mode. */ public void turnOffEnergySavingMode(); /** * Checks if the energy saving mode is enabled. * * @return true, if the energy saving mode is enabled */ public boolean isPowerSavingEnabled(); }
When the energy saving mode is enabled, you should try to turn off the temperature control in the room with low occupancy (e.g. <0.2).
The occupancy threshold can be setted statically to start:
public static final double ROOM_OCCUPANCY_THRESHOLD = 0.2;
In a second time, You may also reduce the number of watts being used by opting for a higher/lower temperature than the targeted one.
Try to propose a consistent energy management strategy based on the room occupancy.
It would be a good idea to extend the TemperatureManagerAdministration to allow the configuration of the factors you are considering as well as the thresholds – it will depend on your strategy.
Write a command to be able to trigger the energy saving mode: Add a command to test your work:
g! temperature:enableEnergySaving g! temperature:disableEnergySaving
Question 7 – maximum amount of power: Finally, you may consider the time factor by reducing the power of the AC. Your system will take more time to reach the targeted temperature but will momentarily use less energy. That is useful if your system is available amount of power at a given time is limited.
Modify the configuration service of your controller so that the maximum amount of available power per room can be configured.
public interface TemperatureConfiguration { /** * Sets the maximum allowed energy consumption in Watts in each room * * @param maximumEnergy * the maximum allowed energy consumption in Watts in each room */ public void setMaximumAllowedEnergyInRoom(double maximumEnergy); }
Modify the administration interface and your manager implementation to allow the expression of an Energy Goal (on the same model as in the follow-me exercises)
Add a command to test your work:
g! temperature:setEnergyGoal LOW
where LOW stands for a given maximum power.