def start(): global stop stop = 0 Sat = e1.get() Lat = float(e2.get()) Lon = float(e3.get()) kmAlt = float(e4.get()) global ser if mode.get() == 2 or mode.get() == 3: if sys.platform == "win32": ser = serial.Serial("COM" + e5.get(), 9600, timeout=0.5) if sys.platform == "linux2": ser = serial.Serial("/dev/ttyUSB" + e5.get(), 9600, timeout=0.5) print "You are tracking " + str.upper(Sat) + "." print "You are at Lon: " + str(Lon) + " Lat: " + str( Lat) + " Altitude " + str(kmAlt) + "." line1, line2, Lat, Lon, kmAlt = GetUserData.get_user_data( "gui", Sat, Lat, Lon, kmAlt) GetSat.generate(line1, line2) GetLook.generate(Lat, Lon, kmAlt) #global timer timer = threading.Timer(0.1, fun_timer) timer.start()
def track(): receive = request.json if receive['lat'] == "update": GetUserData.update("gui") res = { 'az': "Update Done", 'el': " ", } else: receive = request.json Sat = str(receive['satname']) Lat = float(receive['lat']) Lon = float(receive['lon']) Alt = float(receive['alt']) line1, line2, Lat, Lon, Alt = GetUserData.get_user_data( "gui", Sat, Lat, Lon, Alt) GetSat.generate(line1, line2) GetLook.generate(Lat, Lon, Alt) tt = time.time() eciSat = GetSat.get_eciSat(tt) AZ, EL = GetLook.GetLook(tt, eciSat) res = {'az': AZ, 'el': EL} return jsonify(res)
def start(): # i=language.get() global stop stop = 0 Sat = e1.get() Lat = float(e2.get()) Lon = float(e3.get()) Alt = float(e4.get()) global ser if mode.get() == 2 or mode.get() == 3: if sys.platform == "win32": ser = serial.Serial("COM" + e5.get(), 2400, timeout=0.5) if sys.platform == "linux2": ser = serial.Serial("/dev/ttyUSB" + e5.get(), 2400, timeout=0.5) print "You are tracking : " + str.upper(Sat) + "." print "You are at Lat : " +str(Lat) +\ " Lon : " +str(Lon)+\ " Altitude :" +str(Alt)+"m" line1, line2, Lat, Lon, Alt = GetUserData.get_user_data( "gui", Sat, Lat, Lon, Alt) GetSat.generate(line1, line2) GetLook.generate(Lat, Lon, Alt) tt = time.time() eciSat = GetSat.get_eciSat(tt) AZ, EL = GetLook.GetLook(tt, eciSat) if EL >= 5: #pass_time , maxEL = GetLook.GetPassData(tt,eciSat) print "Passing Now ..." var_pass_time.set("Passing Now ...") #var_maxEL.set(str(maxEL)) if EL < 5: pass_time, maxEL = GetLook.GetPassData(tt, eciSat) local_time = time.localtime(pass_time) print "Next Passing Time:" + time.asctime(local_time) var_pass_time.set( str(local_time.tm_year) + "/" + str(local_time.tm_mon) + "/" + str(local_time.tm_mday) + " " + str(local_time.tm_hour) + ":" + str(local_time.tm_min) + ":" + str(local_time.tm_sec)) var_maxEL.set(str(maxEL)) #global timer timer = threading.Timer(0.1, fun_timer) timer.start()
def fun_timer(): global timer global ser tt = time.time() eciSat = GetSat.get_eciSat(tt) AZ, EL = GetLook.GetLook(tt, eciSat) #Screen Output if mode.get() == 1 or mode.get() == 3: AZ_flash.set(str(AZ)) EL_flash.set(str(EL)) #Serial Output if mode.get() == 2 or mode.get() == 3: serial_str = "AZ" + str(AZ) + " EL" + str(EL) + " Easycomm" ser.write(serial_str) if stop == 1: if mode.get() == 2 or mode.get() == 3: ser.close() #Stop fun_timer(y) if stop == 0: timer = threading.Timer(0.1, fun_timer) timer.start()
def track(satname): tt = time.time() eciSat = GetSat.get_eciSat(tt) AZ, EL = GetLook.GetLook(tt, eciSat) AZ_now = azimuth.read() #azimuth EL_now = elevation.read() #elevation time.sleep(0.5)
def fun_timer(): eciSat = GetSat.get_eciSat() tl = time.gmtime(time.time()) date_now_julian = sum( jdcal.gcal2jd(tl.tm_year, tl.tm_mon, tl.tm_mday) ) + tl.tm_hour / 24.0 + tl.tm_min / 24.0 / 60.0 + tl.tm_sec / 24.0 / 3600.0 AZ, EL = GetLook.GetLook(date_now_julian, eciSat) if mode.get() == 1 or mode.get() == 3: AZ_flash.set(str(AZ)) EL_flash.set(str(EL)) if mode.get() == 2 or mode.get() == 3: ser.write(AZ, EL) if stop == 0: timer = threading.Timer(0.1, fun_timer) timer.start()
AZ_old = 0 EL_old = 0 #----------------Big Loop---------------- while True: eciSat = GetSat.get_eciSat() tl = time.gmtime(time.time()) date_now_julian = sum( jdcal.gcal2jd(tl.tm_year, tl.tm_mon, tl.tm_mday) ) + tl.tm_hour / 24.0 + tl.tm_min / 24.0 / 60.0 + tl.tm_sec / 24.0 / 3600.0 AZ, EL = GetLook.GetLook(date_now_julian, eciSat) #date_now为Julian形式 AZ_now = azimuth.read() #azimuth EL_now = elevation.read() #elevation #--------set omega_x & omega_y----------- omega_x = kp_x * abs(e_AZ) omega_y = kp_y * abs(e_EL) #-----------------Move------------------- AZ_old = AZ EL_old = EL
ser=serial.Serial("COM1",9600,timeout=0.5) #Windows ser=serial.Serial("/dev/ttyUSB0",9600,timeout=0.5) ''' #Normal Mode GetUserData.update("shell") line1, line2, Lat, Lon, Alt = GetUserData.get_user_data( "shell", '', '', '', '') #Test Mode # line1 = "1 27607U 02058C 18338.87750224 -.00000040 00000-0 15328-4 0 9993" # line2 = "2 27607 64.5552 288.2486 0079235 293.7328 65.5477 14.75502172858143" # Lat,Lon,Alt = 30,30,0 GetSat.generate(line1, line2) GetLook.generate(Lat, Lon, Alt) # print "You are tracking : "+str.upper(Sat)+"." print "You are at Lat : "+str(Lat) +\ " Lon : "+str(Lon)+\ " Altitude :"+str(Alt)+"m\n" tt = time.time() eciSat = GetSat.get_eciSat(tt) AZ, EL = GetLook.GetLook(tt, eciSat) if EL >= 5: raw_input("Passing Now,Press ENTER to continue tracking ...") if EL < 5: pass_time, maxEL = GetLook.GetPassData(tt, eciSat)
#if you want to use serial. port_num=raw_input("Please Enter Your Serial Port Number:\n") if sys.platform == "linux2": ser=serial.Serial("COM"+porn_num,9600,timeout=0.5) if sys.platform == "win32": ser=serial.Serial("/dev/ttyUSB"+port_num,9600,timeout=0.5) ''' GetUserData.update("shell") line1,line2,Lat,Lon,kmAlt = GetUserData.get_user_data("shell",'','','','' ) GetSat.generate(line1,line2) GetLook.generate(Lat,Lon,kmAlt) while True: eciSat = GetSat.get_eciSat() tl = time.gmtime(time.time()) date_now_julian = sum(jdcal.gcal2jd(tl.tm_year,tl.tm_mon,tl.tm_mday))+tl.tm_hour/24.0+tl.tm_min/24.0/60.0+tl.tm_sec/24.0/3600.0 AZ,EL = GetLook.GetLook(date_now_julian,eciSat) print AZ,EL ''' #if you want to use serial ser.write("Whatever you need")