Skip to content

Commit

Permalink
Merge branch 'main' into acqengj-update
Browse files Browse the repository at this point in the history
  • Loading branch information
henrypinkard authored Sep 29, 2023
2 parents dee8e41 + d6fb88a commit 456341c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pycromanager/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (0, 29, 6)
version_info = (0, 29, 8)
__version__ = ".".join(map(str, version_info))
9 changes: 9 additions & 0 deletions pycromanager/acquisition/acq_eng_py/internal/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,18 @@ def submit_event_iterator_inner():
return self.event_generator_executor.submit(submit_event_iterator_inner)


def check_for_default_devices(self, event: AcquisitionEvent):
xy_stage = self.core.get_xy_stage_device()
z_stage = self.core.get_focus_device()
if event.get_z_position() is not None and (z_stage is None or z_stage == ""):
raise Exception("Event requires a z position, but no Core-Focus device is set")
if event.get_x_position() is not None and (xy_stage is None or xy_stage == ""):
raise Exception("Event requires an x position, but no Core-XYStage device is set")

def process_acquisition_event(self, event: AcquisitionEvent) -> Future:
def process_acquisition_event_inner():
try:
self.check_for_default_devices(event)
if event.acquisition_.is_debug_mode():
self.core.logMessage("Processing event: " + event.to_string())
if event.acquisition_.is_debug_mode():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def copy(self):
e.stageDeviceNamesToAxisNames_ = self.stageDeviceNamesToAxisNames_.copy()
e.xPosition_ = self.xPosition_
e.yPosition_ = self.yPosition_
e.zPosition_ = self.zPosition_
e.miniumumStartTime_ms_ = self.miniumumStartTime_ms_
e.slmImage_ = self.slmImage_
e.acquireImage_ = self.acquireImage_
Expand Down
24 changes: 12 additions & 12 deletions pycromanager/acquisition/java_backend_acquisitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def __init__(
show_display: bool=True,
napari_viewer=None,
saving_queue_size: int=20,
timeout: int=2000,
timeout: int=2500,
port: int=DEFAULT_PORT,
debug: int=False
):
Expand Down Expand Up @@ -286,7 +286,8 @@ def __init__(

try:
self._remote_notification_handler = JavaObject('org.micromanager.remote.RemoteNotificationHandler',
args=[self._acq], port=self._port, new_socket=False)
args=[self._acq], port=self._port, new_socket=False,
timeout=self._timeout)
self._acq_notification_recieving_thread = self._start_receiving_notifications()
self._acq_notification_dispatcher_thread = self._start_notification_dispatcher(notification_callback_fn)
# TODO: can remove this after this feature has been present for a while
Expand Down Expand Up @@ -476,7 +477,7 @@ def _initialize_image_processor(self, **kwargs):

if kwargs['image_process_fn'] is not None:
java_processor = JavaObject(
"org.micromanager.remote.RemoteImageProcessor", port=self._port
"org.micromanager.remote.RemoteImageProcessor", port=self._port, timeout=self._timeout
)
self._acq.add_image_processor(java_processor)
self._processor_thread = self._start_processor(
Expand All @@ -489,29 +490,29 @@ def _initialize_hooks(self, **kwargs):
self._hook_threads = []
if kwargs['event_generation_hook_fn'] is not None:
hook = JavaObject(
"org.micromanager.remote.RemoteAcqHook", port=self._port, args=[self._acq]
"org.micromanager.remote.RemoteAcqHook", port=self._port, args=[self._acq], timeout=self._timeout
)
self._hook_threads.append(self._start_hook(hook, kwargs['event_generation_hook_fn'],
self._event_queue, process=False))
self._acq.add_hook(hook, self._acq.EVENT_GENERATION_HOOK)
if kwargs['pre_hardware_hook_fn'] is not None:
hook = JavaObject(
"org.micromanager.remote.RemoteAcqHook", port=self._port, args=[self._acq]
"org.micromanager.remote.RemoteAcqHook", port=self._port, args=[self._acq], timeout=self._timeout
)
self._hook_threads.append(self._start_hook(hook,
kwargs['pre_hardware_hook_fn'], self._event_queue,
process=False))
self._acq.add_hook(hook, self._acq.BEFORE_HARDWARE_HOOK)
if kwargs['post_hardware_hook_fn'] is not None:
hook = JavaObject(
"org.micromanager.remote.RemoteAcqHook", port=self._port, args=[self._acq]
"org.micromanager.remote.RemoteAcqHook", port=self._port, args=[self._acq], timeout=self._timeout
)
self._hook_threads.append(self._start_hook(hook, kwargs['post_hardware_hook_fn'],
self._event_queue, process=False))
self._acq.add_hook(hook, self._acq.AFTER_HARDWARE_HOOK)
if kwargs['post_camera_hook_fn'] is not None:
hook = JavaObject(
"org.micromanager.remote.RemoteAcqHook", port=self._port, args=[self._acq],
"org.micromanager.remote.RemoteAcqHook", port=self._port, args=[self._acq], timeout=self._timeout
)
self._hook_threads.append(self._start_hook(hook, kwargs['post_camera_hook_fn'],
self._event_queue, process=False))
Expand All @@ -523,7 +524,7 @@ def _create_remote_acquisition(self, **kwargs):
# create a new socket for it to run on so that it can have blocking calls without interfering with
# the main socket or other internal sockets
new_socket=True,
port=self._port, args=[core], debug=self._debug)
port=self._port, args=[core], debug=self._debug, timeout=self._timeout)
show_viewer = kwargs['show_display'] is True and kwargs['napari_viewer'] is None
self._acq = acq_factory.create_acquisition(kwargs['directory'], kwargs['name'], show_viewer,
kwargs['saving_queue_size'], self._debug,)
Expand Down Expand Up @@ -665,9 +666,8 @@ def __init__(

def _create_remote_acquisition(self, port, **kwargs):
core = ZMQRemoteMMCoreJ(port=self._port, timeout=self._timeout)
acq_factory = JavaObject(
"org.micromanager.remote.RemoteAcquisitionFactory", port=self._port, args=[core]
)
acq_factory = JavaObject("org.micromanager.remote.RemoteAcquisitionFactory",
port=self._port, args=[core], timeout=self._timeout)

show_viewer = kwargs['show_display'] is True and\
kwargs['napari_viewer'] is None and\
Expand Down Expand Up @@ -711,7 +711,7 @@ def __init__(
show_display: bool=True,
image_saved_fn: callable=None,
saving_queue_size: int=20,
timeout: int=1000,
timeout: int=2500,
port: int=DEFAULT_PORT,
debug: bool=False,
):
Expand Down

0 comments on commit 456341c

Please sign in to comment.