add recipe class

This commit is contained in:
Jannes Magnusson
2025-10-18 20:15:11 +02:00
parent d619ec1859
commit 06df2e0e9b
7 changed files with 198 additions and 70 deletions

View File

@@ -0,0 +1,61 @@
from __future__ import annotations
from typing import Union
from enum import Enum
class Recipe:
def __init__(self, name: str, steps: list[Step]):
self.name = name
self.steps = steps + [Step(StepType.SECTION, "Enjoy")]
def __str__(self):
return self.name
class StepType(Enum):
SECTION = 0
WEIGH = 1
START_TIME = 2
WAIT_TIME_FINISHED = 3
TARE = 4
class Step:
def __init__(self,
step_type: StepType,
value: float | str = None):
self.step_type = step_type
self.value = value
###### example recipes #########
V60 = Recipe(
"V60",
[
Step(StepType.SECTION, "Grind"),
Step(StepType.TARE),
Step(StepType.WEIGH, 15),
Step(StepType.SECTION, "Brew"),
Step(StepType.TARE),
Step(StepType.START_TIME, 45),
Step(StepType.WEIGH, 50),
Step(StepType.WAIT_TIME_FINISHED),
Step(StepType.START_TIME, -1),
Step(StepType.WEIGH, 250),
]
)
ESPRESSO = Recipe(
"Espresso",
[
Step(StepType.SECTION, "Grind"),
Step(StepType.TARE),
Step(StepType.WEIGH, 18),
Step(StepType.SECTION, "Brew"),
Step(StepType.TARE),
Step(StepType.START_TIME, -1),
Step(StepType.WEIGH, 40),
]
)