From 1381eb5986d7f5fa0017bb6420ae1c188debb3ff Mon Sep 17 00:00:00 2001 From: GermanHydrogen Date: Wed, 20 Mar 2024 10:12:31 +0100 Subject: [PATCH] Fixed comments --- pyobs/modules/roof/basedome.py | 3 --- pyobs/modules/roof/baseroof.py | 3 +-- pyobs/modules/roof/dummyroof.py | 28 +++++++++++----------------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/pyobs/modules/roof/basedome.py b/pyobs/modules/roof/basedome.py index f5e20c7d..086c5c04 100644 --- a/pyobs/modules/roof/basedome.py +++ b/pyobs/modules/roof/basedome.py @@ -19,7 +19,6 @@ def __init__(self, **kwargs: Any): """Initialize a new base dome.""" BaseRoof.__init__(self, **kwargs) - # register exception exc.register_exception(exc.MotionError, 3, timespan=600, callback=self._default_remote_error_callback) async def get_fits_header_before( @@ -34,10 +33,8 @@ async def get_fits_header_before( Dictionary containing FITS headers. """ - # get from parent hdr = await BaseRoof.get_fits_header_before(self, namespaces, **kwargs) - # add azimuth and return it _, az = await self.get_altaz() hdr["ROOF-AZ"] = (az, "Azimuth of roof slit, deg E of N") return hdr diff --git a/pyobs/modules/roof/baseroof.py b/pyobs/modules/roof/baseroof.py index 9c5f4582..0d188022 100644 --- a/pyobs/modules/roof/baseroof.py +++ b/pyobs/modules/roof/baseroof.py @@ -19,7 +19,6 @@ def __init__(self, **kwargs: Any): """Initialize a new base roof.""" Module.__init__(self, **kwargs) - # init mixins WeatherAwareMixin.__init__(self, **kwargs) MotionStatusMixin.__init__(self, **kwargs) @@ -50,7 +49,7 @@ async def get_fits_header_before( } async def is_ready(self, **kwargs: Any) -> bool: - """Returns the device is "ready", whatever that means for the specific device. + """The roof is ready, if it is open. Returns: True, if roof is open. diff --git a/pyobs/modules/roof/dummyroof.py b/pyobs/modules/roof/dummyroof.py index 58b894ac..1a3aca43 100644 --- a/pyobs/modules/roof/dummyroof.py +++ b/pyobs/modules/roof/dummyroof.py @@ -27,7 +27,6 @@ def __init__(self, **kwargs: Any): # dummy state self._open_percentage: int = self._ROOF_CLOSED_PERCENTAGE - # allow to abort motion self._lock_motion = asyncio.Lock() self._abort_motion = asyncio.Event() @@ -35,7 +34,6 @@ async def open(self) -> None: """Open module.""" await BaseRoof.open(self) - # register event await self.comm.register_event(RoofOpenedEvent) await self.comm.register_event(RoofClosingEvent) @@ -61,17 +59,6 @@ async def init(self, **kwargs: Any) -> None: def _is_open(self): return self._open_percentage == self._ROOF_OPEN_PERCENTAGE - async def _move_roof(self, target_pos: int) -> None: - step = 1 if target_pos > self._open_percentage else -1 - - while self._open_percentage != target_pos: - if self._abort_motion.is_set(): - await self._change_motion_status(MotionStatus.IDLE) - return - - self._open_percentage += step - await asyncio.sleep(0.1) - @timeout(15) async def park(self, **kwargs: Any) -> None: """Close the roof. @@ -94,6 +81,17 @@ async def park(self, **kwargs: Any) -> None: def _is_closed(self): return self._open_percentage == self._ROOF_CLOSED_PERCENTAGE + async def _move_roof(self, target_pos: int) -> None: + step = 1 if target_pos > self._open_percentage else -1 + + while self._open_percentage != target_pos: + if self._abort_motion.is_set(): + await self._change_motion_status(MotionStatus.IDLE) + return + + self._open_percentage += step + await asyncio.sleep(0.1) + def get_percent_open(self) -> float: """Get the percentage the roof is open.""" return self._open_percentage @@ -108,13 +106,9 @@ async def stop_motion(self, device: Optional[str] = None, **kwargs: Any) -> None AcquireLockFailed: If current motion could not be aborted. """ - # change status await self._change_motion_status(MotionStatus.ABORTING) - # abort - # acquire lock async with LockWithAbort(self._lock_motion, self._abort_motion): - # change status await self._change_motion_status(MotionStatus.IDLE)