def tracking(self):
     log.debug("Check tracking by sending IS_TRACKING to mount..")
     command = "IS_TRACKING\n"
     SerialReader.write(command)
     response = get_is_tracking_response()
     log.debug(f"Acquired response for is_tracking: {response}")
     return self.__tracking
    def connected(self, value):
        if value == self.is_connected:
            return

        if value:
            log.debug("Sending command to go back to normal mode...")
            SerialReader.write("FO_LOW_CUR_OFF\n")
        else:
            log.debug("Sending command to go into low current halt mode...")
            SerialReader.write("FO_LOW_CUR_ON\n")

        MyDeviceDriver.connected.fset(self, value)
Exemple #3
0
 def __init__(self):
     init_logging()
     self.serial_handler_thread = None
     try:
         initConfig()
         com_port = services.config.ascomConfig["common_port"]
         print(f"COM port = {com_port}")
         self.serial_reader = SerialReader(com_port)
         self.serial_handler_thread = threading.Thread(target=self.serial_reader.loop)
         self.serial_handler_thread.start()
         handlers = get_rest_handlers()
         print("Start the service")
         app = pyrestful.rest.RestService(handlers)
         http_server = tornado.httpserver.HTTPServer(app)
         http_server.listen(11111)
         tornado.ioloop.IOLoop.instance().start()
     except KeyboardInterrupt:
         print("\nStop the service")
    def tracking(self, value):
        log.debug(f"Setting tracking to {value}")
        if value is True:
            command = "RA_TRACK_ON\n"
        else:
            command = "RA_TRACK_OFF\n"

        SerialReader.write(command)
        # log.debug("Getting ack:")
        # command = "IS_TRACKING\n"
        # current_size = get_unspecified_messages_length()
        # SerialReader.write(command)
        # log.debug("Acquiring response...")
        # max_wait_ms = 1000
        # current_wait_ms = 0
        # while (current_wait_ms < max_wait_ms) and (current_size >= get_unspecified_messages_length()):
        #     time.sleep(0.001)
        #     current_wait_ms += 1
        #
        # new_message = get_last_unspecified_message()
        # log.debug(f"Response = {new_message}")
        self.__tracking = value
    def ismoving(self):
        time_now = time.time()
        interval = time_now - self.__last_poll
        log.debug(f"Last poll of focuser status: {self.__last_poll}, interval passed = {interval}")
        if interval < POLLING_MIN_PERIOD_IN_SECONDS:
            return self.__is_slewing

        self.__last_poll = time_now
        log.debug("Sending command position...")
        current_size = get_focuser_messages_length()
        SerialReader.write("FO_POSITION\n")
        log.debug("Acquiring response about position....")
        max_wait_ms = 1000
        current_wait_ms = 0
        while (current_wait_ms < max_wait_ms) and (current_size >= get_focuser_messages_length()):
            time.sleep(0.001)
            current_wait_ms += 1

        new_message = get_last_focuser_message()
        log.debug(f"Current = {new_message}")
        self.__position = new_message["position"]
        self.__is_slewing = new_message["is_slewing"]
        return self.__is_slewing
    def moveaxis(self, axis_str, rate_str):
        axis = int(axis_str)
        rate = float(rate_str)
        log.debug(f"Move axis with axis={axis} and rate={rate}")
        if axis == RA_AXIS_NUMBER:  # DEC
            if abs(rate) < MOVE_THRESHOLD:
                command = "RA_STOP\n"
            else:
                direction = 1 if rate > 0 else 0
                command = "RA_MOVE " +str(direction) +"\n"

            log.debug(f"Sending command:{command}!")
            SerialReader.write(command)
        elif axis == DEC_AXIS_NUMBER:  # DEC
            if abs(rate) < MOVE_THRESHOLD:
                command = "DE_STOP\n"
            else:
                direction = 1 if rate > 0 else 0
                command = "DE_MOVE " +str(direction) +"\n"

            log.debug(f"Sending command:{command}!")
            SerialReader.write(command)
        else:
            log.warning(f"Unknown axis: {axis}!")
 def synctoaltaz(self, altitude, azimuth):
     alt_100th = int(altitude*100)
     az_100th = int(100*azimuth)
     command = f"SET_ALTAZ {alt_100th} {az_100th}"
     log.debug(f"Sending command:{command}!")
     SerialReader.write(command)
 def synctocoordinates(self, right_ascension, declination):
     ra_hours1000 = int(right_ascension*1000)
     dec_100deg = int(100*declination)
     command = f"SET_RADEC {ra_hours1000} {dec_100deg}"
     log.debug(f"Sending command:{command}!")
     SerialReader.write(command)
 def pulseguide(self, direction, duration_ms):
     command = f"PULSE_TIME {direction} {duration_ms}"
     log.debug(f"Sending command:{command}!")
     SerialReader.write(command)
 def move(self, position):
     log.debug("Sending command move...")
     command = "FO_MOVE_REL "+str(position) + "\n"
     SerialReader.write(command)
 def halt(self):
     log.debug("Sending command halt...")
     command = "HALT\n"
     SerialReader.write(command)