@@ -175,18 +175,25 @@ def parse_info(
175175 try :
176176 name = match .group ("name" )
177177 except AttributeError :
178- _logger .warning (f"Error parsing info. No item name found on: { item } " )
178+ _logger .warning (
179+ f"Error parsing info. No item name found on: { item } "
180+ )
179181 continue
180182 try :
181183 value = match .group ("value" )
182184 except AttributeError :
183- _logger .warning (f"Error parsing info. No item value found on: { item } " )
185+ _logger .warning (
186+ f"Error parsing info. No item value found on: { item } "
187+ )
184188 continue
185189 settings [name .strip ()] = {
186190 "value" : value ,
187191 "command" : None
188- if not match .group ("command" ) else match .group ("command" )[1 :- 1 ],
189- "units" : match .group ("units" ) if len (match .group ("units" )) else None ,
192+ if not match .group ("command" )
193+ else match .group ("command" )[1 :- 1 ],
194+ "units" : match .group ("units" )
195+ if len (match .group ("units" ))
196+ else None ,
190197 }
191198
192199 return settings
@@ -235,7 +242,9 @@ def __init__(self, port: str, baudrate: int, timeout: float) -> None:
235242 self .axis_info [axis ] = parse_info (answer )
236243 self .axis_list .append (axis )
237244 except Exception as e :
238- raise InitialiseError (f"Unable to read configuration. Is ASI controller connected?: { e } " )
245+ raise InitialiseError (
246+ f"Unable to read configuration. Is ASI controller connected?: { e } "
247+ )
239248
240249 # As for this version, some MS2000 controllers have integrated control for 2 LEDs
241250 self .led_list = [b"X" , b"Y" ]
@@ -352,7 +361,9 @@ def move_by_relative_position(
352361 ) -> None :
353362 """Send a relative movement command to stated axis"""
354363 if axis not in self .axis_list :
355- raise ValueError (f"Axis { axis } not present. Verify the name of the axis or your configuration files." )
364+ raise ValueError (
365+ f"Axis { axis } not present. Verify the name of the axis or your configuration files."
366+ )
356367 self .move_command (bytes (f"MOVREL { axis } ={ str (delta )} " , "ascii" ))
357368 if wait :
358369 self .wait_for_motor_stop (axis )
@@ -362,37 +373,47 @@ def move_to_absolute_position(
362373 ) -> None :
363374 """Send a relative movement command to stated axis"""
364375 if axis not in self .axis_list :
365- raise ValueError (f"Axis { axis } not present. Verify the name of the axis or your configuration files." )
376+ raise ValueError (
377+ f"Axis { axis } not present. Verify the name of the axis or your configuration files."
378+ )
366379 self .move_command (bytes (f"MOVE { axis } ={ str (pos )} " , "ascii" ))
367380 if wait :
368381 self .wait_for_motor_stop (axis )
369382
370383 def move_to_limit (self , axis : str , speed : int ):
371384 if axis not in self .axis_list :
372- raise ValueError (f"Axis { axis } not present. Verify the name of the axis or your configuration files." )
385+ raise ValueError (
386+ f"Axis { axis } not present. Verify the name of the axis or your configuration files."
387+ )
373388 self .get_command (bytes (f"SPIN { axis } ={ speed } " , "ascii" ))
374389
375390 def motor_moving (self , axis : str ) -> int :
376391 if axis not in self .axis_list :
377- raise ValueError (f"Axis { axis } not present. Verify the name of the axis or your configuration files." )
392+ raise ValueError (
393+ f"Axis { axis } not present. Verify the name of the axis or your configuration files."
394+ )
378395 reply = self .get_command (bytes (f"RDSTAT { axis } " , "ascii" ))
379396 flags = int (reply .strip ()[3 :])
380397 return flags & 1
381398
382399 def set_speed (self , axis : str , speed : int ) -> None :
383400 if axis not in self .axis_list :
384- raise ValueError (f"Axis { axis } not present. Verify the name of the axis or your configuration files." )
401+ raise ValueError (
402+ f"Axis { axis } not present. Verify the name of the axis or your configuration files."
403+ )
385404 self .get_command (bytes (f"SPEED { axis } ={ speed } " , "ascii" ))
386405
387- def find_max_speed (self , axis : str ):
406+ def find_max_speed (self , axis : str ):
388407 if axis not in self .axis_list :
389- raise ValueError (f"Axis { axis } not present. Verify the name of the axis or your configuration files." )
408+ raise ValueError (
409+ f"Axis { axis } not present. Verify the name of the axis or your configuration files."
410+ )
390411 speed = 100000000
391- #set the speed
412+ # set the speed
392413 self .get_command (bytes (f"SPEED { axis } ={ speed } " , "ascii" ))
393- #read off the max speed set by controller
394- response = self .get_command (bytes (f"SPEED { axis } ?" , "ascii" ))
395- return ( float (response .strip ()[5 :]) )
414+ # read off the max speed set by controller
415+ response = self .get_command (bytes (f"SPEED { axis } ?" , "ascii" ))
416+ return float (response .strip ()[5 :])
396417
397418 def wait_for_motor_stop (self , axis : str ):
398419 # give axis a chance to start maybe?
@@ -402,12 +423,16 @@ def wait_for_motor_stop(self, axis: str):
402423
403424 def reset_position (self , axis : str ):
404425 if axis not in self .axis_list :
405- raise ValueError (f"Axis { axis } not present. Verify the name of the axis or your configuration files." )
426+ raise ValueError (
427+ f"Axis { axis } not present. Verify the name of the axis or your configuration files."
428+ )
406429 self .get_command (bytes (f"HERE { axis } =0" , "ascii" ))
407430
408431 def get_absolute_position (self , axis : str ) -> float :
409432 if axis not in self .axis_list :
410- raise ValueError (f"Axis { axis } not present. Verify the name of the axis or your configuration files." )
433+ raise ValueError (
434+ f"Axis { axis } not present. Verify the name of the axis or your configuration files."
435+ )
411436 position = self .get_command (bytes (f"WHERE { axis } " , "ascii" ))
412437 if position [3 :4 ] == b"N" :
413438 print (f"Error: { position } : { _ASI_ERRORS [int (position [4 :6 ])]} " )
@@ -437,8 +462,8 @@ def __init__(self, dev_conn: _ASIController, axis: str) -> None:
437462 self .min_limit = 0.0
438463 self .max_limit = 100000.0
439464 # As detailed in ASI manual set speed to 67% of max
440- max_speed = self ._dev_conn .find_max_speed (self ._axis )
441- self .set_speed (max_speed * 0.67 )
465+ max_speed = self ._dev_conn .find_max_speed (self ._axis )
466+ self .set_speed (max_speed * 0.67 )
442467
443468 def move_by (self , delta : float ) -> None :
444469 self ._dev_conn .move_by_relative_position (self ._axis , int (delta ))
0 commit comments