def save(self, soaring_spot_info): file_name = settings.current_dir + "/debug_logs/flightClassDebug.txt" if self.file_name == soaring_spot_info.file_names[0]: text_file = open(file_name, "w") # overwriting if exist else: text_file = open(file_name, "a") # appending text_file.write("file_name: " + self.file_name + "\n") text_file.write("airplane: " + self.airplane + "\n") text_file.write("competition_id: " + self.competition_id + "\n\n") print_array_debug(text_file, "tsk_t", self.tsk_t) tsk_t_temp = [""] * len(self.tsk_t) for ii in range(len(self.tsk_t)): tsk_t_temp[ii] = ss2hhmmss(self.tsk_t[ii]) print_array_debug(text_file, "tsk_t", tsk_t_temp) print_array_debug(text_file, "tsk_i", self.tsk_i) text_file.write("gps_altitude: " + str(self.gps_altitude) + "\n") text_file.write("outlanded: " + str(self.outlanded) + "\n") if self.outlanded: text_file.write("outlanding_leg: " + str(self.outlanding_leg) + "\n") text_file.write("outlanding time(UTC): " + ss2hhmmss(det_local_time(self.outlanding_b_record, 0)) + "\n") text_file.write("outlanding distance from previous tp: " + str(self.outlanding_distance) + "\n") text_file.write("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n") text_file.close()
def save(self, soaring_spot_info): file_name = settings.current_dir + "/debug_logs/flightClassDebug.txt" if self.file_name == soaring_spot_info.file_names[0]: text_file = open(file_name, "w") # overwriting if exist else: text_file = open(file_name, "a") # appending text_file.write("file_name: " + self.file_name + "\n") text_file.write("airplane: " + self.airplane + "\n") text_file.write("competition_id: " + self.competition_id + "\n\n") print_array_debug(text_file, "tsk_t", self.tsk_t) tsk_t_temp = [""] * len(self.tsk_t) for ii in range(len(self.tsk_t)): tsk_t_temp[ii] = ss2hhmmss(self.tsk_t[ii]) print_array_debug(text_file, "tsk_t", tsk_t_temp) print_array_debug(text_file, "tsk_i", self.tsk_i) text_file.write("gps_altitude: " + str(self.gps_altitude) + "\n") text_file.write("outlanded: " + str(self.outlanded) + "\n") if self.outlanded: text_file.write("outlanding_leg: " + str(self.outlanding_leg) + "\n") text_file.write( "outlanding time(UTC): " + ss2hhmmss(det_local_time(self.outlanding_b_record, 0)) + "\n") text_file.write("outlanding distance from previous tp: " + str(self.outlanding_distance) + "\n") text_file.write( "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n") text_file.close()
def save_phases(self, soaring_spot_info, flight): file_name = settings.current_dir + "/debug_logs/phasesClassPhaseDebug.txt" if flight.file_name == soaring_spot_info.file_names[0]: text_file = open(file_name, "w") # overwriting if exist else: text_file = open(file_name, "a") # appending text_file.write(flight.file_name + "\n\n") text_file.write("phases.all:\n") for entry in self.all: text_file.write(entry['phase'] + '\t' + ss2hhmmss(entry['t_start']) + '\t' + ss2hhmmss(entry['t_end']) + '\t' + str(entry['i_start']) + '\t' + str(entry['i_end']) + "\n") text_file.write("\n") for leg in range(len(self.leg)): text_file.write('leg' + str(leg) + "\n") for entry in self.leg[leg]: text_file.write(entry['phase'] + '\t' + ss2hhmmss(entry['t_start']) + '\t' + ss2hhmmss(entry['t_end']) + '\t' + str(entry['i_start']) + '\t' + str(entry['i_end']) + "\n") text_file.write("\n") text_file.write("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n") text_file.close()
def save(self): file_name = settings.current_dir + "/debug_logs/competitionDayDebug.txt" text_file = open(file_name, "w") print_array_debug(text_file, "task", self.task) print_array_debug(text_file, "task_dists", self.task_distances) text_file.write("task_date: " + self.task_date + "\n\n") text_file.write("no_tps: " + str(self.no_tps) + "\n") text_file.write("no_legs: " + str(self.no_legs) + "\n\n") text_file.write("aat: " + str(self.aat) + "\n") text_file.write("task_found: " + str(self.task_found) + "\n") text_file.write("start_opening: " + ss2hhmmss(self.start_opening) + "\n\n") text_file.close()
def determine_tsk_times(self, competition_day): leg = -1 # leg before startline is crossed possible_enl = 0 # excluding motor test for i in range(len(self.b_records)): if self.gps_altitude and det_height(self.b_records[i], False) != 0: self.gps_altitude = False t = det_local_time(self.b_records[i], competition_day.utc_to_local) if leg == -1 and t > competition_day.start_opening and i > 0: start = competition_day.task[0] if start.taskpoint_completed(self.b_records[i - 1], self.b_records[i]): self.tsk_t.append(t) self.tsk_i.append(i) self.first_start_i = i leg = 0 possible_enl = 0 elif leg == 0: if used_engine(self, i): possible_enl = determine_engine_start_i(self, i) start = competition_day.task[0] tp1 = competition_day.task[1] if start.taskpoint_completed(self.b_records[i - 1], self.b_records[i]): if self.file_name == "PR.igc": print "PR restart at t=%s" % ss2hhmmss(t) self.tsk_t[0] = t self.tsk_i[0] = i possible_enl = 0 if tp1.taskpoint_completed(self.b_records[i - 1], self.b_records[i]): self.tsk_t.append(t) self.tsk_i.append(i) leg += 1 elif 0 < leg < competition_day.no_tps: if used_engine(self, i): possible_enl = determine_engine_start_i(self, i) break next_tp = competition_day.task[leg+1] if next_tp.taskpoint_completed(self.b_records[i - 1], self.b_records[i]): self.tsk_t.append(t) self.tsk_i.append(i) leg += 1 elif leg == competition_day.no_legs - 1: if used_engine(self, i): possible_enl = determine_engine_start_i(self, i) break finish = competition_day.task[-1] if finish.taskpoint_completed(self.b_records[i - 1], self.b_records[i]): self.tsk_t.append(t) self.tsk_i.append(i) leg += 1 b_record1 = self.b_records[self.tsk_i[0]-1] b_record2 = self.b_records[self.tsk_i[0]] self.tsk_t[0] -= self.start_refinement(competition_day, b_record1, b_record2) self.tsk_t[0] -= 1 # Soaring spot takes point before start line! if not possible_enl == 0: self.outlanding_b_record = self.b_records[possible_enl] if not possible_enl == 0 or len(self.tsk_t) != competition_day.no_legs + 1: self.outlanded = True self.outlanding_leg = len(self.tsk_t)-1 self.determine_outlanding_location(competition_day)
def __init__(self, competition_day, flight): self.tsk_distance_all = sum(competition_day.task_distances) self.tsk_distance_leg = competition_day.task_distances self.no_cruises = flight.phases.cruises_all self.no_cruises_leg = flight.phases.cruises_leg self.no_thermals = flight.phases.thermals_all self.no_thermals_leg = flight.phases.thermals_leg startheight = det_height(flight.b_records[flight.tsk_i[0]], flight.gps_altitude) finish_height = det_height(flight.b_records[flight.tsk_i[-1]], flight.gps_altitude) if flight.outlanded: s_flown_task_all = 0 for leg in range(flight.outlanding_leg): s_flown_task_all += competition_day.task_distances[leg] s_flown_task_all += flight.outlanding_distance s_flown_task_all /= 1000 else: s_flown_task_all = sum(competition_day.task_distances) / 1000 self.all = {"ranking": flight.ranking, "airplane": flight.airplane, "compID": flight.competition_id, "t_start": ss2hhmmss(flight.tsk_t[0]), "t_finish": ss2hhmmss(flight.tsk_t[-1]), "h_start": startheight, "h_finish": finish_height, "s_flown_task": s_flown_task_all} self.leg = [] # in case of outlanding: only performance is stored from completed legs for leg in range(competition_day.no_legs): if flight.outlanded and leg == flight.outlanding_leg: t_start = flight.tsk_t[leg] t_finish = 0 s_flown_task_leg = flight.outlanding_distance / 1000 startheight = det_height(flight.b_records[flight.tsk_i[leg]], flight.gps_altitude) finish_height = 0 elif flight.outlanded and leg > flight.outlanding_leg: t_start = 0 t_finish = 0 s_flown_task_leg = 0 startheight = 0 finish_height = 0 else: t_start = flight.tsk_t[leg] t_finish = flight.tsk_t[leg+1] s_flown_task_leg = competition_day.task_distances[leg] / 1000 startheight = det_height(flight.b_records[flight.tsk_i[leg]], flight.gps_altitude) finish_height = det_height(flight.b_records[flight.tsk_i[leg+1]], flight.gps_altitude) self.leg.append({"ranking": self.all["ranking"], "airplane": self.all["airplane"], "compID": self.all["compID"], "t_start": ss2hhmmss(t_start), "t_finish": ss2hhmmss(t_finish), "h_start": startheight, "h_finish": finish_height, "s_flown_task": s_flown_task_leg})
def determine_tsk_times(self, competition_day): leg = -1 # leg before startline is crossed possible_enl = 0 # excluding motor test for i in range(len(self.b_records)): if self.gps_altitude and det_height(self.b_records[i], False) != 0: self.gps_altitude = False t = det_local_time(self.b_records[i], competition_day.utc_to_local) if leg == -1 and t > competition_day.start_opening and i > 0: start = competition_day.task[0] if start.taskpoint_completed(self.b_records[i - 1], self.b_records[i]): self.tsk_t.append(t) self.tsk_i.append(i) self.first_start_i = i leg = 0 possible_enl = 0 elif leg == 0: if used_engine(self, i): possible_enl = determine_engine_start_i(self, i) start = competition_day.task[0] tp1 = competition_day.task[1] if start.taskpoint_completed(self.b_records[i - 1], self.b_records[i]): if self.file_name == "PR.igc": print "PR restart at t=%s" % ss2hhmmss(t) self.tsk_t[0] = t self.tsk_i[0] = i possible_enl = 0 if tp1.taskpoint_completed(self.b_records[i - 1], self.b_records[i]): self.tsk_t.append(t) self.tsk_i.append(i) leg += 1 elif 0 < leg < competition_day.no_tps: if used_engine(self, i): possible_enl = determine_engine_start_i(self, i) break next_tp = competition_day.task[leg + 1] if next_tp.taskpoint_completed(self.b_records[i - 1], self.b_records[i]): self.tsk_t.append(t) self.tsk_i.append(i) leg += 1 elif leg == competition_day.no_legs - 1: if used_engine(self, i): possible_enl = determine_engine_start_i(self, i) break finish = competition_day.task[-1] if finish.taskpoint_completed(self.b_records[i - 1], self.b_records[i]): self.tsk_t.append(t) self.tsk_i.append(i) leg += 1 b_record1 = self.b_records[self.tsk_i[0] - 1] b_record2 = self.b_records[self.tsk_i[0]] self.tsk_t[0] -= self.start_refinement(competition_day, b_record1, b_record2) self.tsk_t[0] -= 1 # Soaring spot takes point before start line! if not possible_enl == 0: self.outlanding_b_record = self.b_records[possible_enl] if not possible_enl == 0 or len( self.tsk_t) != competition_day.no_legs + 1: self.outlanded = True self.outlanding_leg = len(self.tsk_t) - 1 self.determine_outlanding_location(competition_day)