def receive_options(self): # Get number of planes: n_planes = get_last_parameters(self.n_planes_queue, timeout=TIMEOUT_S) if n_planes is not None: self.n_planes = n_planes self.reset() # Get flat noise image to subtract: calibration_ref = get_last_parameters(self.calibration_ref_queue, timeout=TIMEOUT_S) if calibration_ref is not None: self.calibration_ref = calibration_ref
def receive_save_parameters(self): """Receive parameters on the stack shape from the `State` obj and new duration from either the `EsternalTrigger` or the `State` if triggering is disabled. """ # Get parameters: parameters = get_last_parameters(self.saving_parameter_queue) if parameters is not None: self.save_parameters = parameters # Get duration and update number of volumes: new_duration = get_last_parameters(self.duration_queue) if new_duration is not None: self.n_volumes = int( np.ceil(self.save_parameters.volumerate * new_duration))
def camera_loop(self): """Camera running loop, grab frames and set new parameters if available.""" self.logger.log_message("Started acquisition") self.camera.start_acquisition() while (not self.stop_event.is_set() and self.parameters.camera_mode != CameraMode.PAUSED): is_waiting = self.wait_event.is_set() frames = self.camera.get_frames() # if no frames are received (either this loop is in between frames # or we are in the waining period) if frames: for frame in frames: self.logger.log_message("received frame of shape " + str(frame.shape)) # this means this is the first frame received since # the waiting period is over, the signal has to be sent that # saving can start if self.was_waiting and not is_waiting: self.experiment_trigger_event.set() # TODO do not crash here if queue is full self.image_queue.put(frame) self.was_waiting = is_waiting self.update_framerate() # Empty parameters queue and set new parameters with the most recent value new_parameters = get_last_parameters(self.parameter_queue, timeout=0.001) if new_parameters is not None: if new_parameters.camera_mode == CameraMode.ABORT or ( new_parameters != self.parameters): self.update_parameters(new_parameters)
def update_settings(self): """Update parameters and return True only if got new parameters.""" new_params = get_last_parameters(self.parameter_queue) if new_params is None: return False self.parameters = new_params self.lateral_waveform = TriangleWaveform( **asdict(self.parameters.xy.lateral)) self.frontal_waveform = TriangleWaveform( **asdict(self.parameters.xy.frontal)) self.first_update = False # To avoid multiple updates return True
def get_waveform(self): return get_last_parameters(self.scanner.waveform_queue)
def get_triggered_frame_rate(self): return get_last_parameters(self.camera.triggered_frame_rate_queue)
def get_save_status(self) -> Optional[SavingStatus]: return get_last_parameters(self.saver.saved_status_queue)
def retrieve_parameters(self): new_params = get_last_parameters(self.parameter_queue) if new_params is not None: self.parameters = new_params