2015-09-07 11:44:36 -06:00
|
|
|
// innerclasses/GreenhouseController.java
|
2021-01-31 15:42:31 -07:00
|
|
|
// (c)2021 MindView LLC: see Copyright.txt
|
2015-11-15 15:51:35 -08:00
|
|
|
// We make no guarantees that this code is fit for any purpose.
|
2016-09-23 13:23:35 -06:00
|
|
|
// Visit http://OnJava8.com for more book information.
|
2016-01-25 18:05:55 -08:00
|
|
|
// Configure and execute the greenhouse system
|
2015-06-15 17:47:35 -07:00
|
|
|
import innerclasses.controller.*;
|
|
|
|
|
|
|
|
public class GreenhouseController {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
GreenhouseControls gc = new GreenhouseControls();
|
2016-01-25 18:05:55 -08:00
|
|
|
// Instead of using code, you could parse
|
|
|
|
// configuration information from a text file:
|
2015-06-15 17:47:35 -07:00
|
|
|
gc.addEvent(gc.new Bell(900));
|
|
|
|
Event[] eventList = {
|
|
|
|
gc.new ThermostatNight(0),
|
|
|
|
gc.new LightOn(200),
|
|
|
|
gc.new LightOff(400),
|
|
|
|
gc.new WaterOn(600),
|
|
|
|
gc.new WaterOff(800),
|
|
|
|
gc.new ThermostatDay(1400)
|
|
|
|
};
|
|
|
|
gc.addEvent(gc.new Restart(2000, eventList));
|
2017-05-12 08:07:40 -06:00
|
|
|
gc.addEvent(
|
|
|
|
new GreenhouseControls.Terminate(5000));
|
2015-06-15 17:47:35 -07:00
|
|
|
gc.run();
|
|
|
|
}
|
2015-09-07 11:44:36 -06:00
|
|
|
}
|
|
|
|
/* Output:
|
2016-07-22 14:45:35 -06:00
|
|
|
Thermostat on night setting
|
|
|
|
Light is on
|
|
|
|
Light is off
|
|
|
|
Greenhouse water is on
|
|
|
|
Greenhouse water is off
|
|
|
|
Bing!
|
|
|
|
Thermostat on day setting
|
2015-06-15 17:47:35 -07:00
|
|
|
Bing!
|
2016-07-22 14:45:35 -06:00
|
|
|
Restarting system
|
2015-06-15 17:47:35 -07:00
|
|
|
Thermostat on night setting
|
|
|
|
Light is on
|
|
|
|
Light is off
|
|
|
|
Greenhouse water is on
|
2016-07-22 14:45:35 -06:00
|
|
|
Bing!
|
2015-06-15 17:47:35 -07:00
|
|
|
Greenhouse water is off
|
|
|
|
Thermostat on day setting
|
2016-07-22 14:45:35 -06:00
|
|
|
Bing!
|
2015-06-15 17:47:35 -07:00
|
|
|
Restarting system
|
2016-07-22 14:45:35 -06:00
|
|
|
Thermostat on night setting
|
|
|
|
Light is on
|
|
|
|
Light is off
|
|
|
|
Bing!
|
|
|
|
Greenhouse water is on
|
|
|
|
Greenhouse water is off
|
2015-06-15 17:47:35 -07:00
|
|
|
Terminating
|
2015-09-07 11:44:36 -06:00
|
|
|
*/
|