mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-09 17:07:43 +01:00
d7c1b64493
Added fermenter type Added fermenter logic (incl. new class) -> will require cbpi4ui -> >= 0.1.a1 Still under development, but fermentation w/o steps should be working
51 lines
1,020 B
Python
51 lines
1,020 B
Python
from cbpi.api.base import CBPiBase
|
|
from cbpi.api.extension import CBPiExtension
|
|
from abc import ABCMeta
|
|
import logging
|
|
import asyncio
|
|
|
|
|
|
|
|
class CBPiFermenterLogic(CBPiBase, metaclass=ABCMeta):
|
|
|
|
def __init__(self, cbpi, id, props):
|
|
self.cbpi = cbpi
|
|
self.id = id
|
|
self.props = props
|
|
self.state = False
|
|
self.running = False
|
|
|
|
def init(self):
|
|
pass
|
|
|
|
async def on_start(self):
|
|
pass
|
|
|
|
async def on_stop(self):
|
|
pass
|
|
|
|
async def run(self):
|
|
pass
|
|
|
|
async def _run(self):
|
|
|
|
try:
|
|
await self.on_start()
|
|
self.cancel_reason = await self.run()
|
|
except asyncio.CancelledError as e:
|
|
pass
|
|
finally:
|
|
await self.on_stop()
|
|
|
|
def get_state(self):
|
|
return dict(running=self.state)
|
|
|
|
async def start(self):
|
|
|
|
self.state = True
|
|
|
|
async def stop(self):
|
|
|
|
self.task.cancel()
|
|
await self.task
|
|
self.state = False
|