100 lines
6.0 KiB
Python
100 lines
6.0 KiB
Python
# pylint: skip-file
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from ophyd_devices.tests.utils import patched_device
|
|
|
|
from csaxs_bec.devices.epics.eps import EPS
|
|
|
|
ALL_PVS = [
|
|
# ALARMS
|
|
"X12SA-EPS-PLC:AlarmCnt_EPS",
|
|
"ARS00-MIS-PLC-01:AlarmCnt_Frontends",
|
|
# FRONTEND VALVES
|
|
"X12SA-FE-VVPG-0000:PLC_OPEN",
|
|
"X12SA-FE-VVPG-1010:PLC_OPEN",
|
|
"X12SA-FE-VVFV-2010:PLC_OPEN",
|
|
"X12SA-FE-VVPG-2010:PLC_OPEN",
|
|
# Optics VALVES
|
|
"X12SA-OP-VVPG-1010:PLC_OPEN",
|
|
"X12SA-OP-VVPG-2010:PLC_OPEN",
|
|
"X12SA-OP-VVPG-3010:PLC_OPEN",
|
|
"X12SA-OP-VVPG-3020:PLC_OPEN",
|
|
"X12SA-OP-VVPG-4010:PLC_OPEN",
|
|
"X12SA-OP-VVPG-5010:PLC_OPEN",
|
|
"X12SA-OP-VVPG-6010:PLC_OPEN",
|
|
"X12SA-OP-VVPG-7010:PLC_OPEN",
|
|
# Endstation VALVES
|
|
"X12SA-ES-VVPG-1010:PLC_OPEN",
|
|
# Frontend SHUTTERS
|
|
"X12SA-FE-PSH1-EMLS-0010:OPEN",
|
|
"X12SA-FE-STO1-EMLS-0010:OPEN",
|
|
# Optics SHUTTERS
|
|
"X12SA-OP-PSH1-EMLS-7010:OPEN",
|
|
# DMM Monochromator
|
|
"X12SA-OP-DMM-ETTC-3010:TEMP",
|
|
"X12SA-OP-DMM-ETTC-3020:TEMP",
|
|
"X12SA-OP-DMM-ETTC-3030:TEMP",
|
|
"X12SA-OP-DMM-ETTC-3040:TEMP",
|
|
"X12SA-OP-DMM-EMLS-3010:THRU",
|
|
"X12SA-OP-DMM-EMLS-3020:IN",
|
|
"X12SA-OP-DMM-EMLS-3030:THRU",
|
|
"X12SA-OP-DMM-EMLS-3040:IN",
|
|
"X12SA-OP-DMM-EMSW-3050:SWITCH",
|
|
"X12SA-OP-DMM-EMSW-3060:SWITCH",
|
|
"X12SA-OP-DMM-EMSW-3070:SWITCH",
|
|
"X12SA-OP-DMM1:ENERGY-GET",
|
|
"X12SA-OP-DMM1:POSITION",
|
|
"X12SA-OP-DMM1:STRIPE",
|
|
# CCM Monochromator
|
|
"X12SA-OP-CCM-ETTC-4010:TEMP",
|
|
"X12SA-OP-CCM-ETTC-4020:TEMP",
|
|
"X12SA-OP-CCM-EMSW-4010:SWITCH",
|
|
"X12SA-OP-CCM-EMSW-4020:SWITCH",
|
|
"X12SA-OP-CCM-EMSW-4030:SWITCH",
|
|
"X12SA-OP-CCM1:ENERGY-GET",
|
|
"X12SA-OP-CCM1:POSITION",
|
|
# Water Cooling
|
|
"X12SA-OP-SL1-EFSW-2010:FLOW",
|
|
"X12SA-OP-SL2-EFSW-2010:FLOW",
|
|
"X12SA-OP-EB1-EFSW-5010:FLOW",
|
|
"X12SA-OP-EB1-EFSW-5020:FLOW",
|
|
"X12SA-OP-SL3-EFSW-5010:FLOW",
|
|
"X12SA-OP-KB-EFSW-6010:FLOW",
|
|
"X12SA-OP-PSH1-EFSW-7010:FLOW",
|
|
"X12SA-ES-EB2-EFSW-1010:FLOW",
|
|
"X12SA-OP-CS-ECVW-0010:PLC_OPEN",
|
|
"X12SA-OP-CS-ECVW-0020:PLC_OPEN",
|
|
# Request PVs
|
|
"X12SA-EPS-PLC:ACKERR-REQUEST",
|
|
"X12SA-OP-CS-ECVW:PLC_REQUEST",
|
|
]
|
|
|
|
|
|
@pytest.fixture
|
|
def eps():
|
|
dev_name = "EPS"
|
|
with patched_device(EPS, name=dev_name) as eps:
|
|
yield eps
|
|
|
|
|
|
def test_eps_has_signals(eps):
|
|
"""Test that all expected PVs are present in the eps device."""
|
|
found_pvs = [walk.item._read_pv.pvname for walk in eps.walk_signals()]
|
|
assert set(found_pvs) == set(
|
|
ALL_PVS
|
|
), f"Expected PVs {ALL_PVS} but found {set(ALL_PVS) - set(found_pvs)}"
|
|
|
|
|
|
# pylint: disable=line-too-long
|
|
expected_show_all_output = "\x1b[1mX12SA EPS status\x1b[0m\n\n\x1b[1mEPS Alarms\x1b[0m\n - X12SA EPS Alarm count 0\n - FrontEnd MIS Alarm count 0\n\n\x1b[1mValves Frontend\x1b[0m\n - FE-VVPG-0000 \x1b[91mCLOSED\x1b[0m\n - FE-VVPG-1010 \x1b[91mCLOSED\x1b[0m\n - FE-VVFV-2010 \x1b[91mCLOSED\x1b[0m\n - FE-VVPG-2010 \x1b[91mCLOSED\x1b[0m\n\n\x1b[1mValves Optics Hutch\x1b[0m\n - OP-VVPG-1010 \x1b[91mCLOSED\x1b[0m\n - OP-VVPG-2010 \x1b[91mCLOSED\x1b[0m\n - OP-VVPG-3010 \x1b[91mCLOSED\x1b[0m\n - OP-VVPG-3020 \x1b[91mCLOSED\x1b[0m\n - OP-VVPG-4010 \x1b[91mCLOSED\x1b[0m\n - OP-VVPG-5010 \x1b[91mCLOSED\x1b[0m\n - OP-VVPG-6010 \x1b[91mCLOSED\x1b[0m\n - OP-VVPG-7010 \x1b[91mCLOSED\x1b[0m\n\n\x1b[1mValves ES Hutch\x1b[0m\n - ES-VVPG-1010 \x1b[91mCLOSED\x1b[0m\n\n\x1b[1mShutters Frontend\x1b[0m\n - FE-PSH1-EMLS-0010 \x1b[91mCLOSED\x1b[0m\n - FE-STO1-EMLS-0010 \x1b[91mCLOSED\x1b[0m\n\n\x1b[1mShutters Endstation\x1b[0m\n - OP-PSH1-EMLS-7010 \x1b[91mCLOSED\x1b[0m\n\n\x1b[1mDMM Monochromator\x1b[0m\n - DMM Temp Surface 1 0.0\n - DMM Temp Surface 2 0.0\n - DMM Temp Shield 1 (disaster) 0.0\n - DMM Temp Shield 2 (disaster) 0.0\n - DMM Translation ThruPos \x1b[91mINACTIVE\x1b[0m\n - DMM Translation InPos \x1b[91mINACTIVE\x1b[0m\n - DMM Bragg ThruPos \x1b[91mINACTIVE\x1b[0m\n - DMM Bragg InPos \x1b[91mINACTIVE\x1b[0m\n - DMM Heater Fault XTAL 1 \x1b[92mOK\x1b[0m\n - DMM Heater Fault XTAL 2 \x1b[92mOK\x1b[0m\n - DMM Heater Fault Support 1 \x1b[92mOK\x1b[0m\n - DMM Energy 0.0000\n - DMM Position out of beam\n - DMM Stripe Stripe 1 W/B4C\n\n\x1b[1mCCM Monochromator\x1b[0m\n - CCM Temp Crystal 0.0\n - CCM Temp Shield (disaster) 0.0\n - CCM Heater Fault 1 \x1b[92mOK\x1b[0m\n - CCM Heater Fault 2 \x1b[92mOK\x1b[0m\n - CCM Heater Fault 3 \x1b[92mOK\x1b[0m\n - CCM Energy 0.0000\n - CCM Position out of beam\n\n\x1b[1mCooling Water\x1b[0m\n - OP-SL1-EFSW-2010 \x1b[91mFAIL\x1b[0m\n - OP-SL2-EFSW-2010 \x1b[91mFAIL\x1b[0m\n - OP-EB1-EFSW-5010 \x1b[91mFAIL\x1b[0m\n - OP-EB1-EFSW-5020 \x1b[91mFAIL\x1b[0m\n - OP-SL3-EFSW-5010 \x1b[91mFAIL\x1b[0m\n - OP-KB-EFSW-6010 \x1b[91mFAIL\x1b[0m\n - OP-PSH1-EFSW-7010 \x1b[91mFAIL\x1b[0m\n - ES-EB2-EFSW-1010 \x1b[91mFAIL\x1b[0m\n - OP-CS-ECVW-0010 \x1b[91mCLOSED\x1b[0m\n - OP-CS-ECVW-0020 \x1b[91mCLOSED\x1b[0m\n\n\x1b[96mHint:\x1b[0m Both water cooling valves are CLOSED.\nYou can open them using: \x1b[1mdev.x12saEPS.water_cooling_op()\x1b[0m\n"
|
|
|
|
|
|
def test_eps_show_all(eps, capsys):
|
|
"""Test that the show_all method outputs the expected status."""
|
|
eps.show_all()
|
|
output = capsys.readouterr().out
|
|
assert (
|
|
output == expected_show_all_output
|
|
), f"Expected output does not match actual output.\nExpected:\n{expected_show_all_output}\nActual:\n{output}"
|