@@ -566,13 +566,16 @@ class ShakeType(enum.IntEnum):
566566 async def shake (self , shake_type : ShakeType , frequency : int ) -> None :
567567 """Warning: the duration for shaking has to be specified on the machine, and the maximum is
568568 16 minutes. As a hack, we start shaking for the maximum duration every time as long as stop
569- is not called.
569+ is not called. I think the machine might open the door at the end of the 16 minutes and then
570+ move it back in. We have to find a way to shake continuously, which is possible in protocol-mode
571+ with kinetics.
570572
571573 Args:
572574 frequency: speed, in mm
573575 """
574576
575577 max_duration = 16 * 60 # 16 minutes
578+ self ._shaking_started = asyncio .Event ()
576579
577580 async def shake_maximal_duration ():
578581 """This method will start the shaking, but returns immediately after
@@ -588,6 +591,9 @@ async def shake_maximal_duration():
588591 resp = await self .send_command ("O" )
589592 assert resp == b"\x06 0000\x03 "
590593
594+ if not self ._shaking_started .is_set ():
595+ self ._shaking_started .set ()
596+
591597 async def shake_continuous ():
592598 while self ._shaking :
593599 await shake_maximal_duration ()
@@ -602,6 +608,8 @@ async def shake_continuous():
602608 self ._shaking = True
603609 self ._shaking_task = asyncio .create_task (shake_continuous ())
604610
611+ await self ._shaking_started .wait ()
612+
605613 async def stop_shaking (self ) -> None :
606614 await self ._abort ()
607615 if self ._shaking :
0 commit comments