Moved API from action to property view
This commit is contained in:
parent
e886e9db28
commit
86d866c5f9
5 changed files with 30 additions and 23 deletions
|
|
@ -129,6 +129,9 @@ labthing.add_view(
|
||||||
)
|
)
|
||||||
labthing.add_root_link(views.ConfigurationProperty, "instrumentConfiguration")
|
labthing.add_root_link(views.ConfigurationProperty, "instrumentConfiguration")
|
||||||
|
|
||||||
|
# Attach stage resources
|
||||||
|
labthing.add_view(views.StageTypeProperty, "/properties/stage/type")
|
||||||
|
|
||||||
|
|
||||||
# Attach streams resources
|
# Attach streams resources
|
||||||
labthing.add_view(views.MjpegStream, f"/streams/mjpeg")
|
labthing.add_view(views.MjpegStream, f"/streams/mjpeg")
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,4 @@ from .actions import enabled_root_actions
|
||||||
from .captures import *
|
from .captures import *
|
||||||
from .instrument import *
|
from .instrument import *
|
||||||
from .streams import *
|
from .streams import *
|
||||||
|
from .stage import *
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,6 @@ _actions = {
|
||||||
"view_class": stage.ZeroStageAPI,
|
"view_class": stage.ZeroStageAPI,
|
||||||
"conditions": True,
|
"conditions": True,
|
||||||
},
|
},
|
||||||
"setStage": {
|
|
||||||
"rule" : "/stage/type/",
|
|
||||||
"view_class": stage.StageTypeAPI,
|
|
||||||
"conditions": True,
|
|
||||||
},
|
|
||||||
"shutdown": {
|
"shutdown": {
|
||||||
"rule": "/system/shutdown/",
|
"rule": "/system/shutdown/",
|
||||||
"view_class": system.ShutdownAPI,
|
"view_class": system.ShutdownAPI,
|
||||||
|
|
|
||||||
|
|
@ -66,22 +66,4 @@ class ZeroStageAPI(ActionView):
|
||||||
# TODO: Make schema for microscope state
|
# TODO: Make schema for microscope state
|
||||||
return microscope.state["stage"]
|
return microscope.state["stage"]
|
||||||
|
|
||||||
class StageTypeAPI(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"))
|
|
||||||
return {"stage_type": microscope.configuration["stage"]["type"]}
|
|
||||||
|
|
||||||
def get(self):
|
|
||||||
"""
|
|
||||||
Get the stage geometry.
|
|
||||||
"""
|
|
||||||
microscope = find_component("org.openflexure.microscope")
|
|
||||||
return {"stage_type": microscope.configuration["stage"]["type"]}
|
|
||||||
|
|
||||||
|
|
|
||||||
26
openflexure_microscope/api/v2/views/stage.py
Normal file
26
openflexure_microscope/api/v2/views/stage.py
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
from labthings import find_component, fields, schema
|
||||||
|
from labthings.views import PropertyView
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
class StageTypeProperty(PropertyView):
|
||||||
|
"""The type of the stage"""
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
"""
|
||||||
|
Get the stage geometry.
|
||||||
|
"""
|
||||||
|
microscope = find_component("org.openflexure.microscope")
|
||||||
|
return microscope.configuration['stage']['type']
|
||||||
|
|
||||||
|
schema = fields.String(missing=None, example="SangaStage", description="The stage geometry [SangaStage, SangaDeltaStage]")
|
||||||
|
|
||||||
|
def put(self,stage_type):
|
||||||
|
"""
|
||||||
|
Set the stage geometry.
|
||||||
|
"""
|
||||||
|
microscope = find_component("org.openflexure.microscope")
|
||||||
|
microscope.set_stage(stage_type=stage_type)
|
||||||
|
return microscope.configuration["stage"]["type"]
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue