Skip to content
Snippets Groups Projects

[AGIPD] Read bias_voltage for AGIPD at SPB and MID from RUN source

Merged Karim Ahmed requested to merge fix/get_bias_voltage_SPB_MID into master
All threads resolved!
+ 35
15
@@ -173,36 +173,56 @@ class AgipdCtrl:
karabo_id_control: str,
module: Optional[int] = 0
) -> int:
"""Read the voltage information from the FPGA device of module 0.
"""Read the voltage information from the RUN source of module 0.
Different modules may operate at different voltages.
In practice, they all operate at the same voltage.
As such, it is okay to read a single module's value.
If the FPGA module source is not available, 300 will be returned.
300 is the default bias_voltage value before adding it to slow data.
If the FPGA/PSC RUN source is not available, 300 will be returned.
300 was the default bias_voltage value for
MID_DET_AGIPD1M-1 and SPB_DET_AGIPD1M-1.
:param karabo_id_control: The detector karabo id, for the control device.
:param karabo_id_control: The karabo deviceId for the CONTROL device.
:param module: defaults to module 0
:return: voltage, a uint16
"""
voltage_src = (
f"{karabo_id_control}/FPGA/M_{module}",
"highVoltage.actual.value")
# TODO: Add a breaking fix by passing the source and key through
# get_bias_voltage arguments.
if "AGIPD1M" in karabo_id_control:
voltage_src = (
f"{karabo_id_control[:-1]}/PSC/HV",
f"channels.U{module}.measurementSenseVoltage.value")
# TODO: Validate if removing this and depend on adding voltage value
# from the Notebook's first cell.
default_voltage = 300
else: # AGIPD500K
voltage_src = (
f"{karabo_id_control}/FPGA/M_{module}",
"highVoltage.actual.value")
default_voltage = None
if (
voltage_src[0] in self.run_dc.all_sources and
voltage_src[1] in self.run_dc.keys_for_source(voltage_src[0])
):
return self.run_dc[voltage_src].as_single_value(atol=1, reduce_by='max')
# Use RUN source for reading the bias voltage value.
# As HED_DET_AGIPD500K2G has a hardware issue that leads
# to storing arbitrary voltage values in the CONTROL source
# array. e.g. /gpfs/exfel/exp/HED/202230/p900248/raw
return int(self.run_dc.get_run_value(*voltage_src))
else:
print(
"WARNING: Unable to read bias_voltage from"
f" {voltage_src[0]}/{voltage_src[1].replace('.','/')} "
"Returning 300 as default bias voltage value."
)
return 300
# TODO: Validate if removing this and
# and using NB value for old RAW data.
error = ("ERROR: Unable to read bias_voltage from"
f" {voltage_src[0]}/{voltage_src[1].replace('.','/')}.")
if default_voltage:
print(f"{error} Returning {default_voltage} "
"as default bias voltage value.")
else:
raise ValueError(error)
return default_voltage
def get_integration_time(self) -> int:
"""Read integration time from the FPGA device.
Loading