-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from simonsobs/koopman/hwp-module
Add HWP module
- Loading branch information
Showing
7 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import sorunlib as run | ||
from sorunlib._internal import check_response | ||
|
||
|
||
# Public API | ||
def set_freq(freq): | ||
"""Set the rotational frequency of the HWP. | ||
Args: | ||
freq (float): Target frequency to rotate the HWP in Hz. This is a | ||
*signed float*, the meaning of which depends on the OCS site | ||
configuration. For details see the `documentation for the HWP | ||
Supervisor Agent <docs_>`_. | ||
.. _docs: https://socs.readthedocs.io/en/main/agents/hwp_supervisor_agent.html | ||
""" | ||
hwp = run.CLIENTS['hwp'] | ||
resp = hwp.pid_to_freq(target_freq=freq) | ||
check_response(hwp, resp) | ||
|
||
|
||
def stop(active=True, brake_voltage=None): | ||
"""Stop the HWP. | ||
Args: | ||
active (bool, optional): If True, actively try to stop the HWP by | ||
applying the brake. If False, simply turn off the PMX power and let | ||
it spin down on its own. Defaults to True. | ||
brake_voltage (float, optional): Voltage used when actively stopping | ||
the HWP. Only considered when active is True. | ||
""" | ||
hwp = run.CLIENTS['hwp'] | ||
|
||
if active: | ||
if brake_voltage is None: | ||
resp = hwp.brake() | ||
else: | ||
resp = hwp.brake(brake_voltage=brake_voltage) | ||
check_response(hwp, resp) | ||
else: | ||
resp = hwp.pmx_off() | ||
check_response(hwp, resp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
os.environ["OCS_CONFIG_DIR"] = "./test_util/" | ||
|
||
import pytest | ||
|
||
from sorunlib import hwp | ||
|
||
from util import create_patch_clients | ||
|
||
|
||
patch_clients_satp = create_patch_clients('satp') | ||
|
||
|
||
@pytest.mark.parametrize("active", [True, False]) | ||
def test_stop(patch_clients_satp, active): | ||
hwp.stop(active=active) | ||
if active: | ||
hwp.run.CLIENTS['hwp'].brake.assert_called_with() | ||
else: | ||
hwp.run.CLIENTS['hwp'].pmx_off.assert_called() | ||
|
||
|
||
def test_stop_brake_voltage(patch_clients_satp): | ||
VOLTAGE = 5.0 | ||
hwp.stop(active=True, brake_voltage=VOLTAGE) | ||
hwp.run.CLIENTS['hwp'].brake.assert_called_with(brake_voltage=VOLTAGE) | ||
|
||
|
||
def test_set_freq(patch_clients_satp): | ||
hwp.set_freq(freq=2.0) | ||
hwp.run.CLIENTS['hwp'].pid_to_freq.assert_called_with(target_freq=2.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters