In this exercise, you will manage the level of illuminance more precisely.
Question 1 – Reaching a targeted illuminance: Use the photometers to get the illuminance of each room. Change your code to keep a targeted illuminance when moving users from one room to another:
/** * The targeted illuminance in each room **/ private double targetedIlluminance = 4000.0d;
To simplify, you can assume that there is only one dimmer light per room (and no binary lights).
The physical model used by iCASA is basic. You can use the following constant to perform your computation :
/** * Watt to lumens conversion factor * It has been considered that: 1 Watt=680.0 lumens at 555nm. */ public final static double ONE_WATT_TO_ONE_LUMEN = 680.0d;
The light provided by a DimmerLight depends on the configuration of the dimmer (ranging from 0.0d to 1.0d). Let:
The illuminance I given by one dimmer light is given by :
\(I = {\lambda * \beta * P \over R}\)
It is thus easy to find the λ factor to apply to a given light.
Question 2 – more than one dimmer light: You will now try to manage more than one Dimmer Light.
The general equation of our physical model is :
\(I = {\sum_{i=1}^N {\lambda(i) * \beta(i) * P \over R}}\)
where :
To simplify the problem, you can assume that every light has the same maximum power level (P(i)) : P and that the factor λ(i) is the same for every light (λ).
Question 3 (optional) – generic algorithm: Try to find a solution for the generic case of heterogeneous lights (binary lights and dimmer lights with different wattage).
To simplify the problem, you can adopt a test&try approach by turning on the lights and configuring the the dimmer lights progressively. If you choose this approach, you may cache the result of your configuration for the next time (until the targeted light is changed).
Question 4 – Enhancing the configuration service: Now you will improve your configuration service to allow the configuration of the illuminance value.
Implements the following methods :
package org.example.follow.me.configuration; /** * The FollowMeConfiguration service allows to configure the Follow Me * application. */ public interface FollowMeConfiguration { public int getMaximumNumberOfLightsToTurnOn(); public void setMaximumNumberOfLightsToTurnOn(int maximumNumberOfLightsToTurnOn); public double getMaximumAllowedEnergyInRoom(); public void setMaximumAllowedEnergyInRoom(double maximumEnergy); /** * Gets the targeted illuminance for each room * * @return the targeted illuminance in lumens */ public double getTargetedIlluminance(); /** * Sets the targeted illuminance for each room * * @param illuminance * the targeted illuminance in lumens for each room */ public void setTargetedIlluminance(double illuminance); }
Question 5 – Administration interface. Modify the manager IlluminanceGoal to add illuminance configuration :
package org.example.follow.me.manager; /** * This enum describes the different illuminance goals associated with the * manager. */ public enum IlluminanceGoal { /** The goal associated with soft illuminance. */ SOFT(1, 500d), /** The goal associated with medium illuminance. */ MEDIUM(2, 2750d), /** The goal associated with full illuminance. */ FULL(3, 4000d); //... TODO change the enum to take the illuminance into account }
and modify your manager to takes this goal into account.
Question 6 – Test: Using the command you have implemented before, test that your application is working as expected.
g! setIlluminancePreference SOFT g! setIlluminancePreference MEDIUM g! setIlluminancePreference FULL
In particular, make sure that the lights are correctly reconfigured for each room when the targeted illuminance is reconfigured.