From 79f3104409d19fed5a35529995ee82d848f6aac8 Mon Sep 17 00:00:00 2001 From: samuelmcdermott Date: Sun, 11 Oct 2020 01:01:21 +0100 Subject: [PATCH] Add API to set the stage --- .../api/v2/views/actions/__init__.py | 5 +++++ .../api/v2/views/actions/stage.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/openflexure_microscope/api/v2/views/actions/__init__.py b/openflexure_microscope/api/v2/views/actions/__init__.py index 1c26e31a..8a740316 100644 --- a/openflexure_microscope/api/v2/views/actions/__init__.py +++ b/openflexure_microscope/api/v2/views/actions/__init__.py @@ -39,6 +39,11 @@ _actions = { "view_class": stage.ZeroStageAPI, "conditions": True, }, + "setStage": { + "rule" : "/stage/set/", + "view_class": stage.SetStageAPI, + "conditions": True, + }, "shutdown": { "rule": "/system/shutdown/", "view_class": system.ShutdownAPI, diff --git a/openflexure_microscope/api/v2/views/actions/stage.py b/openflexure_microscope/api/v2/views/actions/stage.py index cb26823f..d037cc9c 100644 --- a/openflexure_microscope/api/v2/views/actions/stage.py +++ b/openflexure_microscope/api/v2/views/actions/stage.py @@ -65,3 +65,18 @@ class ZeroStageAPI(ActionView): # TODO: Make schema for microscope state return microscope.state["stage"] + +class SetStageAPI(ActionView): + args = { + "stage_type": fields.String(missing = None, example = "SangaStage", description = "The stage geometry [SangaStage, SangaDeltaStage]") + } + def post(self,args): + """ + Set the stage geometry. + """ + microscope = find_component("org.openflexure.microscope") + microscope.set_stage(stage_type=args.get("stage_type")) + + # TODO: Make schema for microscope state + return microscope.state["stage"] +