Loading openflexure_microscope/api/v1/blueprints/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -172,7 +172,7 @@ class ConfigAPI(MicroscopeView): logging.debug("Updating settings from POST request.") self.microscope.write_config(payload.json) self.microscope.apply_config(payload.json) self.microscope.save_config() return jsonify(self.microscope.read_config(json_safe=True)) Loading openflexure_microscope/camera/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -144,7 +144,7 @@ class BaseCamera(metaclass=ABCMeta): pass @abstractmethod def read_config(self): def read_config(self) -> dict: """Return the current settings as a dictionary""" pass Loading openflexure_microscope/camera/pi.py +2 −2 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ class StreamingCamera(BaseCamera): self.camera.close() # HANDLE SETTINGS def read_config(self): def read_config(self) -> dict: """ Return config dictionary of the StreamingCamera. """ Loading @@ -119,7 +119,7 @@ class StreamingCamera(BaseCamera): return conf_dict def apply_config(self, config: dict) -> None: def apply_config(self, config: dict): """ Write a config dictionary to the StreamingCamera config. Loading openflexure_microscope/microscope.py +2 −19 Original line number Diff line number Diff line Loading @@ -164,15 +164,11 @@ class Microscope: # If attached to a camera if ('camera_settings' in config) and self.camera: # Update camera config self.camera.apply_config(config['camera_settings']) # If attached to a stage if ('stage_settings' in config) and self.stage: if 'backlash' in config: # Construct backlash array backlash = axes_to_array(config['backlash'], ['x', 'y', 'z'], [0, 0, 0]) self.stage.backlash = backlash self.stage.apply_config(config['stage_settings']) # Todo: tidy up with some loopy goodness if 'id' in config: Loading Loading @@ -208,21 +204,8 @@ class Microscope: settings_current['camera_settings'] = settings_current_camera # If attached to a stage # TODO: Offload to stage object if self.stage: if hasattr(self.stage.backlash, 'tolist'): backlash = self.stage.backlash.tolist() else: backlash = self.stage.backlash settings_current_stage = { 'backlash': { 'x': backlash[0], 'y': backlash[1], 'z': backlash[2], } } settings_current_stage = self.stage.read_config() settings_current['stage_settings'] = settings_current_stage settings_full = self.settings_file.merge(settings_current) Loading openflexure_microscope/stage/base.py +10 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,16 @@ class BaseStage(metaclass=ABCMeta): def __init__(self): self.lock = StrictLock(timeout=5) @abstractmethod def apply_config(self, config: dict): """Update settings from a config dictionary""" pass @abstractmethod def read_config(self): """Return the current settings as a dictionary""" pass @property @abstractmethod def state(self): Loading Loading
openflexure_microscope/api/v1/blueprints/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -172,7 +172,7 @@ class ConfigAPI(MicroscopeView): logging.debug("Updating settings from POST request.") self.microscope.write_config(payload.json) self.microscope.apply_config(payload.json) self.microscope.save_config() return jsonify(self.microscope.read_config(json_safe=True)) Loading
openflexure_microscope/camera/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -144,7 +144,7 @@ class BaseCamera(metaclass=ABCMeta): pass @abstractmethod def read_config(self): def read_config(self) -> dict: """Return the current settings as a dictionary""" pass Loading
openflexure_microscope/camera/pi.py +2 −2 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ class StreamingCamera(BaseCamera): self.camera.close() # HANDLE SETTINGS def read_config(self): def read_config(self) -> dict: """ Return config dictionary of the StreamingCamera. """ Loading @@ -119,7 +119,7 @@ class StreamingCamera(BaseCamera): return conf_dict def apply_config(self, config: dict) -> None: def apply_config(self, config: dict): """ Write a config dictionary to the StreamingCamera config. Loading
openflexure_microscope/microscope.py +2 −19 Original line number Diff line number Diff line Loading @@ -164,15 +164,11 @@ class Microscope: # If attached to a camera if ('camera_settings' in config) and self.camera: # Update camera config self.camera.apply_config(config['camera_settings']) # If attached to a stage if ('stage_settings' in config) and self.stage: if 'backlash' in config: # Construct backlash array backlash = axes_to_array(config['backlash'], ['x', 'y', 'z'], [0, 0, 0]) self.stage.backlash = backlash self.stage.apply_config(config['stage_settings']) # Todo: tidy up with some loopy goodness if 'id' in config: Loading Loading @@ -208,21 +204,8 @@ class Microscope: settings_current['camera_settings'] = settings_current_camera # If attached to a stage # TODO: Offload to stage object if self.stage: if hasattr(self.stage.backlash, 'tolist'): backlash = self.stage.backlash.tolist() else: backlash = self.stage.backlash settings_current_stage = { 'backlash': { 'x': backlash[0], 'y': backlash[1], 'z': backlash[2], } } settings_current_stage = self.stage.read_config() settings_current['stage_settings'] = settings_current_stage settings_full = self.settings_file.merge(settings_current) Loading
openflexure_microscope/stage/base.py +10 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,16 @@ class BaseStage(metaclass=ABCMeta): def __init__(self): self.lock = StrictLock(timeout=5) @abstractmethod def apply_config(self, config: dict): """Update settings from a config dictionary""" pass @abstractmethod def read_config(self): """Return the current settings as a dictionary""" pass @property @abstractmethod def state(self): Loading