From 5616e76f505cfb6e3ef3b693914de53cca953992 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Fri, 10 Jan 2020 19:58:30 +0000 Subject: [PATCH] Use LabThings decorators --- openflexure_microscope/api/v2/views/actions/stage.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openflexure_microscope/api/v2/views/actions/stage.py b/openflexure_microscope/api/v2/views/actions/stage.py index 5aa3e501..cad4a776 100644 --- a/openflexure_microscope/api/v2/views/actions/stage.py +++ b/openflexure_microscope/api/v2/views/actions/stage.py @@ -5,6 +5,7 @@ from openflexure_microscope.common.flask_labthings.decorators import ( use_args, marshal_with, doc, + ThingAction, ) from openflexure_microscope.common.flask_labthings import fields @@ -15,10 +16,13 @@ from flask import Blueprint, jsonify, request import logging +@ThingAction class MoveStageAPI(Resource): @use_args( { - "absolute": fields.Boolean(default=False, example=False, description="Move to an absolute position"), + "absolute": fields.Boolean( + default=False, example=False, description="Move to an absolute position" + ), "x": fields.Int(default=0, example=100), "y": fields.Int(default=0, example=100), "z": fields.Int(default=0, example=20), @@ -53,9 +57,11 @@ class MoveStageAPI(Resource): else: logging.warning("Unable to move. No stage found.") + # TODO: Make schema for microscope status return jsonify(microscope.status["stage"]["position"]) +@ThingAction class ZeroStageAPI(Resource): def post(self): """ @@ -65,4 +71,5 @@ class ZeroStageAPI(Resource): microscope = find_device("org.openflexure.microscope") microscope.stage.zero_position() + # TODO: Make schema for microscope status return jsonify(microscope.status["stage"])