Skip to content
Snippets Groups Projects
Commit 704ebd67 authored by Karim Ahmed's avatar Karim Ahmed
Browse files

refactor get_gain_mode and split code

parent 1353ac35
No related branches found
No related tags found
2 merge requests!901Draft: Tests/add more agipd tests,!900[Jungfrau][DARK] Validate and reorder dark runs before processing
from typing import Optional, Tuple
from logging import warning
from typing import Tuple
import extra_data
from cal_tools.enums import JungfrauGainMode, JungfrauSettings
from cal_tools.enums import JungfrauGainMode as JGM
from cal_tools.enums import JungfrauSettings
def _old_settings_to_new(settings: str, index: int) -> str:
......@@ -98,22 +100,22 @@ class JungfrauCtrl():
else: # JungfrauSettings.GAIN_0
return 0
def get_gain_mode(self) -> int:
"""Get gain mode value. Fixed `1` or Adaptive `1`.
- `0` if run_mode = dynamic, forceswitchg1, forceswitchg2, or None.
- `1` if run_mode = fixg1 or fixg2.
"""
def get_gain_mode_str(self):
# Check if run_mode is of an old settings to convert
# into new mode value.
if self.run_mode in [m.value for m in JungfrauGainMode]:
mode = self.run_mode
if self.run_mode in [m.value for m in JGM]:
return self.run_mode
else:
mode = _old_settings_to_new(self.run_mode, 1)
if mode in [
JungfrauGainMode.FIX_GAIN_1.value,
JungfrauGainMode.FIX_GAIN_2.value,
]:
return _old_settings_to_new(self.run_mode, 1)
def get_gain_mode(self) -> int:
"""Get gain mode value. Fixed `1` or Adaptive `0`.
Returns:
(int): gain mode parameter condition
"""
gm_enum = self.get_gain_mode_str()
if gm_enum in [JGM.FIX_GAIN_1.value, JGM.FIX_GAIN_2.value]:
return 1
else: # DYNAMIC, FORCE_SWITCH_G1, or FORCE_SWITCH_G2
else: # DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2 or None
return 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment