def check_time(self): time = [self.current_hour, self.current_min] bt = self.bedtime wu = self.wakeup # if (wu[0] <= self.current_hour < bt[0]) and (wu[1] <= self.current_min < bt[1]) and self.daytime is not True: if (wu[0] <= time[0] < bt[0]) and self.daytime is not True: self.daytime = True # toggle daytime to True sun() # display sun on UnicornHat # elif ((wu[0] > self.current_hour and wu[1] > self.current_min) or (self.current_hour >= bt[0] and self.current_min >= bt[1])) and self.daytime: elif (wu[0] > time[0] or time[0] >= bt[0]) and self.daytime: self.daytime = False # set daytime to False moon() # display moon on UnicornHat
def run(self): #try: #shutdown_hour_before_sunset time.sleep(300) if (self.cfg.set_system_time_from_ntp_server_at_startup): while (not globalvars.TimeSetFromNTP): time.sleep(60) if (self.cfg.shutdown_hour_before_sunset.upper() != "NONE"): s = sun.sun(lat=self.cfg.location_latitude, long=self.cfg.location_longitude) sh = float(self.cfg.shutdown_hour_before_sunset) h = math.floor(sh) m = math.floor((sh - h) * 60) sunset = s.sunset() time_todo = datetime.timedelta(hours=sunset.hour - h, minutes=sunset.minute - m, seconds=sunset.second) time_now = datetime.timedelta( hours=datetime.datetime.now().hour, minutes=datetime.datetime.now().minute, seconds=datetime.datetime.now().second) seconds_todo = (time_todo - time_now).total_seconds() if (seconds_todo < 0): seconds_todo = seconds_todo + 86400 log("SunHalter: System will Halt in %s seconds" % str(seconds_todo)) time.sleep(seconds_todo) systemHalt()
def __init__(self, cfg): self.finalresolution = cfg.cameradivicefinalresolution self.finalresolutionX = cfg.cameradivicefinalresolutionX self.finalresolutionY = cfg.cameradivicefinalresolutionY self.cfg = cfg self.bCaturing = 0 self.god=sun.sun(lat=cfg.location_latitude,long=cfg.location_longitude) # self.CameraWatchDog = CameraWatchDogClass(cfg) # if len(self.detectCameras()) > 0 : # log("Starting camera Watch Dog") # self.CameraWatchDog.run() if ( self.cfg.use_camera_resetter ): GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(self.__PIN_RESET, GPIO.OUT) if cfg.camera_resetter_normaly_on : GPIO.output(self.__PIN_RESET, True) else: GPIO.output(self.__PIN_RESET, False)
def __init__(self, deviceNumber,cfg): if (deviceNumber == 1): self.device = cfg.webcamDevice1 self.captureresolution = cfg.webcamdevice1captureresolution self.finalresolution = cfg.webcamdevice1finalresolution self.caprureresolutionX = cfg.webcamdevice1captureresolutionX self.caprureresolutionY = cfg.webcamdevice1captureresolutionY self.finalresolutionX = cfg.webcamdevice1finalresolutionX self.finalresolutionY = cfg.webcamdevice1finalresolutionY elif (deviceNumber == 2): self.device = cfg.webcamDevice2 self.captureresolution = cfg.webcamdevice2captureresolution self.finalresolution = cfg.webcamdevice2finalresolution self.caprureresolutionX = cfg.webcamdevice2captureresolutionX self.caprureresolutionY = cfg.webcamdevice2captureresolutionY self.finalresolutionX = cfg.webcamdevice2finalresolutionX self.finalresolutionY = cfg.webcamdevice2finalresolutionY else: log( "ERROR Only 2 webcams are allowed in this version of the software" ) self.cfg = cfg self.god=sun.sun(lat=cfg.location_latitude,long=cfg.location_longitude)
def run(self): #try: #shutdown_hour_before_sunset if ( self.cfg.set_system_time_from_ntp_server_at_startup ): while ( not globalvars.TimeSetFromNTP ) : time.sleep(60) if ( self.cfg.shutdown_hour_before_sunset.upper() != "NONE" ): s=sun.sun(lat=self.cfg.location_latitude,long=self.cfg.location_longitude) sh = float(self.cfg.shutdown_hour_before_sunset) h = math.floor(sh) m = math.floor( ( sh-h) * 60 ) sunset = s.sunset() time_todo = datetime.timedelta(hours=sunset.hour-h, minutes=sunset.minute-m, seconds=sunset.second) time_now = datetime.timedelta(hours=datetime.datetime.now().hour, minutes=datetime.datetime.now().minute, seconds=datetime.datetime.now().second) seconds_todo = (time_todo - time_now ).total_seconds() if (seconds_todo < 0 ) : seconds_todo = seconds_todo + 86400 log("SunHalter: System will Halt in %s seconds" % str(seconds_todo)) time.sleep(seconds_todo) systemHalt()
def __init__(self, deviceNumber, cfg): if (deviceNumber == 1): self.device = cfg.webcamDevice1 self.captureresolution = cfg.webcamdevice1captureresolution self.finalresolution = cfg.webcamdevice1finalresolution self.caprureresolutionX = cfg.webcamdevice1captureresolutionX self.caprureresolutionY = cfg.webcamdevice1captureresolutionY self.finalresolutionX = cfg.webcamdevice1finalresolutionX self.finalresolutionY = cfg.webcamdevice1finalresolutionY elif (deviceNumber == 2): self.device = cfg.webcamDevice2 self.captureresolution = cfg.webcamdevice2captureresolution self.finalresolution = cfg.webcamdevice2finalresolution self.caprureresolutionX = cfg.webcamdevice2captureresolutionX self.caprureresolutionY = cfg.webcamdevice2captureresolutionY self.finalresolutionX = cfg.webcamdevice2finalresolutionX self.finalresolutionY = cfg.webcamdevice2finalresolutionY else: log("ERROR Only 2 webcams are allowed in this version of the software" ) self.cfg = cfg self.god = sun.sun(lat=cfg.location_latitude, int=cfg.location_longitude)
def __init__(self, cfg): self.cfg = cfg self.god=sun.sun(lat=cfg.location_latitude,long=cfg.location_longitude)
def __init__(self, cfg): self.cfg = cfg self.god = sun.sun(lat=cfg.location_latitude, long=cfg.location_longitude)