microeye 2.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- microEye/__init__.py +47 -0
- microEye/_version.py +2 -0
- microEye/analysis/__init__.py +1 -0
- microEye/analysis/checklist_dialog.py +143 -0
- microEye/analysis/cmosMaps.py +228 -0
- microEye/analysis/filters/__init__.py +9 -0
- microEye/analysis/filters/base.py +21 -0
- microEye/analysis/filters/spatial.py +338 -0
- microEye/analysis/filters/temporal.py +76 -0
- microEye/analysis/fitting/__init__.py +0 -0
- microEye/analysis/fitting/fit.py +680 -0
- microEye/analysis/fitting/nena.py +375 -0
- microEye/analysis/fitting/phasor_fit.py +90 -0
- microEye/analysis/fitting/processing.py +317 -0
- microEye/analysis/fitting/psf/__init__.py +6 -0
- microEye/analysis/fitting/psf/extract.py +1129 -0
- microEye/analysis/fitting/psf/rubost_mean.py +150 -0
- microEye/analysis/fitting/psf/spline.py +167 -0
- microEye/analysis/fitting/psf/stats/__init__.py +12 -0
- microEye/analysis/fitting/psf/stats/core.py +295 -0
- microEye/analysis/fitting/psf/stats/curve_fit.py +708 -0
- microEye/analysis/fitting/psf/stats/io.py +104 -0
- microEye/analysis/fitting/psf/stats/slope_fit.py +171 -0
- microEye/analysis/fitting/psf/temp.py +147 -0
- microEye/analysis/fitting/psf/test.py +47 -0
- microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUfunctions.py +657 -0
- microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUmleFit_LM.py +1336 -0
- microEye/analysis/fitting/pyfit3Dcspline/CPU/CPUsplineLib.py +270 -0
- microEye/analysis/fitting/pyfit3Dcspline/CPU/__init__.py +1 -0
- microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUfunctions.py +609 -0
- microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUmleFit_LM_EMCCD.py +1396 -0
- microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUmleFit_LM_sCMOS.py +1426 -0
- microEye/analysis/fitting/pyfit3Dcspline/GPU/GPUsplineLib.py +231 -0
- microEye/analysis/fitting/pyfit3Dcspline/GPU/__init__.py +2 -0
- microEye/analysis/fitting/pyfit3Dcspline/__init__.py +10 -0
- microEye/analysis/fitting/pyfit3Dcspline/constants.py +27 -0
- microEye/analysis/fitting/pyfit3Dcspline/mainfunctions.py +903 -0
- microEye/analysis/fitting/results.py +917 -0
- microEye/analysis/fitting/results_stats.py +251 -0
- microEye/analysis/fitting/tardis.py +209 -0
- microEye/analysis/multi_viewer.py +568 -0
- microEye/analysis/processing/__init__.py +1 -0
- microEye/analysis/processing/frc.py +120 -0
- microEye/analysis/rendering/__init__.py +3 -0
- microEye/analysis/rendering/base.py +452 -0
- microEye/analysis/rendering/cloud.py +215 -0
- microEye/analysis/rendering/core.py +47 -0
- microEye/analysis/rendering/volumetric.py +198 -0
- microEye/analysis/tools/__init__.py +0 -0
- microEye/analysis/tools/kymograms.py +1079 -0
- microEye/analysis/tools/roi_selectors.py +556 -0
- microEye/analysis/utils/__init__.py +3 -0
- microEye/analysis/utils/coordinates.py +18 -0
- microEye/analysis/utils/images.py +68 -0
- microEye/analysis/utils/windows.py +19 -0
- microEye/analysis/viewer/__init__.py +3 -0
- microEye/analysis/viewer/image_options_widget.py +615 -0
- microEye/analysis/viewer/images.py +1225 -0
- microEye/analysis/viewer/layers_widget.py +415 -0
- microEye/analysis/viewer/localizations.py +1304 -0
- microEye/analysis/viewer/psf.py +1003 -0
- microEye/analysis/viewer/volume.py +456 -0
- microEye/hardware/__init__.py +3 -0
- microEye/hardware/cams/__init__.py +29 -0
- microEye/hardware/cams/camera_calibration.py +99 -0
- microEye/hardware/cams/camera_list.py +528 -0
- microEye/hardware/cams/camera_options.py +694 -0
- microEye/hardware/cams/camera_panel.py +941 -0
- microEye/hardware/cams/dummy/__init__.py +1 -0
- microEye/hardware/cams/dummy/dummy_panel.py +759 -0
- microEye/hardware/cams/jobs.py +497 -0
- microEye/hardware/cams/line_profiler.py +99 -0
- microEye/hardware/cams/linescan/IR_Cam.py +474 -0
- microEye/hardware/cams/linescan/__init__.py +1 -0
- microEye/hardware/cams/micam.py +524 -0
- microEye/hardware/cams/pco/__init__.py +58 -0
- microEye/hardware/cams/pco/enums.py +382 -0
- microEye/hardware/cams/pco/pco_cam.py +761 -0
- microEye/hardware/cams/pco/pco_panel.py +477 -0
- microEye/hardware/cams/shortcuts.py +312 -0
- microEye/hardware/cams/thorlabs/__init__.py +1 -0
- microEye/hardware/cams/thorlabs/thorlabs.py +1508 -0
- microEye/hardware/cams/thorlabs/thorlabs_panel.py +850 -0
- microEye/hardware/cams/ueye/__init__.py +1 -0
- microEye/hardware/cams/ueye/ueye_camera.py +1023 -0
- microEye/hardware/cams/ueye/ueye_panel.py +861 -0
- microEye/hardware/cams/vimba/__init__.py +1 -0
- microEye/hardware/cams/vimba/vimba_cam.py +1000 -0
- microEye/hardware/cams/vimba/vimba_panel.py +813 -0
- microEye/hardware/device.py +60 -0
- microEye/hardware/lasers/__init__.py +13 -0
- microEye/hardware/lasers/io_matchbox.py +791 -0
- microEye/hardware/lasers/io_params.py +85 -0
- microEye/hardware/lasers/io_single_laser.py +742 -0
- microEye/hardware/lasers/laser_relay.py +594 -0
- microEye/hardware/mieye/__init__.py +1 -0
- microEye/hardware/mieye/acquisition_manager.py +467 -0
- microEye/hardware/mieye/devices_manager.py +533 -0
- microEye/hardware/mieye/miEye.py +659 -0
- microEye/hardware/misc/__init__.py +0 -0
- microEye/hardware/misc/acquisition_view.py +71 -0
- microEye/hardware/misc/reglo.py +761 -0
- microEye/hardware/misc/temp.py +188 -0
- microEye/hardware/port_config.py +59 -0
- microEye/hardware/protocols/__init__.py +2 -0
- microEye/hardware/protocols/actions.py +402 -0
- microEye/hardware/protocols/actions_items.py +703 -0
- microEye/hardware/protocols/designer.py +244 -0
- microEye/hardware/protocols/scene_manager.py +191 -0
- microEye/hardware/protocols/serialization.py +97 -0
- microEye/hardware/pycromanager/__init__.py +16 -0
- microEye/hardware/pycromanager/core.py +1433 -0
- microEye/hardware/pycromanager/devices.py +461 -0
- microEye/hardware/pycromanager/enums.py +107 -0
- microEye/hardware/pycromanager/headless.py +153 -0
- microEye/hardware/pycromanager/utils.py +34 -0
- microEye/hardware/pycromanager/widgets/__init__.py +5 -0
- microEye/hardware/pycromanager/widgets/bridges.py +407 -0
- microEye/hardware/pycromanager/widgets/headless_manager.py +258 -0
- microEye/hardware/pycromanager/widgets/headless_options.py +224 -0
- microEye/hardware/pycromanager/widgets/pycro_panel.py +455 -0
- microEye/hardware/stages/__init__.py +18 -0
- microEye/hardware/stages/elliptec/__init__.py +5 -0
- microEye/hardware/stages/elliptec/baseDevice.py +314 -0
- microEye/hardware/stages/elliptec/device.py +384 -0
- microEye/hardware/stages/elliptec/deviceID.py +212 -0
- microEye/hardware/stages/elliptec/devicePort.py +379 -0
- microEye/hardware/stages/elliptec/deviceStatus.py +65 -0
- microEye/hardware/stages/elliptec/devicesView.py +706 -0
- microEye/hardware/stages/elliptec/ellDevices.py +134 -0
- microEye/hardware/stages/elliptec/messageUpdater.py +34 -0
- microEye/hardware/stages/elliptec/motorInfo.py +153 -0
- microEye/hardware/stages/elliptec/stage.py +62 -0
- microEye/hardware/stages/elliptec/test.py +139 -0
- microEye/hardware/stages/kinesis/__init__.py +1 -0
- microEye/hardware/stages/kinesis/kdc101/__init__.py +1 -0
- microEye/hardware/stages/kinesis/kdc101/enums.py +1002 -0
- microEye/hardware/stages/kinesis/kdc101/factory.py +171 -0
- microEye/hardware/stages/kinesis/kdc101/kdc101.py +718 -0
- microEye/hardware/stages/kinesis/kinesis.py +776 -0
- microEye/hardware/stages/piezo_concept.py +607 -0
- microEye/hardware/stages/stabilizer.py +785 -0
- microEye/hardware/stages/stage.py +89 -0
- microEye/hardware/widgets/__init__.py +10 -0
- microEye/hardware/widgets/controller.py +246 -0
- microEye/hardware/widgets/devices.py +133 -0
- microEye/hardware/widgets/focusWidget.py +264 -0
- microEye/hardware/widgets/qlist_slider.py +113 -0
- microEye/hardware/widgets/scan_acquisition.py +424 -0
- microEye/icons/1024.png +0 -0
- microEye/icons/128.png +0 -0
- microEye/icons/16.png +0 -0
- microEye/icons/24.png +0 -0
- microEye/icons/256.png +0 -0
- microEye/icons/32.png +0 -0
- microEye/icons/48.png +0 -0
- microEye/icons/512.png +0 -0
- microEye/icons/64.png +0 -0
- microEye/icons/__init__.py +0 -0
- microEye/icons/close.svg +88 -0
- microEye/icons/mieye.png +0 -0
- microEye/icons/min.svg +83 -0
- microEye/icons/viewer.png +0 -0
- microEye/launcher.py +42 -0
- microEye/qt.py +181 -0
- microEye/utils/__init__.py +2 -0
- microEye/utils/enum_encoder.py +10 -0
- microEye/utils/expandable_groupbox.py +93 -0
- microEye/utils/gui_helper.py +457 -0
- microEye/utils/hid/__init__.py +8 -0
- microEye/utils/hid/controller.py +153 -0
- microEye/utils/hid/device.py +63 -0
- microEye/utils/hid/enums.py +140 -0
- microEye/utils/hid/utils.py +58 -0
- microEye/utils/labelled_slider.py +134 -0
- microEye/utils/metadata.py +599 -0
- microEye/utils/metadata_tree.py +718 -0
- microEye/utils/micro_launcher.py +245 -0
- microEye/utils/parameter_tree.py +325 -0
- microEye/utils/pyscripting.py +444 -0
- microEye/utils/retry_exec.py +35 -0
- microEye/utils/start_gui.py +112 -0
- microEye/utils/thread_worker.py +115 -0
- microEye/utils/uImage.py +1512 -0
- microeye-2.3.2.dist-info/METADATA +401 -0
- microeye-2.3.2.dist-info/RECORD +190 -0
- microeye-2.3.2.dist-info/WHEEL +5 -0
- microeye-2.3.2.dist-info/entry_points.txt +2 -0
- microeye-2.3.2.dist-info/licenses/LICENSE +674 -0
- microeye-2.3.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def vec_to_list(vector):
|
|
5
|
+
if hasattr(vector, 'size') and hasattr(vector, 'get'):
|
|
6
|
+
return [vector.get(idx) for idx in range(vector.size())]
|
|
7
|
+
elif hasattr(vector, '__len__') and hasattr(vector, '__getitem__'):
|
|
8
|
+
return [vector[idx] for idx in range(len(vector))]
|
|
9
|
+
|
|
10
|
+
raise ValueError('Invalid vector type')
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def config_to_dict(config):
|
|
14
|
+
if hasattr(config, 'size') and hasattr(config, 'get_setting'):
|
|
15
|
+
res = {}
|
|
16
|
+
for idx in range(config.size()):
|
|
17
|
+
setting = config.get_setting(idx)
|
|
18
|
+
res[setting.get_key()] = setting.get_property_value()
|
|
19
|
+
|
|
20
|
+
return res
|
|
21
|
+
elif isinstance(config, dict):
|
|
22
|
+
return config
|
|
23
|
+
|
|
24
|
+
raise ValueError('Invalid config type')
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def group_config_dict(config: dict[str, Any]) -> dict[str, dict[str, Any]]:
|
|
28
|
+
res = {}
|
|
29
|
+
|
|
30
|
+
for key, value in config.items():
|
|
31
|
+
device, prop = key.split('-')
|
|
32
|
+
res.setdefault(device, {})[prop] = value
|
|
33
|
+
|
|
34
|
+
return res
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import contextlib
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Any, Optional
|
|
5
|
+
|
|
6
|
+
from microEye.hardware.pycromanager.core import PycroCore
|
|
7
|
+
from microEye.qt import QAction, QApplication, Qt, QtCore, QtWidgets, Signal
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BridgesWidget(QtWidgets.QDialog):
|
|
11
|
+
'''
|
|
12
|
+
Widget to display and manage running PycroCore bridge instances and their devices.
|
|
13
|
+
'''
|
|
14
|
+
|
|
15
|
+
instance_started = Signal(int) # Signal emitted when new instance is started
|
|
16
|
+
instance_stopped = Signal(int) # Signal emitted when instance is stopped
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
parent: Optional[QtWidgets.QWidget] = None,
|
|
21
|
+
):
|
|
22
|
+
super().__init__(parent=parent)
|
|
23
|
+
self.options_dialog = None
|
|
24
|
+
|
|
25
|
+
self._setup_ui()
|
|
26
|
+
self._connect_signals()
|
|
27
|
+
self._refresh_instances()
|
|
28
|
+
|
|
29
|
+
self.setWindowTitle('Micro-Manager Core Bridge Manager')
|
|
30
|
+
self.setMinimumWidth(900)
|
|
31
|
+
self.setMinimumHeight(600)
|
|
32
|
+
|
|
33
|
+
def _setup_ui(self):
|
|
34
|
+
'''Set up the UI components.'''
|
|
35
|
+
main_layout = QtWidgets.QVBoxLayout(self)
|
|
36
|
+
|
|
37
|
+
# Splitter for instances and devices
|
|
38
|
+
self.splitter = QtWidgets.QSplitter(Qt.Orientation.Horizontal)
|
|
39
|
+
|
|
40
|
+
# Upper part: Core instances
|
|
41
|
+
instances_widget = QtWidgets.QWidget()
|
|
42
|
+
instances_layout = QtWidgets.QVBoxLayout(instances_widget)
|
|
43
|
+
|
|
44
|
+
instances_label = QtWidgets.QLabel('<b>Core Bridge Instances</b>')
|
|
45
|
+
instances_layout.addWidget(instances_label)
|
|
46
|
+
|
|
47
|
+
# Instance list
|
|
48
|
+
self.instance_list = QtWidgets.QTableWidget()
|
|
49
|
+
self.instance_list.setColumnCount(4)
|
|
50
|
+
self.instance_list.setHorizontalHeaderLabels(
|
|
51
|
+
['Port', 'Status', 'Devices', 'Actions']
|
|
52
|
+
)
|
|
53
|
+
self.instance_list.horizontalHeader().setStretchLastSection(True)
|
|
54
|
+
self.instance_list.horizontalHeader().setSectionResizeMode(
|
|
55
|
+
QtWidgets.QHeaderView.ResizeMode.ResizeToContents
|
|
56
|
+
)
|
|
57
|
+
self.instance_list.setSelectionBehavior(
|
|
58
|
+
QtWidgets.QTableWidget.SelectionBehavior.SelectRows
|
|
59
|
+
)
|
|
60
|
+
self.instance_list.setSelectionMode(
|
|
61
|
+
QtWidgets.QAbstractItemView.SelectionMode.SingleSelection
|
|
62
|
+
)
|
|
63
|
+
self.instance_list.setEditTriggers(
|
|
64
|
+
QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers
|
|
65
|
+
)
|
|
66
|
+
instances_layout.addWidget(self.instance_list)
|
|
67
|
+
|
|
68
|
+
# Lower part: Device details
|
|
69
|
+
devices_widget = QtWidgets.QWidget()
|
|
70
|
+
devices_layout = QtWidgets.QVBoxLayout(devices_widget)
|
|
71
|
+
|
|
72
|
+
devices_label = QtWidgets.QLabel('<b>Device Details</b>')
|
|
73
|
+
devices_layout.addWidget(devices_label)
|
|
74
|
+
|
|
75
|
+
# Device list for selected core
|
|
76
|
+
self.device_list = QtWidgets.QTableWidget()
|
|
77
|
+
self.device_list.setColumnCount(3)
|
|
78
|
+
self.device_list.setHorizontalHeaderLabels(['Label', 'Category', 'Properties'])
|
|
79
|
+
self.device_list.horizontalHeader().setStretchLastSection(True)
|
|
80
|
+
self.device_list.setSelectionBehavior(
|
|
81
|
+
QtWidgets.QTableWidget.SelectionBehavior.SelectRows
|
|
82
|
+
)
|
|
83
|
+
self.device_list.setSelectionMode(
|
|
84
|
+
QtWidgets.QAbstractItemView.SelectionMode.SingleSelection
|
|
85
|
+
)
|
|
86
|
+
self.device_list.horizontalHeader().setSectionResizeMode(
|
|
87
|
+
QtWidgets.QHeaderView.ResizeMode.ResizeToContents
|
|
88
|
+
)
|
|
89
|
+
self.device_list.setEditTriggers(
|
|
90
|
+
QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers
|
|
91
|
+
)
|
|
92
|
+
devices_layout.addWidget(self.device_list)
|
|
93
|
+
|
|
94
|
+
# Add widgets to splitter
|
|
95
|
+
self.splitter.addWidget(instances_widget)
|
|
96
|
+
self.splitter.addWidget(devices_widget)
|
|
97
|
+
self.splitter.setStretchFactor(0, 1)
|
|
98
|
+
self.splitter.setStretchFactor(1, 1)
|
|
99
|
+
|
|
100
|
+
main_layout.addWidget(self.splitter)
|
|
101
|
+
|
|
102
|
+
# Bottom buttons
|
|
103
|
+
button_layout = QtWidgets.QHBoxLayout()
|
|
104
|
+
|
|
105
|
+
self.add_button = QtWidgets.QPushButton('Add Core Bridge')
|
|
106
|
+
self.refresh_button = QtWidgets.QPushButton('Refresh')
|
|
107
|
+
self.stop_all_button = QtWidgets.QPushButton('Stop All')
|
|
108
|
+
|
|
109
|
+
button_layout.addWidget(self.add_button)
|
|
110
|
+
button_layout.addWidget(self.refresh_button)
|
|
111
|
+
button_layout.addWidget(self.stop_all_button)
|
|
112
|
+
# button_layout.addStretch()
|
|
113
|
+
|
|
114
|
+
main_layout.addLayout(button_layout)
|
|
115
|
+
|
|
116
|
+
def _connect_signals(self):
|
|
117
|
+
'''Connect signals to slots.'''
|
|
118
|
+
self.add_button.clicked.connect(self._show_add_bridge_dialog)
|
|
119
|
+
self.refresh_button.clicked.connect(self._refresh_instances)
|
|
120
|
+
self.stop_all_button.clicked.connect(self._stop_all_instances)
|
|
121
|
+
self.instance_list.itemSelectionChanged.connect(self._update_device_list)
|
|
122
|
+
|
|
123
|
+
def _refresh_instances(self):
|
|
124
|
+
'''Refresh the list of running core bridge instances.'''
|
|
125
|
+
self.instance_list.setRowCount(0)
|
|
126
|
+
self.device_list.setRowCount(0)
|
|
127
|
+
|
|
128
|
+
instances = PycroCore._instances
|
|
129
|
+
if not instances:
|
|
130
|
+
# Show message if no instances
|
|
131
|
+
self.instance_list.setRowCount(1)
|
|
132
|
+
no_instances = QtWidgets.QTableWidgetItem('No active core bridges')
|
|
133
|
+
self.instance_list.setSpan(0, 0, 1, 4)
|
|
134
|
+
self.instance_list.setItem(0, 0, no_instances)
|
|
135
|
+
return
|
|
136
|
+
|
|
137
|
+
self.instance_list.setRowCount(len(instances))
|
|
138
|
+
|
|
139
|
+
for idx, (port, core_instance) in enumerate(instances.items()):
|
|
140
|
+
# Port
|
|
141
|
+
port_item = QtWidgets.QTableWidgetItem(str(port))
|
|
142
|
+
self.instance_list.setItem(idx, 0, port_item)
|
|
143
|
+
|
|
144
|
+
# Status
|
|
145
|
+
status = core_instance.is_connected()
|
|
146
|
+
status_text = 'Connected' if status else 'Disconnected'
|
|
147
|
+
status_item = QtWidgets.QTableWidgetItem(status_text)
|
|
148
|
+
self.instance_list.setItem(idx, 1, status_item)
|
|
149
|
+
|
|
150
|
+
# Device count
|
|
151
|
+
device_count = 0
|
|
152
|
+
try:
|
|
153
|
+
if status:
|
|
154
|
+
device_count = len(core_instance.get_loaded_devices())
|
|
155
|
+
except Exception:
|
|
156
|
+
pass
|
|
157
|
+
|
|
158
|
+
device_item = QtWidgets.QTableWidgetItem(f'{device_count} devices')
|
|
159
|
+
self.instance_list.setItem(idx, 2, device_item)
|
|
160
|
+
|
|
161
|
+
stop_button = QtWidgets.QPushButton('Stop')
|
|
162
|
+
|
|
163
|
+
stop_button.clicked.connect(
|
|
164
|
+
lambda checked=False, p=port: self._stop_instance(p)
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
self.instance_list.setCellWidget(idx, 3, stop_button)
|
|
168
|
+
|
|
169
|
+
self.instance_list.resizeRowsToContents()
|
|
170
|
+
|
|
171
|
+
# Auto-select first instance
|
|
172
|
+
if instances:
|
|
173
|
+
self.instance_list.selectRow(0)
|
|
174
|
+
|
|
175
|
+
def _update_device_list(self):
|
|
176
|
+
'''Update the device list based on selected core instance.'''
|
|
177
|
+
self.device_list.setRowCount(0)
|
|
178
|
+
|
|
179
|
+
selected_rows = self.instance_list.selectionModel().selectedRows()
|
|
180
|
+
if not selected_rows:
|
|
181
|
+
return
|
|
182
|
+
|
|
183
|
+
# Get the port from the first column of the selected row
|
|
184
|
+
selected_row = selected_rows[0].row()
|
|
185
|
+
port_item = self.instance_list.item(selected_row, 0)
|
|
186
|
+
|
|
187
|
+
if not port_item:
|
|
188
|
+
return
|
|
189
|
+
|
|
190
|
+
if not port_item.text().isdigit():
|
|
191
|
+
return
|
|
192
|
+
|
|
193
|
+
try:
|
|
194
|
+
port = int(port_item.text())
|
|
195
|
+
core_instance = PycroCore._instances.get(port)
|
|
196
|
+
|
|
197
|
+
if not core_instance or not core_instance.is_connected():
|
|
198
|
+
return
|
|
199
|
+
|
|
200
|
+
devices = core_instance.get_loaded_devices()
|
|
201
|
+
self.device_list.setRowCount(len(devices))
|
|
202
|
+
|
|
203
|
+
for idx, device in enumerate(devices):
|
|
204
|
+
# Device Label
|
|
205
|
+
name_item = QtWidgets.QTableWidgetItem(device)
|
|
206
|
+
self.device_list.setItem(idx, 0, name_item)
|
|
207
|
+
|
|
208
|
+
# Device Category
|
|
209
|
+
try:
|
|
210
|
+
category = core_instance.get_device_type(device).name
|
|
211
|
+
except Exception:
|
|
212
|
+
category = 'Unknown'
|
|
213
|
+
category_item = QtWidgets.QTableWidgetItem(category)
|
|
214
|
+
self.device_list.setItem(idx, 1, category_item)
|
|
215
|
+
|
|
216
|
+
# Property count
|
|
217
|
+
try:
|
|
218
|
+
props = core_instance.get_device_property_names(device)
|
|
219
|
+
prop_count = len(props)
|
|
220
|
+
except Exception:
|
|
221
|
+
prop_count = 0
|
|
222
|
+
|
|
223
|
+
props_button = QtWidgets.QPushButton(f'Properties ({prop_count})')
|
|
224
|
+
props_button.setToolTip('Show device properties')
|
|
225
|
+
props_button.clicked.connect(
|
|
226
|
+
lambda checked=False,
|
|
227
|
+
dev=device,
|
|
228
|
+
core=core_instance: self._show_device_properties(dev, core)
|
|
229
|
+
)
|
|
230
|
+
self.device_list.setCellWidget(idx, 2, props_button)
|
|
231
|
+
|
|
232
|
+
self.device_list.resizeRowsToContents()
|
|
233
|
+
|
|
234
|
+
except Exception as e:
|
|
235
|
+
print(f'Error updating device list: {e}')
|
|
236
|
+
return
|
|
237
|
+
|
|
238
|
+
def _show_device_properties(self, device_name: str, core_instance: PycroCore):
|
|
239
|
+
'''Show properties for a specific device.'''
|
|
240
|
+
try:
|
|
241
|
+
props = core_instance.get_device_property_names(device_name)
|
|
242
|
+
|
|
243
|
+
dialog = QtWidgets.QDialog(self)
|
|
244
|
+
dialog.setWindowTitle(f'Properties: {device_name}')
|
|
245
|
+
dialog.setMinimumWidth(500)
|
|
246
|
+
dialog.setMinimumHeight(400)
|
|
247
|
+
|
|
248
|
+
layout = QtWidgets.QVBoxLayout(dialog)
|
|
249
|
+
|
|
250
|
+
prop_table = QtWidgets.QTableWidget()
|
|
251
|
+
prop_table.setColumnCount(3)
|
|
252
|
+
prop_table.setHorizontalHeaderLabels(['Property', 'Value', 'Readonly'])
|
|
253
|
+
prop_table.setRowCount(len(props))
|
|
254
|
+
|
|
255
|
+
for idx, prop in enumerate(props):
|
|
256
|
+
# Property name
|
|
257
|
+
prop_item = QtWidgets.QTableWidgetItem(prop)
|
|
258
|
+
prop_table.setItem(idx, 0, prop_item)
|
|
259
|
+
|
|
260
|
+
# Property value
|
|
261
|
+
try:
|
|
262
|
+
value = core_instance.get_property(device_name, prop)
|
|
263
|
+
except Exception:
|
|
264
|
+
value = 'Error'
|
|
265
|
+
value_item = QtWidgets.QTableWidgetItem(str(value))
|
|
266
|
+
prop_table.setItem(idx, 1, value_item)
|
|
267
|
+
|
|
268
|
+
# Property readonly status
|
|
269
|
+
try:
|
|
270
|
+
readonly = core_instance.is_property_readonly(device_name, prop)
|
|
271
|
+
readonly_text = 'Yes' if readonly else 'No'
|
|
272
|
+
except Exception:
|
|
273
|
+
readonly_text = 'Unknown'
|
|
274
|
+
readonly_item = QtWidgets.QTableWidgetItem(readonly_text)
|
|
275
|
+
prop_table.setItem(idx, 2, readonly_item)
|
|
276
|
+
|
|
277
|
+
prop_table.horizontalHeader().setStretchLastSection(True)
|
|
278
|
+
prop_table.horizontalHeader().setSectionResizeMode(
|
|
279
|
+
QtWidgets.QHeaderView.ResizeMode.ResizeToContents
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
layout.addWidget(prop_table)
|
|
283
|
+
|
|
284
|
+
close_button = QtWidgets.QPushButton('Close')
|
|
285
|
+
close_button.clicked.connect(dialog.close)
|
|
286
|
+
layout.addWidget(close_button)
|
|
287
|
+
|
|
288
|
+
dialog.exec()
|
|
289
|
+
|
|
290
|
+
except Exception as e:
|
|
291
|
+
QtWidgets.QMessageBox.warning(
|
|
292
|
+
self, 'Error', f'Failed to get properties: {str(e)}'
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
def _show_add_bridge_dialog(self):
|
|
296
|
+
'''Show dialog to add a new core bridge instance.'''
|
|
297
|
+
dialog = QtWidgets.QDialog(self)
|
|
298
|
+
dialog.setWindowTitle('Add Core Bridge')
|
|
299
|
+
layout = QtWidgets.QFormLayout(dialog)
|
|
300
|
+
|
|
301
|
+
port_input = QtWidgets.QSpinBox()
|
|
302
|
+
port_input.setRange(1024, 65535)
|
|
303
|
+
port_input.setValue(4827) # Default MM port
|
|
304
|
+
layout.addRow('Port:', port_input)
|
|
305
|
+
|
|
306
|
+
# Add connect button
|
|
307
|
+
button_box = QtWidgets.QDialogButtonBox(
|
|
308
|
+
QtWidgets.QDialogButtonBox.StandardButton.Ok
|
|
309
|
+
| QtWidgets.QDialogButtonBox.StandardButton.Cancel
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
def add_instance():
|
|
313
|
+
port = port_input.value()
|
|
314
|
+
try:
|
|
315
|
+
# Try to create a new core instance
|
|
316
|
+
core = PycroCore(port=port)
|
|
317
|
+
if core.is_connected():
|
|
318
|
+
self._refresh_instances()
|
|
319
|
+
dialog.accept()
|
|
320
|
+
self.instance_started.emit(port)
|
|
321
|
+
else:
|
|
322
|
+
QtWidgets.QMessageBox.warning(
|
|
323
|
+
self,
|
|
324
|
+
'Connection Failed',
|
|
325
|
+
'Could not connect to Micro-Manager core at the specified port',
|
|
326
|
+
)
|
|
327
|
+
except Exception as e:
|
|
328
|
+
QtWidgets.QMessageBox.warning(
|
|
329
|
+
self, 'Error', f'Failed to connect: {str(e)}'
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
button_box.accepted.connect(add_instance)
|
|
333
|
+
button_box.rejected.connect(dialog.reject)
|
|
334
|
+
|
|
335
|
+
layout.addRow(button_box)
|
|
336
|
+
dialog.exec()
|
|
337
|
+
|
|
338
|
+
def _stop_instance(self, port: int):
|
|
339
|
+
'''Stop a specific core bridge instance.'''
|
|
340
|
+
confirm = QtWidgets.QMessageBox.question(
|
|
341
|
+
self,
|
|
342
|
+
f'Confirm Stop {port}',
|
|
343
|
+
f'Are you sure you want to stop the instance on port {port}?'
|
|
344
|
+
+ '\nThis will close the connection to the Micro-Manager core.',
|
|
345
|
+
QtWidgets.QMessageBox.StandardButton.Yes
|
|
346
|
+
| QtWidgets.QMessageBox.StandardButton.No,
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
if confirm != QtWidgets.QMessageBox.StandardButton.Yes:
|
|
350
|
+
return False
|
|
351
|
+
|
|
352
|
+
try:
|
|
353
|
+
core_instance = PycroCore._instances.get(port)
|
|
354
|
+
if core_instance:
|
|
355
|
+
core_instance.close()
|
|
356
|
+
if port in PycroCore._instances:
|
|
357
|
+
del PycroCore._instances[port]
|
|
358
|
+
self._refresh_instances()
|
|
359
|
+
self.instance_stopped.emit(port)
|
|
360
|
+
return True
|
|
361
|
+
except Exception as e:
|
|
362
|
+
QtWidgets.QMessageBox.warning(
|
|
363
|
+
self, 'Error', f'Failed to stop instance: {str(e)}'
|
|
364
|
+
)
|
|
365
|
+
return False
|
|
366
|
+
|
|
367
|
+
def _stop_all_instances(self):
|
|
368
|
+
'''Stop all running core bridge instances.'''
|
|
369
|
+
confirm = QtWidgets.QMessageBox.question(
|
|
370
|
+
self,
|
|
371
|
+
'Confirm Stop All',
|
|
372
|
+
'Are you sure you want to stop all running core bridges?',
|
|
373
|
+
QtWidgets.QMessageBox.StandardButton.Yes
|
|
374
|
+
| QtWidgets.QMessageBox.StandardButton.No,
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
if confirm != QtWidgets.QMessageBox.StandardButton.Yes:
|
|
378
|
+
return
|
|
379
|
+
|
|
380
|
+
instances = list(PycroCore._instances.keys())
|
|
381
|
+
for port in instances:
|
|
382
|
+
with contextlib.suppress(Exception):
|
|
383
|
+
self._stop_instance(port)
|
|
384
|
+
self._refresh_instances()
|
|
385
|
+
|
|
386
|
+
@classmethod
|
|
387
|
+
def show_dialog(cls, parent: Optional[QtWidgets.QWidget] = None) -> None:
|
|
388
|
+
'''Show the bridges manager widget as a dialog.'''
|
|
389
|
+
if not hasattr(cls, '_singleton'):
|
|
390
|
+
cls._singleton = cls(parent=parent)
|
|
391
|
+
|
|
392
|
+
cls._singleton.exec()
|
|
393
|
+
|
|
394
|
+
@classmethod
|
|
395
|
+
def get_menu_action(cls, parent: Optional[QtWidgets.QWidget] = None) -> QAction:
|
|
396
|
+
'''Get the action to show this widget in a menu.'''
|
|
397
|
+
action = QAction('Micro-Manager Core Bridges', parent=parent)
|
|
398
|
+
action.triggered.connect(lambda: cls.show_dialog(parent=parent))
|
|
399
|
+
action.setStatusTip('Show the Micro-Manager Core Bridge Manager')
|
|
400
|
+
return action
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
if __name__ == '__main__':
|
|
404
|
+
app = QApplication(sys.argv)
|
|
405
|
+
window = BridgesWidget()
|
|
406
|
+
window.show()
|
|
407
|
+
sys.exit(app.exec())
|