Beispiel #1
0
def state_switches_delete():

    if request.json is None:
        for switch in Register.POWERMOD_DATA.viewkeys():
            PowerModHelper.remove_override_switch(switch)
    else:
        PowerModHelper.remove_override_switch(request.json)

    return state_switches_get()
Beispiel #2
0
def filter2_logic():

    if Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_FILTER2)]['override']:
        time_now = datetime.datetime.now()
        if time_now < Register.POWERMOD_DATA_OVERRIDE[str(Register.I2C_POWERMOD_FILTER2)]['override_time']:
            return
        else:
            unblock_filter()

    if Register.CHANGE_WATER_MODE:
        PowerModHelper.unset_switch(Register.I2C_POWERMOD_FILTER2)
    else:
        PowerModHelper.set_switch(Register.I2C_POWERMOD_FILTER2)
Beispiel #3
0
def filter1_logic():

    if Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_FILTER1)]['override']:
        time_now = datetime.datetime.now()
        if time_now < Register.POWERMOD_DATA_OVERRIDE[str(Register.I2C_POWERMOD_FILTER1)]['override_time']:
            return
        else:
            unblock_filter()

    if Register.CHANGE_WATER_MODE:
        PowerModHelper.unset_switch(Register.I2C_POWERMOD_FILTER1)
    else:
        PowerModHelper.set_switch(Register.I2C_POWERMOD_FILTER1)
Beispiel #4
0
    def __init__(self):
        threading.Thread.__init__(self)

        self.threads.append(TempThread())
        self.threads.append(LircThread())

        self.threads.append(Light1Logic.Light1Thread())
        self.threads.append(Light2Logic.Light2Thread())
        self.threads.append(BottleLogic.BottleThread())
        self.threads.append(DbDriver.DbThread())
        self.threads.append(PhThread.PhThread())
        self.threads.append(O2Thread.O2Thread())

        PowerModHelper.update_data()
Beispiel #5
0
def water_temp_logic():

    if Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_HEATER)]['override'] or Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_HEATER_LED)]['override']:
        time_now = datetime.datetime.now()
        if (time_now < Register.POWERMOD_DATA_OVERRIDE[str(Register.I2C_POWERMOD_HEATER)]['override_time'] and
                    time_now < Register.POWERMOD_DATA_OVERRIDE[str(Register.I2C_POWERMOD_HEATER_LED)]['override_time']):
            return

    # sprawdzenie czy grzalki powinny dzialac
    if not Register.CHANGE_WATER_MODE:

        #sprwdzenie czy jest potrzebne wlaczenie ogrzewania

        delta = Register.WATER_SETTINGS['temp'] - Register.WATER_TEMP

        if float(delta) > float(Register.HEATER_SETTINGS['delta']):  # zgadzamy sie tylko na 0.5 stopnia roznicy
            # sprawdzenie czy swiatla sa wlaczne
            # jezeli tak - mozemy wlaczyc pompe

            if Register.LAMPS_SETTINGS["1"]['use_heater_on']:
                if math.fabs(Register.LIGHT1_TEMP - Register.WATER_SETTINGS['temp']) > Register.LAMPS_SETTINGS["1"]['use_heater_delta']:
                    PowerModHelper.set_switch(Register.I2C_POWERMOD_HEATER_LED)
                    PowerModHelper.unset_switch(Register.I2C_POWERMOD_HEATER)
                else: # musimy wlaczyc grzalke bo lampa jest za zimna
                    PowerModHelper.set_switch(Register.I2C_POWERMOD_HEATER)
                    PowerModHelper.unset_switch(Register.I2C_POWERMOD_HEATER_LED)

            else:  # jezeli nie jest to uzyjemy grzalki
                PowerModHelper.unset_switch(Register.I2C_POWERMOD_HEATER_LED)
                PowerModHelper.set_switch(Register.I2C_POWERMOD_HEATER)

        else:  # wylaczenie ogrzewania
            turn_off_heaters()
    else:
        if Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_HEATER_LED)]['on']:
            PowerModHelper.unset_switch(Register.I2C_POWERMOD_HEATER_LED)
        if Register.POWERMOD_DATA[str(Register.I2C_POWERMOD_HEATER)]['on'] and \
            Register.HEATER_SETTINGS['water_change_off']:
            PowerModHelper.unset_switch(Register.I2C_POWERMOD_HEATER)
Beispiel #6
0
def toggle_heater_led():
    PowerModHelper.toggle_switch(Register.I2C_POWERMOD_HEATER_LED)
Beispiel #7
0
def toggle_co2():
    PowerModHelper.toggle_switch(Register.I2C_POWERMOD_CO2)
Beispiel #8
0
    def event(self):
        if not Register.LIRC_EVENTS:
            return

        lirc_event = LircEvents.get_event()
        if lirc_event == LircEvents.KEY_BACK:
            DisplayRegister.set_menuWindow()

        if lirc_event == LircEvents.KEY_RIGHT:
            self.selected_index = (self.selected_index + 1) % 8
            self.redraw = True

        if lirc_event == LircEvents.KEY_LEFT:
            self.selected_index = (self.selected_index - 1) % 8
            self.redraw = True

        if lirc_event == LircEvents.KEY_OK:
            if self.selected_index == 0:
                Filter1Logic.block_filter()
                Filter1Logic.toggle_filter()
                self.redraw = True

            if self.selected_index == 1:
                Filter2Logic.block_filter()
                Filter2Logic.toggle_filter()
                self.redraw = True

            if self.selected_index == 2:
                O2Logic.block_o2()
                O2Logic.toggle_o2()
                self.redraw = True

            if self.selected_index == 3:
                Co2Logic.block_co2()
                Co2Logic.toggle_co2()
                self.redraw = True

            if self.selected_index == 4:
                WaterTempLogic.block_heater()
                WaterTempLogic.toggle_heater()
                self.redraw = True

            if self.selected_index == 5:
                WaterTempLogic.block_heater_led()
                WaterTempLogic.toggle_heater_led()
                self.redraw = True

            if self.selected_index == 6:
                PowerModHelper.remove_override_switch(
                    Register.I2C_POWERMOD_FILTER1)
                PowerModHelper.remove_override_switch(
                    Register.I2C_POWERMOD_FILTER2)
                PowerModHelper.remove_override_switch(
                    Register.I2C_POWERMOD_CO2)
                PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_O2)
                PowerModHelper.remove_override_switch(
                    Register.I2C_POWERMOD_HEATER)
                PowerModHelper.remove_override_switch(
                    Register.I2C_POWERMOD_HEATER_LED)

            if self.selected_index == 7:
                DisplayRegister.set_menuWindow()
