Пример #1
0
    def handle_read(self):
        #format: 20 bytes in total. Size: intle:16
        #Incomming messages comes with 160 bytes..
        data0 = self.recv(160)
        if data0:
            data = ConstBitStream(bytes=data0, length=160)
            #print "All: %s" % data.bin

            msize = data.read('intle:16')
            mtype = data.read('intle:16')
            mtime = data.read('intle:64')

            # RA:
            ant_pos = data.bitpos
            ra = data.read('hex:32')
            data.bitpos = ant_pos
            ra_uint = data.read('uintle:32')

            # DEC:
            ant_pos = data.bitpos
            dec = data.read('hex:32')
            data.bitpos = ant_pos
            dec_int = data.read('intle:32')

            logging.debug(
                "Size: %d, Type: %d, Time: %d, RA: %d (%s), DEC: %d (%s)" %
                (msize, mtype, mtime, ra_uint, ra, dec_int, dec))
            (sra, sdec, stime) = coords.eCoords2str(float("%f" % ra_uint),
                                                    float("%f" % dec_int),
                                                    float("%f" % mtime))

            #Sends back the coordinates to Stellarium
            self.act_pos(coords.hourStr_2_rad(sra), coords.degStr_2_rad(sdec))
	def handle_read(self):
		#format: 20 bytes in total. Size: intle:16
		#Incomming messages comes with 160 bytes..
		data0 = self.recv(160);
		if data0:			
			data = ConstBitStream(bytes=data0, length=160)
			#print "All: %s" % data.bin
			
			msize = data.read('intle:16')
			mtype = data.read('intle:16')
			mtime = data.read('intle:64')
			
			# RA: 
			ant_pos = data.bitpos
			ra = data.read('hex:32')
			data.bitpos = ant_pos
			ra_uint = data.read('uintle:32')
			
			# DEC:
			ant_pos = data.bitpos
			dec = data.read('hex:32')
			data.bitpos = ant_pos
			dec_int = data.read('intle:32')
			
			#______ Testing:
			# Sends back to Stellarium the received coordinates, in order to update the field of view indicator
			(sra, sdec, stime) = coords.eCoords2str(float("%f" % ra_uint), float("%f" % dec_int), float("%f" %  mtime))
			self.act_pos(coords.hourStr_2_rad(sra), coords.degStr_2_rad(sdec))
			#______ End Testing
			
			# Emits the signal with received equatorial coordinates (for use in external Qt Gui..)
			self.stell_pos_recv.emit("%f" % ra_uint, "%f" % dec_int, "%f" %  mtime)
Пример #3
0
    def handle_read(self):
        #format: 20 bytes in total. Size: intle:16
        #Incomming messages comes with 160 bytes..
        data0 = self.recv(160)
        if data0:
            data = ConstBitStream(bytes=data0, length=160)
            #print "All: %s" % data.bin

            msize = data.read('intle:16')
            mtype = data.read('intle:16')
            mtime = data.read('intle:64')

            # RA:
            ant_pos = data.bitpos
            ra = data.read('hex:32')
            data.bitpos = ant_pos
            ra_uint = data.read('uintle:32')

            # DEC:
            ant_pos = data.bitpos
            dec = data.read('hex:32')
            data.bitpos = ant_pos
            dec_int = data.read('intle:32')

            #______ Testing:
            # Sends back to Stellarium the received coordinates, in order to update the field of view indicator
            (sra, sdec, stime) = coords.eCoords2str(float("%f" % ra_uint),
                                                    float("%f" % dec_int),
                                                    float("%f" % mtime))
            self.act_pos(coords.hourStr_2_rad(sra), coords.degStr_2_rad(sdec))
            #______ End Testing

            # Emits the signal with received equatorial coordinates (for use in external Qt Gui..)
            self.stell_pos_recv.emit("%f" % ra_uint, "%f" % dec_int,
                                     "%f" % mtime)
