Пример #1
0
 def calculate_generator_duration(
     self,
     context: scanning.hooks.AContext,
     generator: scanning.hooks.AGenerator,
     part_info: scanning.hooks.APartInfo,
     motion_axes: List[str],
 ) -> Optional[float]:
     """
     Calculate a generator duration based on the generator and axes we are moving
     """
     child = context.block_view(self.mri)
     layout_table = child.layout.value
     # Check if we are moving axes in this scan
     if motion_axes:
         # TODO: what happens if axes are not mapped due to the current config on
         # the brick not matching the target config for the scan?
         try:
             axis_mapping = cs_axis_mapping(context, layout_table,
                                            motion_axes)
         except AssertionError:
             # We can't check the axes as they are not mapped, so don't tweak the
             # generator and just return
             self.log.debug(
                 f"{self.name}: can't guess generator duration during "
                 f"validate as axis mappings are not loaded or missing.")
             return None
         # Step scans and fly scans behave differently
         generator.prepare()
         if generator.continuous and generator.size > 1:
             # Estimate the duration for fly scans using the distance between the
             # first two points and max velocities of participating axes
             first_point = generator.get_point(0)
             second_point = generator.get_point(1)
             return self.calculate_duration_from_first_two_points(
                 axis_mapping,
                 first_point,
                 second_point,
             )
         else:
             # Step scans have turnarounds at each point so can use this value
             min_turnaround = get_min_turnaround(part_info)
             return min_turnaround.time
     else:
         # Not moving axes so just return time of one tick
         return TICK_S
Пример #2
0
 def on_configure(
     self,
     context: scanning.hooks.AContext,
     completed_steps: scanning.hooks.ACompletedSteps,
     steps_to_do: scanning.hooks.AStepsToDo,
     # The following were passed from user calling configure()
     generator: scanning.hooks.AGenerator,
     axesToMove: scanning.hooks.AAxesToMove,
     exceptionStep: AExceptionStep = 0,
 ) -> None:
     child = context.block_view(self.mri)
     # Store the generator and place we need to start
     self._generator = generator
     self._completed_steps = completed_steps
     self._steps_to_do = steps_to_do
     self._exception_step = exceptionStep
     self._axes_to_move = axesToMove
     self._movers = {axis: MaybeMover(child, axis) for axis in axesToMove}
     # Move to start (instantly)
     first_point = generator.get_point(completed_steps)
     fs: List[Future] = []
     for axis, mover in self._movers.items():
         mover.maybe_move_async(fs, first_point.lower[axis])
     context.wait_all_futures(fs)