Beispiel #1
0
 def move(self, ac, alt):
     logging.debug("(%s, %s)" % (ac, alt))
     self.serial.write('move')
     if(self.serial.readline().rstrip() == 'float'):
         self.serial.write( coords.rad_2_radStr(6.283185 - coords.degStr_2_rad(ac)) )
         self.serial.write( coords.rad_2_radStr(coords.degStr_2_rad(alt)) )
         self.serial.write( coords.rad_2_radStr(coords.hourStr_2_rad(strftime("%Hh%Mm%Ss", localtime()))) )
         self.sread(wait=10)
Beispiel #2
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()
    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))
    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)
Beispiel #6
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))
Beispiel #7
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)
Beispiel #8
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))
    def goto(self, ra, dec, time):
        Lon = 72.82
        Lat = 18.96
        Alt = 0.01
        ra_rad = coords.hourStr_2_rad(ra)
        dec_rad = coords.degStr_2_rad(dec)
        Az, El = RADec2AzEl(
            float(ra_rad) * 180 / math.pi,
            float(dec_rad) * 180 / math.pi, Lat, Lon, Alt)

        Az, El = Az * math.pi / 180.0, El * math.pi / 180.0

        # logging.debug("(%s, %s, %s)" % (ra, dec, time))
        logging.debug("(%s, %s, %s)" % (Az, El, time))
        self.serial.write('goto')

        # print 'hey bhagawan!! ', coords.rad_2_radStr(Az), coords.rad_2_radStr(coords.hourStr_2_rad(ra))

        if (self.serial.readline().rstrip() == 'float'):
            # print 'kya fart hai'
            # self.serial.write( coords.rad_2_radStr(coords.hourStr_2_rad(ra)) )
            # self.serial.write( coords.rad_2_radStr(coords.degStr_2_rad(dec)) )
            # self.serial.write( coords.rad_2_radStr(coords.hourStr_2_rad(time)) )
            self.serial.write(coords.rad_2_radStr(Az))
            # print 'size of Az', len(coords.rad_2_radStr(Az))
            self.serial.write(coords.rad_2_radStr(El))
            # print 'size of El', len(coords.rad_2_radStr(El))
            self.serial.write(coords.rad_2_radStr(coords.hourStr_2_rad(time)))
            self.sread(wait=10)
 def sread(self, expect='^cmd$', wait=0):
     _d = None
     exp = re.compile(expect)
     line = self.serial.readline().rstrip()
     tag_steps = re.compile('^p_.*$')
     tag_horizontal = re.compile('^h_.*$')
     tag_equatorial = re.compile('^e_.*$')
     _count = 0
     while (not exp.match(line) and _count <= wait):
         if tag_steps.match(line):
             resp = line.replace("p_", '')
             _d = resp.split(' ')
             logging.debug("Steps: (%s, %s)" % (_d[0], _d[1]))
         elif tag_horizontal.match(line):
             resp = line.replace("h_", '')
             _d = resp.split(' ')
             self.pos_received.emit(_d[0], _d[1])
             logging.debug(
                 "PosH: (%s / %s)" %
                 (coords.deg_2_degStr(360.0 - coords.radStr_2_deg(_d[0])),
                  coords.deg_2_degStr(coords.radStr_2_deg(_d[1]))))
         elif tag_equatorial.match(line):
             resp = line.replace("e_", '')
             _d = resp.split(' ')
             self.pos_e_received.emit(_d[0], _d[1])
             logging.debug("PosE: (%s / %s)" % ( \
                 coords.hour_2_hourStr(coords.rad_2_hour(coords.degStr_2_rad(coords.radStr_2_degStr(_d[0])))), \
                 coords.deg_2_degStr(coords.radStr_2_deg(_d[1])) ))
         if line == '':
             _count += 1
         else:
             print("__debug__: %s" % line)
         line = self.serial.readline().rstrip()
     return line
Beispiel #11
0
    def writeInfo(self):
        self.mg = 1

        self.newRA = 180 * coords.hourStr_2_rad(self.sra) / (math.pi * 15)
        self.newDEC = 180 * coords.degStr_2_rad(self.sdec) / math.pi

        self.ecuToalaz = EcuToHor(self.newRA, self.newDEC, self.lat, self.lon)
        (self.az, self.el) = self.ecuToalaz.getHor()

        if self.sweep == True:

            self.az = self.az - (self.tamanox / 2) + self.g * self.pasox
            self.el = self.el + (self.tamanoy / 2) - self.j * self.pasoy

            if self.i >= self.totalx:
                self.i = 0
                self.j = self.j + 1
                self.k = not self.k
                if self.j > self.totaly:
                    self.j = 0
                    self.g = 0
                    self.stop()
            else:
                self.i = self.i + 1
                if self.k == False:
                    self.g = self.g + 1
                else:
                    self.g = self.g - 1

        self.textEdit_11.setText('{0:.4f}'.format(self.az))
        self.textEdit_12.setText('{0:.4f}'.format(self.el))

        self.acumWord()
 def sread(self, expect='^cmd$', wait=0):
     _d = None
     exp = re.compile(expect)
     line = self.serial.readline().rstrip()
     tag_steps = re.compile('^p_.*$')
     tag_horizontal = re.compile('^h_.*$')
     tag_equatorial = re.compile('^e_.*$')
     _count = 0
     while(not exp.match(line) and _count <= wait):
         if tag_steps.match(line):
             resp = line.replace("p_", '')
             _d = resp.split(' ')
             logging.debug("Steps: (%s, %s)" % (_d[0], _d[1]))
         elif tag_horizontal.match(line):
             resp = line.replace("h_", '')
             _d = resp.split(' ')
             self.pos_received.emit(_d[0], _d[1])
             logging.debug("PosH: (%s / %s)" % ( coords.deg_2_degStr( 360.0 - coords.radStr_2_deg(_d[0])), coords.deg_2_degStr( coords.radStr_2_deg(_d[1])) ))
         elif tag_equatorial.match(line):
             resp = line.replace("e_", '')
             _d = resp.split(' ')
             self.pos_e_received.emit(_d[0], _d[1])
             logging.debug("PosE: (%s / %s)" % ( \
                 coords.hour_2_hourStr(coords.rad_2_hour(coords.degStr_2_rad(coords.radStr_2_degStr(_d[0])))), \
                 coords.deg_2_degStr(coords.radStr_2_deg(_d[1])) ))
         if line == '':
             _count += 1
         else:
             print("__debug__: %s" % line)
         line = self.serial.readline().rstrip()
     return line
Beispiel #13
0
 def goto(self, ra, dec, time):
     logging.debug("(%s, %s, %s)" % (ra, dec, time))
     self.serial.write('goto')
     if(self.serial.readline().rstrip() == 'float'):
         self.serial.write( coords.rad_2_radStr(coords.hourStr_2_rad(ra)) )
         self.serial.write( coords.rad_2_radStr(coords.degStr_2_rad(dec)) )
         self.serial.write( coords.rad_2_radStr(coords.hourStr_2_rad(time)) )
         self.sread(wait=10)
 def setRef(self, id_ref, ra, dec, time):
     setf = {1: 'set1', 2: 'set2', 3: 'set3'}
     logging.debug(" %s(%s, %s, %s)" % (setf[id_ref], ra, dec, time))
     self.serial.write(setf[id_ref])
     if (self.serial.readline().rstrip() == 'float'):
         self.serial.write(coords.rad_2_radStr(coords.hourStr_2_rad(ra)))
         self.serial.write(coords.rad_2_radStr(coords.degStr_2_rad(dec)))
         self.serial.write(coords.rad_2_radStr(coords.hourStr_2_rad(time)))
         self.sread(wait=5)
 def setRef(self, id_ref, ra, dec, time):
     setf = {1: 'set1', 2: 'set2', 3: 'set3'}
     logging.debug(" %s(%s, %s, %s)" % (setf[id_ref], ra, dec, time))
     self.serial.write(setf[id_ref])
     if(self.serial.readline().rstrip() == 'float'):
         self.serial.write( coords.rad_2_radStr(coords.hourStr_2_rad(ra)) )
         self.serial.write( coords.rad_2_radStr(coords.degStr_2_rad(dec)) )
         self.serial.write( coords.rad_2_radStr(coords.hourStr_2_rad(time)) )
         self.sread(wait=5)
    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 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()
Beispiel #18
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))
 def set_reference(self, ra, dec):
     ra = coords.hourStr_2_rad(ra)
     dec = coords.degStr_2_rad(dec)
     self.refs.append((ra, dec))