Initial 0.7.0 conversion
This commit is contained in:
parent
3bb870a3a3
commit
e6cb9f6b35
11 changed files with 129 additions and 130 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from labthings.server.find import find_component
|
||||
from labthings.server.extensions import BaseExtension
|
||||
from labthings.server.view import View, ActionView, PropertyView
|
||||
from labthings.server.decorators import ThingAction, ThingProperty
|
||||
from labthings.server import fields
|
||||
|
||||
from openflexure_microscope.devel import JsonResponse, request, abort
|
||||
from openflexure_microscope.utilities import set_properties
|
||||
|
|
@ -336,7 +336,9 @@ class AutofocusAPI(ActionView):
|
|||
"""
|
||||
Run a standard autofocus
|
||||
"""
|
||||
def post(self):
|
||||
args = {"dz": fields.List(fields.Int())}
|
||||
|
||||
def post(self, args):
|
||||
payload = JsonResponse(request)
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
|
|
@ -344,7 +346,7 @@ class AutofocusAPI(ActionView):
|
|||
abort(503, "No microscope connected. Unable to autofocus.")
|
||||
|
||||
# Figure out the range of z values to use
|
||||
dz = payload.param("dz", default=np.linspace(-300, 300, 7), convert=np.array)
|
||||
dz = np.array(args.get("dz", np.linspace(-300, 300, 7)))
|
||||
|
||||
if microscope.has_real_stage():
|
||||
logging.debug("Running autofocus...")
|
||||
|
|
@ -360,18 +362,20 @@ class FastAutofocusAPI(ActionView):
|
|||
"""
|
||||
Run a fast autofocus
|
||||
"""
|
||||
def post(self):
|
||||
payload = JsonResponse(request)
|
||||
args = {
|
||||
"dz": fields.Int(default=2000),
|
||||
"backlash": fields.Int(default=25, minimum=0)
|
||||
}
|
||||
|
||||
def post(self, args):
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
if not microscope:
|
||||
abort(503, "No microscope connected. Unable to autofocus.")
|
||||
|
||||
# Figure out the parameters to use
|
||||
dz = payload.param("dz", default=2000, convert=int)
|
||||
backlash = payload.param("backlash", default=25, convert=int)
|
||||
if backlash < 0:
|
||||
backlash = 0
|
||||
dz = args.get("dz")
|
||||
backlash = args.get("backlash")
|
||||
|
||||
if microscope.has_real_stage():
|
||||
logging.debug("Running autofocus...")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from labthings.server.extensions import BaseExtension
|
||||
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
|
||||
|
||||
|
|
@ -198,8 +197,9 @@ class GetLocationsView(PropertyView):
|
|||
return autostorage_extension_v2.get_locations()
|
||||
|
||||
|
||||
@PropertySchema(fields.String(required=True, example="Default"))
|
||||
class PreferredLocationView(PropertyView):
|
||||
schema = fields.String(required=True, example="Default")
|
||||
|
||||
def get(self):
|
||||
global autostorage_extension_v2
|
||||
|
||||
|
|
@ -219,7 +219,8 @@ class PreferredLocationView(PropertyView):
|
|||
|
||||
|
||||
class PreferredLocationGUIView(View):
|
||||
@use_args({"new_path_title": fields.String(required=True)})
|
||||
args = {"new_path_title": fields.String(required=True)}
|
||||
|
||||
def post(self, args):
|
||||
global autostorage_extension_v2
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from functools import reduce
|
|||
from openflexure_microscope.captures.capture_manager import generate_basename
|
||||
from labthings.server.find import find_component, find_extension
|
||||
from labthings.server.extensions import BaseExtension
|
||||
from labthings.server.decorators import use_args
|
||||
from labthings.server import fields
|
||||
|
||||
from openflexure_microscope.devel import abort, update_task_progress
|
||||
|
|
@ -91,7 +90,7 @@ class ScanExtension(BaseExtension):
|
|||
def __init__(self):
|
||||
self._images_to_be_captured: int = 1
|
||||
self._images_captured_so_far: int = 0
|
||||
return BaseExtension.__init__(self, "org.openflexure.scan", version="2.0.0")
|
||||
BaseExtension.__init__(self, "org.openflexure.scan", version="2.0.0")
|
||||
|
||||
def progress(self):
|
||||
progress = (self._images_captured_so_far / self._images_to_be_captured) * 100
|
||||
|
|
@ -289,24 +288,23 @@ class ScanExtension(BaseExtension):
|
|||
scan_extension_v2 = ScanExtension()
|
||||
|
||||
class TileScanAPI(ActionView):
|
||||
@use_args(
|
||||
{
|
||||
"filename": fields.String(missing=None, example=None),
|
||||
"temporary": fields.Boolean(missing=False),
|
||||
"stride_size": fields.List(
|
||||
fields.Integer, missing=[2000, 1500, 100], example=[2000, 1500, 100]
|
||||
),
|
||||
"grid": fields.List(fields.Integer, missing=[3, 3, 3], example=[3, 3, 3]),
|
||||
"style": fields.String(missing="raster"),
|
||||
"autofocus_dz": fields.Integer(missing=50),
|
||||
"fast_autofocus": fields.Boolean(missing=False),
|
||||
"use_video_port": fields.Boolean(missing=False),
|
||||
"bayer": fields.Boolean(missing=False),
|
||||
"annotations": fields.Dict(missing={}, example={"Foo": "Bar"}),
|
||||
"tags": fields.List(fields.String, missing=[]),
|
||||
"resize": fields.Dict(missing=None), # TODO: Validate keys
|
||||
}
|
||||
)
|
||||
args = {
|
||||
"filename": fields.String(missing=None, example=None),
|
||||
"temporary": fields.Boolean(missing=False),
|
||||
"stride_size": fields.List(
|
||||
fields.Integer, missing=[2000, 1500, 100], example=[2000, 1500, 100]
|
||||
),
|
||||
"grid": fields.List(fields.Integer, missing=[3, 3, 3], example=[3, 3, 3]),
|
||||
"style": fields.String(missing="raster"),
|
||||
"autofocus_dz": fields.Integer(missing=50),
|
||||
"fast_autofocus": fields.Boolean(missing=False),
|
||||
"use_video_port": fields.Boolean(missing=False),
|
||||
"bayer": fields.Boolean(missing=False),
|
||||
"annotations": fields.Dict(missing={}, example={"Foo": "Bar"}),
|
||||
"tags": fields.List(fields.String, missing=[]),
|
||||
"resize": fields.Dict(missing=None), # TODO: Validate keys
|
||||
}
|
||||
|
||||
def post(self, args):
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
|
|
|
|||
|
|
@ -14,16 +14,10 @@ import logging
|
|||
|
||||
from labthings.server.find import find_component
|
||||
from labthings.server.view import View, ActionView, PropertyView
|
||||
from labthings.server.schema import Schema
|
||||
from labthings.server.schema import Schema, pre_dump
|
||||
from labthings.server import fields
|
||||
from labthings.server.extensions import BaseExtension
|
||||
from labthings.server.utilities import description_from_view
|
||||
from labthings.server.decorators import (
|
||||
ThingAction,
|
||||
ThingProperty,
|
||||
marshal_with,
|
||||
pre_dump,
|
||||
)
|
||||
|
||||
|
||||
class ZipObjectSchema(Schema):
|
||||
|
|
@ -140,7 +134,6 @@ default_zip_manager = ZipManager()
|
|||
|
||||
class ZipBuilderAPIView(ActionView):
|
||||
def post(self):
|
||||
|
||||
ids = list(JsonResponse(request).json)
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
|
|
@ -151,7 +144,8 @@ class ZipBuilderAPIView(ActionView):
|
|||
|
||||
|
||||
class ZipListAPIView(PropertyView):
|
||||
@marshal_with(ZipObjectSchema(many=True))
|
||||
schema = ZipObjectSchema(many=True)
|
||||
|
||||
def get(self):
|
||||
return default_zip_manager.session_zips.values()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue