Skip to content

Commit

Permalink
Adapt the constansts.
Browse files Browse the repository at this point in the history
  • Loading branch information
teweitsai committed Jan 17, 2025
1 parent 87f7681 commit e26a52b
Show file tree
Hide file tree
Showing 19 changed files with 192 additions and 247 deletions.
87 changes: 2 additions & 85 deletions python/lsst/ts/mtdomegui/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,105 +20,22 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

__all__ = [
"MAX_JERK",
"MAX_ACCELERATION",
"MAX_VELOCITY",
"MAX_POSITION",
"MAX_TEMPERATURE",
"NUM_INTERLOCK",
"NUM_POSITION_AZIMUTH",
"NUM_RESOLVER_ELEVATION",
"NUM_RESOLVER_SHUTTER",
"NUM_RESOLVER_DOOR",
"NUM_DRIVE_AZIMUTH",
"NUM_DRIVE_ELEVATION",
"NUM_DRIVE_SHUTTER",
"NUM_DRIVE_LOUVER",
"NUM_DRIVE_DOOR",
"NUM_TEMPERATURE_AZIMUTH",
"NUM_TEMPERATURE_ELEVATION",
"NUM_TEMPERATURE_SHUTTER",
"NUM_TEMPERATURE_LOUVER",
"NUM_TEMPERATURE_THERMAL",
"NUM_TEMPERATURE_DOOR",
"NUM_DOOR_LIMIT_SWITCH",
"NUM_DOOR_LOCKING_PIN",
"NUM_DOOR_BRAKE",
"SUBSYSTEMS",
]


# Maximum jerk in degree/second^3
MAX_JERK = 40.0

# Maximum acceleration in degree/second^2
MAX_ACCELERATION = 10.0

# Maximum velocity in degree/second
MAX_VELOCITY = 3.5
from lsst.ts.mtdomecom import APSCS_NUM_MOTORS_PER_SHUTTER, APSCS_NUM_SHUTTERS

# Maximum position in degree
MAX_POSITION = 360.0

# Maximum temperature in degree Celsius
MAX_TEMPERATURE = 10.0

# Number of the interlocks
NUM_INTERLOCK = 16

# Number of the azimuth position encoders
NUM_POSITION_AZIMUTH = 3

# Number of the elevation (light/wind screen) resolvers
NUM_RESOLVER_ELEVATION = 2

# Number of the aperture shutter resolvers
NUM_RESOLVER_SHUTTER = 4

# Number of the rear access door resolvers
NUM_RESOLVER_DOOR = 2

# Number of the azimuth drives
NUM_DRIVE_AZIMUTH = 5

# Number of the elevation (light/wind screen) drives
NUM_DRIVE_ELEVATION = 2

# Number of the aperture shutter drives
NUM_DRIVE_SHUTTER = 4

# Number of the drives per louver
NUM_DRIVE_LOUVER = 2

# Number of the rear access door drives
NUM_DRIVE_DOOR = 2

# Number of the azimuth temperature sensors
NUM_TEMPERATURE_AZIMUTH = 13

# Number of the elevation (light/wind screen) temperature sensors
NUM_TEMPERATURE_ELEVATION = 2

# Number of the aperture shutter temperature sensors
NUM_TEMPERATURE_SHUTTER = 4

# Number of the temperature sensors per louver
NUM_TEMPERATURE_LOUVER = 2

# Number of the thermal temperature sensors
NUM_TEMPERATURE_THERMAL = 13

# Number of the rear access door temperature sensors
NUM_TEMPERATURE_DOOR = 2

# Number of the rear access door limit switches
NUM_DOOR_LIMIT_SWITCH = 4

# Number of the rear access door locking pins
NUM_DOOR_LOCKING_PIN = 2

# Number of the rear access door brakes
NUM_DOOR_BRAKE = 2
NUM_DRIVE_SHUTTER = APSCS_NUM_MOTORS_PER_SHUTTER * APSCS_NUM_SHUTTERS

