Moved to collision-robust device name
This commit is contained in:
parent
cf19939379
commit
8a282db12b
9 changed files with 28 additions and 28 deletions
|
|
@ -69,7 +69,7 @@ app, labthing = create_app(
|
||||||
app.json_encoder = JSONEncoder
|
app.json_encoder = JSONEncoder
|
||||||
|
|
||||||
# Attach lab devices
|
# Attach lab devices
|
||||||
labthing.register_device(api_microscope, "openflexure_microscope")
|
labthing.register_device(api_microscope, "org.openflexure.microscope")
|
||||||
|
|
||||||
# Attach extensions
|
# Attach extensions
|
||||||
if not os.path.isfile(USER_EXTENSIONS_PATH):
|
if not os.path.isfile(USER_EXTENSIONS_PATH):
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,7 @@ def fast_up_down_up_autofocus(
|
||||||
|
|
||||||
class MeasureSharpnessAPI(Resource):
|
class MeasureSharpnessAPI(Resource):
|
||||||
def post(self):
|
def post(self):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
|
|
||||||
if not microscope:
|
if not microscope:
|
||||||
abort(503, "No microscope connected. Unable to measure sharpness.")
|
abort(503, "No microscope connected. Unable to measure sharpness.")
|
||||||
|
|
@ -305,7 +305,7 @@ class AutofocusAPI(Resource):
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
payload = JsonResponse(request)
|
payload = JsonResponse(request)
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
|
|
||||||
if not microscope:
|
if not microscope:
|
||||||
abort(503, "No microscope connected. Unable to autofocus.")
|
abort(503, "No microscope connected. Unable to autofocus.")
|
||||||
|
|
@ -331,7 +331,7 @@ class FastAutofocusAPI(Resource):
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
payload = JsonResponse(request)
|
payload = JsonResponse(request)
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
|
|
||||||
if not microscope:
|
if not microscope:
|
||||||
abort(503, "No microscope connected. Unable to autofocus.")
|
abort(503, "No microscope connected. Unable to autofocus.")
|
||||||
|
|
|
||||||
|
|
@ -359,7 +359,7 @@ class TileScanAPI(Resource):
|
||||||
)
|
)
|
||||||
@marshal_task
|
@marshal_task
|
||||||
def post(self, args):
|
def post(self, args):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
|
|
||||||
if not microscope:
|
if not microscope:
|
||||||
abort(503, "No microscope connected. Unable to autofocus.")
|
abort(503, "No microscope connected. Unable to autofocus.")
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ class ZipBuilderAPIView(Resource):
|
||||||
def post(self):
|
def post(self):
|
||||||
|
|
||||||
ids = list(JsonResponse(request).json)
|
ids = list(JsonResponse(request).json)
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
|
|
||||||
task = taskify(default_zip_manager.build_zip_from_capture_ids)(microscope, ids)
|
task = taskify(default_zip_manager.build_zip_from_capture_ids)(microscope, ids)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class CaptureAPI(Resource):
|
||||||
"""
|
"""
|
||||||
Create a new capture
|
Create a new capture
|
||||||
"""
|
"""
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
|
|
||||||
resize = args.get("resize", None)
|
resize = args.get("resize", None)
|
||||||
if resize:
|
if resize:
|
||||||
|
|
@ -97,7 +97,7 @@ class GPUPreviewStartAPI(Resource):
|
||||||
"""
|
"""
|
||||||
Start the onboard GPU preview.
|
Start the onboard GPU preview.
|
||||||
"""
|
"""
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
payload = JsonResponse(request)
|
payload = JsonResponse(request)
|
||||||
|
|
||||||
window = payload.param("window", default=[])
|
window = payload.param("window", default=[])
|
||||||
|
|
@ -120,6 +120,6 @@ class GPUPreviewStopAPI(Resource):
|
||||||
"""
|
"""
|
||||||
Stop the onboard GPU preview.
|
Stop the onboard GPU preview.
|
||||||
"""
|
"""
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
microscope.camera.stop_preview()
|
microscope.camera.stop_preview()
|
||||||
return jsonify(microscope.state)
|
return jsonify(microscope.state)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class MoveStageAPI(Resource):
|
||||||
"""
|
"""
|
||||||
Move the microscope stage in x, y, z
|
Move the microscope stage in x, y, z
|
||||||
"""
|
"""
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
|
|
||||||
# Handle absolute positioning (calculate a relative move from current position and target)
|
# Handle absolute positioning (calculate a relative move from current position and target)
|
||||||
if (args.get("absolute")) and (microscope.stage): # Only if stage exists
|
if (args.get("absolute")) and (microscope.stage): # Only if stage exists
|
||||||
|
|
@ -62,7 +62,7 @@ class ZeroStageAPI(Resource):
|
||||||
Zero the stage coordinates.
|
Zero the stage coordinates.
|
||||||
Does not move the stage, but rather makes the current position read as [0, 0, 0]
|
Does not move the stage, but rather makes the current position read as [0, 0, 0]
|
||||||
"""
|
"""
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
microscope.stage.zero_position()
|
microscope.stage.zero_position()
|
||||||
|
|
||||||
return jsonify(microscope.status["stage"])
|
return jsonify(microscope.status["stage"])
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ class CaptureList(Resource):
|
||||||
|
|
||||||
@marshal_with(CaptureSchema(many=True))
|
@marshal_with(CaptureSchema(many=True))
|
||||||
def get(self):
|
def get(self):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
image_list = microscope.camera.images
|
image_list = microscope.camera.images
|
||||||
return image_list
|
return image_list
|
||||||
|
|
||||||
|
|
@ -83,7 +83,7 @@ class CaptureResource(Resource):
|
||||||
|
|
||||||
@marshal_with(CaptureSchema())
|
@marshal_with(CaptureSchema())
|
||||||
def get(self, id):
|
def get(self, id):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.image_from_id(id)
|
capture_obj = microscope.camera.image_from_id(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
|
|
@ -92,7 +92,7 @@ class CaptureResource(Resource):
|
||||||
return capture_obj
|
return capture_obj
|
||||||
|
|
||||||
def delete(self, id):
|
def delete(self, id):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.image_from_id(id)
|
capture_obj = microscope.camera.image_from_id(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
|
|
@ -110,7 +110,7 @@ class CaptureDownload(Resource):
|
||||||
|
|
||||||
def get(self, id, filename):
|
def get(self, id, filename):
|
||||||
|
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.image_from_id(id)
|
capture_obj = microscope.camera.image_from_id(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
|
|
@ -146,7 +146,7 @@ class CaptureTags(Resource):
|
||||||
|
|
||||||
def get(self, id):
|
def get(self, id):
|
||||||
|
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.image_from_id(id)
|
capture_obj = microscope.camera.image_from_id(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
|
|
@ -156,7 +156,7 @@ class CaptureTags(Resource):
|
||||||
|
|
||||||
def put(self, id):
|
def put(self, id):
|
||||||
|
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.image_from_id(id)
|
capture_obj = microscope.camera.image_from_id(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
|
|
@ -173,7 +173,7 @@ class CaptureTags(Resource):
|
||||||
|
|
||||||
def delete(self, capture_id):
|
def delete(self, capture_id):
|
||||||
|
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.image_from_id(id)
|
capture_obj = microscope.camera.image_from_id(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
|
|
@ -196,7 +196,7 @@ class CaptureMetadata(Resource):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get(self, id):
|
def get(self, id):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.image_from_id(id)
|
capture_obj = microscope.camera.image_from_id(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
|
|
@ -205,7 +205,7 @@ class CaptureMetadata(Resource):
|
||||||
return jsonify(capture_obj.metadata)
|
return jsonify(capture_obj.metadata)
|
||||||
|
|
||||||
def put(self, id):
|
def put(self, id):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
capture_obj = microscope.camera.image_from_id(id)
|
capture_obj = microscope.camera.image_from_id(id)
|
||||||
|
|
||||||
if not capture_obj:
|
if not capture_obj:
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ import logging
|
||||||
|
|
||||||
class SettingsProperty(Resource):
|
class SettingsProperty(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
return jsonify(microscope.read_settings())
|
return jsonify(microscope.read_settings())
|
||||||
|
|
||||||
def put(self):
|
def put(self):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
payload = JsonResponse(request)
|
payload = JsonResponse(request)
|
||||||
|
|
||||||
logging.debug("Updating settings from PUT request:")
|
logging.debug("Updating settings from PUT request:")
|
||||||
|
|
@ -33,7 +33,7 @@ class SettingsProperty(Resource):
|
||||||
|
|
||||||
class NestedSettingsProperty(Resource):
|
class NestedSettingsProperty(Resource):
|
||||||
def get(self, route):
|
def get(self, route):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
keys = route.split("/")
|
keys = route.split("/")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -44,7 +44,7 @@ class NestedSettingsProperty(Resource):
|
||||||
return jsonify(value)
|
return jsonify(value)
|
||||||
|
|
||||||
def put(self, route):
|
def put(self, route):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
keys = route.split("/")
|
keys = route.split("/")
|
||||||
payload = JsonResponse(request)
|
payload = JsonResponse(request)
|
||||||
|
|
||||||
|
|
@ -59,13 +59,13 @@ class NestedSettingsProperty(Resource):
|
||||||
|
|
||||||
class StatusProperty(Resource):
|
class StatusProperty(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
return jsonify(microscope.status)
|
return jsonify(microscope.status)
|
||||||
|
|
||||||
|
|
||||||
class NestedStatusProperty(Resource):
|
class NestedStatusProperty(Resource):
|
||||||
def get(self, route):
|
def get(self, route):
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
keys = route.split("/")
|
keys = route.split("/")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class MjpegStream(Resource):
|
||||||
"""
|
"""
|
||||||
MJPEG stream from the microscope camera
|
MJPEG stream from the microscope camera
|
||||||
"""
|
"""
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
# Restart stream worker thread
|
# Restart stream worker thread
|
||||||
microscope.camera.start_worker()
|
microscope.camera.start_worker()
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ class SnapshotStream(Resource):
|
||||||
:>header Content-Type: image/jpeg
|
:>header Content-Type: image/jpeg
|
||||||
:status 200: stream active
|
:status 200: stream active
|
||||||
"""
|
"""
|
||||||
microscope = find_device("openflexure_microscope")
|
microscope = find_device("org.openflexure.microscope")
|
||||||
# Restart stream worker thread
|
# Restart stream worker thread
|
||||||
microscope.camera.start_worker()
|
microscope.camera.start_worker()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue