diff --git a/doc/news/DM-47552.feature.rst b/doc/news/DM-47552.feature.rst new file mode 100644 index 00000000..5a9b65bd --- /dev/null +++ b/doc/news/DM-47552.feature.rst @@ -0,0 +1 @@ +Add support for ignoring ``MTCS`` components in open and close mirror covers operation. diff --git a/python/lsst/ts/standardscripts/maintel/close_mirror_covers.py b/python/lsst/ts/standardscripts/maintel/close_mirror_covers.py index 9a57da2c..fbc471da 100644 --- a/python/lsst/ts/standardscripts/maintel/close_mirror_covers.py +++ b/python/lsst/ts/standardscripts/maintel/close_mirror_covers.py @@ -21,6 +21,7 @@ __all__ = ["CloseMirrorCovers"] +import yaml from lsst.ts import salobj from lsst.ts.observatory.control.maintel.mtcs import MTCS, MTCSUsages @@ -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 diff --git a/python/lsst/ts/standardscripts/maintel/open_mirror_covers.py b/python/lsst/ts/standardscripts/maintel/open_mirror_covers.py index e555437f..c863d222 100644 --- a/python/lsst/ts/standardscripts/maintel/open_mirror_covers.py +++ b/python/lsst/ts/standardscripts/maintel/open_mirror_covers.py @@ -21,6 +21,7 @@ __all__ = ["OpenMirrorCovers"] +import yaml from lsst.ts import salobj from lsst.ts.observatory.control.maintel.mtcs import MTCS, MTCSUsages @@ -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 diff --git a/tests/test_maintel_close_mirror_covers.py b/tests/test_maintel_close_mirror_covers.py index fcff88bd..cdc15597 100644 --- a/tests/test_maintel_close_mirror_covers.py +++ b/tests/test_maintel_close_mirror_covers.py @@ -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() diff --git a/tests/test_maintel_open_mirror_covers.py b/tests/test_maintel_open_mirror_covers.py index a5428568..95c40d42 100644 --- a/tests/test_maintel_open_mirror_covers.py +++ b/tests/test_maintel_open_mirror_covers.py @@ -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()