Пример #1
0
  def post(self):
    flush_ingredients = [
        manual_db.Ingredient(
            manual_db.Oz(.725), ingredient)
        for ingredient in ingredients.IngredientsOrdered()
        if ingredient != "air"
    ]

    actions = []
    sorted_ingredients = sorted(
        flush_ingredients,
        key=lambda i: ingredients.IngredientNameToValvePosition(i.name, "Flush"))
    for ingredient in sorted_ingredients:
      valve = ingredients.IngredientNameToValvePosition(ingredient.name,
                                                        "Flush")
      actions.append(SetLedForValve(valve, 255, 0, 0))
    for ingredient in sorted_ingredients:
      valve = ingredients.IngredientNameToValvePosition(ingredient.name,
                                                        "Flush")
      actions.append(Move(valve_position(valve)))
      actions.append(SetLedForValve(valve, 0, 255, 0))
      actions.append(MeterBitters(valve_to_actuate=valve,
                                  drops_to_meter=1))
      actions.append(SetLedForValve(valve, 0, 128, 255))
    actions.append(Move(0.0))
    actions.append(Home(carefully=False))
    for ingredient in sorted_ingredients:
      valve = ingredients.IngredientNameToValvePosition(ingredient.name,
                                                        "Flush")
      actions.append(SetLedForValve(valve, 0, 0, 0))
    controller.EnqueueGroup(actions)
Пример #2
0
def actions_for_recipe(recipe):
  """Returns the actions necessary to make the given recipe.

    recipe: manual_db.Recipe
    """
  logging.info("Enqueuing actions for recipe %s", recipe)
  actions = []
  ingredients.SubstituteIngredients(recipe.ingredients, recipe.name)
  ingredients.ReplaceWithBackups(recipe.ingredients, recipe.name)
  sorted_ingredients = sorted(
      recipe.ingredients,
      key=lambda i: -ingredients.IngredientNameToValvePosition(
        i.name, recipe.name))
  actions.append(HoldPressure())
  for ingredient in sorted_ingredients:
    valve = ingredients.IngredientNameToValvePosition(ingredient.name,
                                                      recipe.name)
    actions.append(SetLedForValve(valve, 255, 0, 0))
  if FLAGS.ice:
    actions.append(Led(max(0, -11.15 - ICE_LOCATION), 255, 255, 0, y=4))
  actions.append(Move(0))
  if FLAGS.ice:
    actions.append(MoveWithIce(ICE_LOCATION, 0.75))
    actions.append(Led(max(0, -11.15 - ICE_LOCATION), 0, 255, 0, y=4))
    actions.append(DispenseIceWithRetry(min_oz_to_meter=1.8))
    actions.append(Led(max(0, -11.15 - ICE_LOCATION), 0, 128, 255, y=4))
  ingredients_added = 0
  for ingredient in sorted_ingredients:
    ingredients_added += 1
    valve = ingredients.IngredientNameToValvePosition(ingredient.name,
                                                      recipe.name)
    actions.append(Move(valve_position(valve)))
    if ingredients_added % 1 == 0:
      actions.append(HoldPressure())
    actions.append(SetLedForValve(valve, 0, 255, 0))
    if hasattr(ingredient.qty, 'drops'):
      actions.append(MeterBitters(valve_to_actuate=valve,
                                  drops_to_meter=ingredient.qty.drops))
    elif hasattr(ingredient.qty, 'oz'):
      actions.append(Meter(valve_to_actuate=valve,
                           oz_to_meter=ingredient.qty.oz))
    else:
      raise Exception("Ingredient %s has no quantity for recipe %s:\n%s",
                      ingredient.name, recipe.name, recipe)
    actions.append(SetLedForValve(valve, 0, 128, 255))
  actions.append(Move(0.0))
  actions.append(Home(carefully=False))
  actions.append(Move(STIR_POSITION))
  actions.append(SlamStir())
  actions.append(Move(0.0))
  actions.append(Home(carefully=False))
  actions.append(WaitForGlassRemoval(recipe.user_name, recipe))
  for ingredient in sorted_ingredients:
    valve = ingredients.IngredientNameToValvePosition(ingredient.name,
                                                      recipe.name)
    actions.append(SetLedForValve(valve, 0, 0, 0))
  actions.append(WaitForGlassPlaced())
  return actions
Пример #3
0
 def post(self):
   print "FILL HANDLER"
   try:
     args = self.request.get('text').replace(" ", "").partition(",")
     valve = int(args[2])
     oz = float(args[0])
     controller.EnqueueGroup([
         SetLedForValve(valve, 255, 0, 0), Move(valve_position(valve)),
         SetLedForValve(valve, 0, 255, 0),
         #Meter(valve_to_actuate=valve, oz_to_meter=oz),
         SetLedForValve(valve, 0, 128, 255)
     ])
   except ValueError:
     self.response.status = 400
     self.response.write("valve and oz arguments are required.")
Пример #4
0
 def post(self):
   controller.EnqueueGroup([
       Move(CUP_DISPENSE_POSITION), DispenseCup(), Move(valve_position(0)),
       ReleaseCup()
   ])