Loading noctua/api/baseresource.py +1 −1 Original line number Diff line number Diff line Loading @@ -169,7 +169,7 @@ def expects(param_type="single", count=1, unit=None, placeholder=None): """ def decorator(func): func._input_schema = { "type": param_type, # "single", "array", "boolean" o None "type": param_type, # "string", "number" "array", "boolean" o None "count": count, # numero di parametri attesi "unit": unit, # unità di misura (es. "°C", "mm") "placeholder": placeholder # valore/i di esempio per l'interfaccia Loading noctua/api/camera.py +12 −3 Original line number Diff line number Diff line Loading @@ -5,13 +5,14 @@ '''REST API for Camera related operations''' # This module imports from .baseresource import BaseResource from .baseresource import BaseResource, expects from noctua.config import constants from noctua.api.sequencer_instance import seq class FrameBinning(BaseResource): """Binning of the camera.""" @expects(param_type="array", count=2, unit="px", placeholder="[1,1]") async def put(self): """Set a new binning for the camera.""" Loading @@ -32,6 +33,7 @@ class Cooler(BaseResource): res = constants.on_off.get(raw, "N/A") return self.make_response(res, raw_data=raw) @expects(param_type="boolean") async def put(self): """Set on or off the CCD cooler.""" Loading @@ -45,6 +47,7 @@ class Cooler(BaseResource): class CoolerTemperatureSetpoint(BaseResource): """Manage the CCD temperature""" @expects(param_type="number", unit="°", placeholder="0") async def put(self): """Set a new temperature of the CCD.""" Loading Loading @@ -100,6 +103,7 @@ class FilterMovement(BaseResource): res = constants.filter_state.get(raw, "Off") return self.make_response(res, raw_data=raw) @expects(param_type="string", placeholder="FREE") async def post(self): """Set a new filter.""" Loading @@ -113,6 +117,7 @@ class FilterMovement(BaseResource): class FrameCustom(BaseResource): """Camera custom frame.""" @expects(param_type="array", count=2, unit="px", placeholder="[45, 180]") async def put(self): """Set a custom windowing.""" Loading Loading @@ -156,14 +161,18 @@ class FrameSmall(BaseResource): class SnapshotRaw(BaseResource): """The acquired image.""" @expects(param_type="array", count=2, placeholder='["10", "Light"]') async def post(self): """Start a raw image using camera interface.""" new = await self.get_payload() # exptime, type try: res = await self.run_blocking( self.dev.start, new["exptime"], new["type"], self.timestamp ) self.dev.start, float(new["exptime"]), new["type"], self.timestamp) except KeyError as e: msg = f"API: Missing keyword: {e}" self.dev.error.append(msg) Loading noctua/api/dome.py +6 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ from quart import request # Custom modules from noctua.config import constants from .baseresource import BaseResource from .baseresource import BaseResource, expects class Position(BaseResource): Loading Loading @@ -41,6 +41,7 @@ class Shutter(BaseResource): class ShutterMovement(BaseResource): '''Manage the movement of the dome shutter.''' @expects(param_type="boolean") async def post(self): '''Move the shutter to a new position (open or closed).''' Loading Loading @@ -72,6 +73,7 @@ class PositionSlaved(BaseResource): slave = await self.run_blocking(lambda: self.dev.slave) return self.make_response(constants.yes_no.get(slave, "N/A"), raw_data=slave) @expects(param_type="boolean") async def put(self): '''Make the dome slaved to the telescope or release it.''' Loading @@ -89,6 +91,7 @@ class PositionSlaved(BaseResource): class PositionSync(BaseResource): '''Manage the reference azimuth of the dome''' @expects(param_type="number", unit="°", placeholder="0.1") async def put(self): '''Tell the dome that its current position corresponds to a given azimuth.''' Loading Loading @@ -127,6 +130,7 @@ class PositionMovementPark(BaseResource): class PositionMovementAzimuth(BaseResource): '''Manage the position of the dome.''' @expects(param_type="number", unit="°", placeholder="57") async def post(self): '''Set a new dome azimuth.''' Loading @@ -152,6 +156,7 @@ class Connection(BaseResource): response_val = constants.yes_no.get(conn, "No") if bool(conn) else False return self.make_response(response_val, raw_data=conn) @expects(param_type="boolean") async def put(self): '''Connect or disconnect the telescope to ASCOM.''' Loading noctua/api/telescope.py +7 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ class Cover(BaseResource): class CoverMovement(BaseResource): '''Manage the primary mirror cover petals.''' @expects(param_type="boolean") async def post(self): '''Set a new position for cover petals (open or closed).''' Loading @@ -45,6 +46,7 @@ class Error(BaseResource): res = await self.run_blocking(lambda: self.dev.state) return self.make_response(res) @expects(param_type="number", unit="#", placeholder="2") async def delete(self): '''Try to clean the errors.''' Loading Loading @@ -115,7 +117,7 @@ class CoordinatesMovement(BaseResource): class CoordinatesMovementRadec(BaseResource): '''Point the telescope in Ra, Dec.''' @expects(param_type="array", count=2, unit="hms ±dms / id", placeholder="Polaris") @expects(param_type="string", count=1, unit="hms ±dms / id", placeholder="Polaris") async def post(self): '''Set new Ra and Dec coordinates.''' Loading Loading @@ -194,6 +196,7 @@ class CoordinatesOffset(BaseResource): res = await self.run_blocking(lambda: self.dev.offset) return self.make_response(res) @expects(param_type="array", count=2, unit="″", placeholder="[-300, -300]") async def put(self): '''Apply to the telescope new offsets in degrees.''' Loading @@ -214,6 +217,7 @@ class CoordinatesTracking(BaseResource): res = await self.run_blocking(lambda: self.dev.tracking) return self.make_response(constants.yes_no.get(res, "N/A"), raw_data=res) @expects(param_type="boolean") async def put(self): '''Set the telescope in tracking mode or not''' Loading Loading @@ -263,6 +267,7 @@ class FocuserMovement(BaseResource): res = await self.run_blocking(lambda: self.dev.is_moving) return self.make_response(res) @expects(param_type="number", count=2, unit="µm", placeholder="20000") async def put(self): '''Update the secondary mirror position.''' Loading Loading @@ -293,6 +298,7 @@ class RotatorMovement(BaseResource): res = await self.run_blocking(lambda: self.dev.is_moving) return self.make_response(res) @expects(param_type="number", count=2, unit="°", placeholder="0") async def post(self): '''Set the field derotator to a new position.''' Loading noctua/config/api.ini +4 −4 Original line number Diff line number Diff line Loading @@ -259,10 +259,10 @@ depends-on = /camera/power # resource = Frame # device = cam [/camera/frame/custom] resource = FrameCustom device = cam depends-on = /camera/power # [/camera/frame/custom] # resource = FrameCustom # device = cam # depends-on = /camera/power [/camera/frame/full] resource = FrameFull Loading Loading
noctua/api/baseresource.py +1 −1 Original line number Diff line number Diff line Loading @@ -169,7 +169,7 @@ def expects(param_type="single", count=1, unit=None, placeholder=None): """ def decorator(func): func._input_schema = { "type": param_type, # "single", "array", "boolean" o None "type": param_type, # "string", "number" "array", "boolean" o None "count": count, # numero di parametri attesi "unit": unit, # unità di misura (es. "°C", "mm") "placeholder": placeholder # valore/i di esempio per l'interfaccia Loading
noctua/api/camera.py +12 −3 Original line number Diff line number Diff line Loading @@ -5,13 +5,14 @@ '''REST API for Camera related operations''' # This module imports from .baseresource import BaseResource from .baseresource import BaseResource, expects from noctua.config import constants from noctua.api.sequencer_instance import seq class FrameBinning(BaseResource): """Binning of the camera.""" @expects(param_type="array", count=2, unit="px", placeholder="[1,1]") async def put(self): """Set a new binning for the camera.""" Loading @@ -32,6 +33,7 @@ class Cooler(BaseResource): res = constants.on_off.get(raw, "N/A") return self.make_response(res, raw_data=raw) @expects(param_type="boolean") async def put(self): """Set on or off the CCD cooler.""" Loading @@ -45,6 +47,7 @@ class Cooler(BaseResource): class CoolerTemperatureSetpoint(BaseResource): """Manage the CCD temperature""" @expects(param_type="number", unit="°", placeholder="0") async def put(self): """Set a new temperature of the CCD.""" Loading Loading @@ -100,6 +103,7 @@ class FilterMovement(BaseResource): res = constants.filter_state.get(raw, "Off") return self.make_response(res, raw_data=raw) @expects(param_type="string", placeholder="FREE") async def post(self): """Set a new filter.""" Loading @@ -113,6 +117,7 @@ class FilterMovement(BaseResource): class FrameCustom(BaseResource): """Camera custom frame.""" @expects(param_type="array", count=2, unit="px", placeholder="[45, 180]") async def put(self): """Set a custom windowing.""" Loading Loading @@ -156,14 +161,18 @@ class FrameSmall(BaseResource): class SnapshotRaw(BaseResource): """The acquired image.""" @expects(param_type="array", count=2, placeholder='["10", "Light"]') async def post(self): """Start a raw image using camera interface.""" new = await self.get_payload() # exptime, type try: res = await self.run_blocking( self.dev.start, new["exptime"], new["type"], self.timestamp ) self.dev.start, float(new["exptime"]), new["type"], self.timestamp) except KeyError as e: msg = f"API: Missing keyword: {e}" self.dev.error.append(msg) Loading
noctua/api/dome.py +6 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ from quart import request # Custom modules from noctua.config import constants from .baseresource import BaseResource from .baseresource import BaseResource, expects class Position(BaseResource): Loading Loading @@ -41,6 +41,7 @@ class Shutter(BaseResource): class ShutterMovement(BaseResource): '''Manage the movement of the dome shutter.''' @expects(param_type="boolean") async def post(self): '''Move the shutter to a new position (open or closed).''' Loading Loading @@ -72,6 +73,7 @@ class PositionSlaved(BaseResource): slave = await self.run_blocking(lambda: self.dev.slave) return self.make_response(constants.yes_no.get(slave, "N/A"), raw_data=slave) @expects(param_type="boolean") async def put(self): '''Make the dome slaved to the telescope or release it.''' Loading @@ -89,6 +91,7 @@ class PositionSlaved(BaseResource): class PositionSync(BaseResource): '''Manage the reference azimuth of the dome''' @expects(param_type="number", unit="°", placeholder="0.1") async def put(self): '''Tell the dome that its current position corresponds to a given azimuth.''' Loading Loading @@ -127,6 +130,7 @@ class PositionMovementPark(BaseResource): class PositionMovementAzimuth(BaseResource): '''Manage the position of the dome.''' @expects(param_type="number", unit="°", placeholder="57") async def post(self): '''Set a new dome azimuth.''' Loading @@ -152,6 +156,7 @@ class Connection(BaseResource): response_val = constants.yes_no.get(conn, "No") if bool(conn) else False return self.make_response(response_val, raw_data=conn) @expects(param_type="boolean") async def put(self): '''Connect or disconnect the telescope to ASCOM.''' Loading
noctua/api/telescope.py +7 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ class Cover(BaseResource): class CoverMovement(BaseResource): '''Manage the primary mirror cover petals.''' @expects(param_type="boolean") async def post(self): '''Set a new position for cover petals (open or closed).''' Loading @@ -45,6 +46,7 @@ class Error(BaseResource): res = await self.run_blocking(lambda: self.dev.state) return self.make_response(res) @expects(param_type="number", unit="#", placeholder="2") async def delete(self): '''Try to clean the errors.''' Loading Loading @@ -115,7 +117,7 @@ class CoordinatesMovement(BaseResource): class CoordinatesMovementRadec(BaseResource): '''Point the telescope in Ra, Dec.''' @expects(param_type="array", count=2, unit="hms ±dms / id", placeholder="Polaris") @expects(param_type="string", count=1, unit="hms ±dms / id", placeholder="Polaris") async def post(self): '''Set new Ra and Dec coordinates.''' Loading Loading @@ -194,6 +196,7 @@ class CoordinatesOffset(BaseResource): res = await self.run_blocking(lambda: self.dev.offset) return self.make_response(res) @expects(param_type="array", count=2, unit="″", placeholder="[-300, -300]") async def put(self): '''Apply to the telescope new offsets in degrees.''' Loading @@ -214,6 +217,7 @@ class CoordinatesTracking(BaseResource): res = await self.run_blocking(lambda: self.dev.tracking) return self.make_response(constants.yes_no.get(res, "N/A"), raw_data=res) @expects(param_type="boolean") async def put(self): '''Set the telescope in tracking mode or not''' Loading Loading @@ -263,6 +267,7 @@ class FocuserMovement(BaseResource): res = await self.run_blocking(lambda: self.dev.is_moving) return self.make_response(res) @expects(param_type="number", count=2, unit="µm", placeholder="20000") async def put(self): '''Update the secondary mirror position.''' Loading Loading @@ -293,6 +298,7 @@ class RotatorMovement(BaseResource): res = await self.run_blocking(lambda: self.dev.is_moving) return self.make_response(res) @expects(param_type="number", count=2, unit="°", placeholder="0") async def post(self): '''Set the field derotator to a new position.''' Loading
noctua/config/api.ini +4 −4 Original line number Diff line number Diff line Loading @@ -259,10 +259,10 @@ depends-on = /camera/power # resource = Frame # device = cam [/camera/frame/custom] resource = FrameCustom device = cam depends-on = /camera/power # [/camera/frame/custom] # resource = FrameCustom # device = cam # depends-on = /camera/power [/camera/frame/full] resource = FrameFull Loading