2015-09-07 11:44:36 -06:00
|
|
|
// innerclasses/GreenhouseController.java
|
2015-12-15 11:47:04 -08:00
|
|
|
// (c)2016 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.
|
|
|
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
2015-06-15 17:47:35 -07:00
|
|
|
// Configure and execute the greenhouse system.
|
|
|
|
// {Args: 5000}
|
|
|
|
import innerclasses.controller.*;
|
|
|
|
|
|
|
|
public class GreenhouseController {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
GreenhouseControls gc = new GreenhouseControls();
|
2015-12-02 09:20:27 -08:00
|
|
|
// Instead of hard-wiring, you can parse
|
2015-06-15 17:47:35 -07:00
|
|
|
// configuration information from a text file here:
|
|
|
|
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));
|
|
|
|
if(args.length == 1)
|
|
|
|
gc.addEvent(
|
|
|
|
new GreenhouseControls.Terminate(
|
|
|
|
new Integer(args[0])));
|
|
|
|
gc.run();
|
|
|
|
}
|
2015-09-07 11:44:36 -06:00
|
|
|
}
|
|
|
|
/* Output:
|
2015-06-15 17:47:35 -07:00
|
|
|
Bing!
|
|
|
|
Thermostat on night setting
|
|
|
|
Light is on
|
|
|
|
Light is off
|
|
|
|
Greenhouse water is on
|
|
|
|
Greenhouse water is off
|
|
|
|
Thermostat on day setting
|
|
|
|
Restarting system
|
|
|
|
Terminating
|
2015-09-07 11:44:36 -06:00
|
|
|
*/
|