Merge branch 'master' of https://gitlab.com/openflexure/openflexure-microscope-server into master
This commit is contained in:
commit
7eaca8d4f3
4 changed files with 52 additions and 7 deletions
|
|
@ -8,10 +8,9 @@ This includes basic installation instructions suitable for most users.
|
||||||
Full developer documentation can be found on [**ReadTheDocs**](https://openflexure-microscope-software.readthedocs.io/).
|
Full developer documentation can be found on [**ReadTheDocs**](https://openflexure-microscope-software.readthedocs.io/).
|
||||||
This includes installing the server in a mode better suited for active development.
|
This includes installing the server in a mode better suited for active development.
|
||||||
|
|
||||||
## Installation
|
## Developer installation
|
||||||
|
|
||||||
* `git clone https://gitlab.com/openflexure/openflexure-microscope-server.git`
|
* `git clone https://gitlab.com/openflexure/openflexure-microscope-server.git`
|
||||||
* (If running on a microscope Pi) `ofm activate`
|
|
||||||
* `poetry install`
|
* `poetry install`
|
||||||
* `poetry run build_static`
|
* `poetry run build_static`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,13 @@ def move_and_find_focus(microscope, dz):
|
||||||
return m.sharpest_z_on_move(0)
|
return m.sharpest_z_on_move(0)
|
||||||
|
|
||||||
|
|
||||||
|
def move_and_measure(microscope, dz):
|
||||||
|
"""Make a relative Z move and return the sharpness data"""
|
||||||
|
with monitor_sharpness(microscope) as m:
|
||||||
|
m.focus_rel(dz)
|
||||||
|
return m.data_dict()
|
||||||
|
|
||||||
|
|
||||||
def fast_autofocus(microscope, dz=2000, backlash=None):
|
def fast_autofocus(microscope, dz=2000, backlash=None):
|
||||||
"""Perform a down-up-down-up autofocus"""
|
"""Perform a down-up-down-up autofocus"""
|
||||||
with monitor_sharpness(
|
with monitor_sharpness(
|
||||||
|
|
@ -333,14 +340,37 @@ class MeasureSharpnessAPI(View):
|
||||||
return {"sharpness": measure_sharpness(microscope)}
|
return {"sharpness": measure_sharpness(microscope)}
|
||||||
|
|
||||||
|
|
||||||
|
class MoveAndMeasureAPI(ActionView):
|
||||||
|
"""
|
||||||
|
Move the stage and measure dynamic sharpness
|
||||||
|
"""
|
||||||
|
|
||||||
|
args = {"dz": fields.List(fields.Int(), required=True)}
|
||||||
|
|
||||||
|
def post(self, args):
|
||||||
|
microscope = find_component("org.openflexure.microscope")
|
||||||
|
|
||||||
|
if not microscope:
|
||||||
|
abort(503, "No microscope connected. Unable to autofocus.")
|
||||||
|
|
||||||
|
if microscope.has_real_stage():
|
||||||
|
# Acquire microscope lock with 1s timeout
|
||||||
|
with microscope.lock(timeout=1):
|
||||||
|
# Run fast_up_down_up_autofocus
|
||||||
|
return move_and_measure(microscope, dz=args.get("dz"))
|
||||||
|
|
||||||
|
else:
|
||||||
|
abort(503, "No stage connected. Unable to autofocus.")
|
||||||
|
|
||||||
|
|
||||||
class AutofocusAPI(ActionView):
|
class AutofocusAPI(ActionView):
|
||||||
"""
|
"""
|
||||||
Run a standard autofocus
|
Run a standard autofocus
|
||||||
"""
|
"""
|
||||||
|
|
||||||
args = {"dz": fields.List(fields.Int())}
|
args = {"dz": fields.List(fields.Int())}
|
||||||
|
|
||||||
def post(self, args):
|
def post(self, args):
|
||||||
payload = JsonResponse(request)
|
|
||||||
microscope = find_component("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
|
|
||||||
if not microscope:
|
if not microscope:
|
||||||
|
|
@ -363,9 +393,10 @@ class FastAutofocusAPI(ActionView):
|
||||||
"""
|
"""
|
||||||
Run a fast autofocus
|
Run a fast autofocus
|
||||||
"""
|
"""
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
"dz": fields.Int(missing=2000),
|
"dz": fields.Int(missing=2000),
|
||||||
"backlash": fields.Int(missing=25, minimum=0)
|
"backlash": fields.Int(missing=25, minimum=0),
|
||||||
}
|
}
|
||||||
|
|
||||||
def post(self, args):
|
def post(self, args):
|
||||||
|
|
@ -403,7 +434,17 @@ autofocus_extension_v2.add_method(
|
||||||
fast_up_down_up_autofocus, "fast_up_down_up_autofocus"
|
fast_up_down_up_autofocus, "fast_up_down_up_autofocus"
|
||||||
)
|
)
|
||||||
autofocus_extension_v2.add_method(autofocus, "autofocus")
|
autofocus_extension_v2.add_method(autofocus, "autofocus")
|
||||||
|
autofocus_extension_v2.add_method(move_and_measure, "move_and_measure")
|
||||||
|
|
||||||
autofocus_extension_v2.add_view(MeasureSharpnessAPI, "/measure_sharpness", endpoint="measure_sharpness")
|
autofocus_extension_v2.add_view(
|
||||||
|
MeasureSharpnessAPI, "/measure_sharpness", endpoint="measure_sharpness"
|
||||||
|
)
|
||||||
autofocus_extension_v2.add_view(AutofocusAPI, "/autofocus", endpoint="autofocus")
|
autofocus_extension_v2.add_view(AutofocusAPI, "/autofocus", endpoint="autofocus")
|
||||||
autofocus_extension_v2.add_view(FastAutofocusAPI, "/fast_autofocus", endpoint="fast_autofocus")
|
autofocus_extension_v2.add_view(
|
||||||
|
FastAutofocusAPI, "/fast_autofocus", endpoint="fast_autofocus"
|
||||||
|
)
|
||||||
|
|
||||||
|
autofocus_extension_v2.add_view(
|
||||||
|
MoveAndMeasureAPI, "/move_and_measure", endpoint="move_and_measure"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
|
||||||
5
poetry.lock
generated
5
poetry.lock
generated
|
|
@ -926,6 +926,11 @@ markupsafe = [
|
||||||
{file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6"},
|
{file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6"},
|
||||||
{file = "MarkupSafe-1.1.1-cp37-cp37m-win32.whl", hash = "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2"},
|
{file = "MarkupSafe-1.1.1-cp37-cp37m-win32.whl", hash = "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2"},
|
||||||
{file = "MarkupSafe-1.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c"},
|
{file = "MarkupSafe-1.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c"},
|
||||||
|
{file = "MarkupSafe-1.1.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15"},
|
||||||
|
{file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2"},
|
||||||
|
{file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42"},
|
||||||
|
{file = "MarkupSafe-1.1.1-cp38-cp38-win32.whl", hash = "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b"},
|
||||||
|
{file = "MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be"},
|
||||||
{file = "MarkupSafe-1.1.1.tar.gz", hash = "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b"},
|
{file = "MarkupSafe-1.1.1.tar.gz", hash = "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b"},
|
||||||
]
|
]
|
||||||
marshmallow = [
|
marshmallow = [
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api"
|
||||||
|
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "openflexure-microscope-server"
|
name = "openflexure-microscope-server"
|
||||||
version = "2.5.0"
|
version = "2.6.0-alpha.1"
|
||||||
description = "Python module, and Flask-based web API, to run the OpenFlexure Microscope."
|
description = "Python module, and Flask-based web API, to run the OpenFlexure Microscope."
|
||||||
|
|
||||||
authors = [
|
authors = [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue