Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tickets/DM-47552: Add ignore feature for open/close mirror covers #248

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading