Merge branch 'scan-shape-limits' into 'master'

Add minimum scan dimension

See merge request openflexure/openflexure-microscope-server!123
This commit is contained in:
Richard Bowman 2021-05-18 10:55:06 +00:00
commit 4d405443bb
3 changed files with 26 additions and 4 deletions

View file

@ -23,7 +23,7 @@ import os
from datetime import datetime
import pkg_resources
from flask import abort, send_file
from flask import abort, send_file, jsonify
from flask_cors import CORS, cross_origin
from labthings import create_app
from labthings.extensions import find_extensions
@ -105,6 +105,20 @@ app, labthing = create_app(
# Enable CORS for some routes outside of LabThings
cors: CORS = CORS(app)
# Enable correct handling of Marshmallow/Webargs validation errors
# Return validation errors as JSON
# (see https://webargs.readthedocs.io/en/latest/framework_support.html)
@app.errorhandler(422)
@app.errorhandler(400)
def handle_error(err):
headers = err.data.get("headers", None)
messages = err.data.get("messages", ["Invalid request."])
if headers:
return jsonify({"errors": messages}), err.code, headers
else:
return jsonify({"errors": messages}), err.code
# Use custom JSON encoder
labthing.json_encoder = JSONEncoder
app.json_encoder = JSONEncoder

View file

@ -2,6 +2,7 @@ import datetime
import logging
import time
import uuid
import marshmallow
from functools import reduce
from typing import Dict, List, Optional, Tuple
@ -361,7 +362,11 @@ class ScanExtension(BaseExtension):
class TileScanArgs(FullCaptureArgs):
namemode = fields.String(missing="coordinates", example="coordinates")
grid = fields.List(fields.Integer, missing=[3, 3, 3], example=[3, 3, 3])
grid = fields.List(
fields.Integer(validate=marshmallow.validate.Range(min=1)),
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)

View file

@ -155,7 +155,7 @@
v-model="scanStepSize.z"
class="uk-input uk-form-small"
type="number"
name="inputPositionZx"
name="inputPositionZ"
/>
</div>
</div>
@ -172,6 +172,7 @@
class="uk-input uk-form-small"
type="number"
name="inputPositionX"
min="1"
/>
</div>
</div>
@ -186,6 +187,7 @@
class="uk-input uk-form-small"
type="number"
name="inputPositionY"
min="1"
/>
</div>
</div>
@ -199,7 +201,8 @@
v-model="scanSteps.z"
class="uk-input uk-form-small"
type="number"
name="inputPositionZx"
name="inputPositionZ"
min="1"
/>
</div>
</div>