Skip to content

Commit

Permalink
Deprecate ignore_m1m3 added disable_m1m3_force_balance property
Browse files Browse the repository at this point in the history
- Deprecate `ignore_m1m3` property.
- 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
- Added unit tests for the property deprecation and the new one
  • Loading branch information
iglesu committed Dec 10, 2024
1 parent b41b69f commit 97d32b8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
26 changes: 25 additions & 1 deletion python/lsst/ts/standardscripts/maintel/home_both_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

__all__ = ["HomeBothAxes"]

import asyncio
import time
import warnings

import yaml
from lsst.ts import salobj
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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(
Expand Down
31 changes: 31 additions & 0 deletions tests/test_maintel_home_both_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 97d32b8

Please sign in to comment.