Added decorators to state routes
This commit is contained in:
parent
c5d4f230c8
commit
c1da678439
1 changed files with 17 additions and 8 deletions
|
|
@ -6,10 +6,10 @@ from openflexure_microscope.common.labthings_core.utilities import (
|
||||||
create_from_path,
|
create_from_path,
|
||||||
)
|
)
|
||||||
|
|
||||||
from openflexure_microscope.common.flask_labthings.find import find_device
|
from openflexure_microscope.common.flask_labthings.find import find_component
|
||||||
from openflexure_microscope.common.flask_labthings.resource import Resource
|
from openflexure_microscope.common.flask_labthings.resource import Resource
|
||||||
|
|
||||||
from openflexure_microscope.common.flask_labthings.decorators import ThingProperty
|
from openflexure_microscope.common.flask_labthings.decorators import ThingProperty, marshal_with
|
||||||
|
|
||||||
from flask import jsonify, request, abort
|
from flask import jsonify, request, abort
|
||||||
import logging
|
import logging
|
||||||
|
|
@ -18,11 +18,17 @@ import logging
|
||||||
@ThingProperty
|
@ThingProperty
|
||||||
class SettingsProperty(Resource):
|
class SettingsProperty(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
microscope = find_device("org.openflexure.microscope")
|
"""
|
||||||
|
Current microscope settings, including camera and stage
|
||||||
|
"""
|
||||||
|
microscope = find_component("org.openflexure.microscope")
|
||||||
return jsonify(microscope.read_settings())
|
return jsonify(microscope.read_settings())
|
||||||
|
|
||||||
def put(self):
|
def put(self):
|
||||||
microscope = find_device("org.openflexure.microscope")
|
"""
|
||||||
|
Update current microscope settings, including camera and stage
|
||||||
|
"""
|
||||||
|
microscope = find_component("org.openflexure.microscope")
|
||||||
payload = JsonResponse(request)
|
payload = JsonResponse(request)
|
||||||
|
|
||||||
logging.debug("Updating settings from PUT request:")
|
logging.debug("Updating settings from PUT request:")
|
||||||
|
|
@ -36,7 +42,7 @@ class SettingsProperty(Resource):
|
||||||
|
|
||||||
class NestedSettingsProperty(Resource):
|
class NestedSettingsProperty(Resource):
|
||||||
def get(self, route):
|
def get(self, route):
|
||||||
microscope = find_device("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
keys = route.split("/")
|
keys = route.split("/")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -47,7 +53,7 @@ class NestedSettingsProperty(Resource):
|
||||||
return jsonify(value)
|
return jsonify(value)
|
||||||
|
|
||||||
def put(self, route):
|
def put(self, route):
|
||||||
microscope = find_device("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
keys = route.split("/")
|
keys = route.split("/")
|
||||||
payload = JsonResponse(request)
|
payload = JsonResponse(request)
|
||||||
|
|
||||||
|
|
@ -63,13 +69,16 @@ class NestedSettingsProperty(Resource):
|
||||||
@ThingProperty
|
@ThingProperty
|
||||||
class StatusProperty(Resource):
|
class StatusProperty(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
microscope = find_device("org.openflexure.microscope")
|
"""
|
||||||
|
Show current read-only state of the microscope
|
||||||
|
"""
|
||||||
|
microscope = find_component("org.openflexure.microscope")
|
||||||
return jsonify(microscope.status)
|
return jsonify(microscope.status)
|
||||||
|
|
||||||
|
|
||||||
class NestedStatusProperty(Resource):
|
class NestedStatusProperty(Resource):
|
||||||
def get(self, route):
|
def get(self, route):
|
||||||
microscope = find_device("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
keys = route.split("/")
|
keys = route.split("/")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue