Skip to content

Commit

Permalink
Merge pull request #254 from lsst-ts/tickets/DM-48022
Browse files Browse the repository at this point in the history
Tickets/dm 48022
  • Loading branch information
iglesu authored Dec 12, 2024
2 parents ee067b2 + f046ad6 commit a6e6525
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 14 deletions.
5 changes: 5 additions & 0 deletions doc/news/DM-48022.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Added new property `disable_m1m3_force_balance` with default `false`.
Maintains the ability to disable the M1M3 balance system, in case
the coupling effect between the elevation axis and m1m3
support system, repeats again, driving the system to a huge
oscillation
1 change: 1 addition & 0 deletions doc/news/DM-48022.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate `ignore_m1m3` property.
31 changes: 17 additions & 14 deletions python/lsst/ts/standardscripts/maintel/home_both_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

__all__ = ["HomeBothAxes"]

import asyncio
import time

import yaml
Expand Down Expand Up @@ -56,10 +55,8 @@ 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.ignore_m1m3 = False
self.warn_wait = 10.0
self.mtcs = None

@classmethod
Expand All @@ -72,7 +69,10 @@ def get_schema(cls):
type: object
properties:
ignore_m1m3:
description: Ignore the m1m3 component?
description: Ignore the m1m3 component? (Deprecated property)
type: boolean
disable_m1m3_force_balance:
description: Disable m1m3 force balance?
type: boolean
default: false
additionalProperties: false
Expand All @@ -83,21 +83,25 @@ async def configure(self, config):
if self.mtcs is None:
self.mtcs = MTCS(domain=self.domain, log=self.log)
await self.mtcs.start_task
self.ignore_m1m3 = config.ignore_m1m3

if hasattr(config, "ignore_m1m3"):
self.log.warning(
"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 not self.ignore_m1m3:
if self.disable_m1m3_force_balance:
await self.checkpoint("Disable M1M3 balance system.")
await self.mtcs.disable_m1m3_balance_system()
else:
self.log.warning(
"Ignoring M1M3. Make sure m1m3 balance system is disabled!"
)
await asyncio.sleep(self.warn_wait)

await self.checkpoint("Homing Both Axes")
start_time = time.time()
await self.mtcs.rem.mtmount.cmd_homeBothAxes.start(
Expand All @@ -108,7 +112,6 @@ async def run(self):

self.log.info(f"Homing both axes took {elapsed_time:.2f} seconds")

if not self.ignore_m1m3:
if not self.disable_m1m3_force_balance:
self.log.info("Enabling M1M3 balance system.")
await asyncio.sleep(self.warn_wait)
await self.mtcs.enable_m1m3_balance_system()
53 changes: 53 additions & 0 deletions tests/test_maintel_home_both_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import unittest
from unittest.mock import patch

from lsst.ts import standardscripts
from lsst.ts.observatory.control.maintel.mtcs import MTCS, MTCSUsages
Expand Down Expand Up @@ -50,7 +51,59 @@ 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 patch.object(self.script.log, "warning") as mock_log_warning:
await self.configure_script(ignore_m1m3=True)

mock_log_warning.assert_called_once_with(
"The 'ignore_m1m3' configuration property is deprecated and will be removed"
" in future releases. Please use 'disable_m1m3_force_balance' instead.",
DeprecationWarning,
stacklevel=2,
)

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 ttest_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
)
Expand Down

0 comments on commit a6e6525

Please sign in to comment.