Skip to content

Commit

Permalink
Merge pull request #248 from lsst-ts/tickets/DM-47552
Browse files Browse the repository at this point in the history
tickets/DM-47552: Add ignore feature for open/close mirror covers
  • Loading branch information
cvillalon authored Nov 25, 2024
2 parents ddf41fa + 63ac5a7 commit 14545d7
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/news/DM-47552.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for ignoring ``MTCS`` components in open and close mirror covers operation.
39 changes: 37 additions & 2 deletions python/lsst/ts/standardscripts/maintel/close_mirror_covers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

__all__ = ["CloseMirrorCovers"]

import yaml
from lsst.ts import salobj
from lsst.ts.observatory.control.maintel.mtcs import MTCS, MTCSUsages

Expand All @@ -47,16 +48,50 @@ def __init__(self, index):

@classmethod
def get_schema(cls):
# This script does not require any configuration
return None
schema_yaml = """
$schema: http://json-schema.org/draft-07/schema#
$id: https://github.com/lsst-ts/ts_standardscripts/maintel/close_mirror_covers.yaml
title: CloseMirrorCovers v1
description: Configuration for CloseMirrorCovers.
type: object
properties:
ignore:
description: >-
CSCs from the group to ignore in status check. Name must
match those in self.group.components, e.g.; hexapod_1.
type: array
items:
type: string
additionalProperties: false
"""
return yaml.safe_load(schema_yaml)

async def configure(self, config):
"""Configure script.
Parameters
----------
config : `types.SimpleNamespace`
Script configuration, as defined by `schema`.
"""
self.config = config
if self.mtcs is None:
self.mtcs = MTCS(
domain=self.domain, intended_usage=MTCSUsages.All, log=self.log
)
await self.mtcs.start_task

if hasattr(self.config, "ignore"):
for comp in self.config.ignore:
if comp not in self.mtcs.components_attr:
self.log.warning(
f"Component {comp} not in CSC Group. "
f"Must be one of {self.mtcs.components_attr}. Ignoring."
)
else:
self.log.debug(f"Ignoring component {comp}.")
setattr(self.mtcs.check, comp, False)

def set_metadata(self, metadata):
metadata.duration = self.mtcs.mirror_covers_timeout

Expand Down
39 changes: 37 additions & 2 deletions python/lsst/ts/standardscripts/maintel/open_mirror_covers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

__all__ = ["OpenMirrorCovers"]

import yaml
from lsst.ts import salobj
from lsst.ts.observatory.control.maintel.mtcs import MTCS, MTCSUsages

Expand All @@ -47,16 +48,50 @@ def __init__(self, index):

@classmethod
def get_schema(cls):
# This script does not require any configuration
return None
schema_yaml = """
$schema: http://json-schema.org/draft-07/schema#
$id: https://github.com/lsst-ts/ts_standardscripts/maintel/open_mirror_covers.yaml
title: OpenMirrorCovers v1
description: Configuration for OpenMirrorCovers.
type: object
properties:
ignore:
description: >-
CSCs from the group to ignore in status check. Name must
match those in self.group.components, e.g.; hexapod_1.
type: array
items:
type: string
additionalProperties: false
"""
return yaml.safe_load(schema_yaml)

async def configure(self, config):
"""Configure script.
Parameters
----------
config : `types.SimpleNamespace`
Script configuration, as defined by `schema`.
"""
self.config = config
if self.mtcs is None:
self.mtcs = MTCS(
domain=self.domain, intended_usage=MTCSUsages.All, log=self.log
)
await self.mtcs.start_task

if hasattr(self.config, "ignore"):
for comp in self.config.ignore:
if comp not in self.mtcs.components_attr:
self.log.warning(
f"Component {comp} not in CSC Group. "
f"Must be one of {self.mtcs.components_attr}. Ignoring."
)
else:
self.log.debug(f"Ignoring component {comp}.")
setattr(self.mtcs.check, comp, False)

def set_metadata(self, metadata):
metadata.duration = self.mtcs.mirror_covers_timeout

Expand Down
15 changes: 15 additions & 0 deletions tests/test_maintel_close_mirror_covers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ async def test_executable(self):
script_path = scripts_dir / "maintel" / "close_mirror_covers.py"
await self.check_executable(script_path)

async def test_configure_ignore(self):
async with self.make_script():
components = ["mtptg"]
await self.configure_script(ignore=components)

assert self.script.mtcs.check.mtptg is False

async def test_configure_ignore_not_csc_component(self):
async with self.make_script():
components = ["not_csc_comp", "mtptg"]
await self.configure_script(ignore=components)

assert hasattr(self.script.mtcs, "not_csc_comp") is False
assert self.script.mtcs.check.mtptg is False


if __name__ == "__main__":
unittest.main()
15 changes: 15 additions & 0 deletions tests/test_maintel_open_mirror_covers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ async def test_executable(self):
script_path = scripts_dir / "maintel" / "open_mirror_covers.py"
await self.check_executable(script_path)

async def test_configure_ignore(self):
async with self.make_script():
components = ["mtptg"]
await self.configure_script(ignore=components)

assert self.script.mtcs.check.mtptg is False

async def test_configure_ignore_not_csc_component(self):
async with self.make_script():
components = ["not_csc_comp", "mtptg"]
await self.configure_script(ignore=components)

assert hasattr(self.script.mtcs, "not_csc_comp") is False
assert self.script.mtcs.check.mtptg is False


if __name__ == "__main__":
unittest.main()

0 comments on commit 14545d7

Please sign in to comment.