Ejemplo n.º 1
0
 def test_state_mash_no_profile(self):
     self.brewhouse.recipe.mash_temperature_profile = MashProfile([])
     self.brewhouse.working_time = 0
     self.brewhouse.state.set_state_by_name("StateMash")
     self.brewhouse.state.state_time_change = 0
     self.brewhouse.state.evaluate()
     self.assertEqual(self.brewhouse.state.state.__class__.__name__,
                      'StateMashoutRamp')
Ejemplo n.º 2
0
 def test_state_post_strike_ready(self):
     self.brewhouse.recipe.mash_temperature_profile = MashProfile([
         MashStep(15.0, 155.0),
     ])
     self.brewhouse.boil_kettle.temperature_sensor.temperature = 156.0
     self.brewhouse.state.set_state_by_name("StatePostStrike")
     self.brewhouse.state.evaluate()
     self.assertTrue(self.brewhouse.request_permission)
Ejemplo n.º 3
0
 def test_state_mash_timer_start(self):
     self.brewhouse.recipe.mash_temperature_profile = MashProfile([
         MashStep(15.0, 155.0),
     ])
     self.brewhouse.working_time = 0
     self.brewhouse.state.set_state_by_name("StateMash")
     self.brewhouse.state.state_time_change = 0
     self.brewhouse.state.evaluate()
     self.assertAlmostEqual(self.brewhouse.timer, 15.0, 9)
Ejemplo n.º 4
0
 def test_state_post_strike(self):
     self.brewhouse.recipe.mash_temperature_profile = MashProfile([
         MashStep(15.0, 155.0),
     ])
     self.brewhouse.state.set_state_by_name("StatePostStrike")
     self.brewhouse.state.evaluate()
     self.assertFalse(self.brewhouse.main_pump.pump_status)
     self.assertTrue(self.brewhouse.boil_kettle.element_status)
     self.assertFalse(self.brewhouse.mash_tun.enabled)
     self.assertAlmostEqual(
         self.brewhouse.boil_kettle.temperature_set_point, 155.0, 9)
Ejemplo n.º 5
0
    def setUp(self):
        self.gpio = StubGPIO()
        http_client = StubJouliaHTTPClient("fake address")
        self.ws_client = StubJouliaWebsocketClient("fake address", http_client)
        self.recipe_instance = 0
        self.analog_reader = StubAnalogReader()

        stub_gpio = StubGPIO()

        heating_element_rating = 5500.0
        boil_kettle_volume = 5.0
        boil_kettle_temperature_sensor = StubRtdSensor(70.0)
        boil_kettle_heating_pin = OutputPin(stub_gpio, 0)
        self.boil_kettle = HeatedVessel(self.ws_client, self.recipe_instance,
                                        heating_element_rating,
                                        boil_kettle_volume,
                                        boil_kettle_temperature_sensor,
                                        boil_kettle_heating_pin)

        mash_tun_volume = 5.0
        mash_tun_temperature_sensor = StubRtdSensor(70.0)
        self.mash_tun = HeatExchangedVessel(self.ws_client,
                                            self.recipe_instance,
                                            mash_tun_volume,
                                            mash_tun_temperature_sensor)

        pump_pin = OutputPin(stub_gpio, 1)
        self.main_pump = SimplePump(self.ws_client, self.recipe_instance,
                                    pump_pin)

        recipe_pk = 3
        strike_temperature = 170.0
        mashout_temperature = 170.0
        mashout_time = 15.0 * 60.0
        boil_time = 60.0 * 60.0
        cool_temperature = 70.0
        mash_temperature_profile = MashProfile([])
        volume = 5.0
        pre_boil_volume_gallons = 6.0
        post_boil_volume_gallons = 5.1
        self.recipe = Recipe(recipe_pk, strike_temperature,
                             mashout_temperature, mashout_time, boil_time,
                             cool_temperature, mash_temperature_profile,
                             volume, pre_boil_volume_gallons,
                             post_boil_volume_gallons)

        self.brewhouse = Brewhouse(self.ws_client, self.recipe_instance,
                                   self.boil_kettle, self.mash_tun,
                                   self.main_pump, self.recipe)
Ejemplo n.º 6
0
 def test_state_mash(self):
     set_point = 155.0
     self.brewhouse.recipe.mash_temperature_profile = MashProfile([
         MashStep(15.0, set_point),
     ])
     self.brewhouse.working_time = 0
     self.brewhouse.state.set_state_by_name("StateMash")
     self.brewhouse.state.state_time_change = 0
     self.brewhouse.state.evaluate()
     self.assertTrue(self.brewhouse.main_pump.pump_status)
     self.assertTrue(self.brewhouse.boil_kettle.element_status)
     self.assertTrue(self.brewhouse.mash_tun.enabled)
     self.assertEqual(self.brewhouse.mash_tun.temperature_set_point,
                      set_point)
     # TODO(willjschmitt): This should be set by the state machine instead of
     # by the parent, but leaving this as is for now.
     self.assertEqual(self.brewhouse.boil_kettle.temperature_set_point, 0.0)
Ejemplo n.º 7
0
    def setUp(self):
        self.http_client = StubJouliaHTTPClient("http://fake-address")
        recipe_instance_pk = 0
        recipe_pk = 0
        self.http_client.recipe_instance = RecipeInstance(
            recipe_instance_pk, recipe_pk)
        with open('testing/brewhouse.json') as brewhouse_file:
            self.http_client.brewhouse = json.load(brewhouse_file)
        strike_temperature = 162.0
        mashout_temperature = 170.0
        mashout_time = 15.0 * 60.0
        boil_time = 60.0 * 60.0
        cool_temperature = 70.0
        mash_temperature_profile = MashProfile([MashStep(15 * 60, 155.0)])
        volume = 5.0
        pre_boil_volume_gallons = 6.0
        post_boil_volume_gallons = 5.1
        self.http_client.recipe = Recipe(recipe_pk, strike_temperature,
                                         mashout_temperature, mashout_time,
                                         boil_time, cool_temperature,
                                         mash_temperature_profile, volume,
                                         pre_boil_volume_gallons,
                                         post_boil_volume_gallons)
        self.ws_client = StubJouliaWebsocketClient("ws://fake-address",
                                                   self.http_client)
        self.start_stop_client = StubAsyncHTTPClient()

        brewhouse_id = 0

        mcp = StubMCP3008(spi=StubSpiDev())
        analog_reference = 3.3  # Volts
        analog_reader = MCP3004AnalogReader(mcp, analog_reference)

        gpio = StubGPIO()

        self.update_manager = StubUpdateManager()

        self.system = SimulatedSystem(self.http_client,
                                      self.ws_client,
                                      self.start_stop_client,
                                      brewhouse_id,
                                      analog_reader,
                                      gpio,
                                      self.update_manager,
                                      clock=StubClock())
Ejemplo n.º 8
0
    def get_recipe(self, recipe_pk):
        """Retrieves the recipe associated with a recipe instance and loads it
        into a Recipe object.

        Args:
            recipe_pk: the primary key/id for the recipe interested in for the
                mash profile.

        Returns:
            Mash points as an array of (duration, temperature) pairs.
        """
        mash_points = self.get_mash_points(recipe_pk)
        mash_profile = MashProfile(mash_points)

        recipe_url = self._get_recipe_url(recipe_pk)
        recipe_response = self._get(recipe_url)
        recipe_json_response = recipe_response.json()

        return Recipe.from_joulia_webserver(recipe_json_response, mash_profile)