Skip to content

Commit

Permalink
Add overwatcher observing status data to /overwatcher/status
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Oct 28, 2024
1 parent 7371a8f commit 71cf634
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/lvmapi/routers/overwatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class OverwatcherStatusModel(BaseModel):
Field(description="Is the overwatcher observing?"),
] = False

cancelling: Annotated[
bool,
Field(description="Are observations being cancelled?"),
] = False

calibrating: Annotated[
bool,
Field(description="Is the overwatcher taking cals?"),
Expand All @@ -63,6 +68,26 @@ class OverwatcherStatusModel(BaseModel):
Field(description="Name of the currently running calibration"),
] = None

tile_id: Annotated[
int | None,
Field(description="Tile ID of the current observation"),
] = None

dither_position: Annotated[
int | None,
Field(description="Dither position of the current observation"),
] = None

stage: Annotated[
str | None,
Field(description="Stage of the current observation"),
] = None

standard_no: Annotated[
int | None,
Field(description="Standard number of the current observation"),
] = None


class OverwatcherCalibrationModel(BaseModel):
"""Overwatcher calibration model."""
Expand Down Expand Up @@ -135,9 +160,21 @@ async def get_overwatcher_status() -> OverwatcherStatusModel:
except KeyError:
status = {"running": False}

observer_command = await clu.send_command("lvm.overwatcher", "observer status")

try:
observer_status = observer_command.replies.get("observer_status")
except KeyError:
observer_status = {}
observer_status.pop("observing") # Duplicated.

running_cal = await route_get_calibrations_current()

return OverwatcherStatusModel(**status, running_calibration=running_cal)
return OverwatcherStatusModel(
**status,
**observer_status,
running_calibration=running_cal,
)


@router.get("/status/enabled", summary="Is the overwatcher enabled?")
Expand Down

0 comments on commit 71cf634

Please sign in to comment.