Merge branch 'master' of https://gitlab.com/openflexure/openflexure-microscope-server
This commit is contained in:
commit
e1e553c1cd
20 changed files with 64 additions and 99 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from labthings.server.find import find_component
|
||||
from labthings.server.extensions import BaseExtension
|
||||
from labthings.server.view import View
|
||||
from labthings.server.view import View, ActionView, PropertyView
|
||||
from labthings.server.decorators import ThingAction, ThingProperty
|
||||
|
||||
from openflexure_microscope.devel import JsonResponse, request, abort
|
||||
|
|
@ -332,8 +332,7 @@ class MeasureSharpnessAPI(View):
|
|||
return {"sharpness": measure_sharpness(microscope)}
|
||||
|
||||
|
||||
@ThingAction
|
||||
class AutofocusAPI(View):
|
||||
class AutofocusAPI(ActionView):
|
||||
"""
|
||||
Run a standard autofocus
|
||||
"""
|
||||
|
|
@ -357,8 +356,7 @@ class AutofocusAPI(View):
|
|||
abort(503, "No stage connected. Unable to autofocus.")
|
||||
|
||||
|
||||
@ThingAction
|
||||
class FastAutofocusAPI(View):
|
||||
class FastAutofocusAPI(ActionView):
|
||||
"""
|
||||
Run a fast autofocus
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from labthings.server.extensions import BaseExtension
|
||||
from labthings.server.view import View
|
||||
from labthings.server.view import View, PropertyView
|
||||
from labthings.server.decorators import ThingProperty, PropertySchema, use_args
|
||||
from labthings.server import fields
|
||||
from labthings.server.find import find_component
|
||||
|
|
@ -190,8 +190,7 @@ class AutostorageExtension(BaseExtension):
|
|||
autostorage_extension_v2 = AutostorageExtension()
|
||||
|
||||
|
||||
@ThingProperty
|
||||
class GetLocationsView(View):
|
||||
class GetLocationsView(PropertyView):
|
||||
def get(self):
|
||||
global autostorage_extension_v2
|
||||
|
||||
|
|
@ -199,9 +198,8 @@ class GetLocationsView(View):
|
|||
return autostorage_extension_v2.get_locations()
|
||||
|
||||
|
||||
@ThingProperty
|
||||
@PropertySchema(fields.String(required=True, example="Default"))
|
||||
class PreferredLocationView(View):
|
||||
class PreferredLocationView(PropertyView):
|
||||
def get(self):
|
||||
global autostorage_extension_v2
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ API extension for stage calibration
|
|||
|
||||
This file contains the HTTP API for camera/stage calibration.
|
||||
"""
|
||||
from labthings.server.view import View
|
||||
from labthings.server.view import View, ActionView, PropertyView
|
||||
from labthings.server.find import find_component
|
||||
from labthings.server.extensions import BaseExtension
|
||||
from labthings.server.decorators import (
|
||||
|
|
@ -139,8 +139,7 @@ class CSMExtension(BaseExtension):
|
|||
csm_extension = CSMExtension()
|
||||
|
||||
|
||||
@ThingAction
|
||||
class Calibrate1DView(View):
|
||||
class Calibrate1DView(ActionView):
|
||||
@use_args(
|
||||
{"direction": fields.List(fields.Float(), required=True, example=[1, 0, 0])}
|
||||
)
|
||||
|
|
@ -155,8 +154,7 @@ class Calibrate1DView(View):
|
|||
csm_extension.add_view(Calibrate1DView, "/calibrate_1d", endpoint="calibrate_1d")
|
||||
|
||||
|
||||
@ThingAction
|
||||
class CalibrateXYView(View):
|
||||
class CalibrateXYView(ActionView):
|
||||
def post(self):
|
||||
"""Calibrate both axes of the microscope stage against the camera."""
|
||||
return csm_extension.calibrate_xy()
|
||||
|
|
@ -165,8 +163,7 @@ class CalibrateXYView(View):
|
|||
csm_extension.add_view(CalibrateXYView, "/calibrate_xy", endpoint="calibrate_xy")
|
||||
|
||||
|
||||
@ThingAction
|
||||
class MoveInImageCoordinatesView(View):
|
||||
class MoveInImageCoordinatesView(ActionView):
|
||||
@use_args(
|
||||
{
|
||||
"x": fields.Float(
|
||||
|
|
@ -194,8 +191,7 @@ class MoveInImageCoordinatesView(View):
|
|||
csm_extension.add_view(MoveInImageCoordinatesView, "/move_in_image_coordinates", endpoint="move_in_image_coordinates")
|
||||
|
||||
|
||||
@ThingProperty
|
||||
class GetCalibrationFile(View):
|
||||
class GetCalibrationFile(PropertyView):
|
||||
def get(self):
|
||||
"""Get the calibration data in JSON format."""
|
||||
datafile_name = CSM_DATAFILE_NAME
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from labthings.server.view import View
|
||||
from labthings.server.view import View, ActionView
|
||||
from labthings.server.find import find_component
|
||||
from labthings.server.extensions import BaseExtension
|
||||
from labthings.server.decorators import ThingAction
|
||||
|
|
@ -58,8 +58,7 @@ def recalibrate(microscope):
|
|||
microscope.save_settings()
|
||||
|
||||
|
||||
@ThingAction
|
||||
class RecalibrateView(View):
|
||||
class RecalibrateView(ActionView):
|
||||
def post(self):
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
|
|
@ -71,8 +70,7 @@ class RecalibrateView(View):
|
|||
return recalibrate(microscope)
|
||||
|
||||
|
||||
@ThingAction
|
||||
class FlattenLSTView(View):
|
||||
class FlattenLSTView(ActionView):
|
||||
def post(self):
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
|
|
@ -95,8 +93,7 @@ class FlattenLSTView(View):
|
|||
)
|
||||
|
||||
|
||||
@ThingAction
|
||||
class DeleteLSTView(View):
|
||||
class DeleteLSTView(ActionView):
|
||||
def post(self):
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import tempfile
|
|||
import logging
|
||||
|
||||
from labthings.server.find import find_component
|
||||
from labthings.server.view import View
|
||||
from labthings.server.view import View, ActionView, PropertyView
|
||||
from labthings.server.schema import Schema
|
||||
from labthings.server import fields
|
||||
from labthings.server.extensions import BaseExtension
|
||||
|
|
@ -138,8 +138,7 @@ class ZipManager:
|
|||
default_zip_manager = ZipManager()
|
||||
|
||||
|
||||
@ThingAction
|
||||
class ZipBuilderAPIView(View):
|
||||
class ZipBuilderAPIView(ActionView):
|
||||
def post(self):
|
||||
|
||||
ids = list(JsonResponse(request).json)
|
||||
|
|
@ -151,8 +150,7 @@ class ZipBuilderAPIView(View):
|
|||
)
|
||||
|
||||
|
||||
@ThingProperty
|
||||
class ZipListAPIView(View):
|
||||
class ZipListAPIView(PropertyView):
|
||||
@marshal_with(ZipObjectSchema(many=True))
|
||||
def get(self):
|
||||
return default_zip_manager.session_zips.values()
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 4a482f3e0f1f1e1774ec559a28a8c6a85c5a4977
|
||||
Subproject commit c32bca436c2b17837e73097e9977d077a14305ab
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
from openflexure_microscope.api.utilities import get_bool, JsonResponse
|
||||
from labthings.server.view import View
|
||||
from labthings.server.view import View, ActionView
|
||||
from labthings.server.find import find_component
|
||||
from labthings.server.decorators import (
|
||||
use_args,
|
||||
|
|
@ -20,8 +20,7 @@ import io
|
|||
from flask import request, abort, url_for, redirect, send_file
|
||||
|
||||
|
||||
@ThingAction
|
||||
class CaptureAPI(View):
|
||||
class CaptureAPI(ActionView):
|
||||
"""
|
||||
Create a new image capture.
|
||||
"""
|
||||
|
|
@ -75,8 +74,7 @@ class CaptureAPI(View):
|
|||
|
||||
|
||||
|
||||
@ThingAction
|
||||
class RAMCaptureAPI(View):
|
||||
class RAMCaptureAPI(ActionView):
|
||||
"""
|
||||
Take a non-persistant image capture.
|
||||
"""
|
||||
|
|
@ -124,8 +122,7 @@ class RAMCaptureAPI(View):
|
|||
return send_file(io.BytesIO(stream.getbuffer()), mimetype="image/jpeg")
|
||||
|
||||
|
||||
@ThingAction
|
||||
class GPUPreviewStartAPI(View):
|
||||
class GPUPreviewStartAPI(ActionView):
|
||||
"""
|
||||
Start the onboard GPU preview.
|
||||
Optional "window" parameter can be passed to control the position and size of the preview window,
|
||||
|
|
@ -157,8 +154,7 @@ class GPUPreviewStartAPI(View):
|
|||
return microscope.state
|
||||
|
||||
|
||||
@ThingAction
|
||||
class GPUPreviewStopAPI(View):
|
||||
class GPUPreviewStopAPI(ActionView):
|
||||
def post(self):
|
||||
"""
|
||||
Stop the onboard GPU preview.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from openflexure_microscope.api.utilities import JsonResponse
|
||||
from labthings.server.view import View
|
||||
from labthings.server.view import View, ActionView
|
||||
from labthings.server.find import find_component
|
||||
from labthings.server.decorators import use_args, marshal_with, doc, ThingAction
|
||||
from labthings.server import fields
|
||||
|
|
@ -11,8 +11,7 @@ from flask import Blueprint, request
|
|||
import logging
|
||||
|
||||
|
||||
@ThingAction
|
||||
class MoveStageAPI(View):
|
||||
class MoveStageAPI(ActionView):
|
||||
@use_args(
|
||||
{
|
||||
"absolute": fields.Boolean(
|
||||
|
|
@ -56,8 +55,7 @@ class MoveStageAPI(View):
|
|||
return microscope.state["stage"]["position"]
|
||||
|
||||
|
||||
@ThingAction
|
||||
class ZeroStageAPI(View):
|
||||
class ZeroStageAPI(ActionView):
|
||||
def post(self):
|
||||
"""
|
||||
Zero the stage coordinates.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from labthings.server.view import View
|
||||
from labthings.server.view import View, ActionView
|
||||
import subprocess
|
||||
import os
|
||||
from sys import platform
|
||||
|
|
@ -14,8 +14,7 @@ def is_raspberrypi(raise_on_errors=False):
|
|||
return os.path.exists("/usr/bin/raspi-config")
|
||||
|
||||
|
||||
@ThingAction
|
||||
class ShutdownAPI(View):
|
||||
class ShutdownAPI(ActionView):
|
||||
"""
|
||||
Attempt to shutdown the device
|
||||
"""
|
||||
|
|
@ -35,8 +34,7 @@ class ShutdownAPI(View):
|
|||
return {"out": out, "err": err}, 201
|
||||
|
||||
|
||||
@ThingAction
|
||||
class RebootAPI(View):
|
||||
class RebootAPI(ActionView):
|
||||
"""
|
||||
Attempt to reboot the device
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from openflexure_microscope.api.utilities import get_bool, JsonResponse
|
|||
|
||||
from labthings.server.schema import Schema
|
||||
from labthings.server import fields
|
||||
from labthings.server.view import View
|
||||
from labthings.server.view import View, PropertyView
|
||||
from labthings.server.utilities import description_from_view
|
||||
from labthings.server.decorators import marshal_with, doc_response, Tag, ThingProperty
|
||||
|
||||
|
|
@ -91,9 +91,8 @@ capture_list_schema = CaptureSchema(many=True)
|
|||
from pprint import pprint
|
||||
|
||||
|
||||
@ThingProperty
|
||||
@Tag("captures")
|
||||
class CaptureList(View):
|
||||
class CaptureList(PropertyView):
|
||||
@marshal_with(CaptureSchema(many=True))
|
||||
def get(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from openflexure_microscope.api.utilities import JsonResponse
|
|||
from labthings.core.utilities import get_by_path, set_by_path, create_from_path
|
||||
|
||||
from labthings.server.find import find_component
|
||||
from labthings.server.view import View
|
||||
from labthings.server.view import View, PropertyView
|
||||
|
||||
from labthings.server.decorators import ThingProperty, Tag, doc_response
|
||||
|
||||
|
|
@ -11,8 +11,7 @@ from flask import request, abort
|
|||
import logging
|
||||
|
||||
|
||||
@ThingProperty
|
||||
class SettingsProperty(View):
|
||||
class SettingsProperty(PropertyView):
|
||||
def get(self):
|
||||
"""
|
||||
Current microscope settings, including camera and stage
|
||||
|
|
@ -71,8 +70,7 @@ class NestedSettingsProperty(View):
|
|||
return self.get(route)
|
||||
|
||||
|
||||
@ThingProperty
|
||||
class StateProperty(View):
|
||||
class StateProperty(PropertyView):
|
||||
def get(self):
|
||||
"""
|
||||
Show current read-only state of the microscope
|
||||
|
|
@ -99,8 +97,7 @@ class NestedStateProperty(View):
|
|||
return value
|
||||
|
||||
|
||||
@ThingProperty
|
||||
class ConfigurationProperty(View):
|
||||
class ConfigurationProperty(PropertyView):
|
||||
def get(self):
|
||||
"""
|
||||
Show current read-only state of the microscope
|
||||
|
|
|
|||
|
|
@ -3,14 +3,13 @@ from openflexure_microscope.api.utilities import gen, JsonResponse
|
|||
from labthings.core.utilities import get_by_path, set_by_path, create_from_path
|
||||
|
||||
from labthings.server.find import find_component
|
||||
from labthings.server.view import View
|
||||
from labthings.server.view import View, PropertyView
|
||||
from labthings.server.decorators import doc_response, ThingProperty
|
||||
|
||||
from flask import Response
|
||||
|
||||
|
||||
@ThingProperty
|
||||
class MjpegStream(View):
|
||||
class MjpegStream(PropertyView):
|
||||
"""
|
||||
Real-time MJPEG stream from the microscope camera
|
||||
"""
|
||||
|
|
@ -38,8 +37,7 @@ class MjpegStream(View):
|
|||
)
|
||||
|
||||
|
||||
@ThingProperty
|
||||
class SnapshotStream(View):
|
||||
class SnapshotStream(PropertyView):
|
||||
"""
|
||||
Single JPEG snapshot from the camera stream
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue