Skip to content

Commit

Permalink
Typing
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Nov 9, 2023
1 parent 0b02f9d commit a325041
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/lvmecp/actor/commands/dome.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ async def status(command: ECPCommand):
"""Returns the status of the dome."""

status = await command.actor.plc.dome.update()
if status is None:
return command.fail("Failed retrieving dome status.")

if status & DomeStatus.MOVING:
command.warning("Dome is moving!!!")
Expand Down
6 changes: 6 additions & 0 deletions python/lvmecp/dome.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def _update_internal(self):

dome_status = SimpleNamespace(**dome_registers)

assert self.flag
new_status = self.flag(0)

if dome_status.drive_state:
Expand Down Expand Up @@ -85,6 +86,8 @@ async def _move(self, open: bool, force: bool = False):

await self.update()

assert self.status is not None and self.flag is not None

if self.status & self.flag.UNKNOWN:
raise DomeError("Dome is in unknown state.")

Expand Down Expand Up @@ -145,6 +148,9 @@ async def stop(self):
drive_enabled = await self.plc.modbus["drive_enabled"].get()
status = await self.update()

if status is None or self.flag is None:
raise RuntimeError("Failed retrieving dome status.")

if not drive_enabled:
return

Expand Down
1 change: 0 additions & 1 deletion python/lvmecp/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ async def update(self, force_output: bool = False, **notifier_kwargs):
try:
new_status = await self._update_internal()
except Exception as err:
raise
log.warning(f"{self.name}: failed updating status: {err}")
new_status = self.flag(self.flag.__unknown__) if self.flag else None

Expand Down
2 changes: 2 additions & 0 deletions python/lvmecp/safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,6 @@ async def is_remote(self):
return True

await self.update()
assert self.status is not None and self.flag is not None

return not (self.status & self.flag.LOCAL)

0 comments on commit a325041

Please sign in to comment.