**
*******************************************************************************************************************************************/
// private static final int NUMBER_OF_TIMES_PER_WEEK_TO_WATER = 2;
- //TODO: Change these back to normal - this is just for testing to make it awake all the time
-// private static final int TIME_HOURS_TO_WATER_GRASS = 7; // 7 am
- private static final int TIME_HOURS_TO_WATER_GRASS = 3;
-// private static final int TIME_MINUTES_TO_WATER_GRASS = 30; // 30 minutes
- private static final int TIME_MINUTES_TO_WATER_GRASS = 30;
-// private static final int TIME_TO_RECOVER_GRASS_FOR = 8 * 24 * 60 * 60; // 8 days
- private static final int TIME_TO_RECOVER_GRASS_FOR = 10;
-// private static final int TIME_TO_HIBERNATE_GRASS_FOR = 30 * 24 * 60 * 60; // 30 days
- private static final int TIME_TO_HIBERNATE_GRASS_FOR = 10;
+ private static final int TIME_HOURS_TO_WATER_GRASS = 7; // 7 am
+ private static final int TIME_MINUTES_TO_WATER_GRASS = 30; // 30 minutes
+ private static final int TIME_TO_RECOVER_GRASS_FOR = 8 * 24 * 60 * 60; // 8 days
+ private static final int TIME_TO_HIBERNATE_GRASS_FOR = 30 * 24 * 60 * 60; // 30 days
public static final int CAMERA_FPS = 15; // In frames per second
// Seconds since the start of the day to start the watering
long secondsForWateringStart = (TIME_HOURS_TO_WATER_GRASS * 3600) + (TIME_MINUTES_TO_WATER_GRASS * 60);
-// System.out.println("beginingOfToday " + beginingOfToday);
-// System.out.println("secondsSinceStartOfDay " + secondsSinceStartOfDay);
-// System.out.println("secondsForWateringStart " + secondsForWateringStart);
+ System.out.println("beginingOfToday " + beginingOfToday);
+ System.out.println("secondsSinceStartOfDay " + secondsSinceStartOfDay);
+ System.out.println("secondsForWateringStart " + secondsForWateringStart);
// check if the current time is within the start watering interval
- /*if ((secondsSinceStartOfDay < secondsForWateringStart) || (secondsSinceStartOfDay > (secondsForWateringStart + (60 * 60)))) {
+ if ((secondsSinceStartOfDay < secondsForWateringStart) || (secondsSinceStartOfDay > (secondsForWateringStart + (60 * 60)))) {
System.out.println("Sleep for 10 minutes.. ");
try {
//Thread.sleep(10 * 60 * 1000); // sleep for 10 minutes
}
continue;
- }*/
+ }
// check if we already checked if we should water today
// we only need to do this once per day
- /*if ((dayOfLastCheck == currentDate.getDate()) && (monthOfLastCheck == currentDate.getMonth())) {
+ if ((dayOfLastCheck == currentDate.getDate()) && (monthOfLastCheck == currentDate.getMonth())) {
System.out.println("Sleep for 1 hour...");
try {
Thread.sleep(60 * 60 * 1000); // sleep for an hour
}
continue;
- }*/
+ }
// we decided to check if we should water today so save the fact that we chose to water on this day
dayOfLastCheck = currentDate.getDate();
}
// check if we are in hibernation mode and do the correct loop action
if (isHibernationMode) {
-// System.out.println("Hibernation mode!");
+ System.out.println("Hibernation mode!");
// If we are in hibernation mode then use the hibernation loop code
wateringHibernationLoop(currentDate);
} else {
-// System.out.println("Normal mode!");
+ System.out.println("Normal mode!");
// Using the normal watering loop code
wateringNormalLoop(currentDate);
}
public void informationRetrieved(double _inchesPerWeek, int _weatherZipCode, int _daysToWaterOn, double _inchesPerMinute) {
System.out.println("DEBUG: Information is retrieved from phone!!!");
- /*try {
- // get the parameters that the interface (phone app) reads from the user
- inchesPerWeek = _wgw.getInchesPerWeek();
- weatherZipCode = _wgw.getWeatherZipCode();
- daysToWaterOn = _wgw.getDaysToWaterOn();
- inchesPerMinute.add(_wgw.getInchesPerMinute());
- } catch(RemoteException ex) {
- ex.printStackTrace();
- }*/
inchesPerWeek = _inchesPerWeek;
weatherZipCode = _weatherZipCode;
e.printStackTrace();
}
}
- // TODO: Use a phone input interface later
- /*inchesPerWeek = 20.00;
- weatherZipCode = 92612;
- daysToWaterOn = 255;
- inchesPerMinute.add(1.50);*/
System.out.println("DEBUG: inchesPerWeek: " + inchesPerWeek);
System.out.println("DEBUG: weatherZipCode: " + weatherZipCode);
// Setup the cameras, start them all and assign each one a motion detector
for (CameraSmart cam : cameraSet.values()) {
- //try {
- // initialize the camera, might need to setup some stuff internally
- cam.init();
- // set the camera parameters.
- cam.setFPS(CAMERA_FPS);
- cam.setResolution(Resolution.RES_VGA);
+ // initialize the camera, might need to setup some stuff internally
+ cam.init();
- // Start the camera (example is start the HTTP stream if it is a network camera)
- cam.start();
- System.out.println("DEBUG: Init camera! " + cam.toString());
- //} catch (RemoteException e) {
- // e.printStackTrace();
- //}
+ // set the camera parameters.
+ cam.setFPS(CAMERA_FPS);
+ cam.setResolution(Resolution.RES_VGA);
+ // Start the camera (example is start the HTTP stream if it is a network camera)
+ cam.start();
+ System.out.println("DEBUG: Init camera! " + cam.toString());
}
// counter so that we can match the lawn inches per min data with the specific lawn
Iterator camIt = cameras.iterator();
CameraSmart cam = (CameraSmart)camIt.next();
System.out.println("DEBUG: Registering callback to camera: " + cam.toString());
- //try {
- // setup the callback
- cam.registerCallback(mo);
- //} catch (RemoteException e) {
- // e.printStackTrace();
- //}
+ cam.registerCallback(mo);
}
// we also only need 1 sprinkler controller per lawn so grab the first one
// get the weather data for the next little bit
List<DayWeather> weatherData = weatherGrabber.getWeatherData();
- // TODO: Replace this with the WeatherGrabber.getWeatherData() above
-// List<DayWeather> weatherData = new ArrayList<DayWeather>();
// Go through each lawn and check if we should water it and if we should, water it
for (LawnState ls : lawns) {
// if we are in recovery mode then run the recovery action
// we are still in hibernation mode but we need to recover the grass
if (isInHibernationRecoveryMode) {
-// System.out.println("DEBUG: Recovery mode!");
+ System.out.println("DEBUG: Recovery mode!");
hibernationRecoveryLoop(_currentDate);
return;
}
// start recovery mode
isInHibernationRecoveryMode = true;
hibernationRecoveryModeStartDate = null;
-// System.out.println("DEBUG: We enter recovery mode for the first time!");
+ System.out.println("DEBUG: We enter recovery mode for the first time!");
// first cycle of recovery
hibernationRecoveryLoop(_currentDate);
return;
if (!lawnHasMotion) {
continue;
}
-// System.out.println("DEBUG: We water the lawn! (wateringHibernationLoop)");
+ System.out.println("DEBUG: We water the lawn! (wateringHibernationLoop)");
// water specific lawn since it has motion
waterLawn(ls, _currentDate, weatherData);
}
// we have been in recovery mode long enough
if (elapsedTime >= TIME_TO_RECOVER_GRASS_FOR) {
-// System.out.println("DEBUG: We have been in recovery mode long enough!");
+ System.out.println("DEBUG: We have been in recovery mode long enough!");
// reset the recovery mode
isInHibernationRecoveryMode = false;
hibernationRecoveryModeStartDate = null;
// Go through each lawn and check if we should water it and if we should, water it
for (LawnState ls : lawns) {
-// System.out.println("DEBUG: We water the lawn! (hibernationRecoveryLoop)");
+ System.out.println("DEBUG: We water the lawn! (hibernationRecoveryLoop)");
// water specific lawn since it has motion
waterLawn(ls, _currentDate, weatherData);
}
// check if today or tomorrow is a wet day
boolean todayIsWetDay = _weatherData.get(0).getIsWetDay();
boolean tomorrowIsWetDay = _weatherData.get(1).getIsWetDay();
- // TODO: Remove this later - hack the values for now!!!
-// boolean todayIsWetDay = false;
-// boolean tomorrowIsWetDay = false;
-
// lawn cannot wait anymore for water so water not
boolean lawnNeedsWaterNow = _ls.needsWateringUrgently(_currentDate);
if (lawnNeedsWaterNow) {
System.out.println("DEBUG: Is wet day? " + todayIsWetDay);
System.out.println("DEBUG: Tomorrow is wet day? " + tomorrowIsWetDay);
// if it is not going to rain today then water the lawn
- // TODO: Put this back to uncommented!!! Only for testing!!!
-// if (!todayIsWetDay) {
+ if (!todayIsWetDay) {
_ls.waterLawn(_currentDate);
-// }
+ }
return;
}