Пример #4
0
    def listen_client_thread(self, client_socket):
        logging.info("Servidor conectado a un nuevo cliente...")

        while self.conectado:
            data0 = client_socket.recv(160)
            if data0:
                data = ConstBitStream(bytes=data0, length=160)
                # print "All: %s" % data.bin

                msize = data.read('intle:16')
                mtype = data.read('intle:16')
                mtime = data.read('intle:64')

                # RA:
                ant_pos = data.bitpos
                ra = data.read('hex:32')
                data.bitpos = ant_pos
                ra_uint = data.read('uintle:32')

                # DEC:
                ant_pos = data.bitpos
                dec = data.read('hex:32')
                data.bitpos = ant_pos
                dec_int = data.read('intle:32')
                (sra, sdec,
                 stime) = coords.eCoords2str(float("%f" % ra_uint),
                                             float("%f" % dec_int),
                                             float("%f" % mtime))
                self.act_pos(coords.hourStr_2_rad(sra),
                             coords.degStr_2_rad(sdec))
                self.coords_sig.emit((sra, sdec, stime))
Пример #5
0
    def handle_read(self):
        #format: 20 bytes in total. Size: intle:16
        #Incomming messages comes with 160 bytes..
        data0 = self.recv(160);
        if data0:            
            data = ConstBitStream(bytes=data0, length=160)
            print "All: %s" % data.bin
 
            msize = data.read('intle:16')
            mtype = data.read('intle:16')
            mtime = data.read('intle:64')
 
            # RA: 
            ant_pos = data.bitpos
            ra = data.read('hex:32')
            data.bitpos = ant_pos
            ra_uint = data.read('uintle:32')
 
            # DEC:
            ant_pos = data.bitpos
            dec = data.read('hex:32')
            data.bitpos = ant_pos
            dec_int = data.read('intle:32')
 
            logging.debug("Size: %d, Type: %d, Time: %d, RA: %d (%s), DEC: %d (%s)" % (msize, mtype, mtime, ra_uint, ra, dec_int, dec))
            (sra, sdec, stime) = coords.eCoords2str(float("%f" % ra_uint), float("%f" % dec_int), float("%f" %  mtime))
 
            #Sends back the coordinates to Stellarium
            self.act_pos(coords.hourStr_2_rad(sra), coords.degStr_2_rad(sdec))
Пример #6
0
    def handle_read(self):
        #formato: 20 bytes en total.
        #Los mensajes entrantes vienen con 160 bytes..
        data0 = self.recv(160);
        if data0:            
            data = ConstBitStream(bytes=data0, length=160)
            #print "Recibido (binario): %s" % data.bin
 
            msize = data.read('intle:16')
            mtype = data.read('intle:16')
            mtime = data.read('intle:64')
 
            # RA: 
            ant_pos = data.bitpos
            ra = data.read('hex:32')
            data.bitpos = ant_pos
            ra_uint = data.read('uintle:32')
 
            # DEC:
            ant_pos = data.bitpos
            dec = data.read('hex:32')
            data.bitpos = ant_pos
            dec_int = data.read('intle:32')
 
            logging.debug("Size: %d, Type: %d, Time: %d, RA: %d (%s), DEC: %d (%s)" % (msize, mtype, mtime, ra_uint, ra, dec_int, dec))
            (sra, sdec, stime) = coords.eCoords2str(float("%f" % ra_uint), float("%f" % dec_int), float("%f" %  mtime))
 
            #Enviando de nuevo las coordenadas a Stellarium
            self.act_pos(coords.hourStr_2_rad(sra), coords.degStr_2_rad(sdec))
Пример #7
0
    def stellariumRead(self, ra, dec, mtime):
        ra = float(ra)
        dec = float(dec)
        mtime = float(mtime)
        (self.sra, self.sdec, stime) = coords.eCoords2str(ra, dec, mtime)

        if self.find == True or self.mg < 1:
            self.writeInfo()
Пример #8
0
 def stellariumRecv(self, ra, dec, mtime):
     ra = float(ra)
     dec = float(dec)
     mtime = float(mtime)
     logging.debug("%s" % coords.toJ2000(ra, dec, mtime))
     (sra, sdec, stime) = coords.eCoords2str(ra, dec, mtime)
     (self._ra, self._dec) = (sra, sdec)
     print str(sra) + ',' + str(sdec)
     self.lcd_az.display(sra)
Пример #9
0
    def read_data(self, mesData):
        #format: 20 bytes in total. Size: intle:16
        #Incomming messages comes with 160 bytes..
        try:
            if mesData:
                data = ConstBitStream(bytes=mesData, length=160)
                #print "All: %s" % data.bin

                msize = data.read('intle:16')
                mtype = data.read('intle:16')
                mtime = data.read('intle:64')

                # RA:
                ant_pos = data.bitpos
                ra = data.read('hex:32')
                data.bitpos = ant_pos
                ra_uint = data.read('uintle:32')

                # DEC:
                ant_pos = data.bitpos
                dec = data.read('hex:32')
                data.bitpos = ant_pos
                dec_int = data.read('intle:32')

                logging.info(
                    "Size: %d, Type: %d, Time: %d, RA: %d (%s), DEC: %d (%s)" %
                    (msize, mtype, mtime, ra_uint, ra, dec_int, dec))
                (sra, sdec,
                 stime) = coords.eCoords2str(float("%f" % ra_uint),
                                             float("%f" % dec_int),
                                             float("%f" % mtime))
                logging.info(
                    f"Coordonnées Ciblé Par Stellarium : sra : {sra} - sdec = {sdec} - stime = {stime}"
                )

                if self.positionInit == None:
                    self.positionInit = self.positionCible = [
                        coords.hourStr_2_rad(sra),
                        coords.degStr_2_rad(sdec)
                    ]
                    self.positionInit = tuple(self.positionInit)
                else:
                    self.positionCible = [
                        coords.hourStr_2_rad(sra),
                        coords.degStr_2_rad(sdec)
                    ]

        except Exception as e:
            print(f"Erreur read_data() : {e}")
            exit()
