Skip to content

Commit

Permalink
Add a command get_fan_drive_max_frequency.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrondel committed Jan 16, 2025
1 parent ff56efb commit 3e28f6b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/lsst/ts/vent/controller/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Config:
device_id = 1
"""The default modbus device ID for the variable frequency drive."""

max_freq = 50.0
max_freq = 25.0
"""Default maximum frequency for the dome fans."""

megaind_bus = 1
Expand Down
8 changes: 8 additions & 0 deletions python/lsst/ts/vent/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ async def get_fan_frequency(self) -> float:
output_frequency *= 0.1 # RFR register holds frequency in units of 0.1 Hz
return output_frequency

def get_max_frequency(self) -> float:
"""Returns the maximum allowed frequency.
Calls to `set_fan_frequency` may not have an argument exceeding
this value.
"""
return self.config.max_freq

async def set_fan_frequency(self, frequency: float) -> None:
"""Sets the target frequency for the dome exhaust fan. The frequency
must be between zero and MAX_FREQ.
Expand Down
7 changes: 6 additions & 1 deletion python/lsst/ts/vent/controller/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def __init__(
self.dispatch_dict: Final[dict[str, list[type]]] = {
"close_vent_gate": [int, int, int, int],
"open_vent_gate": [int, int, int, int],
"get_fan_drive_max_frequency": [],
"reset_extraction_fan_drive": [],
"set_extraction_fan_drive_freq": [float],
"set_extraction_fan_manual_control_mode": [bool],
Expand Down Expand Up @@ -164,12 +165,13 @@ async def read_and_dispatch(self) -> None:
# Convert the arguments to their expected type.
args = [cast_string_to_type(t, arg) for t, arg in zip(types, args)]
# Call the method with the specified arguments.
await getattr(self, command)(*args)
return_value = await getattr(self, command)(*args)
# Send back a success response.
await self.respond(
json.dumps(
dict(
command=command,
return_value=return_value,
error=0,
exception_name="",
message="",
Expand Down Expand Up @@ -211,6 +213,9 @@ async def open_vent_gate(
if gate != -1:
raise ValueError(f"Invalid vent ({gate}) must be between 0 and 3.")

async def get_fan_drive_max_frequency(self) -> float:
return self.controller.get_max_frequency()

async def reset_extraction_fan_drive(self) -> None:
await self.controller.vfd_fault_reset()

Expand Down

0 comments on commit 3e28f6b

Please sign in to comment.