# Subsystems. This should be consistent with
# lsst.ts.xml.enums.MTDome.SubSystemId.
Expand Down
6 changes: 2 additions & 4 deletions python/lsst/ts/mtdomegui/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@

from dataclasses import dataclass, field

from lsst.ts.mtdomecom import CBCS_NUM_CAPACITOR_BANKS
from lsst.ts.mtdomecom import CBCS_NUM_CAPACITOR_BANKS, MON_NUM_SENSORS
from lsst.ts.xml.enums import MTDome

from .constants import NUM_INTERLOCK


@dataclass
class Status:
"""System status."""

# Interlocks.
interlocks: list[bool] = field(default_factory=lambda: [False] * NUM_INTERLOCK)
interlocks: list[bool] = field(default_factory=lambda: [False] * MON_NUM_SENSORS)

# System state. See the `SignalState` for the enum of each field.
# Put the default values of "lockingPinsEngaged" and "brakeEngaged" to -1
Expand Down
12 changes: 6 additions & 6 deletions python/lsst/ts/mtdomegui/tab/tab_aperture_shutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)
from qasync import asyncSlot

from ..constants import NUM_DRIVE_SHUTTER, NUM_RESOLVER_SHUTTER, NUM_TEMPERATURE_SHUTTER
from ..constants import NUM_DRIVE_SHUTTER
from ..model import Model
from ..signals import SignalFaultCode, SignalMotion, SignalState, SignalTelemetry
from ..utils import (
Expand Down Expand Up @@ -111,7 +111,7 @@ def _create_status(self) -> dict[str, QLabel | list[QLabel]]:
drive_torque_actual = [create_label() for _ in range(NUM_DRIVE_SHUTTER)]
drive_torque_commanded = [create_label() for _ in range(NUM_DRIVE_SHUTTER)]
drive_current_actual = [create_label() for _ in range(NUM_DRIVE_SHUTTER)]
drive_temperature = [create_label() for _ in range(NUM_TEMPERATURE_SHUTTER)]
drive_temperature = [create_label() for _ in range(NUM_DRIVE_SHUTTER)]

return {
"position_actual": position_actual,
Expand Down Expand Up @@ -157,13 +157,13 @@ def _create_figures(self) -> dict[str, TabFigure]:
"Drive Temperature",
self.model,
"deg C",
[str(idx) for idx in range(NUM_TEMPERATURE_SHUTTER)],
[str(idx) for idx in range(NUM_DRIVE_SHUTTER)],
),
"resolver": TabFigure(
"Calibrated Resolver",
self.model,
"deg",
[str(idx) for idx in range(NUM_RESOLVER_SHUTTER)],
[str(idx) for idx in range(NUM_DRIVE_SHUTTER)],
),
"power": TabFigure(
"Total Power",
Expand Down Expand Up @@ -315,7 +315,7 @@ def _create_group_drive_temperature(self) -> QGroupBox:

layout = QFormLayout()

for idx in range(NUM_TEMPERATURE_SHUTTER):
for idx in range(NUM_DRIVE_SHUTTER):
layout.addRow(f"Temperature {idx}:", self._status["drive_temperature"][idx])

return create_group_box("Drive Temperature", layout)
Expand Down Expand Up @@ -378,7 +378,7 @@ async def _callback_telemetry(self, telemetry: dict) -> None:
f"{telemetry['driveCurrentActual'][idx]:.2f} A"
)

for idx in range(NUM_TEMPERATURE_SHUTTER):
for idx in range(NUM_DRIVE_SHUTTER):
self._status["drive_temperature"][idx].setText(
f"{telemetry['driveTemperature'][idx]:.2f} deg C"
)
Expand Down
34 changes: 19 additions & 15 deletions python/lsst/ts/mtdomegui/tab/tab_azimuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
__all__ = ["TabAzimuth"]

from lsst.ts.guitool import TabTemplate, create_group_box, create_label
from lsst.ts.mtdomecom import (
AMCS_NUM_MOTOR_TEMPERATURES,
AMCS_NUM_MOTORS,
AMCS_NUM_RESOLVERS,
)
from lsst.ts.xml.enums import MTDome
from PySide6.QtWidgets import (
QFormLayout,
Expand All @@ -33,7 +38,6 @@
)
from qasync import asyncSlot

from ..constants import NUM_DRIVE_AZIMUTH, NUM_POSITION_AZIMUTH, NUM_TEMPERATURE_AZIMUTH
from ..model import Model
from ..signals import (
SignalFaultCode,
Expand Down Expand Up @@ -113,10 +117,10 @@ def _create_status(self) -> dict[str, QLabel | list[QLabel]]:
System status.
"""

drive_torque_actual = [create_label() for _ in range(NUM_DRIVE_AZIMUTH)]
drive_torque_commanded = [create_label() for _ in range(NUM_DRIVE_AZIMUTH)]
drive_current_actual = [create_label() for _ in range(NUM_DRIVE_AZIMUTH)]
drive_temperature = [create_label() for _ in range(NUM_TEMPERATURE_AZIMUTH)]
drive_torque_actual = [create_label() for _ in range(AMCS_NUM_MOTORS)]
drive_torque_commanded = [create_label() for _ in range(AMCS_NUM_MOTORS)]
drive_current_actual = [create_label() for _ in range(AMCS_NUM_MOTORS)]
drive_temperature = [create_label() for _ in range(AMCS_NUM_MOTOR_TEMPERATURES)]

return {
"position_actual": create_label(),
Expand Down Expand Up @@ -149,31 +153,31 @@ def _create_figures(self) -> dict[str, TabFigure]:
"Actual Drive Torque",
self.model,
"J",
[str(idx) for idx in range(NUM_DRIVE_AZIMUTH)],
[str(idx) for idx in range(AMCS_NUM_MOTORS)],
),
"drive_current": TabFigure(
"Actual Drive Current",
self.model,
"A",
[str(idx) for idx in range(NUM_DRIVE_AZIMUTH)],
[str(idx) for idx in range(AMCS_NUM_MOTORS)],
),
"drive_temperature": TabFigure(
"Drive Temperature",
self.model,
"deg C",
[str(idx) for idx in range(NUM_TEMPERATURE_AZIMUTH)],
[str(idx) for idx in range(AMCS_NUM_MOTOR_TEMPERATURES)],
),
"encoder_head": TabFigure(
"Calibrated Encoder Head",
self.model,
"deg",
[str(idx) for idx in range(NUM_DRIVE_AZIMUTH)],
[str(idx) for idx in range(AMCS_NUM_MOTORS)],
),
"position_encoder": TabFigure(
"Calibrated Position Encoder",
self.model,
"deg",
[str(idx) for idx in range(NUM_POSITION_AZIMUTH)],
[str(idx) for idx in range(AMCS_NUM_RESOLVERS)],
),
}

Expand Down Expand Up @@ -291,7 +295,7 @@ def _create_group_drive_torque(self) -> QGroupBox:

layout = QFormLayout()

for idx in range(NUM_DRIVE_AZIMUTH):
for idx in range(AMCS_NUM_MOTORS):
layout.addRow(
f"Torque {idx} (commanded):",
self._status["drive_torque_commanded"][idx],
Expand All @@ -301,7 +305,7 @@ def _create_group_drive_torque(self) -> QGroupBox:
)
add_empty_row_to_form_layout(layout)

for idx in range(NUM_DRIVE_AZIMUTH):
for idx in range(AMCS_NUM_MOTORS):
layout.addRow(
f"Current {idx} (actual):", self._status["drive_current_actual"][idx]
)
Expand All @@ -319,7 +323,7 @@ def _create_group_drive_temperature(self) -> QGroupBox:

layout = QFormLayout()

for idx in range(NUM_TEMPERATURE_AZIMUTH):
for idx in range(AMCS_NUM_MOTOR_TEMPERATURES):
layout.addRow(f"Temperature {idx}:", self._status["drive_temperature"][idx])

return create_group_box("Drive Temperature", layout)
Expand Down Expand Up @@ -375,7 +379,7 @@ async def _callback_telemetry(self, telemetry: dict) -> None:
)
self._status["velocity_actual"].setText(f"{velocity_actual:.2f} deg/sec") # type: ignore[union-attr]

for idx in range(NUM_DRIVE_AZIMUTH):
for idx in range(AMCS_NUM_MOTORS):
self._status["drive_torque_commanded"][idx].setText(
f"{telemetry['driveTorqueCommanded'][idx]:.2f} J"
)
Expand All @@ -386,7 +390,7 @@ async def _callback_telemetry(self, telemetry: dict) -> None:
f"{telemetry['driveCurrentActual'][idx]:.2f} A"
)

for idx in range(NUM_TEMPERATURE_AZIMUTH):
for idx in range(AMCS_NUM_MOTOR_TEMPERATURES):
self._status["drive_temperature"][idx].setText(
f"{telemetry['driveTemperature'][idx]:.2f} deg C"
)
Expand Down
22 changes: 9 additions & 13 deletions python/lsst/ts/mtdomegui/tab/tab_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@

__all__ = ["TabCommand"]

import math

from lsst.ts.guitool import (
TabTemplate,
create_double_spin_box,
create_group_box,
set_button,
)
from lsst.ts.mtdomecom import AMCS_NUM_MOTORS, LWSCS_VMAX
from lsst.ts.xml.enums import MTDome
from PySide6.QtWidgets import (
QComboBox,
Expand All @@ -38,14 +41,7 @@
)
from qasync import asyncSlot

from ..constants import (
MAX_POSITION,
MAX_TEMPERATURE,
MAX_VELOCITY,
NUM_DRIVE_AZIMUTH,
NUM_DRIVE_SHUTTER,
SUBSYSTEMS,
)
from ..constants import MAX_POSITION, MAX_TEMPERATURE, NUM_DRIVE_SHUTTER, SUBSYSTEMS
from ..model import Model
from .tab_selector import TabSelector

Expand Down Expand Up @@ -98,7 +94,7 @@ def _create_tabs(self, model: Model) -> dict[str, TabSelector]:
names_louver = [
f"{louver.name} ({idx})" for (idx, louver) in enumerate(MTDome.Louver)
]
names_drive_azimuth = [str(idx) for idx in range(NUM_DRIVE_AZIMUTH)]
names_drive_azimuth = [str(idx) for idx in range(AMCS_NUM_MOTORS)]
names_drive_shuttor = [str(idx) for idx in range(NUM_DRIVE_SHUTTER)]

return {
Expand All @@ -107,13 +103,13 @@ def _create_tabs(self, model: Model) -> dict[str, TabSelector]:
"drive_shuttor": TabSelector("Shutter Drive", model, names_drive_shuttor),
}

def _create_command_parameters(self, decimal: int = 2) -> dict:
def _create_command_parameters(self, decimal: int = 3) -> dict:
"""Create the command parameters.
Parameters
----------
decimal : `int`, optional
Decimal. (the default is 2)
Decimal. (the default is 3)
Returns
-------
Expand All @@ -132,8 +128,8 @@ def _create_command_parameters(self, decimal: int = 2) -> dict:
velocity = create_double_spin_box(
"deg/sec",
decimal,
maximum=MAX_VELOCITY,
minimum=-MAX_VELOCITY,
maximum=math.degrees(LWSCS_VMAX),
minimum=-math.degrees(LWSCS_VMAX),
)

speed = create_double_spin_box(
Expand Down
Loading

0 comments on commit e26a52b

Please sign in to comment.