etho-python 1.2.5__py3-none-any.whl → 1.3__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.
- etho/app.py +60 -2
- etho/assets/etho_icon1_pipeline_dark.svg +23 -23
- etho/assets/etho_icon1_pipeline_light.svg +30 -30
- etho/cli.py +33 -16
- etho/res_app.py +225 -225
- etho/resumable.py +283 -283
- etho/services/DAQZeroService.py +34 -7
- etho/services/DLPZeroService.py +13 -1
- etho/services/GCMZeroService.py +67 -22
- etho/services/GOVZeroService.py +304 -291
- etho/services/ZeroService.py +7 -0
- etho/services/__init__.py +63 -52
- etho/services/callbacks/_image.py +65 -87
- etho/services/camera/__init__.py +2 -0
- etho/services/camera/base.py +4 -0
- etho/services/camera/basler.py +9 -2
- etho/services/camera/dummy.py +5 -13
- etho/services/camera/hamamatsu.py +8 -1
- etho/services/camera/spinnaker.py +28 -2
- etho/services/camera/spinnaker_old.py +310 -312
- etho/services/camera/webcam.py +215 -0
- etho/services/camera/ximea.py +16 -2
- etho/services/daq/IOTask.py +16 -9
- etho/services/hardware.py +46 -0
- etho/services/resumable.py +494 -476
- etho/utils/calibration.py +88 -88
- etho/utils/runner.py +121 -121
- {etho_python-1.2.5.dist-info → etho_python-1.3.dist-info}/METADATA +2 -2
- etho_python-1.3.dist-info/RECORD +51 -0
- {etho_python-1.2.5.dist-info → etho_python-1.3.dist-info}/licenses/LICENSE +21 -21
- etho_python-1.2.5.dist-info/RECORD +0 -49
- {etho_python-1.2.5.dist-info → etho_python-1.3.dist-info}/WHEEL +0 -0
- {etho_python-1.2.5.dist-info → etho_python-1.3.dist-info}/entry_points.txt +0 -0
etho/res_app.py
CHANGED
|
@@ -1,225 +1,225 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import sys
|
|
3
|
-
import threading
|
|
4
|
-
from typing import Optional
|
|
5
|
-
|
|
6
|
-
from qtpy.QtCore import QObject, Signal
|
|
7
|
-
from qtpy.QtWidgets import QApplication, QLabel, QMessageBox, QPushButton, QSizePolicy
|
|
8
|
-
|
|
9
|
-
from .app import MainWindow as EthoMainWindow
|
|
10
|
-
from .app import _system_icon
|
|
11
|
-
from .resumable import ResumableExperimentRunner
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
logger = logging.getLogger(__name__)
|
|
15
|
-
CONTROL_COLUMN_WIDTH = 145
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class WorkerSignals(QObject):
|
|
19
|
-
finished = Signal(str)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class MainWindow(EthoMainWindow):
|
|
23
|
-
def __init__(self, protocol_folder: Optional[str] = None, playlist_folder: Optional[str] = None):
|
|
24
|
-
super().__init__(protocol_folder, playlist_folder)
|
|
25
|
-
self.setWindowTitle("etho resumable control")
|
|
26
|
-
self.runner = None
|
|
27
|
-
self.worker = None
|
|
28
|
-
self.progress_thread = None
|
|
29
|
-
self.progress_stop_event = None
|
|
30
|
-
self.run_active = False
|
|
31
|
-
self.signals = WorkerSignals()
|
|
32
|
-
self.signals.finished.connect(self.on_worker_finished)
|
|
33
|
-
try:
|
|
34
|
-
self.run_timer.timeout.disconnect(self.sync_run_state)
|
|
35
|
-
except (TypeError, RuntimeError):
|
|
36
|
-
pass
|
|
37
|
-
self.run_timer.stop()
|
|
38
|
-
|
|
39
|
-
buttons = self.layout.itemAtPosition(0, 0).layout()
|
|
40
|
-
self.button["Initialize hardware"] = QPushButton("Initialize hardware")
|
|
41
|
-
self.button["Initialize hardware"].clicked.connect(self.initialize_hardware)
|
|
42
|
-
self.button["Shutdown hardware"] = QPushButton("Shutdown hardware")
|
|
43
|
-
self.button["Shutdown hardware"].clicked.connect(self.shutdown_hardware)
|
|
44
|
-
self.status_label = QLabel("Select a protocol and initialize hardware.")
|
|
45
|
-
self.status_label.setWordWrap(True)
|
|
46
|
-
self.status_label.setFixedWidth(CONTROL_COLUMN_WIDTH)
|
|
47
|
-
self.status_label.setMinimumHeight(72)
|
|
48
|
-
self.status_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
|
|
49
|
-
|
|
50
|
-
buttons.insertWidget(1, self.button["Initialize hardware"])
|
|
51
|
-
buttons.insertWidget(2, self.button["Shutdown hardware"])
|
|
52
|
-
buttons.insertSpacing(3, 12)
|
|
53
|
-
buttons.insertSpacing(6, 8)
|
|
54
|
-
buttons.insertWidget(buttons.count() - 1, self.status_label)
|
|
55
|
-
self.layout.setColumnMinimumWidth(0, CONTROL_COLUMN_WIDTH)
|
|
56
|
-
self.layout.setColumnStretch(0, 0)
|
|
57
|
-
for button in self.button.values():
|
|
58
|
-
if hasattr(button, "setFixedWidth"):
|
|
59
|
-
button.setFixedWidth(CONTROL_COLUMN_WIDTH)
|
|
60
|
-
self.set_resumable_buttons("idle")
|
|
61
|
-
|
|
62
|
-
def refresh_lists(self, init: bool = False):
|
|
63
|
-
super().refresh_lists(init)
|
|
64
|
-
if self.playlists_view.selected_string is None:
|
|
65
|
-
self.playlists_view.selected_string = str(self.playlists_view.model()._data.iloc[0, 0])
|
|
66
|
-
if self.protocols_view.selected_string is None:
|
|
67
|
-
self.protocols_view.selected_string = str(self.protocols_view.model()._data.iloc[0, 0])
|
|
68
|
-
|
|
69
|
-
def selected_playlist(self):
|
|
70
|
-
if self.playlists_view.selected_string is None:
|
|
71
|
-
return None
|
|
72
|
-
return (self.playlist_folder / self.playlists_view.selected_string).as_posix()
|
|
73
|
-
|
|
74
|
-
def run_background(self, message, target):
|
|
75
|
-
if self.worker is not None and self.worker.is_alive():
|
|
76
|
-
return
|
|
77
|
-
self.status_label.setText(message)
|
|
78
|
-
self.set_resumable_buttons("busy")
|
|
79
|
-
|
|
80
|
-
def wrapped():
|
|
81
|
-
try:
|
|
82
|
-
status = target()
|
|
83
|
-
except Exception as e:
|
|
84
|
-
logger.exception("Resumable GUI action failed.")
|
|
85
|
-
self.run_active = False
|
|
86
|
-
status = f"Error: {e}"
|
|
87
|
-
self.signals.finished.emit(status)
|
|
88
|
-
|
|
89
|
-
self.worker = threading.Thread(target=wrapped, daemon=True)
|
|
90
|
-
self.worker.start()
|
|
91
|
-
|
|
92
|
-
def on_worker_finished(self, status):
|
|
93
|
-
self.worker = None
|
|
94
|
-
self.status_label.setText(status)
|
|
95
|
-
if not self.run_active:
|
|
96
|
-
self.run_timer.stop()
|
|
97
|
-
elif self.progress_thread is None or not self.progress_thread.is_alive():
|
|
98
|
-
self.start_progress_monitor()
|
|
99
|
-
self.set_resumable_buttons("ready" if self.runner else "idle")
|
|
100
|
-
|
|
101
|
-
def initialize_hardware(self):
|
|
102
|
-
if self.runner is not None:
|
|
103
|
-
return
|
|
104
|
-
|
|
105
|
-
def work():
|
|
106
|
-
logging.getLogger().setLevel(logging.DEBUG if self.button["Debug"].isChecked() else logging.INFO)
|
|
107
|
-
runner = ResumableExperimentRunner(protocol=self.current_protocol)
|
|
108
|
-
runner.setup_hardware()
|
|
109
|
-
self.runner = runner
|
|
110
|
-
services = ", ".join(runner.services)
|
|
111
|
-
return f"Hardware {services} initialized. Ready to run an experiment"
|
|
112
|
-
|
|
113
|
-
self.run_background("Initializing hardware...", work)
|
|
114
|
-
|
|
115
|
-
def shutdown_hardware(self):
|
|
116
|
-
if self.runner is None:
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
def work():
|
|
120
|
-
self.runner.close()
|
|
121
|
-
self.runner = None
|
|
122
|
-
self.run_active = False
|
|
123
|
-
if self.progress_stop_event is not None:
|
|
124
|
-
self.progress_stop_event.set()
|
|
125
|
-
return "Hardware shut down."
|
|
126
|
-
|
|
127
|
-
self.run_background("Shutting down hardware...", work)
|
|
128
|
-
|
|
129
|
-
def start(self, preview: bool = False):
|
|
130
|
-
if self.runner is None:
|
|
131
|
-
QMessageBox.warning(self, "Hardware not initialized", "Initialize hardware first.")
|
|
132
|
-
return
|
|
133
|
-
playlist = self.selected_playlist()
|
|
134
|
-
if playlist is None:
|
|
135
|
-
QMessageBox.warning(self, "Missing playlist", "Select a playlist first.")
|
|
136
|
-
return
|
|
137
|
-
|
|
138
|
-
def work():
|
|
139
|
-
logging.getLogger().setLevel(logging.DEBUG if self.button["Debug"].isChecked() else logging.INFO)
|
|
140
|
-
if self.progress_stop_event is not None:
|
|
141
|
-
self.progress_stop_event.set()
|
|
142
|
-
if self.progress_thread is not None and self.progress_thread.is_alive():
|
|
143
|
-
self.progress_thread.join(timeout=0.2)
|
|
144
|
-
self.runner.stop_run()
|
|
145
|
-
self.progress_stop_event = threading.Event()
|
|
146
|
-
self.runner.prepare_playlist_run(playlist, preview=preview)
|
|
147
|
-
self.runner.start()
|
|
148
|
-
self.run_active = True
|
|
149
|
-
return "Camera preview running." if preview else "Experiment running."
|
|
150
|
-
|
|
151
|
-
self.run_background("Starting experiment...", work)
|
|
152
|
-
|
|
153
|
-
def request_stop(self):
|
|
154
|
-
if self.runner is None:
|
|
155
|
-
return
|
|
156
|
-
|
|
157
|
-
def work():
|
|
158
|
-
if self.progress_stop_event is not None:
|
|
159
|
-
self.progress_stop_event.set()
|
|
160
|
-
self.runner.stop_run()
|
|
161
|
-
self.run_active = False
|
|
162
|
-
return "Experiment stopped."
|
|
163
|
-
|
|
164
|
-
self.run_background("Stopping experiment...", work)
|
|
165
|
-
|
|
166
|
-
def camera_preview(self):
|
|
167
|
-
self.start(preview=True)
|
|
168
|
-
|
|
169
|
-
def start_progress_monitor(self):
|
|
170
|
-
if self.runner is None or self.progress_stop_event is None:
|
|
171
|
-
return
|
|
172
|
-
|
|
173
|
-
def monitor():
|
|
174
|
-
try:
|
|
175
|
-
self.runner.monitor_progress(
|
|
176
|
-
show_progress=self.button["Progress"].isChecked(),
|
|
177
|
-
stop_event=self.progress_stop_event,
|
|
178
|
-
)
|
|
179
|
-
finally:
|
|
180
|
-
if self.run_active and self.progress_stop_event is not None and not self.progress_stop_event.is_set():
|
|
181
|
-
self.runner.stop_run()
|
|
182
|
-
self.run_active = False
|
|
183
|
-
self.signals.finished.emit("Experiment finished.")
|
|
184
|
-
|
|
185
|
-
self.progress_thread = threading.Thread(target=monitor, daemon=True)
|
|
186
|
-
self.progress_thread.start()
|
|
187
|
-
|
|
188
|
-
def set_resumable_buttons(self, state):
|
|
189
|
-
busy = state == "busy"
|
|
190
|
-
ready = self.runner is not None
|
|
191
|
-
running = ready and self.run_active
|
|
192
|
-
self.button["Refresh lists"].setEnabled(not busy and not ready)
|
|
193
|
-
self.button["Initialize hardware"].setEnabled(not busy and not ready)
|
|
194
|
-
self.button["Shutdown hardware"].setEnabled(not busy and ready)
|
|
195
|
-
self.button["Start"].setEnabled(not busy and ready)
|
|
196
|
-
self.button["Stop"].setEnabled(not busy and running)
|
|
197
|
-
self.button["Camera_preview"].setEnabled(not busy and ready)
|
|
198
|
-
self.button["Debug"].setEnabled(not busy)
|
|
199
|
-
self.button["Progress"].setEnabled(not busy)
|
|
200
|
-
self.button["Exit"].setEnabled(not busy)
|
|
201
|
-
self.protocols_view.setEnabled(not busy and not ready)
|
|
202
|
-
self.protocol_view.setEnabled(not busy and not ready)
|
|
203
|
-
self.playlists_view.setEnabled(not busy)
|
|
204
|
-
self.playlist_view.setEnabled(not busy)
|
|
205
|
-
|
|
206
|
-
def closeEvent(self, event):
|
|
207
|
-
if self.progress_stop_event is not None:
|
|
208
|
-
self.progress_stop_event.set()
|
|
209
|
-
if self.runner is not None:
|
|
210
|
-
self.runner.close()
|
|
211
|
-
self.runner = None
|
|
212
|
-
self.run_active = False
|
|
213
|
-
event.accept()
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
def main(protocol_folder: Optional[str] = None, playlist_folder: Optional[str] = None):
|
|
217
|
-
app = QApplication(sys.argv)
|
|
218
|
-
icon = _system_icon(app)
|
|
219
|
-
app.setWindowIcon(icon)
|
|
220
|
-
|
|
221
|
-
window = MainWindow(protocol_folder, playlist_folder)
|
|
222
|
-
window.setWindowIcon(icon)
|
|
223
|
-
window.show()
|
|
224
|
-
|
|
225
|
-
sys.exit(app.exec_())
|
|
1
|
+
import logging
|
|
2
|
+
import sys
|
|
3
|
+
import threading
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
from qtpy.QtCore import QObject, Signal
|
|
7
|
+
from qtpy.QtWidgets import QApplication, QLabel, QMessageBox, QPushButton, QSizePolicy
|
|
8
|
+
|
|
9
|
+
from .app import MainWindow as EthoMainWindow
|
|
10
|
+
from .app import _system_icon
|
|
11
|
+
from .resumable import ResumableExperimentRunner
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
|
+
CONTROL_COLUMN_WIDTH = 145
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class WorkerSignals(QObject):
|
|
19
|
+
finished = Signal(str)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class MainWindow(EthoMainWindow):
|
|
23
|
+
def __init__(self, protocol_folder: Optional[str] = None, playlist_folder: Optional[str] = None):
|
|
24
|
+
super().__init__(protocol_folder, playlist_folder)
|
|
25
|
+
self.setWindowTitle("etho resumable control")
|
|
26
|
+
self.runner = None
|
|
27
|
+
self.worker = None
|
|
28
|
+
self.progress_thread = None
|
|
29
|
+
self.progress_stop_event = None
|
|
30
|
+
self.run_active = False
|
|
31
|
+
self.signals = WorkerSignals()
|
|
32
|
+
self.signals.finished.connect(self.on_worker_finished)
|
|
33
|
+
try:
|
|
34
|
+
self.run_timer.timeout.disconnect(self.sync_run_state)
|
|
35
|
+
except (TypeError, RuntimeError):
|
|
36
|
+
pass
|
|
37
|
+
self.run_timer.stop()
|
|
38
|
+
|
|
39
|
+
buttons = self.layout.itemAtPosition(0, 0).layout()
|
|
40
|
+
self.button["Initialize hardware"] = QPushButton("Initialize hardware")
|
|
41
|
+
self.button["Initialize hardware"].clicked.connect(self.initialize_hardware)
|
|
42
|
+
self.button["Shutdown hardware"] = QPushButton("Shutdown hardware")
|
|
43
|
+
self.button["Shutdown hardware"].clicked.connect(self.shutdown_hardware)
|
|
44
|
+
self.status_label = QLabel("Select a protocol and initialize hardware.")
|
|
45
|
+
self.status_label.setWordWrap(True)
|
|
46
|
+
self.status_label.setFixedWidth(CONTROL_COLUMN_WIDTH)
|
|
47
|
+
self.status_label.setMinimumHeight(72)
|
|
48
|
+
self.status_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
|
|
49
|
+
|
|
50
|
+
buttons.insertWidget(1, self.button["Initialize hardware"])
|
|
51
|
+
buttons.insertWidget(2, self.button["Shutdown hardware"])
|
|
52
|
+
buttons.insertSpacing(3, 12)
|
|
53
|
+
buttons.insertSpacing(6, 8)
|
|
54
|
+
buttons.insertWidget(buttons.count() - 1, self.status_label)
|
|
55
|
+
self.layout.setColumnMinimumWidth(0, CONTROL_COLUMN_WIDTH)
|
|
56
|
+
self.layout.setColumnStretch(0, 0)
|
|
57
|
+
for button in self.button.values():
|
|
58
|
+
if hasattr(button, "setFixedWidth"):
|
|
59
|
+
button.setFixedWidth(CONTROL_COLUMN_WIDTH)
|
|
60
|
+
self.set_resumable_buttons("idle")
|
|
61
|
+
|
|
62
|
+
def refresh_lists(self, init: bool = False):
|
|
63
|
+
super().refresh_lists(init)
|
|
64
|
+
if self.playlists_view.selected_string is None:
|
|
65
|
+
self.playlists_view.selected_string = str(self.playlists_view.model()._data.iloc[0, 0])
|
|
66
|
+
if self.protocols_view.selected_string is None:
|
|
67
|
+
self.protocols_view.selected_string = str(self.protocols_view.model()._data.iloc[0, 0])
|
|
68
|
+
|
|
69
|
+
def selected_playlist(self):
|
|
70
|
+
if self.playlists_view.selected_string is None:
|
|
71
|
+
return None
|
|
72
|
+
return (self.playlist_folder / self.playlists_view.selected_string).as_posix()
|
|
73
|
+
|
|
74
|
+
def run_background(self, message, target):
|
|
75
|
+
if self.worker is not None and self.worker.is_alive():
|
|
76
|
+
return
|
|
77
|
+
self.status_label.setText(message)
|
|
78
|
+
self.set_resumable_buttons("busy")
|
|
79
|
+
|
|
80
|
+
def wrapped():
|
|
81
|
+
try:
|
|
82
|
+
status = target()
|
|
83
|
+
except Exception as e:
|
|
84
|
+
logger.exception("Resumable GUI action failed.")
|
|
85
|
+
self.run_active = False
|
|
86
|
+
status = f"Error: {e}"
|
|
87
|
+
self.signals.finished.emit(status)
|
|
88
|
+
|
|
89
|
+
self.worker = threading.Thread(target=wrapped, daemon=True)
|
|
90
|
+
self.worker.start()
|
|
91
|
+
|
|
92
|
+
def on_worker_finished(self, status):
|
|
93
|
+
self.worker = None
|
|
94
|
+
self.status_label.setText(status)
|
|
95
|
+
if not self.run_active:
|
|
96
|
+
self.run_timer.stop()
|
|
97
|
+
elif self.progress_thread is None or not self.progress_thread.is_alive():
|
|
98
|
+
self.start_progress_monitor()
|
|
99
|
+
self.set_resumable_buttons("ready" if self.runner else "idle")
|
|
100
|
+
|
|
101
|
+
def initialize_hardware(self):
|
|
102
|
+
if self.runner is not None:
|
|
103
|
+
return
|
|
104
|
+
|
|
105
|
+
def work():
|
|
106
|
+
logging.getLogger().setLevel(logging.DEBUG if self.button["Debug"].isChecked() else logging.INFO)
|
|
107
|
+
runner = ResumableExperimentRunner(protocol=self.current_protocol)
|
|
108
|
+
runner.setup_hardware()
|
|
109
|
+
self.runner = runner
|
|
110
|
+
services = ", ".join(runner.services)
|
|
111
|
+
return f"Hardware {services} initialized. Ready to run an experiment"
|
|
112
|
+
|
|
113
|
+
self.run_background("Initializing hardware...", work)
|
|
114
|
+
|
|
115
|
+
def shutdown_hardware(self):
|
|
116
|
+
if self.runner is None:
|
|
117
|
+
return
|
|
118
|
+
|
|
119
|
+
def work():
|
|
120
|
+
self.runner.close()
|
|
121
|
+
self.runner = None
|
|
122
|
+
self.run_active = False
|
|
123
|
+
if self.progress_stop_event is not None:
|
|
124
|
+
self.progress_stop_event.set()
|
|
125
|
+
return "Hardware shut down."
|
|
126
|
+
|
|
127
|
+
self.run_background("Shutting down hardware...", work)
|
|
128
|
+
|
|
129
|
+
def start(self, preview: bool = False):
|
|
130
|
+
if self.runner is None:
|
|
131
|
+
QMessageBox.warning(self, "Hardware not initialized", "Initialize hardware first.")
|
|
132
|
+
return
|
|
133
|
+
playlist = self.selected_playlist()
|
|
134
|
+
if playlist is None:
|
|
135
|
+
QMessageBox.warning(self, "Missing playlist", "Select a playlist first.")
|
|
136
|
+
return
|
|
137
|
+
|
|
138
|
+
def work():
|
|
139
|
+
logging.getLogger().setLevel(logging.DEBUG if self.button["Debug"].isChecked() else logging.INFO)
|
|
140
|
+
if self.progress_stop_event is not None:
|
|
141
|
+
self.progress_stop_event.set()
|
|
142
|
+
if self.progress_thread is not None and self.progress_thread.is_alive():
|
|
143
|
+
self.progress_thread.join(timeout=0.2)
|
|
144
|
+
self.runner.stop_run()
|
|
145
|
+
self.progress_stop_event = threading.Event()
|
|
146
|
+
self.runner.prepare_playlist_run(playlist, preview=preview)
|
|
147
|
+
self.runner.start()
|
|
148
|
+
self.run_active = True
|
|
149
|
+
return "Camera preview running." if preview else "Experiment running."
|
|
150
|
+
|
|
151
|
+
self.run_background("Starting experiment...", work)
|
|
152
|
+
|
|
153
|
+
def request_stop(self):
|
|
154
|
+
if self.runner is None:
|
|
155
|
+
return
|
|
156
|
+
|
|
157
|
+
def work():
|
|
158
|
+
if self.progress_stop_event is not None:
|
|
159
|
+
self.progress_stop_event.set()
|
|
160
|
+
self.runner.stop_run()
|
|
161
|
+
self.run_active = False
|
|
162
|
+
return "Experiment stopped."
|
|
163
|
+
|
|
164
|
+
self.run_background("Stopping experiment...", work)
|
|
165
|
+
|
|
166
|
+
def camera_preview(self):
|
|
167
|
+
self.start(preview=True)
|
|
168
|
+
|
|
169
|
+
def start_progress_monitor(self):
|
|
170
|
+
if self.runner is None or self.progress_stop_event is None:
|
|
171
|
+
return
|
|
172
|
+
|
|
173
|
+
def monitor():
|
|
174
|
+
try:
|
|
175
|
+
self.runner.monitor_progress(
|
|
176
|
+
show_progress=self.button["Progress"].isChecked(),
|
|
177
|
+
stop_event=self.progress_stop_event,
|
|
178
|
+
)
|
|
179
|
+
finally:
|
|
180
|
+
if self.run_active and self.progress_stop_event is not None and not self.progress_stop_event.is_set():
|
|
181
|
+
self.runner.stop_run()
|
|
182
|
+
self.run_active = False
|
|
183
|
+
self.signals.finished.emit("Experiment finished.")
|
|
184
|
+
|
|
185
|
+
self.progress_thread = threading.Thread(target=monitor, daemon=True)
|
|
186
|
+
self.progress_thread.start()
|
|
187
|
+
|
|
188
|
+
def set_resumable_buttons(self, state):
|
|
189
|
+
busy = state == "busy"
|
|
190
|
+
ready = self.runner is not None
|
|
191
|
+
running = ready and self.run_active
|
|
192
|
+
self.button["Refresh lists"].setEnabled(not busy and not ready)
|
|
193
|
+
self.button["Initialize hardware"].setEnabled(not busy and not ready)
|
|
194
|
+
self.button["Shutdown hardware"].setEnabled(not busy and ready)
|
|
195
|
+
self.button["Start"].setEnabled(not busy and ready)
|
|
196
|
+
self.button["Stop"].setEnabled(not busy and running)
|
|
197
|
+
self.button["Camera_preview"].setEnabled(not busy and ready)
|
|
198
|
+
self.button["Debug"].setEnabled(not busy)
|
|
199
|
+
self.button["Progress"].setEnabled(not busy)
|
|
200
|
+
self.button["Exit"].setEnabled(not busy)
|
|
201
|
+
self.protocols_view.setEnabled(not busy and not ready)
|
|
202
|
+
self.protocol_view.setEnabled(not busy and not ready)
|
|
203
|
+
self.playlists_view.setEnabled(not busy)
|
|
204
|
+
self.playlist_view.setEnabled(not busy)
|
|
205
|
+
|
|
206
|
+
def closeEvent(self, event):
|
|
207
|
+
if self.progress_stop_event is not None:
|
|
208
|
+
self.progress_stop_event.set()
|
|
209
|
+
if self.runner is not None:
|
|
210
|
+
self.runner.close()
|
|
211
|
+
self.runner = None
|
|
212
|
+
self.run_active = False
|
|
213
|
+
event.accept()
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def main(protocol_folder: Optional[str] = None, playlist_folder: Optional[str] = None):
|
|
217
|
+
app = QApplication(sys.argv)
|
|
218
|
+
icon = _system_icon(app)
|
|
219
|
+
app.setWindowIcon(icon)
|
|
220
|
+
|
|
221
|
+
window = MainWindow(protocol_folder, playlist_folder)
|
|
222
|
+
window.setWindowIcon(icon)
|
|
223
|
+
window.show()
|
|
224
|
+
|
|
225
|
+
sys.exit(app.exec_())
|