Additional debug logging
This commit is contained in:
parent
3f6bf67c12
commit
5ef9215051
3 changed files with 21 additions and 9 deletions
|
|
@ -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!")
|
||||
|
|
@ -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'))
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
"""
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
||||
|
|
@ -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…
Add table
Add a link
Reference in a new issue