Beispiel #1
0
 def boil_target_reached(self, temp):
     with self._lock:
         logging.info("boiler target reached: " + str(temp) + " stage: " +
                      self._brewing_stage["name"])
         if self._brewing_stage == BrewStages.INITIAL:
             return
         if temp == 99:
             logging.debug(
                 "99C reached while preheating wort in boiler, do nothing.")
             return
         if temp == self._sparging_temperature:
             self._sparging_water_ready = True
         if self._brewing_stage == BrewStages.WAIT_FOR_SPARGING_WATER:
             # Process waited for sparging water
             self._enter_stage(BrewStages.WAIT_FOR_SPARGING_WATER["next"])
         elif self._brewing_stage == BrewStages.BOIL:
             # Boiling
             # TODO: hops
             notify("Wort has reached 100 Celsius. Prepare your hops!")
             timer = utils.PausableTimer(self.recipe.boiling_time * 60,
                                         self._boil_finished,
                                         name="boiler timer")
             self._timers.append(timer)
             timer.start()
             # Update remaining time
             self._stage_minutes[self._brewing_stage[
                 "name"]] = self.recipe.boiling_time * 60
         elif self._brewing_stage == BrewStages.MASHING_PREPARE and config.config.mash_start == 'BOILER':
             self._enter_stage(self._brewing_stage["next"])
Beispiel #2
0
 def _sparge_continue(self, timer, waittime, *_, **__):
     with self._lock:
         self._timers.remove(timer)
         self._set_valves_and_pumps(
             mash_pump=True, mash_valve=BrewProcess._MASH_VALVE_TO_TEMP)
         timer = utils.PausableTimer(waittime,
                                     self._enter_next_stage_on_timer,
                                     "pumping remaining 33% to temp")
         self._timers.append(timer)
         timer.start()
Beispiel #3
0
 def _preboil_cycle_pump(self, timer, cycle_left, *_, **__):
     # Preboil next cycle, turn on mash pump
     with self._lock:
         self._timers.remove(timer)
         self._set_valves_and_pumps(
             mash_pump=True, mash_valve=BrewProcess._MASH_VALVE_TO_TEMP)
         timer = utils.PausableTimer(
             10, self._preboil_cycle_idle,
             "pumping remaining wort from mash to temp", cycle_left - 1)
         self._timers.append(timer)
         timer.start()
Beispiel #4
0
 def _sparge(self, waittime, **kwargs):
     with self._lock:
         self._set_valves_and_pumps(**kwargs)
         if 'mash_pump' in kwargs and kwargs[
                 'mash_pump'] and 'mash_valve' in kwargs and kwargs[
                     'mash_valve'] == BrewProcess._MASH_VALVE_TO_TEMP:
             # This is from mash to temp. In this case, we pause the process at 67%
             timer = utils.PausableTimer(waittime * 0.67,
                                         self._sparge_pause,
                                         "pumping 67% to temp",
                                         waittime * 0.33)
             logging.debug(
                 "This is from mash to temp, pumping only 67% percent of the time, then there will be a pause"
             )
         else:
             timer = utils.PausableTimer(waittime,
                                         self._enter_next_stage_on_timer,
                                         "sparging timer")
         self._timers.append(timer)
         timer.start()
Beispiel #5
0
 def _preboil_cycle_idle(self, timer, cycle_left, *_, **__):
     # Preboil idle time up, wait
     # If this is the last cycle, pump from temp to boil
     with self._lock:
         if timer is not None:
             self._timers.remove(timer)
         if cycle_left == 0:
             # last cycle
             self._set_valves_and_pumps(temp_pump=True)
             timer = utils.PausableTimer(
                 70, self._preboil_cycle_end,
                 "Pumping remaining wort from temp to boil")
             self._timers.append(timer)
             timer.start()
         else:
             self._set_valves_and_pumps()
             timer = utils.PausableTimer(
                 config.config.preboil_mash_to_temp_period,
                 self._preboil_cycle_pump, "Preboil idle cycle", cycle_left)
             self._timers.append(timer)
             timer.start()
Beispiel #6
0
 def _sparge_pause(self, timer, waittime, *_, **__):
     "Called when the 75% of the wort has been transferred from mash to temp at sparging"
     with self._lock:
         self._timers.remove(timer)
         self._set_valves_and_pumps(
             mash_valve=BrewProcess._MASH_VALVE_TO_TEMP)
         timer = utils.PausableTimer(
             config.config.sparging_delay_between_mash_to_temp_stages,
             self._sparge_continue, "waiting for wort to settle in mashtun",
             waittime)
         self._timers.append(timer)
         timer.start()
Beispiel #7
0
 def mash_target_reached(self, temp):
     with self._lock:
         logging.info("mashtun target reached: " + str(temp))
         if self._brewing_stage == BrewStages.INITIAL:
             logging.info("--> This is the initial stage, do nothing")
             return
         elif self._brewing_stage == BrewStages.MASHING_PREPARE and config.config.mash_start == 'MASHTUN':
             self._enter_stage(self._brewing_stage["next"])
         elif temp == config.config.sparging_temperature:
             logging.info(
                 "--> Sparging temperature reached in mashtun as well, do nothing"
             )
             return
         _, minutes = self.recipe.mash_stages[self._brewing_stage["mash"] -
                                              1]
         timer = utils.PausableTimer(minutes * 60,
                                     self._enter_next_stage_on_timer,
                                     name="mash timer for temperature " +
                                     str(temp))
         timer.start()
         self._timers.append(timer)
         # Update to reflect correct remaining time
         self._stage_minutes[self._brewing_stage["name"]] = 60 * minutes
         self._brewing_stage_started_at = datetime.datetime.utcnow()
Beispiel #8
0
 def _enter_stage(self, stage):
     logging.info("enter stage: " + stage["name"])
     notify("Entering stage: " + stage["name"])
     #self.log_call_stack()
     pause_stage = stage in [
         BrewStages.SPARGE_PAUSE_1, BrewStages.SPARGE_PAUSE_2,
         BrewStages.MASHING_PAUSE
     ]
     if not config.config.pause and pause_stage:
         logging.info(
             "Pausing not enabled by config, skipping automatically to next stage"
         )
         self._enter_stage(stage[BrewStages.KEY_NEXT_STAGE])
         return
     mashstage = stage["mash"]
     first_mash_temp = self.recipe.mash_stages[0][0]
     self._brewing_stage_started_at = datetime.datetime.utcnow()
     if stage == BrewStages.INITIAL:
         raise ValueError("Initial is not a valid stage to resume to.")
     elif stage == BrewStages.MASHING_PREPARE:
         if config.config.mash_start == 'BOILER':
             self.actor.task(
                 BrewTask(BrewTask.BOIL_TARGET_TEMP, first_mash_temp + 5))
         else:
             self.actor.task(
                 BrewTask(BrewTask.MASH_TARGET_TEMP, first_mash_temp + 5))
     elif stage == BrewStages.MASHING_BOIL_TO_MASH:
         if config.config.transfer_mode == "MANUAL":
             if config.config.mash_start == "BOILER":
                 notify(
                     "Water is ready in boiler. Please transfer manually to mash tun, move the water from temporary to boiler and hit next."
                 )
             else:
                 notify("Water is ready in mash tun. Infuse the malt")
         else:
             self._set_valves_and_pumps(
                 boil_valve=BrewProcess._BOIL_VALVE_TO_MASH, boil_pump=True)
             timer = utils.PausableTimer(
                 self._get_pump_time_boil_to_mash(self.recipe.mash_water,
                                                  True),
                 self._enter_next_stage_on_timer,
                 name='timer: mash water from boil to mash')
             self._timers.append(timer)
             timer.start()
             #self.actor.task(BrewTask(BrewTask.MASH_TARGET_TEMP, first_mash_temp))
     elif stage == BrewStages.MASHING_TEMP_TO_BOIL:
         if config.config.transfer_mode == "MANUAL":
             # this is not used in manual mode, go to next stage
             self._enter_stage(stage["next"])
             return
         self._set_valves_and_pumps(temp_pump=True)
         timer = utils.PausableTimer(
             self._get_pump_time_temp_to_boil(self.recipe.sparge_water,
                                              True),
             self._enter_next_stage_on_timer,
             name='timer: sparging water from temp to boil')
         self._timers.append(timer)
         timer.start()
     elif mashstage > 0:
         if mashstage == 1:
             self.actor.task(
                 BrewTask(BrewTask.BOIL_TARGET_TEMP,
                          self._sparging_temperature))
         self._mash(mashstage)
     elif stage == BrewStages.WAIT_FOR_SPARGING_WATER:
         # It is possible that sparging water is already hot enough
         if self._sparging_water_ready:
             self._enter_stage(stage["next"])
             return  # to avoid setting the brewing stage at the end...
     elif stage == BrewStages.SPARGE_MASH_TO_TEMP_1:
         if config.config.transfer_mode == "MANUAL":
             notify(
                 "Mashing ended. Please 1) transfer wort from mash to temporary 2) half of the sparging water from bolier to mash tun."
             )
             self._set_valves_and_pumps()
         else:
             self._sparge(self._get_pump_time_mash_to_temp(
                 self.recipe.mash_water, True),
                          mash_pump=True,
                          mash_valve=BrewProcess._MASH_VALVE_TO_TEMP)
     elif stage == BrewStages.SPARGE_BOIL_TO_MASH_1:
         if config.config.transfer_mode == "MANUAL":
             self._enter_stage(stage["next"])
             return
         self._sparge(self._get_pump_time_boil_to_mash(
             self.recipe.sparge_water / 2.0, False),
                      boil_pump=True,
                      boil_valve=BrewProcess._BOIL_VALVE_TO_MASH)
         self.actor.task(
             BrewTask(BrewTask.MASH_TARGET_TEMP,
                      config.config.sparging_temperature))
     elif stage == BrewStages.SPARGE_CIRCULATE_IN_MASH_1:
         self._sparge(config.config.sparging_circulate_secs,
                      mash_pump=True,
                      mash_valve=BrewProcess._MASH_VALVE_TO_MASH,
                      param='SPARGE_DISTRIBUTION')
     elif stage == BrewStages.SPARGE_PAUSE_1 or stage == BrewStages.SPARGE_PAUSE_2:
         self._set_valves_and_pumps(mash_valve=None, boil_valve=None)
     elif stage == BrewStages.SPARGE_MASH_TO_TEMP_2:
         if config.config.transfer_mode == "MANUAL":
             notify(
                 "1st stage sparging ended. Please 1) transfer wort from mash to temporary 2) other half of the sparging water from bolier to mash tun. 3) wort from temporary to boiler, and start heating up"
             )
             self._set_valves_and_pumps()
         else:
             self._sparge(self._get_pump_time_mash_to_temp(
                 self.recipe.sparge_water / 2.0, True),
                          mash_pump=True,
                          mash_valve=BrewProcess._MASH_VALVE_TO_TEMP)
     elif stage == BrewStages.SPARGE_BOIL_TO_MASH_2:
         if config.config.transfer_mode == "MANUAL":
             self._enter_stage(stage["next"])
             return
         self._sparge(self._get_pump_time_boil_to_mash(
             self.recipe.sparge_water / 2.0, True),
                      boil_pump=True,
                      boil_valve=BrewProcess._BOIL_VALVE_TO_MASH)
         self.actor.task(BrewTask(BrewTask.STOP_BOIL_KETTLE))
     elif stage == BrewStages.SPARGE_TEMP_TO_BOIL_1:
         if config.config.transfer_mode == "MANUAL":
             self._enter_stage(stage["next"])
             return
         self._sparge(self._get_pump_time_temp_to_boil(
             self.recipe.mash_water + self.recipe.sparge_water / 2.0, True),
                      temp_pump=True)
         self.actor.task(BrewTask(BrewTask.BOIL_TARGET_TEMP, 99))
     elif stage == BrewStages.SPARGE_CIRCULATE_IN_MASH_2:
         self._sparge(config.config.sparging_circulate_secs,
                      mash_pump=True,
                      mash_valve=BrewProcess._MASH_VALVE_TO_MASH,
                      param='SPARGE_DISTRIBUTION')
     elif stage == BrewStages.SPARGE_MASH_TO_TEMP_3:
         if config.config.transfer_mode == "MANUAL":
             notify(
                 "2nd stage sparging ended. Please transfer wort from mash to boiler"
             )
             self._set_valves_and_pumps()
         else:
             self.actor.task(BrewTask(BrewTask.STOP_MASHING_TUN))
             self._sparge(self._get_pump_time_mash_to_temp(
                 self.recipe.sparge_water / 2.0, True),
                          mash_pump=True,
                          mash_valve=BrewProcess._MASH_VALVE_TO_TEMP)
     elif stage == BrewStages.SPARGE_TEMP_TO_BOIL_2:
         if config.config.transfer_mode == "MANUAL":
             self._enter_stage(stage["next"])
             return
         self._sparge(self._get_pump_time_temp_to_boil(
             self.recipe.mash_water + self.recipe.sparge_water, True),
                      temp_pump=True)
     elif stage == BrewStages.BOIL:
         self._stop_all()
         self.actor.task(BrewTask(BrewTask.BOIL_TARGET_TEMP, 100))
         # start preboil cycles (transfer remaining wort from mash->temp->boil)
         self._preboil_cycle_start()
     elif pause_stage:
         pass
     else:
         raise ValueError("Unhandled target stage:" + stage["name"])
     self._brewing_stage_started_at = datetime.datetime.utcnow()
     self._brewing_stage = stage