157157
158158
159159def parse_info (
160- info : list ,
160+ info : list ,
161161) -> dict [str , dict [str , Union [typing .Optional [str ], Any ]]]:
162162 items = []
163163 for line in info :
@@ -342,14 +342,18 @@ def move_command(self, command: bytes) -> None:
342342 # other process to check position
343343 # self.get_command(command)
344344
345- def move_by_relative_position (self , axis : int , delta : float , wait = True ) -> None :
345+ def move_by_relative_position (
346+ self , axis : int , delta : float , wait = True
347+ ) -> None :
346348 """Send a relative movement command to stated axis"""
347349 axis_name = self ._axis_mapper [axis ]
348350 self .move_command (bytes (f"MOVREL { axis_name } ={ str (delta )} " , "ascii" ))
349351 if wait :
350352 self .wait_for_motor_stop (axis )
351353
352- def move_to_absolute_position (self , axis : int , pos : float , wait = True ) -> None :
354+ def move_to_absolute_position (
355+ self , axis : int , pos : float , wait = True
356+ ) -> None :
353357 """Send a relative movement command to stated axis"""
354358 axis_name = self ._axis_mapper [axis ]
355359 self .move_command (bytes (f"MOVE { axis_name } ={ str (pos )} " , "ascii" ))
@@ -492,22 +496,32 @@ def _get_setting(self, command, axis, dtype, value):
492496 )
493497 answer = answer .strip ().decode ()
494498 if answer [:2 ] == ":A" :
495- if answer [- 2 :] == " A" : # Some setting return a non-standard pattern with two A's: ':A axis=value A'
499+ if (
500+ answer [- 2 :] == " A"
501+ ): # Some setting return a non-standard pattern with two A's: ':A axis=value A'
496502 answer = answer [5 :- 1 ]
497- elif command == "MC" : # The MC command does not follow the standard return pattern. It returns ':A 1'
503+ elif (
504+ command == "MC"
505+ ): # The MC command does not follow the standard return pattern. It returns ':A 1'
498506 answer = answer [3 :]
499507 else :
500- answer = answer [5 :] # What I believe is the standard pattern: ':A axis=value' (':A X=42')
508+ answer = answer [
509+ 5 :
510+ ] # What I believe is the standard pattern: ':A axis=value' (':A X=42')
501511 elif answer [:2 ] == f":{ axis } " :
502- answer = answer [3 :- 2 ] # Many settings return ':axis=value A' (':X=42 A')
512+ answer = answer [
513+ 3 :- 2
514+ ] # Many settings return ':axis=value A' (':X=42 A')
503515 elif answer [0 ] == "N" :
504516 # this is an error string
505517 error = answer [2 :]
506518 raise Exception (
507519 f"ASI controller error on command { command } : { error } ,{ ASI_ERRORS [error ]} "
508520 )
509521 else :
510- raise Exception (f"ASI controller error on command { command } : { answer } " )
522+ raise Exception (
523+ f"ASI controller error on command { command } : { answer } "
524+ )
511525
512526 if dtype == "int" :
513527 return int (answer )
@@ -520,7 +534,9 @@ def _set_setting(self, value, command, axis):
520534 if command is None :
521535 return False
522536 else :
523- self ._dev_conn .set_command (bytes (f"{ command } { axis } ={ value } " , "ascii" ))
537+ self ._dev_conn .set_command (
538+ bytes (f"{ command } { axis } ={ value } " , "ascii" )
539+ )
524540
525541 def _add_settings (self , settings ) -> None :
526542 """INFO command returns a list of settings that is parsed into a dict. This function takes that dict and
@@ -531,7 +547,12 @@ def _add_settings(self, settings) -> None:
531547 if setting_params ["value" ].replace ("-" , "" , 1 ).isdigit ():
532548 value = int (setting_params ["value" ])
533549 dtype = "int"
534- elif setting_params ["value" ].replace ("." , "" , 1 ).replace ("-" , "" , 1 ).isdigit ():
550+ elif (
551+ setting_params ["value" ]
552+ .replace ("." , "" , 1 )
553+ .replace ("-" , "" , 1 )
554+ .isdigit ()
555+ ):
535556 value = float (setting_params ["value" ])
536557 dtype = "float"
537558 else :
@@ -586,9 +607,7 @@ def move_by(self, delta: typing.Mapping[str, float]) -> None:
586607 """Move specified axes by the specified distance."""
587608 for axis_name , axis_delta in delta .items ():
588609 self ._dev_conn .move_by_relative_position (
589- int (axis_name ),
590- int (axis_delta ),
591- wait = False
610+ int (axis_name ), int (axis_delta ), wait = False
592611 )
593612 self ._dev_conn .wait_until_idle ()
594613
@@ -597,14 +616,15 @@ def move_to(self, position: typing.Mapping[str, float]) -> None:
597616 print (position )
598617 for axis_name , axis_position in position .items ():
599618 self ._dev_conn .move_to_absolute_position (
600- int (axis_name ),
601- int (axis_position ),
602- wait = False
619+ int (axis_name ), int (axis_position ), wait = False
603620 )
604621 self ._dev_conn .wait_until_idle ()
605622
606623
607- class _ASILED (microscope ._utils .OnlyTriggersBulbOnSoftwareMixin , microscope .abc .LightSource ):
624+ class _ASILED (
625+ microscope ._utils .OnlyTriggersBulbOnSoftwareMixin ,
626+ microscope .abc .LightSource ,
627+ ):
608628 # In principle the light source of the MS2000 and the tiger controllers support triggers, but as not yet implemented
609629 # we set this class as oly triggerable by software
610630 # TODO: Look into implementation of triggers
@@ -616,7 +636,9 @@ def __init__(self, dev_conn: _ASIController, channel: int) -> None:
616636 self ._do_disable ()
617637
618638 def get_status (self ) -> typing .List [str ]:
619- return super ().get_status () # TODO: Verify what am I doing here. Just copying from the Zaber led controller
639+ return (
640+ super ().get_status ()
641+ ) # TODO: Verify what am I doing here. Just copying from the Zaber led controller
620642
621643 def get_is_on (self ) -> bool :
622644 return self ._dev_conn .is_led_on (self ._channel )
@@ -697,7 +719,7 @@ class ASIMS2000(microscope.abc.Controller):
697719 """
698720
699721 def __init__ (
700- self , port : str , baudrate : int = 9600 , timeout : float = 0.5 , ** kwargs
722+ self , port : str , baudrate : int = 9600 , timeout : float = 0.5 , ** kwargs
701723 ) -> None :
702724 super ().__init__ ()
703725 self ._conn = _ASIController (port , baudrate , timeout )
@@ -706,7 +728,6 @@ def __init__(
706728 for light_ch , light in enumerate (kwargs ["lights" ]):
707729 self ._devices [light ] = _ASILED (self ._conn , light_ch )
708730
709-
710731 @property
711732 def devices (self ) -> typing .Mapping [str , microscope .abc .Device ]:
712733 return self ._devices
0 commit comments