Skip to content

Commit

Permalink
Fixed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanHydrogen committed Mar 20, 2024
1 parent 3967cb6 commit 1381eb5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
3 changes: 0 additions & 3 deletions pyobs/modules/roof/basedome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions pyobs/modules/roof/baseroof.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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.
Expand Down
28 changes: 11 additions & 17 deletions pyobs/modules/roof/dummyroof.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ 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()

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)

Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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)


Expand Down

0 comments on commit 1381eb5

Please sign in to comment.