From 6387004c1067573c36c47cbc84e4e669f85decbe Mon Sep 17 00:00:00 2001 From: Stanislaw Malinowski Date: Wed, 18 Sep 2024 16:25:36 +0100 Subject: [PATCH] adapt pressure jumpt to use the clear prefix --- src/dodal/beamlines/p38.py | 4 +- src/dodal/devices/pressure_jump_cell.py | 49 ++++++++++++------- .../unit_tests/test_pressure_jump_cell.py | 6 +-- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/dodal/beamlines/p38.py b/src/dodal/beamlines/p38.py index 23738cac29..e5965dbe27 100644 --- a/src/dodal/beamlines/p38.py +++ b/src/dodal/beamlines/p38.py @@ -313,7 +313,7 @@ def linkam( return device_instantiation( Linkam3, "linkam", - "-EA-LINKM-02:", + f"{BeamlinePrefix(BL).insertion_prefix}-EA-LINKM-02:", wait_for_connection, fake_with_ophyd_sim, ) @@ -337,7 +337,7 @@ def high_pressure_xray_cell( return device_instantiation( PressureJumpCell, "high_pressure_xray_cell", - "-EA", + f"{BeamlinePrefix(BL).insertion_prefix}-EA", wait_for_connection, fake_with_ophyd_sim, cell_prefix="-HPXC-01:", diff --git a/src/dodal/devices/pressure_jump_cell.py b/src/dodal/devices/pressure_jump_cell.py index 0bea4ba29a..2b8686e9fc 100644 --- a/src/dodal/devices/pressure_jump_cell.py +++ b/src/dodal/devices/pressure_jump_cell.py @@ -181,16 +181,34 @@ def __init__(self, prefix: str, name: str = "") -> None: class PressureTransducer(StandardReadable): + """ + Pressure transducer for a high pressure X-ray cell. + This is the chamber and there are three of them. + 1 is the start, 3 is where the sample is. + NOTE: the distinction between the adc prefix and the cell prefix is kept here. + + """ + def __init__( - self, prefix: str, number: int, name: str = "", adc_prefix: str = "" + self, + prefix: str, + cell_prefix: str, + number: int, + name: str = "", + full_different_prefix_adc: str = "", ) -> None: + final_prefix = f"{prefix}{cell_prefix}" with self.add_children_as_readables(): - self.omron_pressure = epics_signal_r(float, f"{prefix}PP{number}:PRES") - self.omron_voltage = epics_signal_r(float, f"{prefix}PP{number}:RAW") + self.omron_pressure = epics_signal_r( + float, f"{final_prefix}PP{number}:PRES" + ) + self.omron_voltage = epics_signal_r(float, f"{final_prefix}PP{number}:RAW") self.beckhoff_pressure = epics_signal_r( - float, f"{prefix}STATP{number}:MeanValue_RBV" + float, f"{final_prefix}STATP{number}:MeanValue_RBV" + ) + self.slow_beckhoff_voltage_readout = epics_signal_r( + float, f"{full_different_prefix_adc}CH1" ) - self.beckhoff_voltage = epics_signal_r(float, adc_prefix + "CH1") super().__init__(name) @@ -219,40 +237,37 @@ def name(self): class PressureJumpCell(StandardReadable): """ High pressure X-ray cell, used to apply pressure or pressure jumps to a sample. + prefix: str + The prefix of beamline - SPECIAL - unusual that the cell prefix is computed separately """ def __init__( self, - beamline_prefix: str, prefix: str, cell_prefix: str = "-HPXC-01:", adc_prefix: str = "-ADC", - ctrl_prefix: str = "CTRL:", name: str = "", ): - self.all_valves_control = AllValvesControl( - f"{beamline_prefix}{prefix}{cell_prefix}", name - ) - self.pump = Pump(f"{beamline_prefix}{prefix}{cell_prefix}", name) + self.all_valves_control = AllValvesControl(f"{prefix}{cell_prefix}", name) + self.pump = Pump(f"{prefix}{cell_prefix}", name) self.controller = PressureJumpCellController( - f"{beamline_prefix}{prefix}{cell_prefix}{ctrl_prefix}", name + f"{prefix}{cell_prefix}CTRL:", name ) with self.add_children_as_readables(): self.pressure_transducers: DeviceVector[PressureTransducer] = DeviceVector( { i: PressureTransducer( - prefix=f"{beamline_prefix}{prefix}{cell_prefix}", + prefix=prefix, number=i, - adc_prefix=f"{beamline_prefix}{adc_prefix}-0{i}:", + cell_prefix=cell_prefix, + full_different_prefix_adc=f"{prefix}{adc_prefix}-0{i}:", ) for i in [1, 2, 3] } ) - self.cell_temperature = epics_signal_r( - float, f"{beamline_prefix}{prefix}{cell_prefix}TEMP" - ) + self.cell_temperature = epics_signal_r(float, f"{prefix}{cell_prefix}TEMP") super().__init__(name) diff --git a/tests/devices/unit_tests/test_pressure_jump_cell.py b/tests/devices/unit_tests/test_pressure_jump_cell.py index 8f2a611f55..21c7b1df72 100644 --- a/tests/devices/unit_tests/test_pressure_jump_cell.py +++ b/tests/devices/unit_tests/test_pressure_jump_cell.py @@ -99,17 +99,17 @@ async def test_reading_pjumpcell_includes_read_fields_transducers( set_mock_value(cell.pressure_transducers[1].omron_pressure, 1001) set_mock_value(cell.pressure_transducers[1].omron_voltage, 2.51) set_mock_value(cell.pressure_transducers[1].beckhoff_pressure, 1001.1) - set_mock_value(cell.pressure_transducers[1].beckhoff_voltage, 2.51) + set_mock_value(cell.pressure_transducers[1].slow_beckhoff_voltage_readout, 2.51) set_mock_value(cell.pressure_transducers[2].omron_pressure, 1002) set_mock_value(cell.pressure_transducers[2].omron_voltage, 2.52) set_mock_value(cell.pressure_transducers[2].beckhoff_pressure, 1002.2) - set_mock_value(cell.pressure_transducers[2].beckhoff_voltage, 2.52) + set_mock_value(cell.pressure_transducers[2].slow_beckhoff_voltage_readout, 2.52) set_mock_value(cell.pressure_transducers[3].omron_pressure, 1003) set_mock_value(cell.pressure_transducers[3].omron_voltage, 2.53) set_mock_value(cell.pressure_transducers[3].beckhoff_pressure, 1003.3) - set_mock_value(cell.pressure_transducers[3].beckhoff_voltage, 2.53) + set_mock_value(cell.pressure_transducers[3].slow_beckhoff_voltage_readout, 2.53) await assert_reading( cell.pressure_transducers[1],