Beispiel #9
0
def toggle_light():
    PowerModHelper.toggle_switch(Register.I2C_POWERMOD_LIGHT2)
Beispiel #10
0
def turn_on():
    #ustawienie czasu start
    PowerModHelper.set_switch(Register.I2C_POWERMOD_CO2)
Beispiel #11
0
def unblock_o2():
    PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_O2)
Beispiel #12
0
def block():
    PowerModHelper.override_switch(Register.I2C_POWERMOD_LIGHT1)
Beispiel #13
0
def turn_on():
    PowerModHelper.set_switch(Register.I2C_POWERMOD_LIGHT2)
Beispiel #14
0
def block_filter():
    PowerModHelper.override_switch(Register.I2C_POWERMOD_FILTER1)
Beispiel #15
0
def toggle_light():
    PowerModHelper.toggle_switch(Register.I2C_POWERMOD_LIGHT2)
Beispiel #16
0
def unblock():
    PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_LIGHT2)
Beispiel #17
0
def turn_on():
    PowerModHelper.set_switch(Register.I2C_POWERMOD_LIGHT2)
Beispiel #18
0
def unblock_filter():
    PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_FILTER2)
Beispiel #19
0
def toggle_o2():
    PowerModHelper.toggle_switch(Register.I2C_POWERMOD_O2)
Beispiel #20
0
def toggle_filter():
    PowerModHelper.toggle_switch(Register.I2C_POWERMOD_FILTER2)
Beispiel #21
0
def block():
    PowerModHelper.override_switch(Register.I2C_POWERMOD_LIGHT1)
Beispiel #22
0
def block_o2():
    PowerModHelper.override_switch(Register.I2C_POWERMOD_O2)
Beispiel #23
0
def unblock():
    PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_LIGHT2)
Beispiel #24
0
def turn_off():
    PowerModHelper.unset_switch(Register.I2C_POWERMOD_O2)
Beispiel #25
0
def unblock_filter():
    PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_FILTER2)
Beispiel #26
0
def state_switches_put(index):

    #ids = str(index)
    PowerModHelper.toggle_switch(index)
    PowerModHelper.override_switch(index)
    return state_switches_get()
Beispiel #27
0
def toggle_filter():
    PowerModHelper.toggle_switch(Register.I2C_POWERMOD_FILTER2)
Beispiel #28
0
def unblock_co2():
    PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_CO2)
Beispiel #29
0
def turn_off_heaters():
    PowerModHelper.unset_switch(Register.I2C_POWERMOD_HEATER)
    PowerModHelper.unset_switch(Register.I2C_POWERMOD_HEATER_LED)
Beispiel #30
0
def turn_off():
    #ustawienie czasu stop
    PowerModHelper.unset_switch(Register.I2C_POWERMOD_CO2)
Beispiel #31
0
def block_heater():
    PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_HEATER)
Beispiel #32
0
def unblock_heater_led():
    PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_HEATER_LED)
Beispiel #33
0
    def event(self):
        if not Register.LIRC_EVENTS:
            return

        lirc_event = LircEvents.get_event()
        if lirc_event == LircEvents.KEY_BACK:
            DisplayRegister.set_menuWindow()

        if lirc_event == LircEvents.KEY_RIGHT:
            self.selected_index = (self.selected_index + 1) % 8
            self.redraw = True

        if lirc_event == LircEvents.KEY_LEFT:
            self.selected_index = (self.selected_index - 1) % 8
            self.redraw = True

        if lirc_event == LircEvents.KEY_OK:
            if self.selected_index == 0:
                Filter1Logic.block_filter()
                Filter1Logic.toggle_filter()
                self.redraw = True

            if self.selected_index == 1:
                Filter2Logic.block_filter()
                Filter2Logic.toggle_filter()
                self.redraw = True

            if self.selected_index == 2:
                O2Logic.block_o2()
                O2Logic.toggle_o2()
                self.redraw = True

            if self.selected_index == 3:
                Co2Logic.block_co2()
                Co2Logic.toggle_co2()
                self.redraw = True

            if self.selected_index == 4:
                WaterTempLogic.block_heater()
                WaterTempLogic.toggle_heater()
                self.redraw = True

            if self.selected_index == 5:
                WaterTempLogic.block_heater_led()
                WaterTempLogic.toggle_heater_led()
                self.redraw = True

            if self.selected_index == 6:
                PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_FILTER1)
                PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_FILTER2)
                PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_CO2)
                PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_O2)
                PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_HEATER)
                PowerModHelper.remove_override_switch(Register.I2C_POWERMOD_HEATER_LED)

            if self.selected_index == 7:
                DisplayRegister.set_menuWindow()