Newer
Older
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''REST API for Dome related operations'''
# Third-party modules
# Custom modules
from config import constants
'''Check the azimuth of the dome, and if
this corresponds to the parking position.'''
Davide Ricci
committed
res = {
"raw": self.dev.is_parked,
Davide Ricci
committed
"response": {
"parked": constants.yes_no[self.dev.is_parked],
Davide Ricci
committed
},
Davide Ricci
committed
return res
'''Dome Shutter'''
'''Check the state of the dome shutter.'''
"raw": self.dev.shutter,
"response": constants.open_state[self.dev.shutter],
}
return res
# @api.route("/shutter/movement")
'''Manage the movement of the dome shutter.'''
'''Move the shutter to a new position
"raw": self.dev.open,
"response": constants.open_state[self.open],
}
return res
def delete(self):
'''Stop the movement of the shutter.'''
res = {
"response": self.dev.abort(),
"error": self.dev.error,
}
return res
# @api.route("/position/slaved")
'''Manage the minioning of the shutter
'''Check if the dome is slaved
Davide Ricci
committed
res = {
"raw": self.dev.slave,
"response": constants.yes_no[self.dev.slave],
Davide Ricci
committed
return res
'''Make the dome slaved to the telescope
Davide Ricci
committed
res = {
"raw": self.dev.slave,
"response": constants.yes_no[self.dev.slave],
Davide Ricci
committed
return res
'''Manage the reference azimuth of the dome'''
'''Tell the dome that its current position
res = {
"response": self.dev.sync(new_azimuth),
"error": self.dev.error,
}
return res
# @api.route("/position/movement")
'''Manage the movement of the dome.'''
# @api.marshal_with(model_bool, 200)
'''Return if the dome is moving or not.'''
res = {
"raw": self.dev.is_moving,
"response": constants.yes_no[self.dev.is_moving],
}
return res
def delete(self):
'''Stop the movement of the dome.'''
res = {
"response": self.dev.abort(),
"error": self.dev.error,
}
return res
# @api.route("/position/movement/park")
res = {
"response": self.dev.park(),
"error": self.dev.error,
}
return res
# @api.route("/position/movement/azimuth")
'''Manage the position of the dome.'''
Davide Ricci
committed
res = {
"response": self.dev.azimuth,
"error": self.dev.error,
Davide Ricci
committed
return res
Davide Ricci
committed
Davide Ricci
committed
'''Manage the connection to ASCOM.'''
def get(self):
'''check if the dome is connected to ASCOM.'''
conn = self.dev.connection
Davide Ricci
committed
res = {
"raw": conn,
"response": constants.yes_no[conn] if bool(conn) else False,
Davide Ricci
committed
}
return res
def put(self):
'''Connect or disconnect the telescope to ASCOM.'''
self.dev.connection = connection
Davide Ricci
committed
res = {
"raw": self.dev.connection,
"response": constants.yes_no[self.dev.connection],