@@ -325,6 +325,8 @@ def start_device(
325325 Index of device in the configuration dictionary. Default is 0.
326326 is_synthetic : bool
327327 Run synthetic version of hardware. Default is False.
328+ daq_connection: Optional[Any]
329+ Data acquisition connection. Default is None.
328330 plugin_devices : Optional[Dict]
329331 Dictionary of plugin devices. Default is None.
330332
@@ -371,26 +373,35 @@ def start_device(
371373 if is_synthetic or device_type .lower ().startswith ("synthetic" ):
372374 device_type = "Synthetic"
373375 elif device_type .endswith (class_name_suffix ):
374- device_type = device_type [:- len (class_name_suffix )]
376+ device_type = device_type [: - len (class_name_suffix )]
375377
376378 # device type naming rules: manufacturer(file_name).device_model
377- # if the device is currrently supported in Navigate, you can use device_model as device type.
379+ # if the device is currently supported in Navigate, you can use device_model as the
380+ # device type.
378381 if "." in device_type :
379382 device_manufacturer , device_type = device_type .split ("." )[:2 ]
380383 elif device_type in temp_device_ref :
381384 device_manufacturer = temp_device_ref [device_type ]
382385 else :
383386 device_manufacturer = None
384387
385- if device_manufacturer is not None and importlib .util .find_spec (f"navigate.model.devices.{ device_category } .{ device_manufacturer } " ):
388+ if device_manufacturer is not None and importlib .util .find_spec (
389+ f"navigate.model.devices.{ device_category } .{ device_manufacturer } "
390+ ):
386391 module = importlib .import_module (
387392 f"navigate.model.devices.{ device_category } .{ device_manufacturer } "
388393 )
389394 try :
390395 _class = getattr (module , device_type + class_name_suffix )
391396 except (KeyError , AttributeError ):
392- logger .error (f"There is no device class { device_type + class_name_suffix } in the file: { device_manufacturer } .py" )
393- return device_not_found (microscope_name , device_category , device_type , device_id )
397+ logger .error (
398+ f"There is no device class { device_type + class_name_suffix } in the file: { device_manufacturer } .py"
399+ )
400+ return device_not_found (
401+ microscope_name , device_category , device_type , device_id
402+ )
403+
404+ # Load serial devices via the SerialDevice factory.
394405 if issubclass (_class , SerialDevice ):
395406 device_connection = SerialConnectionFactory .build_connection (
396407 _class .connect ,
@@ -401,6 +412,8 @@ def start_device(
401412 ),
402413 exception = Exception ,
403414 )
415+
416+ # Load integrated devices via the IntegratedDevice factory.
404417 elif issubclass (_class , IntegratedDevice ):
405418 # get connection parameters
406419 connection_params = []
@@ -459,25 +472,31 @@ def start_device(
459472 elif device_category in plugin_devices :
460473 # device_category in ["stage", "shutter", "filter_wheel", "remote_focus", "camera", "galvo", "zoom", "laser"]
461474 if device_category == "stage" :
462- hardware_configuration = configuration ["configuration" ]["microscopes" ][microscope_name ][
463- device_category ]["hardware" ][device_id ]
475+ hardware_configuration = configuration ["configuration" ]["microscopes" ][
476+ microscope_name
477+ ][device_category ]["hardware" ][device_id ]
464478 else :
465- hardware_configuration = configuration ["configuration" ]["microscopes" ][microscope_name ][
466- device_category ][device_id ]["hardware" ]
479+ hardware_configuration = configuration ["configuration" ]["microscopes" ][
480+ microscope_name
481+ ][device_category ][device_id ]["hardware" ]
467482 # find the device in plugins
468483 if device_type + class_name_suffix in plugin_devices [device_category ]:
469484 device_type += class_name_suffix
470485 elif device_type not in plugin_devices [device_category ]:
471486 device_not_found (microscope_name , device_category , device_type , device_id )
472-
487+
473488 try :
474-
475- device_connection = plugin_devices [device_category ][device_type ]["load_device" ](
489+
490+ device_connection = plugin_devices [device_category ][device_type ][
491+ "load_device"
492+ ](
476493 hardware_configuration ,
477494 is_synthetic ,
478- device_type = device_category ,
495+ device_type = device_category ,
479496 )
480- start_function = plugin_devices [device_category ][device_type ]["start_device" ]
497+ start_function = plugin_devices [device_category ][device_type ][
498+ "start_device"
499+ ]
481500 return start_function (
482501 microscope_name ,
483502 device_connection ,
@@ -487,8 +506,10 @@ def start_device(
487506 device_type = device_category ,
488507 )
489508 except RuntimeError :
490- print (f"{ device_category } :{ device_type } can't be loaded correctly, "
491- f"make sure you have specify SUPPORTED_DEVICE_TYPES in your plugin!" )
509+ print (
510+ f"{ device_category } :{ device_type } can't be loaded correctly, "
511+ f"make sure you have specify SUPPORTED_DEVICE_TYPES in your plugin!"
512+ )
492513 device_not_found (microscope_name , device_category , device_type , device_id )
493514
494515
0 commit comments