Skip to content
Snippets Groups Projects
Commit 9e38518f authored by David Hammer's avatar David Hammer
Browse files

Move some initialization out of __init__

parent 7cfb2ca6
No related branches found
No related tags found
2 merge requests!12Snapshot: field test deployed version as of end of run 202201,!3Base correction device, CalCat interaction, DSSC and AGIPD devices
...@@ -219,7 +219,7 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner): ...@@ -219,7 +219,7 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner):
self.g_gain_value = cupy.float32(override_value) self.g_gain_value = cupy.float32(override_value)
def load_bad_pixels_map(self, bad_pixels_map, override_flags_to_use=None): def load_bad_pixels_map(self, bad_pixels_map, override_flags_to_use=None):
print(f"Loading bad pixels with shape: {bad_pixels_map.shape}") self.log_status_info(f"Loading bad pixels with shape: {bad_pixels_map.shape}")
# will simply OR with already loaded, does not take into account which ones # will simply OR with already loaded, does not take into account which ones
# TODO: inquire what "mask for double size pixels" means # TODO: inquire what "mask for double size pixels" means
if len(bad_pixels_map.shape) == 3: if len(bad_pixels_map.shape) == 3:
...@@ -619,11 +619,12 @@ class AgipdCorrection(BaseCorrection): ...@@ -619,11 +619,12 @@ class AgipdCorrection(BaseCorrection):
else: else:
self._override_md_additional_offset = None self._override_md_additional_offset = None
# configurability: disabling subset of bad pixel masking bits
self._has_updated_bad_pixel_selection = False self._has_updated_bad_pixel_selection = False
self.registerInitialFunction(self._update_bad_pixel_selection)
self.updateState(State.ON)
def _initialization(self):
self._update_bad_pixel_selection()
super()._initialization()
def process_data( def process_data(
self, self,
...@@ -763,6 +764,7 @@ class AgipdCorrection(BaseCorrection): ...@@ -763,6 +764,7 @@ class AgipdCorrection(BaseCorrection):
def postReconfigure(self): def postReconfigure(self):
super().postReconfigure() super().postReconfigure()
# TODO: move after getting cached update, check if necessary
if self.get("corrections.relGainPc.overrideMdAdditionalOffset"): if self.get("corrections.relGainPc.overrideMdAdditionalOffset"):
self._override_md_additional_offset = self.get( self._override_md_additional_offset = self.get(
"corrections.relGainPc.mdAdditionalOffset" "corrections.relGainPc.mdAdditionalOffset"
......
...@@ -205,10 +205,6 @@ class DsscCorrection(BaseCorrection): ...@@ -205,10 +205,6 @@ class DsscCorrection(BaseCorrection):
self.get("dataFormat.pixelsX"), self.get("dataFormat.pixelsX"),
) )
def __init__(self, config):
super().__init__(config)
self.updateState(State.ON)
def process_data( def process_data(
self, self,
data_hash, data_hash,
......
...@@ -555,34 +555,34 @@ class BaseCorrection(PythonDevice): ...@@ -555,34 +555,34 @@ class BaseCorrection(PythonDevice):
k: config.get(k) for k in self._schema_cache_fields if config.has(k) k: config.get(k) for k in self._schema_cache_fields if config.has(k)
} }
super().__init__(config) super().__init__(config)
self.updateState(State.INIT)
if not sorted(config.get("dataFormat.outputAxisOrder")) == ["c", "x", "y"]: if not sorted(config.get("dataFormat.outputAxisOrder")) == ["c", "x", "y"]:
# TODO: figure out how to get this information to operator # TODO: figure out how to get this information to operator
self.log_status_error("Invalid output axis order string") self.log_status_error("Invalid output axis order string")
return return
self.KARABO_ON_INPUT("dataInput", self.input_handler) self.input_data_dtype = np.dtype(config.get("dataFormat.inputImageDtype"))
self.KARABO_ON_EOS("dataInput", self.handle_eos) self.output_data_dtype = np.dtype(config.get("dataFormat.outputImageDtype"))
self.sources = set(config.get("fastSources")) self.sources = set(config.get("fastSources"))
self.input_data_dtype = np.dtype(config.get("dataFormat.inputImageDtype"))
self.output_data_dtype = np.dtype(config.get("dataFormat.outputImageDtype"))
self.kernel_runner = None # must call _update_buffers to initialize self.kernel_runner = None # must call _update_buffers to initialize
self.registerInitialFunction(self._update_frame_filter) self._shmem_buffer = None # ditto
self.registerInitialFunction(self._update_buffers)
self.calcat_friend = self._calcat_friend_class(
self, pathlib.Path.cwd() / "calibration-client-secrets.json"
)
self._correction_flag_enabled = self._correction_flag_class.NONE self._correction_flag_enabled = self._correction_flag_class.NONE
self._correction_flag_preview = self._correction_flag_class.NONE self._correction_flag_preview = self._correction_flag_class.NONE
self._buffer_lock = threading.Lock()
self._last_processing_started = 0 # used for processing time and timeout
self._shmem_buffer = None self.registerInitialFunction(self._initialization)
self._processing_time_ema = utils.ExponentialMovingAverage(alpha=0.3)
self._rate_tracker = utils.WindowRateTracker() def _initialization(self):
self.updateState(State.INIT)
self.calcat_friend = self._calcat_friend_class(
self, pathlib.Path.cwd() / "calibration-client-secrets.json"
)
self._update_frame_filter()
self._update_buffers()
self._buffered_status_update = Hash( self._buffered_status_update = Hash(
"trainId", "trainId",
...@@ -592,14 +592,15 @@ class BaseCorrection(PythonDevice): ...@@ -592,14 +592,15 @@ class BaseCorrection(PythonDevice):
"performance.processingTime", "performance.processingTime",
0, 0,
) )
self._last_processing_started = 0 # used for processing time and timeout self._processing_time_ema = utils.ExponentialMovingAverage(alpha=0.3)
self._rate_tracker = utils.WindowRateTracker()
self._rate_update_timer = utils.RepeatingTimer( self._rate_update_timer = utils.RepeatingTimer(
interval=1, interval=1,
callback=self._update_rate_and_state, callback=self._update_rate_and_state,
) )
self._buffer_lock = threading.Lock()
self.KARABO_SLOT(self.loadMostRecentConstants) self.KARABO_ON_INPUT("dataInput", self.input_handler)
self.KARABO_SLOT(self.requestScene) self.KARABO_ON_EOS("dataInput", self.handle_eos)
if parse_version(karaboVersion) >= parse_version("2.11"): if parse_version(karaboVersion) >= parse_version("2.11"):
# TODO: the CalCatFriend could add these for us # TODO: the CalCatFriend could add these for us
...@@ -620,6 +621,8 @@ class BaseCorrection(PythonDevice): ...@@ -620,6 +621,8 @@ class BaseCorrection(PythonDevice):
slotName=meth_name, slotName=meth_name,
) )
self.updateState(State.ON)
def __del__(self): def __del__(self):
del self._shmem_buffer del self._shmem_buffer
......
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