-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a98d03
commit 415dc52
Showing
3 changed files
with
36 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,34 @@ | ||
from mmpycorex import create_core_instance, download_and_install_mm, terminate_core_instances | ||
from mmpycorex import create_core_instance, terminate_core_instances | ||
from exengine.kernel.executor import ExecutionEngine | ||
from exengine.backends.micromanager.mm_device_implementations import MicroManagerCamera, MicroManagerSingleAxisStage | ||
from exengine.kernel.notification_base import Notification | ||
from exengine.backends.micromanager.mm_device_implementations import MicroManagerSingleAxisStage | ||
from exengine.events.positioner_events import SetPosition1DEvent | ||
|
||
def event_complete(notification: Notification) -> None: | ||
print(f"Event complete, notification: {notification.category} - {notification.description} - {notification.payload}") | ||
|
||
# download_and_install_mm() # If needed | ||
# Start Micro-Manager core instance with Demo config | ||
create_core_instance() | ||
try: | ||
create_core_instance() | ||
|
||
executor = ExecutionEngine() | ||
z_stage = MicroManagerSingleAxisStage() | ||
executor = ExecutionEngine() | ||
z_stage = MicroManagerSingleAxisStage() | ||
|
||
# This occurs on the executor thread. The event is submitted to the executor and its result is awaited, | ||
# meaning the call will block until the method is executed. | ||
z_stage.set_position(100, thread='device_setting_thread') | ||
# it is equivalent to: | ||
executor.submit(SetPosition1DEvent(position=100, device=z_stage)).await_execution() | ||
executor.subscribe_to_notifications(event_complete) | ||
|
||
# explicit | ||
z_stage.set_position(100) | ||
# it is equivalent to: | ||
# executor.submit(SetPosition1DEvent(position=100, device=z_stage), thread_name='device_setting_thread').await_execution() | ||
# but the execution thread is the main thread | ||
|
||
# implicit | ||
# start capture first; we use await execution in order to make sure that the camera has finished acquisition | ||
executor.submit(SetPosition1DEvent(position=100, device=z_stage), thread_name='device_setting_thread') | ||
|
||
executor.submit(SetPosition1DEvent(position=100, device=z_stage), thread='device_setting_thread') | ||
executor.submit(ReadoutImages(), thread='readout_thread') | ||
|
||
|
||
|
||
executor.shutdown() | ||
executor.shutdown() | ||
terminate_core_instances() | ||
except Exception as e: | ||
print(f"An error occurred: {e}") | ||
terminate_core_instances() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters