diff --git a/python/lsst/ts/standardscripts/maintel/home_both_axes.py b/python/lsst/ts/standardscripts/maintel/home_both_axes.py index f22c79f8..07cc844f 100644 --- a/python/lsst/ts/standardscripts/maintel/home_both_axes.py +++ b/python/lsst/ts/standardscripts/maintel/home_both_axes.py @@ -21,8 +21,8 @@ __all__ = ["HomeBothAxes"] -import asyncio import time +import warnings import yaml from lsst.ts import salobj @@ -56,6 +56,7 @@ class HomeBothAxes(salobj.BaseScript): def __init__(self, index, add_remotes: bool = True): super().__init__(index=index, descr="Home both TMA axis.") + self.disable_m1m3_force_balance = False self.home_both_axes_timeout = 300.0 # timeout to home both MTMount axes. self.warn_wait = 10.0 @@ -69,6 +70,15 @@ def get_schema(cls): title: HomeBothAxes v1 description: Configuration for HomeBothAxes. type: object + properties: + ignore_m1m3: + description: Ignore the m1m3 component? + type: boolean + default: false + disable_m1m3_force_balance: + description: Disable m1m3 force balance? + type: boolean + default: false additionalProperties: false """ return yaml.safe_load(schema_yaml) @@ -78,10 +88,24 @@ async def configure(self, config): self.mtcs = MTCS(domain=self.domain, log=self.log) await self.mtcs.start_task + if hasattr(config, "ignore_m1m3"): + warnings.warn( + "The 'ignore_m1m3' configuration property is deprecated and will be removed" + " in future releases. Please use 'disable_m1m3_force_balance' instead.", + DeprecationWarning, + stacklevel=2, + ) + self.disable_m1m3_force_balance = config.disable_m1m3_force_balance + def set_metadata(self, metadata): metadata.duration = self.home_both_axes_timeout async def run(self): + + if self.disable_m1m3_force_balance: + await self.checkpoint("Disable M1M3 balance system.") + await self.mtcs.disable_m1m3_balance_system() + await self.checkpoint("Homing Both Axes") start_time = time.time() await self.mtcs.rem.mtmount.cmd_homeBothAxes.start( diff --git a/tests/test_maintel_home_both_axes.py b/tests/test_maintel_home_both_axes.py index 0377d494..abbda295 100644 --- a/tests/test_maintel_home_both_axes.py +++ b/tests/test_maintel_home_both_axes.py @@ -50,7 +50,38 @@ async def test_run(self): await self.run_script() + self.script.mtcs.disable_m1m3_balance_system.assert_not_called() + self.script.mtcs.rem.mtmount.cmd_homeBothAxes.start.assert_awaited_once_with( + timeout=self.script.home_both_axes_timeout + ) + + async def test_run_with_balance_disabled(self): + async with self.make_script(): + await self.configure_script(disable_m1m3_force_balance=True) + + await self.run_script() + self.script.mtcs.disable_m1m3_balance_system.assert_awaited_once() + + self.script.mtcs.rem.mtmount.cmd_homeBothAxes.start.assert_awaited_once_with( + timeout=self.script.home_both_axes_timeout + ) + + async def test_deprecated_ignore_m1m3_usage(self): + async with self.make_script(): + + with self.assertWarns(DeprecationWarning) as cm: + await self.configure_script(ignore_m1m3=True) + + self.assertIn( + "The 'ignore_m1m3' configuration property is deprecated and will be removed" + " in future releases. Please use 'disable_m1m3_force_balance' instead.", + str(cm.warning), + ) + + await self.run_script() + + # Assert that homeBothAxes command was called self.script.mtcs.rem.mtmount.cmd_homeBothAxes.start.assert_awaited_once_with( timeout=self.script.home_both_axes_timeout )