Skip to content

Commit

Permalink
more debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Spohn committed Nov 25, 2024
1 parent 8abef80 commit df180e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/qudi/hardware/dummy/scanning_probe_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
)
from dataclasses import dataclass

from qudi.logic.scanning_probe_logic import TrackedRecursiveMutex

logger = getLogger(__name__)


Expand Down Expand Up @@ -402,7 +404,7 @@ def __init__(self, *args, **kwargs):
# "Hardware" constraints
self._constraints: Optional[DummyScanConstraints] = None
# Mutex for access serialization
self._thread_lock = RecursiveMutex()
self._thread_lock = TrackedRecursiveMutex()

self.__scan_start = 0
self.__last_forward_pixel = 0
Expand Down Expand Up @@ -574,8 +576,9 @@ def move_absolute(self, position, velocity=None, blocking=False):
Log error and return current target position if something fails or a 1D/2D scan is in
progress.
"""
self.log.warning(f"move_absolute from {QtCore.QThread.currentThread()}")
with self._thread_lock:
# self.log.debug('Scanning probe dummy "move_absolute" called.')
self.log.debug('Scanning probe dummy "move_absolute" called.')
if self.module_state() != 'idle':
raise RuntimeError('Scanning in progress. Unable to move to position.')
elif not set(position).issubset(self._position_ranges):
Expand All @@ -590,6 +593,7 @@ def move_absolute(self, position, velocity=None, blocking=False):
move_time = max(0.01, np.sqrt(np.sum(dist**2 for dist in move_distance.values())) / velocity)
time.sleep(move_time)
self._current_position.update(position)
self.log.warning("move_absolute returning")
return self._current_position

def move_relative(self, distance, velocity=None, blocking=False):
Expand Down Expand Up @@ -626,6 +630,7 @@ def get_target(self):
dict
A dictionary representing the current target position for each axis.
"""
self.log.warning(f"get_target from {QtCore.QThread.currentThread()}")
with self._thread_lock:
return self._current_position.copy()

Expand Down
11 changes: 8 additions & 3 deletions src/qudi/logic/scanning_probe_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,17 +371,21 @@ def set_back_scan_frequency(self, axis: str, frequency: float) -> None:

def set_target_position(self, pos_dict, caller_id=None, move_blocking=False):
with self._thread_lock:
self.log.debug("In set_target_position")
if self.module_state() != 'idle':
self.log.error('Unable to change scanner target position while a scan is running.')
new_pos = self._scanner().get_target()
self.sigScannerTargetChanged.emit(new_pos, self.module_uuid)
return new_pos

# self.log.debug(f"Requested Set pos to= {pos_dict}")
self.log.debug("Get scanner constraints")
ax_constr = self.scanner_constraints.axes
self.log.debug("expanding coordinates")
pos_dict = self._scanner()._expand_coordinate(cp.copy(pos_dict))
# self.log.debug(f"Expand to= {pos_dict}")

self.log.debug("transforming coordinates")
pos_dict = self._scanner().coordinate_transform(pos_dict)

for ax, pos in pos_dict.items():
Expand All @@ -399,13 +403,14 @@ def set_target_position(self, pos_dict, caller_id=None, move_blocking=False):
)

# move_absolute expects untransformed coordinatess, so invert clipped pos
self.log.debug("inverse coordinate transform")
pos_dict = self._scanner().coordinate_transform(pos_dict, inverse=True)
# self.log.debug(f"In front of hw.move_abs {pos_dict}")
self.log.debug(f"In front of hw.move_abs {pos_dict}")
new_pos = self._scanner().move_absolute(pos_dict, blocking=move_blocking)
# self.log.debug(f"Set pos to= {pos_dict} => new pos {new_pos}. Bare {self._scanner()._get_position_bare()}")
self.log.debug(f"Set pos to= {pos_dict} => new pos {new_pos}")
if any(pos != new_pos[ax] for ax, pos in pos_dict.items()):
caller_id = None
# self.log.debug(f"Logic set target with id {caller_id} to new: {new_pos}")
self.log.debug(f"Logic set target with id {caller_id} to new: {new_pos}")
self.sigScannerTargetChanged.emit(new_pos, self.module_uuid if caller_id is None else caller_id)
return new_pos

Expand Down

0 comments on commit df180e1

Please sign in to comment.