Loading openflexure_microscope/api/app.py +1 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ def attach_microscope(): logging.debug("First request made. Populating microscope with hardware...") logging.debug("Creating camera object...") api_camera = StreamingCamera(config=api_microscope.rc.asdict()) api_camera = StreamingCamera(config=api_microscope.rc.read()) logging.debug("Creating stage object...") api_stage = Stage("/dev/ttyUSB0") Loading openflexure_microscope/api/v1/blueprints/base.py +2 −1 Original line number Diff line number Diff line Loading @@ -172,7 +172,8 @@ class ConfigAPI(MicroscopeView): print(payload.json) self.microscope.apply_config(payload.json) self.microscope.write_config(payload.json) self.microscope.save_config() return jsonify(self.microscope.config) Loading openflexure_microscope/config.py +3 −6 Original line number Diff line number Diff line Loading @@ -109,17 +109,14 @@ class OpenflexureConfig: @property def config(self): return self._config return self.read() def asdict(self): def read(self): return self._config def update(self, update_dict: dict): def write(self, update_dict: dict): self._config.update(update_dict) def overwrite(self, new_dict: dict): self._config = new_dict def load(self): # Unexpanded config dictionary (used at load/save time) self._config = load_yaml_file(self.config_path) Loading openflexure_microscope/microscope.py +19 −12 Original line number Diff line number Diff line Loading @@ -56,10 +56,10 @@ class Microscope(object): # Set default parameters if 'name' not in self.rc.config: self.rc.update({'name': uuid.uuid4().hex}) self.rc.write({'name': uuid.uuid4().hex}) if 'fov' not in self.rc.config: self.rc.update({'fov': [0, 0]}) self.rc.write({'fov': [0, 0]}) # Initialise with an empty composite lock self.lock = CompositeLock([]) #: :py:class:`openflexure_microscope.lock.CompositeLock`: Composite lock controlling thread access to multiple pieces of hardware Loading Loading @@ -96,7 +96,7 @@ class Microscope(object): if isinstance(self.camera, StreamingCamera): logging.info("Attached camera {}".format(camera)) logging.info("Updating camera settings") self.apply_config(self.camera.read_config()) self.write_config(self.camera.read_config()) elif not self.camera: logging.info("Attached dummy camera.") # If camera has a lock Loading Loading @@ -180,9 +180,9 @@ class Microscope(object): return state def apply_config(self, config: dict): def write_config(self, config: dict): """ Updates and applies a config dictionary. Missing parameters will be left untouched. Writes and applies a config dictionary. Missing parameters will be left untouched. """ # If attached to a camera if self.camera: Loading @@ -198,9 +198,7 @@ class Microscope(object): self.stage.backlash = backlash # Cache config self.rc.update(config) # Save to disk self.rc.save() self.rc.write(config) def read_config(self): """ Loading @@ -209,7 +207,7 @@ class Microscope(object): # If attached to a camera if self.camera: # Update camera config params from StreamingCamera object self.rc.update(self.camera.config) self.rc.write(self.camera.config) # If attached to a stage if self.stage: Loading @@ -225,9 +223,18 @@ class Microscope(object): } } self.rc.update(backlash) self.rc.write(backlash) return self.rc.asdict() return self.rc.read() def save_config(self): """ Saves the current runtime-config back to disk """ # Get any changed device settings self.read_config() # Save to disk self.rc.save() @property def config(self) -> dict: Loading @@ -235,4 +242,4 @@ class Microscope(object): @config.setter def config(self, config: dict) -> None: self.apply_config(config) self.write_config(config) openflexure_microscope/plugins/camera_calibration/plugin.py +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ class Plugin(MicroscopePlugin): recalibrate_camera(scamera.camera) finally: scamera.camera.resolution=old_resolution self. if streaming: logging.info("Restarting stream after recalibration") scamera.start_stream_recording() Loading Loading
openflexure_microscope/api/app.py +1 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ def attach_microscope(): logging.debug("First request made. Populating microscope with hardware...") logging.debug("Creating camera object...") api_camera = StreamingCamera(config=api_microscope.rc.asdict()) api_camera = StreamingCamera(config=api_microscope.rc.read()) logging.debug("Creating stage object...") api_stage = Stage("/dev/ttyUSB0") Loading
openflexure_microscope/api/v1/blueprints/base.py +2 −1 Original line number Diff line number Diff line Loading @@ -172,7 +172,8 @@ class ConfigAPI(MicroscopeView): print(payload.json) self.microscope.apply_config(payload.json) self.microscope.write_config(payload.json) self.microscope.save_config() return jsonify(self.microscope.config) Loading
openflexure_microscope/config.py +3 −6 Original line number Diff line number Diff line Loading @@ -109,17 +109,14 @@ class OpenflexureConfig: @property def config(self): return self._config return self.read() def asdict(self): def read(self): return self._config def update(self, update_dict: dict): def write(self, update_dict: dict): self._config.update(update_dict) def overwrite(self, new_dict: dict): self._config = new_dict def load(self): # Unexpanded config dictionary (used at load/save time) self._config = load_yaml_file(self.config_path) Loading
openflexure_microscope/microscope.py +19 −12 Original line number Diff line number Diff line Loading @@ -56,10 +56,10 @@ class Microscope(object): # Set default parameters if 'name' not in self.rc.config: self.rc.update({'name': uuid.uuid4().hex}) self.rc.write({'name': uuid.uuid4().hex}) if 'fov' not in self.rc.config: self.rc.update({'fov': [0, 0]}) self.rc.write({'fov': [0, 0]}) # Initialise with an empty composite lock self.lock = CompositeLock([]) #: :py:class:`openflexure_microscope.lock.CompositeLock`: Composite lock controlling thread access to multiple pieces of hardware Loading Loading @@ -96,7 +96,7 @@ class Microscope(object): if isinstance(self.camera, StreamingCamera): logging.info("Attached camera {}".format(camera)) logging.info("Updating camera settings") self.apply_config(self.camera.read_config()) self.write_config(self.camera.read_config()) elif not self.camera: logging.info("Attached dummy camera.") # If camera has a lock Loading Loading @@ -180,9 +180,9 @@ class Microscope(object): return state def apply_config(self, config: dict): def write_config(self, config: dict): """ Updates and applies a config dictionary. Missing parameters will be left untouched. Writes and applies a config dictionary. Missing parameters will be left untouched. """ # If attached to a camera if self.camera: Loading @@ -198,9 +198,7 @@ class Microscope(object): self.stage.backlash = backlash # Cache config self.rc.update(config) # Save to disk self.rc.save() self.rc.write(config) def read_config(self): """ Loading @@ -209,7 +207,7 @@ class Microscope(object): # If attached to a camera if self.camera: # Update camera config params from StreamingCamera object self.rc.update(self.camera.config) self.rc.write(self.camera.config) # If attached to a stage if self.stage: Loading @@ -225,9 +223,18 @@ class Microscope(object): } } self.rc.update(backlash) self.rc.write(backlash) return self.rc.asdict() return self.rc.read() def save_config(self): """ Saves the current runtime-config back to disk """ # Get any changed device settings self.read_config() # Save to disk self.rc.save() @property def config(self) -> dict: Loading @@ -235,4 +242,4 @@ class Microscope(object): @config.setter def config(self, config: dict) -> None: self.apply_config(config) self.write_config(config)
openflexure_microscope/plugins/camera_calibration/plugin.py +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ class Plugin(MicroscopePlugin): recalibrate_camera(scamera.camera) finally: scamera.camera.resolution=old_resolution self. if streaming: logging.info("Restarting stream after recalibration") scamera.start_stream_recording() Loading