Пример #10
0
    def stellariumRecv(self, ra, dec, mtime):
        ra = float(ra)
        dec = float(dec)
        mtime = float(mtime)

        mtime = 1.46037891509e+15

        logging.debug("%s" % mtime)
        logging.debug("%s" % coords.toJ2000(ra, dec, mtime))
        (sra, sdec, stime) = coords.eCoords2str(ra, dec, mtime)
        # print stime
        (self._ra, self._dec) = (sra, sdec)

        if self.device != None:
            logging.debug("Sending to the device: '%s','%s','%s'" %
                          (sra, sdec, stime))
            try:
                if self.ui.Reconfigure.isChecked():
                    if self.ui.redef_1:
                        self.ui.redef_1.setChecked(False)
                        redef = 1
                    elif self.ui.redef_2:
                        self.ui.redef_2.setChecked(False)
                        redef = 2
                    else:
                        self.ui.redef_3.setChecked(False)
                        redef = 3
                    self.ui.Reconfigure.setChecked(False)
                    self.device.setRef(redef, sra, sdec, stime)
                elif not self.confMode:
                    self.device.goto(sra, sdec, stime)
                else:
                    self.nRef = self.nRef + 1
                    self.ui.text_status.setText("References: %d/2" % self.nRef)
                    self.device.setRef(self.nRef, sra, sdec, stime)
                    if self.nRef == 2:
                        self.setConfigDone()
                        self.nRef = 0
            except:
                logging.debug("Device not found..")
                e = sys.exc_info()[1]
                print("Error: %s" % e)
    def handle_read(self):
        #format: 20 bytes in total. Size: intle:16
        #Incomming messages comes with 160 bytes..
        data0 = self.recv(160)
        if data0:
            data = ConstBitStream(bytes=data0, length=160)
            #print "All: %s" % data.bin

            msize = data.read('intle:16')
            mtype = data.read('intle:16')
            mtime = data.read('intle:64')

            # RA:
            ant_pos = data.bitpos
            ra = data.read('hex:32')
            data.bitpos = ant_pos
            ra_uint = data.read('uintle:32')

            # DEC:
            ant_pos = data.bitpos
            dec = data.read('hex:32')
            data.bitpos = ant_pos
            dec_int = data.read('intle:32')

            # convert to useable floats
            (sra, sdec, stime) = coords.eCoords2str(float("%f" % ra_uint),
                                                    float("%f" % dec_int),
                                                    float("%f" % mtime))
            ra_rad = coords.hourStr_2_rad(sra)
            dec_rad = coords.degStr_2_rad(sdec)

            # Manu
            print "Manu: ra, dec=", ra_rad * 180. / np.pi, dec_rad * 180. / np.pi, "deg"
            print "Manu: this is where I would send the command to move the motors!"

            # Sends back to Stellarium the received coordinates, in order to update the field of view indicator
            self.act_pos(coords.hourStr_2_rad(sra), coords.degStr_2_rad(sdec))

            # Emits the signal with received equatorial coordinates (for use in external Qt Gui..)
            self.stell_pos_recv.emit("%f" % ra_uint, "%f" % dec_int,
                                     "%f" % mtime)
	def stellariumRecv(self, ra, dec, mtime):
		ra = float(ra)
		dec = float(dec)
		mtime = float(mtime)
		logging.debug("%s" % coords.toJ2000(ra, dec, mtime))
		(sra, sdec, stime) = coords.eCoords2str(ra, dec, mtime)
		(self._ra, self._dec) = (sra, sdec)

		if self.device != None:
			logging.debug("Sending to the device: '%s','%s','%s'" % (sra, sdec, stime))
			try:
				if self.ui.Reconfigure.isChecked():
					if self.ui.redef_1:
						self.ui.redef_1.setChecked(False)
						redef = 1
					elif self.ui.redef_2:
						self.ui.redef_2.setChecked(False)
						redef = 2
					else:
						self.ui.redef_3.setChecked(False)
						redef = 3
					self.ui.Reconfigure.setChecked(False)
					self.device.setRef(redef, sra, sdec, stime)
				elif not self.confMode:
					self.device.goto(sra, sdec, stime)
				else:
					self.nRef = self.nRef + 1
					self.ui.text_status.setText("References: %d/2" % self.nRef)
					self.device.setRef(self.nRef, sra, sdec, stime)
					if self.nRef == 2:
						self.setConfigDone()
						self.nRef = 0
			except:
				logging.debug("Device not found..")
				e = sys.exc_info()[1]
				print("Error: %s" % e)
	def handle_read(self):
		#format: 20 bytes in total. Size: intle:16
		#Incomming messages comes with 160 bytes..
		data0 = self.recv(160);
		if data0:			
			data = ConstBitStream(bytes=data0, length=160)
			#print "All: %s" % data.bin

			msize = data.read('intle:16')
			mtype = data.read('intle:16')
			mtime = data.read('intle:64')

			# RA: 
			ant_pos = data.bitpos
			ra = data.read('hex:32')
			data.bitpos = ant_pos
			ra_uint = data.read('uintle:32')

			# DEC:
			ant_pos = data.bitpos
			dec = data.read('hex:32')
			data.bitpos = ant_pos
			dec_int = data.read('intle:32')

			logging.debug("Size: %d, Type: %d, Time: %d, RA: %d (%s), DEC: %d (%s)" % (msize, mtype, mtime, ra_uint, ra, dec_int, dec))
			(sra, sdec, stime) = coords.eCoords2str(float("%f" % ra_uint), float("%f" % dec_int), float("%f" %  mtime))

			#Sends back the coordinates to Stellarium
			self.act_pos(coords.hourStr_2_rad(sra), coords.degStr_2_rad(sdec))
			calibrate = raw_input("Do you want to calibrate? - Y/N \n")
			if calibrate == "Y":
				
				#Calibration GUI

				app = Tk()
				#app.title("Calibration")

				#app.configure(background = "grey")

				tframe = Frame(app)
				tframe.pack()

				lrframe = Frame(app)
				lrframe.pack()

				dframe = Frame(app)
				dframe.pack()

				bframe = Frame(app)
				bframe.pack(side = BOTTOM)

				def upCallBack():
					ser.write('w\n');
					#tkMessageBox.showinfo( "UP")


				def downCallBack():
					ser.write("s\n");
					#tkMessageBox.showinfo( "DOWN")
				def leftCallBack():
					ser.write("a\n");
					#tkMessageBox.showinfo( "LEFT")

				def rightCallBack():
					ser.write("d\n");
					#tkMessageBox.showinfo( "RIGHT")
				def close_window():
					app.destroy();


				UpButton = Button(tframe, text = "Up", command = upCallBack);
				UpButton.pack()
				DownButton = Button(dframe, text = "Down", command = downCallBack);
				DownButton.pack()
				LeftButton = Button(lrframe, text = "Left", command = leftCallBack);
				LeftButton.pack( side = LEFT)
				RightButton = Button(lrframe, text = "Right", command = rightCallBack);
				RightButton.pack( side = LEFT)
				DoneButton = Button(bframe, text = "Done", command = close_window);
				DoneButton.pack( side = BOTTOM)

				app.mainloop()
Пример #14
0
    def handle_read(self):
        #format: 20 bytes in total. Size: intle:16
        #Incomming messages comes with 160 bytes..
        data0 = self.recv(160)
        if data0:
            data = ConstBitStream(bytes=data0, length=160)
            #print "All: %s" % data.bin

            msize = data.read('intle:16')
            mtype = data.read('intle:16')
            mtime = data.read('intle:64')

            # RA:
            ant_pos = data.bitpos
            ra = data.read('hex:32')
            data.bitpos = ant_pos
            ra_uint = data.read('uintle:32')

            # DEC:
            ant_pos = data.bitpos
            dec = data.read('hex:32')
            data.bitpos = ant_pos
            dec_int = data.read('intle:32')

            logging.debug(
                "Size: %d, Type: %d, Time: %d, RA: %d (%s), DEC: %d (%s)" %
                (msize, mtype, mtime, ra_uint, ra, dec_int, dec))
            (sra, sdec, stime) = coords.eCoords2str(float("%f" % ra_uint),
                                                    float("%f" % dec_int),
                                                    float("%f" % mtime))
            #Sends back the coordinates to Stellarium
            self.act_pos(coords.hourStr_2_rad(sra), coords.degStr_2_rad(sdec))
            convdec = sdec.replace('º', 'd').replace("''",
                                                     's').replace("'", 'm')
            convra = sra.replace('h', '.').replace("m", '.').replace("s", '.')
            sra_aux = convra.split('.')
            sra_h = float(sra_aux[0])
            sra_m = float(sra_aux[1])
            sra_s = float(sra_aux[2])
            sra_d = sra_h * 15
            sra_m = sra_m * 0.25
            sra_s = sra_s * 0.00416667
            sra_sum = sra_d + sra_m + sra_s
            sra_aux1 = str(sra_sum)
            sra_aux2 = sra_aux1.split('.')
            sra_df = int(sra_aux2[0])
            sra_dec = sra_sum - sra_df
            sra_dec = sra_dec * 60
            sra_aux3 = str(sra_dec)
            sra_aux4 = sra_aux3.split('.')
            sra_mf = int(sra_aux4[0])
            sra_dec1 = sra_dec - sra_mf
            sra_dec1 = sra_dec1 * 60
            sra_aux5 = str(sra_dec1)
            sra_aux6 = sra_aux5.split('.')
            sra_sf = str(sra_aux6[0])
            sra_df = str(sra_df)
            sra_mf = str(sra_mf)
            convraf = sra_df + 'd' + sra_mf + 'm' + sra_sf + 's'
            #print(convraf)
            #print(convdec)
            Qro = EarthLocation(lat=Angle('20d35m17.02s'),
                                lon=Angle('-100d23m17.02s'),
                                height=2152 * u.m)
            # Fecha y hora
            utc_time = Time(datetime.utcnow(), scale='utc')
            time = utc_time

            # Ecuatoriales
            Objeto = SkyCoord(Angle(convraf), Angle(convdec), frame='icrs')
            # Horizontales
            Objeto = Objeto.transform_to(AltAz(obstime=time, location=Qro))

            print("Azimut: ", int(Objeto.az.degree))
            print("Altura: ", int(Objeto.alt.degree))