magscope.processes

Contents

magscope.processes#

Attributes#

Classes#

InterprocessValues

SingletonMeta

SingletonABCMeta

Metaclass for defining Abstract Base Classes (ABCs).

ManagerProcessBase

Abstract base class for processes in the MagScope

Module Contents#

magscope.processes.logger[source]#
magscope.processes.ValueTypeUI8[source]#
class magscope.processes.InterprocessValues[source]#
video_process_busy_count: ValueTypeUI8[source]#
video_process_reserved_stacks: multiprocessing.Value[ctypes.c_uint32][source]#
video_process_completed_stacks: multiprocessing.Value[ctypes.c_uint64][source]#
live_profile_enabled: ValueTypeUI8[source]#
live_profile_bead: multiprocessing.Value[ctypes.c_int][source]#
camera_total_frames: multiprocessing.Value[ctypes.c_uint64][source]#
camera_consecutive_timeouts: multiprocessing.Value[ctypes.c_uint32][source]#
camera_queue_full_events: multiprocessing.Value[ctypes.c_uint64][source]#
camera_last_frame_timestamp: multiprocessing.Value[ctypes.c_double][source]#
class magscope.processes.SingletonMeta[source]#

Bases: type

_instances[source]#
__call__(*args, **kwargs)[source]#
class magscope.processes.SingletonABCMeta[source]#

Bases: abc.ABCMeta, SingletonMeta

Metaclass for defining Abstract Base Classes (ABCs).

Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as ‘virtual subclasses’ – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).

class magscope.processes.ManagerProcessBase[source]#

Bases: multiprocessing.Process, abc.ABC

Abstract base class for processes in the MagScope

Subclass requirements: * Each subclass should have a unique name. * There should only be one instance of each subclass (singleton). * The class name is used for consistent inter-process identification.

_acquisition_on: bool = True[source]#
_acquisition_dir: str | None = None[source]#
_acquisition_dir_on: bool = False[source]#
_acquisition_mode: magscope.utils.AcquisitionMode[source]#
bead_roi_buffer: magscope.datatypes.BeadRoiBuffer | None = None[source]#
_bead_roi_ids: numpy.ndarray[source]#
_bead_roi_values: numpy.ndarray[source]#
camera_type: type[magscope.camera.CameraBase] | None = None[source]#
hardware_types: dict[str, type[magscope.hardware.HardwareManagerBase]][source]#
locks: dict[str, multiprocessing.synchronize.Lock] | None = None[source]#
_magscope_quitting: multiprocessing.synchronize.Event | None = None[source]#
name: str = 'ManagerProcessBase'[source]#
_pipe: multiprocessing.connection.Connection | None = None[source]#
live_profile_buffer: magscope.datatypes.LiveProfileBuffer | None = None[source]#
_quitting: multiprocessing.synchronize.Event[source]#
_quit_requested: bool = False[source]#
_running: bool = False[source]#
settings = None[source]#
tracks_buffer: magscope.datatypes.MatrixBuffer | None = None[source]#
video_buffer: magscope.datatypes.VideoBuffer | None = None[source]#
shared_values: InterprocessValues | None = None[source]#
_command_registry: magscope.ipc.CommandRegistry | None = None[source]#
_command_handlers: dict[type[magscope.ipc_commands.Command], str][source]#
property quitting_event: multiprocessing.synchronize.Event[source]#

Event set when this process has begun quitting.

property bead_rois: dict[int, tuple[int, int, int, int]][source]#
get_cached_bead_rois() tuple[numpy.ndarray, numpy.ndarray][source]#
_refresh_bead_roi_cache() None[source]#
configure_shared_resources(*, camera_type: type[magscope.camera.CameraBase] | None, hardware_types: dict[str, type[magscope.hardware.HardwareManagerBase]], quitting_event: multiprocessing.synchronize.Event, settings: magscope.settings.MagScopeSettings, shared_values: InterprocessValues, locks: dict[str, multiprocessing.synchronize.Lock], pipe_end: multiprocessing.connection.Connection, command_registry: magscope.ipc.CommandRegistry) None[source]#

Attach shared references provided by MagScope.

This centralizes initialization so callers do not need to mutate underscored attributes directly when preparing processes before start() is invoked.

run()[source]#

Start the process when start() is called.

Subclasses should create a main loop that calls receive_ipc() last:

while self._running:
    # do other stuff
    self.receive_ipc()
abstractmethod setup()[source]#
abstractmethod do_main_loop()[source]#
quit()[source]#

Shutdown the process (and ask the other processes to quit too).

send_ipc(command: magscope.ipc_commands.Command)[source]#
receive_ipc()[source]#
set_acquisition_dir(value: str | None)[source]#
set_acquisition_dir_on(value: bool)[source]#
set_acquisition_mode(mode: magscope.utils.AcquisitionMode)[source]#
set_acquisition_on(value: bool)[source]#
refresh_bead_rois()[source]#
set_settings(settings: magscope.settings.MagScopeSettings)[source]#
_report_exception(exc: BaseException) None[source]#