Telescope.py 1.38 KB
from pyrosapp.models import *
from .Device import DeviceObj
from enum import Enum
import configparser

class RotatorEnum(Enum):
    none = "None"
    synchro = "Synchro"
    tracking = "Tracking"

class MoveModeEnum(Enum):
    goto = "Goto"
    track = "Track"
    goto_track = "GotoTrack"

class CoordsFrameEnum(Enum):
    hadec = "Hadec"
    radec = "Radec"
    altaz = "Altaz"

CONFIG_FILE = "../simulators/socket_config.ini"

class TelescopeObj(DeviceObj):

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

        self.set_msgs = [
            ("SPEED", [2, 3], float),
            ("COORDS", [2, 3], float),
            ("TRACKING_SPEED", [2, 3], float),
            ("ACCEL", [2, 3], float),

            ("ROTATOR", [1, ], RotatorEnum),
            ("FOCUS", [1, ], float),
            ("MOVE_MODE", [1, ], MoveModeEnum),
            ("COORDS_FRAME", [1, ], CoordsFrameEnum),
        ]

        self.get_msgs = [
            "POSITION",
            "STATUS",
            "SETUP",
        ]

        self.do_msgs = [
            ("DOORS", [1, ], bool),
            ("START", [0, ],),
            ("ABORT", [0, ],),
            ("STOP", [0, ],),
            ("HOMING", [0, ],),
        ]

        config = configparser.ConfigParser()
        config.read(CONFIG_FILE)

        self.ip = config.get("Telescope", "ip")
        self.port = int(config.get("Telescope", "port"))

        print(self.ip, self.port)