Loading openflexure_microscope/api/app.py +9 −2 Original line number Diff line number Diff line Loading @@ -70,9 +70,15 @@ def attach_microscope(): logging.debug("First request made. Populating microscope with hardware...") openflexurerc = config.load_config() # Load default user config logging.debug("Creating camera object.") api_camera = StreamingCamera(config=openflexurerc) logging.debug("Creating stage object.") api_stage = OpenFlexureStage("/dev/ttyUSB0") logging.debug("Attaching to microscope.") api_microscope.attach( StreamingCamera(config=openflexurerc), OpenFlexureStage("/dev/ttyUSB0") api_camera, api_stage ) logging.debug("Microscope successfully attached!") Loading @@ -92,6 +98,7 @@ def index(): ##### API ROUTES ###### from openflexure_microscope.api.v1 import blueprints logging.debug("Registering blueprints...") # Base routes base_blueprint = blueprints.base.construct_blueprint(api_microscope) app.register_blueprint(base_blueprint, url_prefix=uri('', 'v1')) Loading openflexure_microscope/microscope.py +9 −2 Original line number Diff line number Diff line Loading @@ -60,14 +60,20 @@ class Microscope(object): apply_config (bool): Should the microscope config dictionary be applied to the attached hardware? """ logging.debug("Attaching camera...") self.camera = camera #: :py:class:`openflexure_microscope.camera.pi.StreamingCamera`: Picamera object if isinstance(camera, StreamingCamera): if isinstance(self.camera, StreamingCamera): logging.info("Attached camera {}".format(camera)) elif not self.camera: logging.info("Attached dummy camera.") logging.debug("Attaching stage...") self.stage = stage #: :py:class:`openflexure_stage.stage.OpenFlexureStage`: OpenFlexure stage object if isinstance(self.stage, OpenFlexureStage): # If a stage object has been attached logging.info("Attached stage {}".format(stage)) self.stage.backlash = np.zeros(3, dtype=np.int) elif not self.stage: logging.info("Attached dummy stage.") def find_plugins(self, plugin_paths=[], include_default=True): """ Loading @@ -77,12 +83,13 @@ class Microscope(object): plugin_paths (list): List of strings of plugin directories. include_default (bool): Also load plugins from the module default directory (DEFAULT_PLUGIN_PATH) """ # TODO: Get paths from rc file logging.debug("Attaching plugins...") plugins_list = search_plugin_dirs(plugin_paths, include_default=include_default) for i in plugins_list: module = load_plugin(i) self.plugin.attach(module) logging.debug("Plugins attached.") # Create unified state @property Loading openflexure_microscope/plugins/loader.py +3 −5 Original line number Diff line number Diff line Loading @@ -104,8 +104,7 @@ class PluginMount(object): # Grant plugin access to the hardware assert(isinstance(plugin_object, MicroscopePlugin)) plugin_object.camera = self.parent.camera plugin_object.stage = self.parent.stage plugin_object.microscope = self.parent print("Adding plugin: {}".format(plugin_name)) Loading @@ -114,9 +113,8 @@ class MicroscopePlugin(): """ Parent class for all microscope plugins. Initially only defines an empty object for camera and stage. All plugins Initially only defines an empty object for microscope. All plugins must be an instance of this class to successfully attach to PluginMount. """ def __init__(self): self.camera = None #: :py:class:`openflexure_microscope.camera.pi.StreamingCamera`: Picamera object self.stage = None #: :py:class:`openflexure_stage.stage.OpenFlexureStage`: OpenFlexure stage object self.microscope = None #: :py:class:`openflexure_microscope.microscope.Microscope`: Microscope object Loading
openflexure_microscope/api/app.py +9 −2 Original line number Diff line number Diff line Loading @@ -70,9 +70,15 @@ def attach_microscope(): logging.debug("First request made. Populating microscope with hardware...") openflexurerc = config.load_config() # Load default user config logging.debug("Creating camera object.") api_camera = StreamingCamera(config=openflexurerc) logging.debug("Creating stage object.") api_stage = OpenFlexureStage("/dev/ttyUSB0") logging.debug("Attaching to microscope.") api_microscope.attach( StreamingCamera(config=openflexurerc), OpenFlexureStage("/dev/ttyUSB0") api_camera, api_stage ) logging.debug("Microscope successfully attached!") Loading @@ -92,6 +98,7 @@ def index(): ##### API ROUTES ###### from openflexure_microscope.api.v1 import blueprints logging.debug("Registering blueprints...") # Base routes base_blueprint = blueprints.base.construct_blueprint(api_microscope) app.register_blueprint(base_blueprint, url_prefix=uri('', 'v1')) Loading
openflexure_microscope/microscope.py +9 −2 Original line number Diff line number Diff line Loading @@ -60,14 +60,20 @@ class Microscope(object): apply_config (bool): Should the microscope config dictionary be applied to the attached hardware? """ logging.debug("Attaching camera...") self.camera = camera #: :py:class:`openflexure_microscope.camera.pi.StreamingCamera`: Picamera object if isinstance(camera, StreamingCamera): if isinstance(self.camera, StreamingCamera): logging.info("Attached camera {}".format(camera)) elif not self.camera: logging.info("Attached dummy camera.") logging.debug("Attaching stage...") self.stage = stage #: :py:class:`openflexure_stage.stage.OpenFlexureStage`: OpenFlexure stage object if isinstance(self.stage, OpenFlexureStage): # If a stage object has been attached logging.info("Attached stage {}".format(stage)) self.stage.backlash = np.zeros(3, dtype=np.int) elif not self.stage: logging.info("Attached dummy stage.") def find_plugins(self, plugin_paths=[], include_default=True): """ Loading @@ -77,12 +83,13 @@ class Microscope(object): plugin_paths (list): List of strings of plugin directories. include_default (bool): Also load plugins from the module default directory (DEFAULT_PLUGIN_PATH) """ # TODO: Get paths from rc file logging.debug("Attaching plugins...") plugins_list = search_plugin_dirs(plugin_paths, include_default=include_default) for i in plugins_list: module = load_plugin(i) self.plugin.attach(module) logging.debug("Plugins attached.") # Create unified state @property Loading
openflexure_microscope/plugins/loader.py +3 −5 Original line number Diff line number Diff line Loading @@ -104,8 +104,7 @@ class PluginMount(object): # Grant plugin access to the hardware assert(isinstance(plugin_object, MicroscopePlugin)) plugin_object.camera = self.parent.camera plugin_object.stage = self.parent.stage plugin_object.microscope = self.parent print("Adding plugin: {}".format(plugin_name)) Loading @@ -114,9 +113,8 @@ class MicroscopePlugin(): """ Parent class for all microscope plugins. Initially only defines an empty object for camera and stage. All plugins Initially only defines an empty object for microscope. All plugins must be an instance of this class to successfully attach to PluginMount. """ def __init__(self): self.camera = None #: :py:class:`openflexure_microscope.camera.pi.StreamingCamera`: Picamera object self.stage = None #: :py:class:`openflexure_stage.stage.OpenFlexureStage`: OpenFlexure stage object self.microscope = None #: :py:class:`openflexure_microscope.microscope.Microscope`: Microscope object