Skip to content

Commit de93405

Browse files
We had some stuff that was no longer necessary, so this was removed. Also provided a few parts of the device startup functions with consistent spacing to make it more readable. Ready to merge.
1 parent b5ddde2 commit de93405

File tree

3 files changed

+130
-76
lines changed

3 files changed

+130
-76
lines changed

src/navigate/model/device_startup_functions.py

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,11 @@ def start_camera(
257257
for start_function in plugin_devices["camera"]["start_device"]:
258258
try:
259259
return start_function(
260-
microscope_name, device_connection, configuration, is_synthetic,
261-
device_type="camera"
260+
microscope_name,
261+
device_connection,
262+
configuration,
263+
is_synthetic,
264+
device_type="camera",
262265
)
263266
except RuntimeError:
264267
continue
@@ -438,9 +441,10 @@ def load_stages(configuration, is_synthetic=False, plugin_devices={}):
438441
exception=TLFTDICommunicationError,
439442
)
440443
)
444+
441445
elif stage_type == "KST101":
442446
from navigate.model.devices.stages.stage_tl_kcube_steppermotor import (
443-
build_TLKSTStage_connection
447+
build_TLKSTStage_connection,
444448
)
445449

446450
stage_devices.append(
@@ -450,6 +454,7 @@ def load_stages(configuration, is_synthetic=False, plugin_devices={}):
450454
exception=Exception,
451455
)
452456
)
457+
453458
elif stage_type == "MCL" and platform.system() == "Windows":
454459
from navigate.model.devices.stages.stage_mcl import (
455460
build_MCLStage_connection,
@@ -644,12 +649,12 @@ def start_stage(
644649
from navigate.model.devices.stages.stage_tl_kcube_inertial import TLKIMStage
645650

646651
return TLKIMStage(microscope_name, device_connection, configuration, id)
647-
652+
648653
elif device_type == "KST101":
649654
from navigate.model.devices.stages.stage_tl_kcube_steppermotor import TLKSTStage
650655

651656
return TLKSTStage(microscope_name, device_connection, configuration, id)
652-
657+
653658
elif device_type == "MCL":
654659
from navigate.model.devices.stages.stage_mcl import MCLStage
655660

@@ -685,8 +690,12 @@ def start_stage(
685690
for start_function in plugin_devices["stage"]["start_device"]:
686691
try:
687692
return start_function(
688-
microscope_name, device_connection, configuration, is_synthetic,
689-
device_type="stage", id=id
693+
microscope_name,
694+
device_connection,
695+
configuration,
696+
is_synthetic,
697+
device_type="stage",
698+
id=id,
690699
)
691700
except RuntimeError:
692701
continue
@@ -812,8 +821,11 @@ def start_zoom(
812821
for start_zoom in plugin_devices["zoom"]["start_device"]:
813822
try:
814823
return start_zoom(
815-
microscope_name, device_connection, configuration, is_synthetic,
816-
device_type="zoom"
824+
microscope_name,
825+
device_connection,
826+
configuration,
827+
is_synthetic,
828+
device_type="zoom",
817829
)
818830
except RuntimeError:
819831
continue
@@ -874,7 +886,7 @@ def load_filter_wheel_connection(configuration, is_synthetic=False, plugin_devic
874886

875887
elif device_type == "NI":
876888
return DummyDeviceConnection()
877-
889+
878890
elif (
879891
device_type.lower() == "syntheticfilterwheel"
880892
or device_type.lower() == "synthetic"
@@ -891,6 +903,7 @@ def load_filter_wheel_connection(configuration, is_synthetic=False, plugin_devic
891903
except RuntimeError:
892904
continue
893905
device_not_found("filter_wheel", device_type)
906+
894907
else:
895908
device_not_found("filter_wheel", device_type)
896909

@@ -939,6 +952,7 @@ def start_filter_wheel(
939952
device_type = configuration["configuration"]["microscopes"][microscope_name][
940953
"filter_wheel"
941954
]["hardware"]["type"]
955+
942956
if device_type == "SutterFilterWheel":
943957
from navigate.model.devices.filter_wheel.filter_wheel_sutter import (
944958
SutterFilterWheel,
@@ -952,11 +966,10 @@ def start_filter_wheel(
952966
return ASIFilterWheel(microscope_name, device_connection, configuration)
953967

954968
elif device_type == "NI":
955-
956969
from navigate.model.devices.filter_wheel.filter_wheel_daq import DAQFilterWheel
957-
970+
958971
return DAQFilterWheel(microscope_name, device_connection, configuration)
959-
972+
960973
elif (
961974
device_type.lower() == "syntheticfilterwheel"
962975
or device_type.lower() == "synthetic"
@@ -968,16 +981,19 @@ def start_filter_wheel(
968981
return SyntheticFilterWheel(microscope_name, device_connection, configuration)
969982

970983
elif "filter_wheel" in plugin_devices:
971-
972984
for start_function in plugin_devices["filter_wheel"]["start_device"]:
973985
try:
974986
return start_function(
975-
microscope_name, device_connection, configuration, is_synthetic,
976-
device_type="filter_wheel"
987+
microscope_name,
988+
device_connection,
989+
configuration,
990+
is_synthetic,
991+
device_type="filter_wheel",
977992
)
978993
except RuntimeError:
979994
continue
980995
device_not_found(microscope_name, "filter_wheel", device_type)
996+
981997
else:
982998
device_not_found(microscope_name, "filter_wheel", device_type)
983999

@@ -1090,8 +1106,11 @@ def start_shutter(
10901106
for start_function in plugin_devices["shutter"]["start_device"]:
10911107
try:
10921108
return start_function(
1093-
microscope_name, None, configuration, is_synthetic,
1094-
device_type="shutter"
1109+
microscope_name,
1110+
None,
1111+
configuration,
1112+
is_synthetic,
1113+
device_type="shutter",
10951114
)
10961115
except RuntimeError:
10971116
continue
@@ -1163,7 +1182,12 @@ def start_lasers(
11631182
for start_function in plugin_devices["lasers"]["start_device"]:
11641183
try:
11651184
return start_function(
1166-
microscope_name, device_connection, configuration, is_synthetic, device_type="lasers", id=id
1185+
microscope_name,
1186+
device_connection,
1187+
configuration,
1188+
is_synthetic,
1189+
device_type="lasers",
1190+
id=id,
11671191
)
11681192
except RuntimeError:
11691193
continue
@@ -1217,14 +1241,12 @@ def start_remote_focus_device(
12171241

12181242
if device_type == "NI":
12191243
from navigate.model.devices.remote_focus.remote_focus_ni import RemoteFocusNI
1220-
12211244
return RemoteFocusNI(microscope_name, device_connection, configuration)
12221245

12231246
elif device_type == "EquipmentSolutions":
12241247
from navigate.model.devices.remote_focus.remote_focus_equipment_solutions import (
12251248
RemoteFocusEquipmentSolutions,
12261249
)
1227-
12281250
return RemoteFocusEquipmentSolutions(
12291251
microscope_name, device_connection, configuration
12301252
)
@@ -1244,8 +1266,11 @@ def start_remote_focus_device(
12441266
for start_function in plugin_devices["remote_focus_device"]["start_device"]:
12451267
try:
12461268
return start_function(
1247-
microscope_name, device_connection, configuration, is_synthetic,
1248-
device_type="remote_focus_device"
1269+
microscope_name,
1270+
device_connection,
1271+
configuration,
1272+
is_synthetic,
1273+
device_type="remote_focus_device",
12491274
)
12501275
except RuntimeError:
12511276
continue
@@ -1312,8 +1337,12 @@ def start_galvo(
13121337
for start_function in plugin_devices["galvo"]["start_device"]:
13131338
try:
13141339
return start_function(
1315-
microscope_name, device_connection, configuration, is_synthetic,
1316-
device_type="galvo", id=id
1340+
microscope_name,
1341+
device_connection,
1342+
configuration,
1343+
is_synthetic,
1344+
device_type="galvo",
1345+
id=id,
13171346
)
13181347
except RuntimeError:
13191348
continue

src/navigate/model/devices/daq/daq_ni.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import nidaqmx.constants
4141
import nidaqmx.task
4242
import numpy as np
43-
import time
4443

4544
# Local Imports
4645
from navigate.model.devices.daq.daq_base import DAQBase
@@ -223,7 +222,6 @@ def create_camera_task(self, channel_key):
223222
self.microscope_name
224223
]["daq"]["camera_trigger_out_line"]
225224
camera_high_time = 0.004
226-
exposure_time = self.exposure_times[channel_key]
227225
sweep_time = self.sweep_times[channel_key]
228226
camera_low_time = sweep_time - camera_high_time
229227
camera_delay = self.camera_delay
@@ -302,7 +300,10 @@ def create_analog_output_tasks(self, channel_key):
302300
# TODO: may change this later to automatically expand the waveform to the
303301
# longest
304302
for k, v in self.analog_outputs.items():
305-
if k.split("/")[0] == board and len(v["waveform"][channel_key]) < max_sample:
303+
if (
304+
k.split("/")[0] == board
305+
and len(v["waveform"][channel_key]) < max_sample
306+
):
306307
v["waveform"][channel_key] = np.hstack(
307308
[v["waveform"][channel_key]] * self.waveform_expand_num
308309
)
@@ -432,10 +433,13 @@ def enable_microscope(self, microscope_name):
432433
self.microscope_name = microscope_name
433434
self.analog_outputs = {}
434435
self.analog_output_tasks = {}
435-
436-
self.camera_delay = self.configuration["configuration"]["microscopes"][
437-
microscope_name
438-
]["camera"]["delay"] / 1000
436+
437+
self.camera_delay = (
438+
self.configuration["configuration"]["microscopes"][microscope_name][
439+
"camera"
440+
]["delay"]
441+
/ 1000
442+
)
439443
self.sample_rate = self.configuration["configuration"]["microscopes"][
440444
microscope_name
441445
]["daq"]["sample_rate"]
@@ -519,14 +523,3 @@ def update_analog_task(self, board_name):
519523

520524
self.is_updating_analog_task = False
521525
self.wait_to_run_lock.release()
522-
523-
# This function is moved to filter_wheel_daq.py
524-
# def send_do_pulse(self, address):
525-
# self.filter_wheel_task = nidaqmx.Task()
526-
# self.filter_wheel_task.do_channels.add_do_chan(
527-
# address,
528-
# line_grouping=nidaqmx.constants.LineGrouping.CHAN_FOR_ALL_LINES,
529-
# )
530-
# self.filter_wheel_task.write([False, True, True, False], auto_start=True)
531-
# self.filter_wheel_task.stop()
532-
# self.filter_wheel_task.close()

0 commit comments

Comments
 (0)