Telescope.py 1.02 KB
from common.models import *
import abc
from .Device import DeviceController

'''
    Device controller for Telescope.
    This class must implement set, get and do functions (DeviceController is an abstract)
'''
class TelescopeController(DeviceController):

    def __init__(self):
        super().__init__("Telescope")

    def get(self, command: str, *args):
        message = "GET " + command + " " + " ".join([str(arg) for arg in args])
        self.sendMessage(message)
        return (self.blockAndReadMessage())

    def set(self, command: str, *args):
        message = "SET " + command + " " + " ".join([str(arg) for arg in args])
        self.sendMessage(message)
        response = self.blockAndReadMessage()
        return response

    def do(self, command: str, *args):
        message = "DO " + command + " " + " ".join([str(arg) for arg in args])
        self.sendMessage(message)
        response = self.blockAndReadMessage()
        return response

    def getStatus(self):
        self.get("STATUS")
        return "OK"