def increase_times(event: Event, increase_percentage: float, threshold: int, forecast: Forecast): # print(event) degrees_above = int(forecast.get_max_temp()) - threshold total_increase_percentage = degrees_above * increase_percentage #print("The total increase percentage: " + str(total_increase_percentage)) total_watering_time = event.stop_time - event.start_time total_watering_time_hour = int(total_watering_time) total_watering_time_minute = int( (total_watering_time - total_watering_time) * 100) total_watering_time_in_minutes = (total_watering_time_hour * 60) + total_watering_time_minute #print("total_watering_time: " + str(total_watering_time_in_minutes)) increase_in_minutes = total_watering_time_in_minutes * total_increase_percentage #print(increase_in_minutes) #print("Total increase time: " + str(increase)) increase_hour = int(increase_in_minutes / 60) increase_minute = int(increase_in_minutes - increase_hour * 60) #print("Increase hour: " + str(increase_hour) + " Increase minute: " + str(increase_minute)) current_hour = int(event.stop_time) current_minute = int((event.stop_time - current_hour) * 100) if (int(current_minute) + increase_minute) == 60: new_hour = int(current_hour) + 1 + increase_hour new_minute = 0 temp = str(new_hour) + '.' + str(new_minute) new_time = float(temp) event.set_stop_time(new_time) elif (int(current_minute) + increase_minute) > 60: new_hour = current_hour + 1 + increase_hour new_minute = (current_minute + increase_minute) - 60 if new_minute < 10: temp = str(new_hour) + ".0" + str(new_minute) new_time = float(temp) event.set_stop_time(new_time) else: temp = str(new_hour) + "." + str(new_minute) new_time = float(temp) event.set_stop_time(new_time) else: new_hour = current_hour + increase_hour new_minute = current_minute + increase_minute temp = str(new_hour) + "." + str(new_minute) new_time = float(temp) event.set_stop_time(new_time) return event
def increase_times(event: Event, increase_percentage: float, threshold: int, forecast: Forecast): # print(event) degrees_above = int(forecast.get_max_temp()) - threshold total_increase_percentage = degrees_above * increase_percentage #print("The total increase percentage: " + str(total_increase_percentage)) total_watering_time = event.stop_time - event.start_time total_watering_time_hour = int(total_watering_time) total_watering_time_minute = int((total_watering_time - total_watering_time) * 100) total_watering_time_in_minutes = (total_watering_time_hour * 60) + total_watering_time_minute #print("total_watering_time: " + str(total_watering_time_in_minutes)) increase_in_minutes = total_watering_time_in_minutes*total_increase_percentage #print(increase_in_minutes) #print("Total increase time: " + str(increase)) increase_hour = int(increase_in_minutes/60) increase_minute = int(increase_in_minutes - increase_hour*60) #print("Increase hour: " + str(increase_hour) + " Increase minute: " + str(increase_minute)) current_hour = int(event.stop_time) current_minute = int((event.stop_time - current_hour) * 100) if (int(current_minute) + increase_minute) == 60: new_hour = int(current_hour) + 1 + increase_hour new_minute = 0 temp = str(new_hour) + '.' + str(new_minute) new_time = float(temp) event.set_stop_time(new_time) elif (int(current_minute) + increase_minute) > 60: new_hour = current_hour + 1 + increase_hour new_minute = (current_minute + increase_minute) - 60 if new_minute < 10: temp = str(new_hour) + ".0" + str(new_minute) new_time = float(temp) event.set_stop_time(new_time) else: temp = str(new_hour) + "." + str(new_minute) new_time = float(temp) event.set_stop_time(new_time) else: new_hour = current_hour + increase_hour new_minute = current_minute + increase_minute temp = str(new_hour) + "." + str(new_minute) new_time = float(temp) event.set_stop_time(new_time) return event
""" ############################################# GLOBAL DEFINITIONS ###################################################### """ # GLOBAL VARIABLEs RECV_BUFFER = 8192 ipc_file = "/var/www/Team16Website/garden_net/gn_util/ipc_file.txt" user_info_file = "/var/www/Team16Website/garden_net/gn_util/user_info.txt" alerts_file = "/var/www/Team16Website/garden_net/gn_util/alerts.txt" file_data = "" db = Database(False) json_conversion = JSON_Interface() SOCKET_LIST = [] EVENT_LIST = [] forecast = Forecast() sending_todays_schedule = False # Parse the command line for the options on ways to run the script parser = argparse.ArgumentParser(description="A prattle server") # -v allows the user to view all of the output of the server parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", help="turn verbose output on") args = parser.parse_args() """******************* START THE SOCKETS ***********************""" # @server_socket: Socket that listens for new connections server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) host = socket.gethostname() port = 5530 if args.verbose:
import socket from weather_forecast import Forecast from database import Database from JSON import JSON_Interface forecast = Forecast() #db = Database(False) ipc_file = "ipc_file.txt" rain_threshold = .8 temp_threshold = 10 json_convert = JSON_Interface() soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = socket.gethostname() port = 5538 #########TESTING db = Database(True) from event import Event from zone import Zone z = Zone(1) z2 = Zone(2) z3 = Zone(3) db.add_zone(z) db.add_zone(z2) test_event0 = Event(3.0, 4.0, 'Sunday', 1, 1) test_event1 = Event(1.0, 2.0, 'Sunday', 1, 1)
# print("rain") # elif line.split('\t')[0] == "hot": # if line.split('\t')[1].upper() == "TRUE": # print("hot as balls") # hot = True # demo_weather_report.close() import json from database import Database from event import Event from zone import Zone from weather_forecast import Forecast db = Database(True) forecast = Forecast() z = Zone(1) z2 = Zone(2) z3 = Zone(3) db.add_zone(z) db.add_zone(z2) db.add_zone(z3) test_event0 = Event(3.0, 5.0, 'Everyday', 1, 1) test_event1 = Event(1.0, 3.0, 'Everyday', 1, 1) test_event2 = Event(2.0, 4.0, 'Everyday', 1, 1) test_event3 = Event(1.5, 3.5, 'Everyday', 1, 1) test_event4 = Event(1.0, 3.0, 'Everyday', 1, 2) test_event5 = Event(1.0, 3.0, 'Everyday', 1, 3) test_event6 = Event(1.5, 4.0, 'Everyday', 1, 3)
from weather_forecast import Forecast forecast = Forecast() forecast.check_for_freeze()