Moved status routes to instrument/state

This commit is contained in:
Joel Collins 2020-01-29 17:43:52 +00:00
parent e9e2419fe4
commit 9b4bf4c8fc
16 changed files with 52 additions and 64 deletions

View file

@ -94,16 +94,18 @@ labthing.add_view(views.CaptureDownload, f"/captures/<id>/download/<filename>")
labthing.add_view(views.CaptureTags, f"/captures/<id>/tags")
labthing.add_view(views.CaptureAnnotations, f"/captures/<id>/annotations")
# Attach settings and status resources
labthing.add_view(views.SettingsProperty, f"/settings")
labthing.add_root_link(views.SettingsProperty, "settings")
labthing.add_view(views.NestedSettingsProperty, "/settings/<path:route>")
labthing.add_view(views.StatusProperty, "/status")
labthing.add_view(views.NestedStatusProperty, "/status/<path:route>")
labthing.add_root_link(views.StatusProperty, "status")
labthing.add_view(views.ConfigurationProperty, "/configuration")
labthing.add_view(views.NestedConfigurationProperty, "/configuration/<path:route>")
labthing.add_root_link(views.ConfigurationProperty, "configuration")
# Attach settings and state resources
labthing.add_view(views.SettingsProperty, f"/instrument/settings")
labthing.add_root_link(views.SettingsProperty, "instrumentSettings")
labthing.add_view(views.NestedSettingsProperty, "/instrument/settings/<path:route>")
labthing.add_view(views.StateProperty, "/instrument/state")
labthing.add_view(views.NestedStateProperty, "/instrument/state/<path:route>")
labthing.add_root_link(views.StateProperty, "instrumentState")
labthing.add_view(views.ConfigurationProperty, "/instrument/configuration")
labthing.add_view(
views.NestedConfigurationProperty, "/instrument/configuration/<path:route>"
)
labthing.add_root_link(views.ConfigurationProperty, "instrumentConfiguration")
# Attach streams resources

View file

@ -73,17 +73,15 @@ class ZipManager:
# Update task progress
update_task_progress(int((index / n_files) * 100))
session_id = uuid.uuid4()
session_key = str(session_id)
# self.session_zips[session_id] = fp
self.session_zips[session_key] = {
session_id = str(uuid.uuid4())
self.session_zips[session_id] = {
"id": session_id,
"fp": fp,
"data_size": data_size_megabytes,
"zip_size": os.path.getsize(fp.name) * 1e-6,
}
return self.session_zips[session_key]
return self.session_zips[session_id]
def zip_from_id(self, session_id):
return self.session_zips[session_id]["fp"]
@ -103,13 +101,13 @@ class ZipBuilderAPIView(View):
task = taskify(default_zip_manager.build_zip_from_capture_ids)(microscope, ids)
# Return a handle on the autofocus task
return jsonify(task.state), 201
return task.state, 201
@ThingProperty
class ZipListAPIView(View):
def get(self):
return jsonify(default_zip_manager.session_zips)
return default_zip_manager.session_zips
class ZipGetterAPIView(View):
@ -141,7 +139,7 @@ class ZipGetterAPIView(View):
del default_zip_manager.session_zips[session_id]
return jsonify({"return": session_id})
return {"return": session_id}
zip_extension_v2 = BaseExtension("org.openflexure.zipbuilder", version="2.0.0-beta.1")

View file

@ -1,4 +1,4 @@
from .actions import enabled_root_actions
from .captures import *
from .state import *
from .instrument import *
from .streams import *

View file

@ -163,8 +163,8 @@ class GPUPreviewStartAPI(View):
microscope.camera.start_preview(fullscreen=fullscreen, window=window)
# TODO: Make schema for microscope status
return jsonify(microscope.status)
# TODO: Make schema for microscope state
return jsonify(microscope.state)
@ThingAction
@ -175,5 +175,5 @@ class GPUPreviewStopAPI(View):
"""
microscope = find_component("org.openflexure.microscope")
microscope.camera.stop_preview()
# TODO: Make schema for microscope status
return jsonify(microscope.status)
# TODO: Make schema for microscope state
return jsonify(microscope.state)

View file

@ -52,7 +52,7 @@ class MoveStageAPI(View):
else:
logging.warning("Unable to move. No stage found.")
# TODO: Make schema for microscope status
# TODO: Make schema for microscope state
return jsonify(microscope.state["stage"]["position"])
@ -66,5 +66,5 @@ class ZeroStageAPI(View):
microscope = find_component("org.openflexure.microscope")
microscope.stage.zero_position()
# TODO: Make schema for microscope status
return jsonify(microscope.status["stage"])
# TODO: Make schema for microscope state
return jsonify(microscope.state["stage"])

View file

@ -72,7 +72,7 @@ class NestedSettingsProperty(View):
@ThingProperty
class StatusProperty(View):
class StateProperty(View):
def get(self):
"""
Show current read-only state of the microscope
@ -82,7 +82,7 @@ class StatusProperty(View):
@Tag("properties")
class NestedStatusProperty(View):
class NestedStateProperty(View):
@doc_response(404, description="Status key cannot be found")
def get(self, route):
"""