Adjusting back into the original lengthy version of IrrigationController; for testing...
[iot2.git] / benchmarks / Java / IrrigationController / LawnState.java
index 10ac4f0dc5a432fdb0a36ddcded3e1efdf391888..35583546a5ab5d3ecf1c8a9ac08c8c6bc382e9dc 100644 (file)
@@ -204,8 +204,7 @@ public class LawnState extends UnicastRemoteObject implements MotionDetectionCal
        public boolean needsWateringUrgently(Date _currentDate) {
 
                // get difference between now and last time watered
-               // TODO: Remove this to uncommented!!! This is only for testing!!!
-/*             long timeElapsed = (_currentDate.getTime() - lastTimeWatered.getTime()) / 1000;
+               long timeElapsed = (_currentDate.getTime() - lastTimeWatered.getTime()) / 1000;
 
                // needs watering now urgently
                if (timeElapsed >= MAX_TIME_BETWEEN_WATERING_SESSIONS) {
@@ -215,7 +214,7 @@ public class LawnState extends UnicastRemoteObject implements MotionDetectionCal
                // calculate the average moisture readings of all the
                // sensors in this lawn
                double averageMoistureValue = getAverageMoistureReading();
-
+               System.out.println("DEBUG: Average moisture value: " + averageMoistureValue);
                // is a valid average
                if (averageMoistureValue != -1) {
                        // moisture is very low so we need to water now!
@@ -228,11 +227,6 @@ public class LawnState extends UnicastRemoteObject implements MotionDetectionCal
                }
 
                return false;
-*/
-               double averageMoistureValue = getAverageMoistureReading();
-//             System.out.println("DEBUG: Average moisture value: " + averageMoistureValue);
-
-               return true;
        }
 
 
@@ -502,12 +496,12 @@ public class LawnState extends UnicastRemoteObject implements MotionDetectionCal
                        System.out.println("DEBUG: Current time stamp: " + currentTime.getTime());
                        System.out.println("Time elapsed: " + (currentTime.getTime() - readingTimestamp.getTime()) / 1000);                     
 
-                       //long timeElapsedSinceLastWatering = (currentTime.getTime() - readingTimestamp.getTime()) / 1000;
+                       long timeElapsedSinceLastWatering = (currentTime.getTime() - readingTimestamp.getTime()) / 1000;
 
                        // if reading is old then dont use it since it is noise
-                       //if (timeElapsedSinceLastWatering > TWO_HOURS) {
-                       //      continue;
-                       //}
+                       if (timeElapsedSinceLastWatering > TWO_HOURS) {
+                               continue;
+                       }
 
                        // Do averaging
                        numberOfReadings++;