Skip to content

Commit

Permalink
adapt pressure jumpt to use the clear prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-dot committed Nov 14, 2024
1 parent d1a3776 commit 6387004
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/dodal/beamlines/p38.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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:",
Expand Down
49 changes: 32 additions & 17 deletions src/dodal/devices/pressure_jump_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions tests/devices/unit_tests/test_pressure_jump_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 6387004

Please sign in to comment.