From e5c7262791a36fd9b522a790c6b0cd16a48adc1b Mon Sep 17 00:00:00 2001 From: Benjamin Braatz Date: Wed, 17 Feb 2021 12:52:32 +0100 Subject: [PATCH] Wait before changing mode --- schaltschrank/config.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/schaltschrank/config.py b/schaltschrank/config.py index ab1aa16..902cd20 100644 --- a/schaltschrank/config.py +++ b/schaltschrank/config.py @@ -65,6 +65,7 @@ async def process_andpin_conf(andpin_conf, queues, pins): async def fu_handler(queues, fu): in_queue = asyncio.Queue() queues.append(in_queue) + previous = '' while True: event = await in_queue.get() if event['name'] == 'motorstop': @@ -72,11 +73,16 @@ async def fu_handler(queues, fu): for out_queue in queues: await out_queue.put({'name': 'motoraus'}) elif event['name'] == 'dauervor': + if previous != 'dauervor': + await asyncio.sleep(1) for out_queue in queues: await out_queue.put({'name': 'motoran'}) await fu.set_frequency(50) await fu.start_inverter() + previous = 'dauervor' elif event['name'] == 'tippenvor': + if previous != 'tippenvor': + await asyncio.sleep(1) for out_queue in queues: await out_queue.put({'name': 'motoran'}) await fu.set_frequency(30) @@ -88,7 +94,10 @@ async def fu_handler(queues, fu): await asyncio.sleep(0.5) for out_queue in queues: await out_queue.put({'name': 'tippenfertig'}) + previous = 'tippenvor' elif event['name'] == 'tippenrück': + if previous != 'tippenrück': + await asyncio.sleep(1) for out_queue in queues: await out_queue.put({'name': 'motoran'}) await fu.set_frequency(-30) @@ -100,6 +109,7 @@ async def fu_handler(queues, fu): await asyncio.sleep(0.5) for out_queue in queues: await out_queue.put({'name': 'tippenfertig'}) + previous = 'tippenrück' in_queue.task_done() -- 2.34.1