Skip to content

Commit

Permalink
Move all T&S enums to enums.py for easier removal
Browse files Browse the repository at this point in the history
  • Loading branch information
mfisherlevine committed Jul 7, 2023
1 parent bb6004b commit 813462a
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 65 deletions.
95 changes: 95 additions & 0 deletions python/lsst/summit/utils/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# This file is part of summit_utils.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import enum

__all__ = [
'ScriptState',
'AxisMotionState',
'PowerState',
]

# TODO: Remove this file once RFC-942 passes and we can import from the source.


class ScriptState(enum.IntEnum):
"""ScriptState constants.
Note: this is copied over from
https://github.com/lsst-ts/ts_idl/blob/develop/python/lsst/ts/idl/enums/Script.py # noqa: W505
to save having to depend on T&S code directly. These enums are extremely
static, so this is a reasonable thing to do, and much easier than setting
up a dependency on ts_idl.
"""

UNKNOWN = 0
UNCONFIGURED = 1
CONFIGURED = 2
RUNNING = 3
PAUSED = 4
ENDING = 5
STOPPING = 6
FAILING = 7
DONE = 8
STOPPED = 9
FAILED = 10
CONFIGURE_FAILED = 11


class AxisMotionState(enum.IntEnum):
"""Motion state of azimuth elevation and camera cable wrap.
Note: this is copied over from
https://github.com/lsst-ts/ts_idl/blob/develop/python/lsst/ts/idl/enums/MTMount.py # noqa: W505
to save having to depend on T&S code directly. These enums are extremely
static, so this is a reasonable thing to do, and much easier than setting
up a dependency on ts_idl.
"""

STOPPING = 0
STOPPED = 1
MOVING_POINT_TO_POINT = 2
JOGGING = 3
TRACKING = 4
TRACKING_PAUSED = 5


class PowerState(enum.IntEnum):
"""Power state of a system or motion controller.
Also used for motion controller state.
Note that only a few systems (and no motion controllers)
use TURNING_ON and TURNING_OFF. The oil supply system is one.
Note: this is copied over from
https://github.com/lsst-ts/ts_idl/blob/develop/python/lsst/ts/idl/enums/MTMount.py # noqa: W505
to save having to depend on T&S code directly. These enums are extremely
static, so this is a reasonable thing to do, and much easier than setting
up a dependency on ts_idl.
"""

OFF = 0
ON = 1
FAULT = 2
TURNING_ON = 3
TURNING_OFF = 4
UNKNOWN = 15
66 changes: 1 addition & 65 deletions python/lsst/summit/utils/tmaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import matplotlib.pyplot as plt
from lsst.utils.iteration import ensure_iterable

from .enums import ScriptState, AxisMotionState, PowerState
from .utils import getCurrentDayObs_int, dayObsIntToString
from .efdUtils import (getEfdData,
makeEfdClient,
Expand Down Expand Up @@ -430,30 +431,6 @@ def __str__(self):
)


class ScriptState(enum.IntEnum):
"""ScriptState constants.
Note: this is copied over from
https://github.com/lsst-ts/ts_idl/blob/develop/python/lsst/ts/idl/enums/Script.py # noqa: W505
to save having to depend on T&S code directly. These enums are extremely
static, so this is a reasonable thing to do, and much easier than setting
up a dependency on ts_idl.
"""

UNKNOWN = 0
UNCONFIGURED = 1
CONFIGURED = 2
RUNNING = 3
PAUSED = 4
ENDING = 5
STOPPING = 6
FAILING = 7
DONE = 8
STOPPED = 9
FAILED = 10
CONFIGURE_FAILED = 11


@dataclass(slots=True, kw_only=True, frozen=True)
class ScriptStatePoint:
time: Time
Expand Down Expand Up @@ -547,47 +524,6 @@ def __repr__(self):
return f"TMAState.{self.name}"


class AxisMotionState(enum.IntEnum):
"""Motion state of azimuth elevation and camera cable wrap.
Note: this is copied over from
https://github.com/lsst-ts/ts_idl/blob/develop/python/lsst/ts/idl/enums/MTMount.py # noqa: W505
to save having to depend on T&S code directly. These enums are extremely
static, so this is a reasonable thing to do, and much easier than setting
up a dependency on ts_idl.
"""

STOPPING = 0
STOPPED = 1
MOVING_POINT_TO_POINT = 2
JOGGING = 3
TRACKING = 4
TRACKING_PAUSED = 5


class PowerState(enum.IntEnum):
"""Power state of a system or motion controller.
Also used for motion controller state.
Note that only a few systems (and no motion controllers)
use TURNING_ON and TURNING_OFF. The oil supply system is one.
Note: this is copied over from
https://github.com/lsst-ts/ts_idl/blob/develop/python/lsst/ts/idl/enums/MTMount.py # noqa: W505
to save having to depend on T&S code directly. These enums are extremely
static, so this is a reasonable thing to do, and much easier than setting
up a dependency on ts_idl.
"""

OFF = 0
ON = 1
FAULT = 2
TURNING_ON = 3
TURNING_OFF = 4
UNKNOWN = 15


def getAxisAndType(rowFor):
"""Get the axis the data relates to, and the type of data it contains.
Expand Down

0 comments on commit 813462a

Please sign in to comment.