├── .DS_Store ├── .gitignore ├── EnvironmentController ├── SetUp │ ├── content.txt │ └── properties.xml ├── TestCases │ ├── 102-20080710135800.zip │ ├── 104-20080710135846.zip │ ├── 11-20080710101111.zip │ ├── 110-20080710135856.zip │ ├── 116-20080710135920.zip │ ├── 122-20080710135942.zip │ ├── 124-20080710140031.zip │ ├── 138-20080710140047.zip │ ├── 14-20080710101824.zip │ ├── 156-20080710140258.zip │ ├── 174-20080710140555.zip │ ├── 21-20080710101944.zip │ ├── 25-20080710123115.zip │ ├── 28-20080710124309.zip │ ├── 45-20080710124319.zip │ ├── 58-20080710130515.zip │ ├── 6-20080710100856.zip │ ├── 62-20080710135328.zip │ ├── 64-20080710135522.zip │ ├── 70-20080710135532.zip │ ├── 76-20080710135601.zip │ ├── 84-20080710135626.zip │ ├── 90-20080710135712.zip │ ├── 96-20080710135733.zip │ ├── CoolingComfortable │ │ ├── 100-20080710135810.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── CoolingSettlingComfortable │ │ ├── 142-20080710140316.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── CoolingSettlingSettled │ │ ├── 146-20080710140338.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── CoolingSettlingTooCold │ │ ├── 136-20080710140143.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── CoolingTooCold │ │ ├── 94-20080710135743.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── HeatingComfortable │ │ ├── 88-20080710135719.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── HeatingRelaxingComfortable │ │ ├── 154-20080710140426.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── HeatingRelaxingRelaxed │ │ ├── 160-20080710140616.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── HeatingRelaxingTooHot │ │ ├── 150-20080710140404.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── HeatingTooHot │ │ ├── 80-20080710135635.zip │ │ ├── 82-20080710135644.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── IdleTooCold │ │ ├── 74-20080710135609.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── IdleTooHot │ │ ├── 68-20080710135542.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── RelaxingRelaxed │ │ ├── 114-20080710135927.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── RelaxingSettlingRelaxed │ │ ├── 168-20080710140655.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── RelaxingSettlingSettled │ │ ├── 172-20080710140709.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── RelaxingSettlingTooCold │ │ ├── 164-20080710140635.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── RelaxingTooCold │ │ ├── 108-20080710135903.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── SettlingSettled │ │ ├── 132-20080710140120.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── SettlingTooCold │ │ ├── 128-20080710140057.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── SettlingTooHot │ │ ├── 120-20080710135950.zip │ │ ├── content.txt │ │ └── properties.xml │ ├── content.txt │ └── properties.xml ├── content.txt └── properties.xml ├── README └── src └── environmentController ├── EnvironmentControlHardware.java ├── EnvironmentController.java ├── EnvironmentControllerTest.java ├── MockControlHardware.java └── fixtures └── EnvironmentScenario.java /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | classes 2 | *.iws 3 | *.iml 4 | *.ipr 5 | 6 | -------------------------------------------------------------------------------- /EnvironmentController/SetUp/content.txt: -------------------------------------------------------------------------------- 1 | 2 | !|Import| 3 | |environmentController.fixtures| 4 | -------------------------------------------------------------------------------- /EnvironmentController/SetUp/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | true 5 | 20080710135353 6 | true 7 | true 8 | true 9 | true 10 | true 11 | true 12 | 1215716033512 13 | -3578955024693019809 14 | 15 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/102-20080710135800.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/102-20080710135800.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/104-20080710135846.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/104-20080710135846.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/11-20080710101111.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/11-20080710101111.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/110-20080710135856.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/110-20080710135856.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/116-20080710135920.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/116-20080710135920.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/122-20080710135942.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/122-20080710135942.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/124-20080710140031.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/124-20080710140031.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/138-20080710140047.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/138-20080710140047.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/14-20080710101824.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/14-20080710101824.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/156-20080710140258.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/156-20080710140258.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/174-20080710140555.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/174-20080710140555.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/21-20080710101944.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/21-20080710101944.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/25-20080710123115.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/25-20080710123115.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/28-20080710124309.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/28-20080710124309.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/45-20080710124319.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/45-20080710124319.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/58-20080710130515.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/58-20080710130515.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/6-20080710100856.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/6-20080710100856.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/62-20080710135328.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/62-20080710135328.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/64-20080710135522.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/64-20080710135522.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/70-20080710135532.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/70-20080710135532.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/76-20080710135601.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/76-20080710135601.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/84-20080710135626.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/84-20080710135626.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/90-20080710135712.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/90-20080710135712.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/96-20080710135733.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/96-20080710135733.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingComfortable/100-20080710135810.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/CoolingComfortable/100-20080710135810.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingComfortable/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Cooling/Comfortable| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|75|-|X|X| 4 | |1|70|-|-|-| 5 | |3|75|-|X|-| 6 | |4|75|-|X|X| 7 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingComfortable/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710135817 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716290138 16 | -8683237634225860626 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingSettlingComfortable/142-20080710140316.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/CoolingSettlingComfortable/142-20080710140316.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingSettlingComfortable/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Cooling & Settling/Comfortable| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|65|X|X|-| 4 | |1|75|-|X|X| 5 | |2|70|-|X|-| 6 | |4|75|-|X|-| 7 | |5|75|-|X|X| 8 | |6|70|-|-|-| 9 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingSettlingComfortable/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140320 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716596712 16 | 584455175210546336 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingSettlingSettled/146-20080710140338.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/CoolingSettlingSettled/146-20080710140338.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingSettlingSettled/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Cooling & Settling/Settled| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|65|X|X|-| 4 | |1|75|-|X|X| 5 | |5|70|-|X|-| 6 | |6|70|-|-|-| 7 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingSettlingSettled/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140342 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716618631 16 | 974895649668357480 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingSettlingTooCold/136-20080710140143.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/CoolingSettlingTooCold/136-20080710140143.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingSettlingTooCold/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Cooling & Settling/Too Cold| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|65|X|X|-| 4 | |1|75|-|X|X| 5 | |2|65|X|X|-| 6 | |4|75|-|X|-| 7 | |5|75|-|X|X| 8 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingSettlingTooCold/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140147 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716503210 16 | 484170123607064389 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingTooCold/94-20080710135743.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/CoolingTooCold/94-20080710135743.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingTooCold/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Cooling/Too Cold| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|75|-|X|X| 4 | |1|65|X|X|-| 5 | |2|75|-|X|-| 6 | |3|75|-|X|-| 7 | |4|75|-|X|X| 8 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/CoolingTooCold/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710135748 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716263915 16 | -1850188218566623327 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingComfortable/88-20080710135719.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/HeatingComfortable/88-20080710135719.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingComfortable/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Heating/Comfortable| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|65|X|X|-| 4 | |1|70|-|X|-| 5 | |5|70|-|X|-| 6 | |6|70|-|-|-| 7 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingComfortable/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710135723 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716239567 16 | 4790636441263271552 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingRelaxingComfortable/154-20080710140426.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/HeatingRelaxingComfortable/154-20080710140426.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingRelaxingComfortable/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Heating & Relaxing/Comfortable| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|75|-|X|X| 4 | |1|65|X|X|-| 5 | |2|70|-|X|-| 6 | |3|75|-|X|-| 7 | |4|75|-|X|X| 8 | |6|70|-|X|-| 9 | |7|70|-|-|-| 10 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingRelaxingComfortable/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140431 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716666173 16 | 5610794676144957065 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingRelaxingRelaxed/160-20080710140616.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/HeatingRelaxingRelaxed/160-20080710140616.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingRelaxingRelaxed/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Heating & Relaxing/Relaxed| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|75|-|X|X| 4 | |1|65|X|X|-| 5 | |3|75|-|X|-| 6 | |4|75|-|X|X| 7 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingRelaxingRelaxed/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140620 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716776504 16 | 8674076216507403156 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingRelaxingTooHot/150-20080710140404.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/HeatingRelaxingTooHot/150-20080710140404.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingRelaxingTooHot/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Heating & Relaxing/Too Hot| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|75|-|X|X| 4 | |1|65|X|X|-| 5 | |2|75|-|X|-| 6 | |3|75|-|X|-| 7 | |4|75|-|X|X| 8 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingRelaxingTooHot/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140409 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716644669 16 | -2720089484732397918 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingTooHot/80-20080710135635.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/HeatingTooHot/80-20080710135635.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingTooHot/82-20080710135644.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/HeatingTooHot/82-20080710135644.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingTooHot/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Heating/Too Hot| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|65|X|X|-| 4 | |1|75|-|X|X| 5 | |2|70|-|X|-| 6 | |6|70|-|-|-| 7 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/HeatingTooHot/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710135649 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716204323 16 | 3417974363629156133 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/IdleTooCold/74-20080710135609.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/IdleTooCold/74-20080710135609.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/IdleTooCold/content.txt: -------------------------------------------------------------------------------- 1 | 2 | !|EnvironmentScenario|Idle/Too Cold| 3 | |Minute|Temp|Heater?|Blower?|Cooler?| 4 | |0|70|-|-|-| 5 | |1|65|X|X|-| 6 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/IdleTooCold/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710135614 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716169893 16 | 5903429411750262742 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/IdleTooHot/68-20080710135542.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/IdleTooHot/68-20080710135542.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/IdleTooHot/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Idle/Too Hot| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|70|-|-|-| 4 | |1|75|-|X|X| 5 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/IdleTooHot/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710135548 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716142820 16 | 4541912600183199847 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingRelaxed/114-20080710135927.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/RelaxingRelaxed/114-20080710135927.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingRelaxed/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Relaxing/Relaxed| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|75|-|X|X| 4 | |1|70|-|-|-| 5 | |3|75|-|X|-| 6 | |4|70|-|-|-| 7 | |5|75|-|X|X| 8 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingRelaxed/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710135931 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716367151 16 | -8644386281537425257 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingSettlingRelaxed/168-20080710140655.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/RelaxingSettlingRelaxed/168-20080710140655.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingSettlingRelaxed/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Relaxing & Settling/Relaxed| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|75|-|X|X| 4 | |1|65|X|X|-| 5 | |2|70|-|X|-| 6 | |3|75|-|X|-| 7 | |4|75|-|X|X| 8 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingSettlingRelaxed/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140658 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716815085 16 | 2844365749020538521 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingSettlingSettled/172-20080710140709.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/RelaxingSettlingSettled/172-20080710140709.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingSettlingSettled/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Relaxing & Settling/Settled| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|75|-|X|X| 4 | |1|65|X|X|-| 5 | |2|70|-|X|-| 6 | |6|70|-|X|-| 7 | |7|70|-|-|-| 8 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingSettlingSettled/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140714 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716829080 16 | 6024863984391044090 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingSettlingTooCold/164-20080710140635.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/RelaxingSettlingTooCold/164-20080710140635.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingSettlingTooCold/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Relaxing & Settling/Too Cold| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|75|-|X|X| 4 | |1|65|X|X|-| 5 | |2|70|-|X|-| 6 | |3|65|X|X|-| 7 | |4|75|-|X|X| 8 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingSettlingTooCold/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140639 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716795302 16 | -4004240369800827336 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingTooCold/108-20080710135903.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/RelaxingTooCold/108-20080710135903.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingTooCold/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Relaxing/Too Cold| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|75|-|X|X| 4 | |1|70|-|-|-| 5 | |2|65|X|X|-| 6 | |3|75|-|X|-| 7 | |4|75|-|X|X| 8 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/RelaxingTooCold/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710135907 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716343226 16 | 948624090952273866 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/SettlingSettled/132-20080710140120.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/SettlingSettled/132-20080710140120.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/SettlingSettled/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Settling/Settled| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|65|X|X|-| 4 | |1|70|-|X|-| 5 | |5|70|-|X|-| 6 | |6|70|-|-|-| 7 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/SettlingSettled/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140127 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716480930 16 | -6096650090232906283 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/SettlingTooCold/128-20080710140057.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/SettlingTooCold/128-20080710140057.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/SettlingTooCold/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Settling/Too Cold| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|65|X|X|-| 4 | |1|70|-|X|-| 5 | |2|65|X|X|-| 6 | |3|70|-|X|-| 7 | |7|70|-|X|-| 8 | |8|70|-|-|-| 9 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/SettlingTooCold/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140101 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716457505 16 | 7615765054668433390 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/SettlingTooHot/120-20080710135950.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unclebob/environmentcontroller/fa412ea125a1f2763fc526ef3f64cdc622d453c4/EnvironmentController/TestCases/SettlingTooHot/120-20080710135950.zip -------------------------------------------------------------------------------- /EnvironmentController/TestCases/SettlingTooHot/content.txt: -------------------------------------------------------------------------------- 1 | !|EnvironmentScenario|Settling/Too Hot| 2 | |Minute|Temp|Heater?|Blower?|Cooler?| 3 | |0|65|X|X|-| 4 | |1|70|-|X|-| 5 | |2|75|-|X|X| 6 | |3|70|-|X|-| 7 | |5|70|-|X|-| 8 | |6|70|-|-|-| 9 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/SettlingTooHot/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710135953 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716390212 16 | 4020502456719163794 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/content.txt: -------------------------------------------------------------------------------- 1 | >IdleTooHot 2 | >IdleTooCold 3 | >HeatingTooHot 4 | >HeatingComfortable 5 | >CoolingTooCold 6 | >CoolingComfortable 7 | >RelaxingTooCold 8 | >RelaxingRelaxed 9 | >SettlingTooHot 10 | >SettlingTooCold 11 | >SettlingSettled 12 | >CoolingSettlingTooCold 13 | >CoolingSettlingComfortable 14 | >CoolingSettlingSettled 15 | >HeatingRelaxingTooHot 16 | >HeatingRelaxingComfortable 17 | >HeatingRelaxingRelaxed 18 | >RelaxingSettlingTooCold 19 | >RelaxingSettlingRelaxed 20 | >RelaxingSettlingSettled 21 | -------------------------------------------------------------------------------- /EnvironmentController/TestCases/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 20080710140724 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 1215716755535 16 | -8359156107448263912 17 | 18 | -------------------------------------------------------------------------------- /EnvironmentController/content.txt: -------------------------------------------------------------------------------- 1 | !contents -g -p -f -h 2 | This is the Environment Controller Project 3 | !path fitnesse.jar 4 | !path /Users/unclebob/projects/EnvironmentController/classes/production/EnvironmentController 5 | !define TEST_SYSTEM {slim} 6 | 7 | !3 Requirements 8 | The Environment Controller keeps a computer room within a closely controlled temperature range by using both a heater and a cooler. 9 | * The temperature must never deviate more than 5 degrees from 70F. 10 | * If the temperature is ever more than 10 degrees away from 70F then the appropriate Hi or Lo alarm must sound. 11 | * When the heater is on, the blower must be on. 12 | * When the cooler is on, the blower must be on. 13 | * The blower must continue to run for 5 minutes after the heater is turned off 14 | * Because the heat exchanger has latent heat that must not be allowed to accumulate lest it melt the sensitive vanes. 15 | * The cooler must not be turned on within 3 minutes of being turned off 16 | * Because the freon must be given time to recondense lest the compressor vapor lock. 17 | 18 | !3 Finite State Machine for Environment Controller 19 | * Settling = The time that the blower must be on in order to cool down the heat exchanger 20 | * Relaxing = The time the compressor must remain off to prevent vapor lock 21 | 22 | |State|Event|Next State| 23 | |Idle|Too Hot|Cooling| 24 | ||Too Cold|Heating| 25 | ||Comfortable|-| 26 | ||Relaxed|-| 27 | ||Settled|-| 28 | || 29 | |Heating|Too Hot|Cooling + Settling| 30 | ||Too Cold|-| 31 | ||Comfortable|Settling| 32 | ||Relaxed|-| 33 | ||Settled|-| 34 | || 35 | |Cooling|Too Hot|-| 36 | ||Too Cold|Heating + Relaxing| 37 | ||Comfortable|Relaxing| 38 | ||Relaxed|-| 39 | ||Settled|-| 40 | || 41 | |Relaxing|Too Hot|-| 42 | ||Too Cold|Heating + Relaxing| 43 | ||Comfortable|-| 44 | ||Relaxed|Idle| 45 | ||Settled|-| 46 | || 47 | |Settling|Too Hot|Cooling + Settling| 48 | ||Too Cold|Heating| 49 | ||Comfortable|-| 50 | ||Relaxed|-| 51 | ||Settled|Idle| 52 | || 53 | |Cooling + Settling|Too Hot|-| 54 | ||Too Cold|Heating + Relaxing| 55 | ||Comfortable|Relaxing + Settling| 56 | ||Relaxed|-| 57 | ||Settled|Cooling| 58 | || 59 | |Heating + Relaxing|Too Hot|Relaxing| 60 | ||Too Cold|-| 61 | ||Comfortable|Relaxing + Settling| 62 | ||Relaxed|Heating| 63 | ||Settled|-| 64 | || 65 | |Relaxing + Settling|Too Hot|| 66 | ||Too Cold|Heating + Relaxing| 67 | ||Comfortable|-| 68 | ||Relaxed|Settling| 69 | ||Settled|Relaxing| 70 | 71 | -------------------------------------------------------------------------------- /EnvironmentController/properties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | true 5 | true 6 | true 7 | true 8 | true 9 | true 10 | true 11 | 1215718483197 12 | -4054872896039884539 13 | 14 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | One of the exercises I use when I teach TDD. 2 | 3 | -------------------------------------------------------------------------------- /src/environmentController/EnvironmentControlHardware.java: -------------------------------------------------------------------------------- 1 | package environmentController; 2 | 3 | public interface EnvironmentControlHardware { 4 | 5 | void setHeater(boolean heater); 6 | 7 | void setCooler(boolean cooler); 8 | 9 | void setBlower(boolean blower); 10 | 11 | void setHiTempAlarm(boolean hiTempAlarm); 12 | 13 | void setLoTempAlarm(boolean loTempAlarm); 14 | 15 | int getTemp(); 16 | 17 | boolean blowerState(); 18 | 19 | boolean coolerState(); 20 | 21 | boolean heaterState(); 22 | 23 | boolean hiTempAlarm(); 24 | 25 | boolean loTempAlarm(); 26 | } 27 | -------------------------------------------------------------------------------- /src/environmentController/EnvironmentController.java: -------------------------------------------------------------------------------- 1 | package environmentController; 2 | 3 | public class EnvironmentController { 4 | private EnvironmentControlHardware hw; 5 | private int hotAlarm; 6 | private int tooHot; 7 | private int tooCold; 8 | private int coldAlarm; 9 | private int coolerOnDelay; 10 | private int blowerOffDelay; 11 | public final static int COOLER_DELAY = 3; 12 | public final static int BLOWER_DELAY = 5; 13 | 14 | public EnvironmentController(EnvironmentControlHardware hw) { 15 | this.hw = hw; 16 | hw.setHeater(false); 17 | hw.setCooler(false); 18 | hw.setBlower(false); 19 | hw.setHiTempAlarm(false); 20 | hw.setLoTempAlarm(false); 21 | } 22 | 23 | public void hotAlarm(int temp) { 24 | hotAlarm = temp; 25 | } 26 | 27 | public void tooHot(int temp) { 28 | tooHot = temp; 29 | } 30 | 31 | public void tooCold(int temp) { 32 | tooCold = temp; 33 | } 34 | 35 | public void coldAlarm(int temp) { 36 | coldAlarm = temp; 37 | } 38 | 39 | public boolean isTooCold(int temp) { 40 | return temp <= tooCold; 41 | } 42 | 43 | public boolean isComfortable(int temp) { 44 | return temp < tooHot && temp > tooCold; 45 | } 46 | 47 | public boolean isTooHot(int temp) { 48 | return temp >= tooHot; 49 | } 50 | 51 | public boolean isWayTooHot(int temp) { 52 | return temp >= hotAlarm; 53 | } 54 | 55 | public boolean isWayTooCold(int temp) { 56 | return temp <= coldAlarm; 57 | } 58 | 59 | public void regulate() { 60 | decrementTimers(); 61 | int temp = hw.getTemp(); 62 | if (isTooHot(temp)) { 63 | processTooHot(temp); 64 | } else if (isComfortable(temp)) { 65 | processComfortable(); 66 | } else if (isTooCold(temp)) { 67 | processTooCold(temp); 68 | } 69 | } 70 | 71 | private void decrementTimers() { 72 | if (coolerOnDelay > 0) 73 | coolerOnDelay--; 74 | if (blowerOffDelay > 0) 75 | blowerOffDelay--; 76 | } 77 | 78 | private void processTooCold(int temp) { 79 | turnOnBlower(); 80 | turnOnHeater(); 81 | turnOffCooler(); 82 | checkLoTempAlarm(temp); 83 | } 84 | 85 | private void processComfortable() { 86 | turnOffHeater(); 87 | turnOffCooler(); 88 | turnOffBlower(); 89 | } 90 | 91 | private void processTooHot(int temp) { 92 | turnOffHeater(); 93 | turnOnBlower(); 94 | turnOnCooler(); 95 | checkHiTempAlarm(temp); 96 | } 97 | 98 | private void turnOnBlower() { 99 | hw.setBlower(true); 100 | } 101 | 102 | private void turnOffBlower() { 103 | if (blowerOffDelay == 0) 104 | hw.setBlower(false); 105 | } 106 | 107 | private void turnOnHeater() { 108 | hw.setHeater(true); 109 | } 110 | 111 | private void turnOffHeater() { 112 | if (hw.heaterState()) { 113 | blowerOffDelay = BLOWER_DELAY; 114 | hw.setHeater(false); 115 | } 116 | } 117 | 118 | private void turnOnCooler() { 119 | if (coolerOnDelay == 0) 120 | hw.setCooler(true); 121 | } 122 | 123 | 124 | private void turnOffCooler() { 125 | if (hw.coolerState()) { 126 | coolerOnDelay = COOLER_DELAY; 127 | hw.setCooler(false); 128 | } 129 | } 130 | 131 | private void checkLoTempAlarm(int temp) { 132 | if (isWayTooCold(temp)) { 133 | hw.setLoTempAlarm(true); 134 | } else { 135 | hw.setLoTempAlarm(false); 136 | } 137 | } 138 | 139 | private void checkHiTempAlarm(int temp) { 140 | if (isWayTooHot(temp)) { 141 | hw.setHiTempAlarm(true); 142 | } else { 143 | hw.setHiTempAlarm(false); 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/environmentController/EnvironmentControllerTest.java: -------------------------------------------------------------------------------- 1 | package environmentController; 2 | 3 | import static environmentController.EnvironmentController.BLOWER_DELAY; 4 | import static environmentController.EnvironmentController.COOLER_DELAY; 5 | import static org.junit.Assert.assertEquals; 6 | import static org.junit.Assert.assertFalse; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | 10 | public class EnvironmentControllerTest { 11 | private MockControlHardware hw; 12 | private EnvironmentController controller; 13 | private final int WAY_TOO_HOT = 80; 14 | private final int TOO_HOT = 70; 15 | private final int TOO_COLD = 60; 16 | private final int WAY_TOO_COLD = 50; 17 | private final int COMFORTABLE = (TOO_HOT + TOO_COLD) / 2; 18 | 19 | @Before 20 | public void initialize() { 21 | hw = new MockControlHardware(); 22 | controller = new EnvironmentController(hw); 23 | controller.hotAlarm(WAY_TOO_HOT); 24 | controller.tooHot(TOO_HOT); 25 | controller.tooCold(TOO_COLD); 26 | controller.coldAlarm(WAY_TOO_COLD); 27 | } 28 | 29 | @Test 30 | public void thresholds() throws Exception { 31 | assertThreshold("WAY_TOO_HOT", WAY_TOO_HOT + 1); 32 | assertThreshold("WAY_TOO_HOT", WAY_TOO_HOT); 33 | 34 | assertThreshold("TOO_HOT", WAY_TOO_HOT - 1); 35 | assertThreshold("TOO_HOT", TOO_HOT); 36 | 37 | assertThreshold("COMFORTABLE", TOO_HOT - 1); 38 | assertThreshold("COMFORTABLE", TOO_COLD + 1); 39 | 40 | assertThreshold("TOO_COLD", TOO_COLD); 41 | assertThreshold("TOO_COLD", TOO_COLD - 1); 42 | 43 | assertThreshold("WAY_TOO_COLD", WAY_TOO_COLD); 44 | assertThreshold("WAY_TOO_COLD", WAY_TOO_COLD - 1); 45 | } 46 | 47 | private void assertThreshold(String threshold, int temp) { 48 | assertEquals(threshold, threshold(temp)); 49 | } 50 | 51 | private String threshold(int temp) { 52 | if (controller.isWayTooHot(temp)) return "WAY_TOO_HOT"; 53 | if (controller.isTooHot(temp)) return "TOO_HOT"; 54 | if (controller.isComfortable(temp)) return "COMFORTABLE"; 55 | if (controller.isWayTooCold(temp)) return "WAY_TOO_COLD"; 56 | if (controller.isTooCold(temp)) return "TOO_COLD"; 57 | return null; 58 | } 59 | 60 | 61 | @Test 62 | public void shouldStartUpOff() throws Exception { 63 | turnEverythingOn(); 64 | controller = new EnvironmentController(hw); 65 | assertEverythingOff(); 66 | } 67 | 68 | private void assertEverythingOff() { 69 | assertState("hbchl"); 70 | } 71 | 72 | private void turnEverythingOn() { 73 | hw.setHeater(true); 74 | hw.setCooler(true); 75 | hw.setBlower(true); 76 | hw.setHiTempAlarm(true); 77 | hw.setLoTempAlarm(true); 78 | } 79 | 80 | @Test 81 | public void nothingTurnsOnIfTempJustRight() throws Exception { 82 | comfortable(); 83 | assertEverythingOff(); 84 | } 85 | 86 | @Test 87 | public void turnOnCoolerAndBlowerIfTooHot() throws Exception { 88 | tooHot(); 89 | assertState("hBChl"); 90 | } 91 | 92 | @Test 93 | public void turnOnHeaterAndBlowerIfTooCold() throws Exception { 94 | tooCold(); 95 | assertState("HBchl"); 96 | } 97 | 98 | @Test 99 | public void turnOnHiTempAlarmAtThreshold() throws Exception { 100 | wayTooHot(); 101 | assertState("hBCHl"); 102 | } 103 | 104 | @Test 105 | public void turnOnLoTempAlarmAtThreshold() throws Exception { 106 | wayTooCold(); 107 | assertState("HBchL"); 108 | } 109 | 110 | @Test 111 | public void hiTempAlarmResetsWhenTempGoesDown() throws Exception { 112 | wayTooHot(); 113 | tooHot(); 114 | assertState("hBChl"); 115 | } 116 | 117 | @Test 118 | public void loTempAlarmResetsWhenTempGoesUp() throws Exception { 119 | wayTooCold(); 120 | tooCold(); 121 | assertState("HBchl"); 122 | } 123 | 124 | @Test 125 | public void heaterTurnsOffButBlowerRemainsOnAfterHeating() throws Exception { 126 | tooCold(); 127 | comfortable(); 128 | assertState("hBchl"); 129 | } 130 | 131 | @Test 132 | public void coolerTurnsOffIfHotAgain() throws Exception { 133 | tooHot(); 134 | comfortable(); 135 | assertState("hbchl"); 136 | } 137 | 138 | @Test 139 | public void coolerMustRemainOffForFiveMinBeforeRestart() throws Exception { 140 | tooHot(); 141 | comfortable(); 142 | tooHot(); 143 | delayAndCheck(COOLER_DELAY - 1, "hBchl"); 144 | assertState("hBChl"); 145 | } 146 | 147 | @Test 148 | public void coolerDoesNotTurnOnAfterDelayIfNotNeeded() throws Exception { 149 | tooHot(); 150 | comfortable(); 151 | tooHot(); 152 | tooCold(); 153 | delayAndCheck(COOLER_DELAY + 1, "HBchl"); 154 | } 155 | 156 | @Test 157 | public void blowerDelaysAfterFurnaceGoesOff() throws Exception { 158 | tooCold(); 159 | comfortable(); 160 | delayAndCheck(BLOWER_DELAY - 1, "hBchl"); 161 | controller.regulate(); 162 | assertState("hbchl"); 163 | } 164 | 165 | @Test 166 | public void blowerStaysOnWhenCoolingAfterHeating() throws Exception { 167 | tooCold(); 168 | tooHot(); 169 | delayAndCheck(BLOWER_DELAY+1, "hBChl"); 170 | } 171 | 172 | 173 | private void delayAndCheck(int delay, String state) { 174 | for (int i = 0; i < delay; i++) { 175 | assertState(state); 176 | controller.regulate(); 177 | } 178 | } 179 | 180 | private void comfortable() { 181 | hw.setTemp(COMFORTABLE); 182 | controller.regulate(); 183 | } 184 | 185 | private void tooHot() { 186 | hw.setTemp(TOO_HOT); 187 | controller.regulate(); 188 | } 189 | 190 | private void tooCold() { 191 | hw.setTemp(TOO_COLD); 192 | controller.regulate(); 193 | } 194 | 195 | private void wayTooHot() { 196 | hw.setTemp(WAY_TOO_HOT); 197 | controller.regulate(); 198 | } 199 | 200 | private void wayTooCold() { 201 | hw.setTemp(WAY_TOO_COLD); 202 | controller.regulate(); 203 | } 204 | 205 | private void assertState(String state) { 206 | assertEquals(state, hw.getState()); 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /src/environmentController/MockControlHardware.java: -------------------------------------------------------------------------------- 1 | package environmentController; 2 | 3 | public class MockControlHardware implements EnvironmentControlHardware { 4 | private boolean heater; 5 | private boolean cooler; 6 | private boolean blower; 7 | private boolean hiTempAlarm; 8 | private boolean loTempAlarm; 9 | private int temp; 10 | 11 | public boolean blowerState() { 12 | return blower; 13 | } 14 | 15 | public boolean coolerState() { 16 | return cooler; 17 | } 18 | 19 | public boolean heaterState() { 20 | return heater; 21 | } 22 | 23 | public boolean hiTempAlarm() { 24 | return hiTempAlarm; 25 | } 26 | 27 | public boolean loTempAlarm() { 28 | return loTempAlarm; 29 | } 30 | 31 | public void setHeater(boolean heater) { 32 | this.heater = heater; 33 | } 34 | 35 | public void setCooler(boolean cooler) { 36 | this.cooler = cooler; 37 | } 38 | 39 | public void setBlower(boolean blower) { 40 | this.blower = blower; 41 | } 42 | 43 | public void setHiTempAlarm(boolean hiTempAlarm) { 44 | this.hiTempAlarm = hiTempAlarm; 45 | } 46 | 47 | public void setLoTempAlarm(boolean loTempAlarm) { 48 | this.loTempAlarm = loTempAlarm; 49 | } 50 | 51 | public int getTemp() { 52 | return temp; 53 | } 54 | 55 | public void setTemp(int temp) { 56 | this.temp = temp; 57 | } 58 | 59 | public String getState() { 60 | String state = ""; 61 | state += heater ? "H" : "h"; 62 | state += blower ? "B" : "b"; 63 | state += cooler ? "C" : "c"; 64 | state += hiTempAlarm ? "H" : "h"; 65 | state += loTempAlarm ? "L" : "l"; 66 | return state; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/environmentController/fixtures/EnvironmentScenario.java: -------------------------------------------------------------------------------- 1 | package environmentController.fixtures; 2 | 3 | import environmentController.EnvironmentController; 4 | import environmentController.MockControlHardware; 5 | 6 | public class EnvironmentScenario { 7 | private int minute; 8 | private int temp; 9 | private EnvironmentController controller; 10 | private MockControlHardware hw; 11 | private int time = 0; 12 | 13 | public EnvironmentScenario(String comment) { 14 | hw = new MockControlHardware(); 15 | controller = new EnvironmentController(hw); 16 | controller.tooHot(75); 17 | controller.tooCold(65); 18 | } 19 | 20 | public void execute() throws Exception { 21 | while (time < minute) { 22 | time++; 23 | controller.regulate(); 24 | } 25 | 26 | hw.setTemp(temp); 27 | controller.regulate(); 28 | time++; 29 | } 30 | 31 | public String Heater() { 32 | return hw.heaterState() ? "X" : "-"; 33 | } 34 | 35 | public String Blower() { 36 | return hw.blowerState() ? "X" : "-"; 37 | } 38 | 39 | public String Cooler() { 40 | return hw.coolerState() ? "X" : "-"; 41 | } 42 | 43 | public void setMinute(int minute) { 44 | this.minute = minute; 45 | } 46 | 47 | public void setTemp(int temp) { 48 | this.temp = temp; 49 | } 50 | } 51 | --------------------------------------------------------------------------------