def generate(self, logged=False): if logged: logging.debug('Group splits generate for ' + self.group.name) # to have group count ResultCalculation(self.race).get_group_persons(self.group) for i in ResultCalculation(self.race).get_group_finishes(self.group): self.person_splits.append(PersonSplits(self.race, i).generate()) self.set_places() if self.group.is_relay(): self.sort_by_place() else: self.sort_by_result() return self
def apply_changes_impl(self): obj = race() start_date = self.item_start_date.dateTime().toPython() end_date = self.item_end_date.dateTime().toPython() obj.data.title = self.item_main_title.text() obj.data.description = self.item_sub_title.toPlainText() obj.data.description = obj.data.description.replace('\n', '<br>\n') obj.data.location = self.item_location.text() obj.data.url = self.item_url.text() obj.data.chief_referee = self.item_refery.text() obj.data.secretary = self.item_secretary.text() obj.data.start_datetime = start_date obj.data.end_datetime = end_date t = RaceType.get_by_name(self.item_type.currentText()) if t is not None: obj.data.race_type = t obj.data.relay_leg_count = self.item_relay_legs.value() obj.set_setting('system_zero_time', (start_date.hour, start_date.minute, 0)) ResultCalculation(race()).process_results() GlobalAccess().get_main_window().set_title()
def reverse_start_time(): obj = race() handicap_start = OTime(msec=obj.get_setting('handicap_start', OTime(hour=11).to_msec())) handicap_interval = OTime(msec=obj.get_setting('handicap_interval', OTime(minute=30).to_msec())) handicap_dsg_offset = OTime( msec=obj.get_setting('handicap_dsg_offset', OTime(minute=10).to_msec())) rc = ResultCalculation(obj) for group in obj.groups: results = rc.get_group_finishes(group) # get sorted results first_group = [] second_group = [] for result in results: assert isinstance(result, Result) if result.status == ResultStatus.OK and result.person: second_group.append(result.person) # reverse main group, leader should be last second_group.reverse() persons = rc.get_group_persons(group) for person in persons: if person not in second_group: first_group.append(person) # first process DSQ and DNS - toss them first_group = DrawManager(obj).process_array(first_group, False, True, False) cur_time = handicap_start for person in first_group: assert isinstance(person, Person) person.start_time = cur_time cur_time += handicap_interval # add offset after DSQ and DNS cur_time += handicap_dsg_offset - handicap_interval # set time for main group for person in second_group: assert isinstance(person, Person) person.start_time = cur_time cur_time += handicap_interval
def execute(self): logging.debug('Penalty removing start') for result in race().results: result.penalty_time = OTime(msec=0) result.penalty_laps = 0 logging.debug('Penalty removing finish') ResultCalculation(race()).process_results() self.app.refresh()
def execute(self): logging.debug('Penalty calculation start') for result in race().results: if result.person is not None: ResultChecker.calculate_penalty(result) logging.debug('Penalty calculation finish') ResultCalculation(race()).process_results() self.app.refresh()
def _delete_object(self): indexes = self.get_selected_rows() if not len(indexes): return confirm = messageBoxQuestion(self, _('Question'), _('Please confirm'), QMessageBox.Yes | QMessageBox.No) if confirm == QMessageBox.No: return tab = self.current_tab res = [] if tab == 0: res = race().delete_persons(indexes) ResultCalculation(race()).process_results() self.refresh() elif tab == 1: res = race().delete_results(indexes) ResultCalculation(race()).process_results() self.refresh() elif tab == 2: try: res = race().delete_groups(indexes) except NotEmptyException as e: logging.warning(str(e)) QMessageBox.question(self.get_group_table(), _('Error'), _('Cannot remove group')) self.refresh() elif tab == 3: try: res = race().delete_courses(indexes) except NotEmptyException as e: logging.warning(str(e)) QMessageBox.question(self.get_course_table(), _('Error'), _('Cannot remove course')) self.refresh() elif tab == 4: try: res = race().delete_organizations(indexes) except NotEmptyException as e: logging.warning(str(e)) QMessageBox.question(self.get_organization_table(), _('Error'), _('Cannot remove organization')) self.refresh() if len(res): Teamwork().delete([r.to_dict() for r in res])
def load(file): event, current_race = get_races_from_file(file) new_event(event) set_current_race_index(current_race) obj = race() ResultChecker.check_all() ResultCalculation(obj).process_results() RaceSplits(obj).generate() ScoreCalculation(obj).calculate_scores()
def apply_changes_impl(self): for i in Qualification: name = i.name if i in self.group.ranking.rank: rank = self.group.ranking.rank[i] assert isinstance(rank, RankingItem) rank.is_active = self.findChild(QCheckBox, name + '_checkbox').isChecked() rank.max_place = self.findChild(QSpinBox, name + '_place').value() rank.max_time = time_to_otime(self.findChild(QTimeEdit, name + '_time').time()) rank.use_scores = self.findChild(AdvComboBox, name + '_combo').currentText() == _('Rank') ResultCalculation(race()).set_rank(self.group)
def handicap_start_time(): obj = race() handicap_start = OTime(msec=obj.get_setting('handicap_start', OTime(hour=11).to_msec())) handicap_max_gap = OTime(msec=obj.get_setting('handicap_max_gap', OTime(minute=30).to_msec())) handicap_second_start = OTime( msec=obj.get_setting('handicap_second_start', OTime(hour=11, minute=30).to_msec())) handicap_interval = OTime(msec=obj.get_setting('handicap_interval', OTime(minute=30).to_msec())) rc = ResultCalculation(obj) for group in obj.groups: results = rc.get_group_finishes(group) # get sorted results leader_time = rc.get_group_leader_time(group) changed_persons = [] current_second_group_time = handicap_second_start for result in results: assert isinstance(result, Result) cur_time = result.get_result_otime() gap = cur_time - leader_time if gap < handicap_max_gap and result.status == ResultStatus.OK: start_time = handicap_start + gap else: start_time = current_second_group_time current_second_group_time += handicap_interval if result.person: result.person.start_time = start_time changed_persons.append(result.person) # also process people without finish (DNS) persons = rc.get_group_persons(group) for person in persons: if person not in changed_persons: person.start_time = current_second_group_time current_second_group_time += handicap_interval
def teamwork(self, command): try: race().update_data(command.data) logging.info(repr(command.data)) if 'object' in command.data and command.data['object'] in [ 'ResultManual', 'ResultSportident', 'ResultSFR', 'ResultSportiduino' ]: ResultCalculation(race()).process_results() Broker().produce('teamwork_recieving', command.data) self.refresh() except Exception as e: logging.error(str(e))
def load(file): data = json.load(file) event = [] for race_dict in data['races']: race_migrate(race_dict) obj = Race() obj.id = uuid.UUID(str(race_dict['id'])) obj.update_data(race_dict) event.append(obj) new_event(event) if 'current_race' in data: set_current_race_index(data['current_race']) obj = race() ResultChecker.check_all() ResultCalculation(obj).process_results() RaceSplits(obj).generate() ScoreCalculation(obj).calculate_scores()
def get_leader_time(self, result): # find leader time in group if result and isinstance(result, Result): if result.person and result.person.group: group = result.person.group results = ResultCalculation( self.race).get_group_finishes(group) best_time = None for cur_result in results: assert isinstance(cur_result, Result) if self.race.get_type(group) == RaceType.RELAY: cur_time = get_team_result(result.person) else: cur_time = cur_result.get_result_otime() if not best_time or cur_time < best_time: best_time = cur_time return best_time return None
def add_sportident_result_from_sireader(self, result): try: assignment_mode = race().get_setting('system_assignment_mode', False) if not assignment_mode: self.clear_filters(remove_condition=False) rg = ResultSportidentGeneration(result) if rg.add_result(): result = rg.get_result() ResultCalculation(race()).process_results() if race().get_setting('split_printout', False): try: split_printout(result) except NoResultToPrintException as e: logging.error(str(e)) except NoPrinterSelectedException as e: logging.error(str(e)) except Exception as e: logging.error(str(e)) elif result.person and result.person.group: GroupSplits(race(), result.person.group).generate(True) Teamwork().send(result.to_dict()) TelegramClient().send_result(result) if result.person: if result.is_status_ok(): Sound().ok() else: Sound().fail() if result.person.is_rented_card or RentCards().exists( result.person.card_number): Sound().rented_card() else: for person in race().persons: if not person.card_number: old_person = race().person_card_number( person, result.card_number) if old_person is not None: Teamwork().send(old_person.to_dict()) person.is_rented_card = True Teamwork().send(person.to_dict()) break self.refresh() except Exception as e: logging.error(str(e))
def apply_changes_impl(self): number = self.item_number.value() if not number: return obj = race() is_course = self.item_is_course.isChecked() if is_course: courses = obj.courses for course in courses: controls = [] for i, control in enumerate(course.controls): if str(number) == control.code: if i < len(course.controls) - 1: course.controls[i + 1].length += control.length logging.info('Del {} from {}'.format( number, course.name)) else: controls.append(control) course.controls = controls is_result = self.item_is_result.isChecked() if is_result: results = obj.results for result in results: splits = [] for split in result.splits: if str(number) == str(split.code): logging.info('Del {} from {} {}'.format( number, result.card_number, split.time)) else: splits.append(split) result.splits = splits obj.clear_results() ResultChecker.check_all() ResultCalculation(obj).process_results() RaceSplits(obj).generate() ScoreCalculation(obj).calculate_scores() GlobalAccess().get_main_window().refresh()
def apply_changes_impl(self): course = self.current_object if self.is_new: race().courses.insert(0, course) if course.name != self.item_name.text(): course.name = self.item_name.text() if course.length != self.item_length.value(): course.length = self.item_length.value() if course.climb != self.item_climb.value(): course.climb = self.item_climb.value() text = self.item_controls.toPlainText() course.controls.clear() for i in text.split('\n'): control = CourseControl() if i is None or len(i) == 0: continue control.code = i.split()[0] if len(i.split()) > 1: try: control.length = int(i.split()[1]) except Exception as e: logging.error(str(e)) control.length = 0 course.controls.append(control) obj = race() ResultChecker.check_all() ResultCalculation(obj).process_results() RaceSplits(obj).generate() ScoreCalculation(obj).calculate_scores() GlobalAccess().get_main_window().refresh() Teamwork().send(course.to_dict())
def create_objects(self): """Create objects in memory, according to model""" my_race = race() assert(isinstance(my_race, Race)) my_race.data.title = '\n'.join(self.wdb_object.info.title) my_race.data.location = self.wdb_object.info.place my_race.data.chief_referee = self.wdb_object.info.referee my_race.data.secretary = self.wdb_object.info.secretary for team in self.wdb_object.team: assert (isinstance(team, WDBTeam)) new_team = Organization() new_team.name = team.name new_team.address = Address() new_team.contact = Contact() my_race.organizations.append(new_team) for course in self.wdb_object.dist: assert (isinstance(course, WDBDistance)) new_course = Course() new_course.controls = [] new_course.name = course.name new_course.climb = course.elevation new_course.length = course.length # new_course.type = self.wdb_object.info.type # TODO parse type # controls for i in range(course.point_quantity): control = CourseControl() control.code = str(course.point[i]) if i < len(course.leg): control.length = course.leg[i] new_course.controls.append(control) my_race.courses.append(new_course) for group in self.wdb_object.group: assert (isinstance(group, WDBGroup)) new_group = Group() new_group.name = group.name new_group.price = group.owner_cost course = group.get_course() if course is not None: new_group.course = find(race().courses, name=course.name) my_race.groups.append(new_group) for man in self.wdb_object.man: assert (isinstance(man, WDBMan)) new_person = Person() new_person.surname = man.name.split(" ")[0] new_person.name = man.name.split(" ")[-1] new_person.bib = man.number if man.qualification: if man.qualification == 10: man.qualification = Qualification.MSMK.value # Convert ZMS to MSMK new_person.qual = Qualification.get_qual_by_code(man.qualification) new_person.set_year(man.year) race().person_card_number(new_person, man.si_card) new_person.is_out_of_competition = man.is_not_qualified new_person.comment = man.comment new_person.start_group = man.start_group found_group = man.get_group() if found_group: group_name = found_group.name new_person.group = find(race().groups, name=group_name) found_team = man.get_team() if found_team: team_name = found_team.name new_person.organization = find(race().organizations, name=team_name) my_race.persons.append(new_person) new_person.start_time = int_to_otime(man.start) # result fin = man.get_finish() if fin is not None: result = ResultSportident() result.person = new_person result.card_number = int(man.si_card) result.start_time = int_to_otime(man.start) result.finish_time = int_to_otime(fin.time) result.penalty_time = OTime(sec = man.penalty_second) if man.status in self.status: result.status = self.status[man.status] my_race.add_result(result) # splits chip = man.get_chip() if chip is not None: result.splits = [] for i in range(chip.quantity): p = chip.punch[i] assert isinstance(p, WDBPunch) code = p.code time = int_to_otime(p.time) split = Split() split.code = str(code) split.time = time if code > 0: result.splits.append(split) ResultCalculation(race()).process_results()
def apply_changes_impl(self): person = self.current_object assert (isinstance(person, Person)) if self.is_new: race().persons.insert(0, person) if person.name != self.item_name.currentText(): person.name = self.item_name.currentText() if person.surname != self.item_surname.text(): person.surname = self.item_surname.text() if (person.group is not None and person.group.name != self.item_group.currentText()) or\ (person.group is None and len(self.item_group.currentText()) > 0): person.group = find(race().groups, name=self.item_group.currentText()) if (person.organization is not None and person.organization.name != self.item_team.currentText()) or \ (person.organization is None and len(self.item_team.currentText()) > 0): organization = find(race().organizations, name=self.item_team.currentText()) if organization is None: organization = Organization() organization.name = self.item_team.currentText() race().organizations.append(organization) Teamwork().send(organization.to_dict()) person.organization = organization if person.qual.get_title() != self.item_qual.currentText(): person.qual = Qualification.get_qual_by_name( self.item_qual.currentText()) if person.bib != self.item_bib.value(): person.bib = self.item_bib.value() new_time = time_to_otime(self.item_start.time()) if person.start_time != new_time: person.start_time = new_time if person.start_group != self.item_start_group.value( ) and self.item_start_group.value(): person.start_group = self.item_start_group.value() if (not person.card_number or int(person.card_number) != self.item_card.value()) \ and self.item_card.value: race().person_card_number(person, self.item_card.value()) if person.is_out_of_competition != self.item_out_of_competition.isChecked( ): person.is_out_of_competition = self.item_out_of_competition.isChecked( ) if person.is_paid != self.item_paid.isChecked(): person.is_paid = self.item_paid.isChecked() if person.is_rented_card != self.item_rented.isChecked(): person.is_rented_card = self.item_rented.isChecked() if person.is_personal != self.item_personal.isChecked(): person.is_personal = self.item_personal.isChecked() if person.comment != self.item_comment.toPlainText(): person.comment = self.item_comment.toPlainText() use_birthday = Config().configuration.get('use_birthday', False) if use_birthday: new_birthday = qdate_to_date(self.item_birthday.date()) if person.birth_date != new_birthday and new_birthday: if person.birth_date or new_birthday != date.today(): person.birth_date = new_birthday else: if person.get_year() != self.item_year.value(): person.set_year(self.item_year.value()) ResultCalculation(race()).process_results() Teamwork().send(person.to_dict())
def apply_changes_impl(self): result = self.current_object if self.is_new: race().results.insert(0, result) if result.is_punch(): if result.card_number != self.item_card_number.value(): result.card_number = self.item_card_number.value() new_splits = self.splits.splits() if len(result.splits) == len(new_splits): for i, split in enumerate(result.splits): if split != new_splits[i]: break result.splits = new_splits time_ = time_to_otime(self.item_finish.time()) if result.finish_time != time_: result.finish_time = time_ time_ = time_to_otime(self.item_start.time()) if result.start_time != time_: result.start_time = time_ time_ = time_to_otime(self.item_credit.time()) if result.credit_time != time_: result.credit_time = time_ time_ = time_to_otime(self.item_penalty.time()) if result.penalty_time != time_: result.penalty_time = time_ if result.penalty_laps != self.item_penalty_laps.value(): result.penalty_laps = self.item_penalty_laps.value() cur_bib = -1 new_bib = self.item_bib.value() if result.person: cur_bib = result.person.bib if new_bib == 0: if result.person and result.is_punch(): if result.person.card_number == result.card_number: result.person.card_number = 0 result.person = None elif cur_bib != new_bib: new_person = find(race().persons, bib=new_bib) if new_person is not None: assert isinstance(new_person, Person) if result.person: if result.is_punch(): result.person.card_number = 0 result.person = new_person if result.is_punch(): race().person_card_number(result.person, result.card_number) result.bib = new_bib GlobalAccess().get_main_window().get_result_table().model().init_cache() if self.item_days.value() != result.days: result.days = self.item_days.value() result.status = ResultStatus.get_by_name(self.item_status.currentText()) status = StatusComments().remove_hint(self.item_status_comment.currentText()) if result.status_comment != status: result.status_comment = status if result.is_punch(): result.clear() try: ResultChecker.checking(result) ResultChecker.calculate_penalty(result) if result.person and result.person.group: GroupSplits(race(), result.person.group).generate(True) except ResultCheckerException as e: logging.error(str(e)) ResultCalculation(race()).process_results() Teamwork().send(result.to_dict())
def apply_changes_impl(self): obj = race() mw = GlobalAccess().get_main_window() map_items = [ obj.persons, obj.results, obj.groups, obj.courses, obj.organizations ] map_names = [ 'persons', 'results', 'groups', 'courses', 'organizations' ] selected_items = { 'persons': [], 'results': [], 'groups': [], 'courses': [], 'organizations': [], } template_path = self.item_template.currentText() _settings['last_template'] = template_path _settings['open_in_browser'] = self.item_open_in_browser.isChecked() _settings['save_to_last_file'] = self.item_save_to_last_file.isChecked( ) _settings['selected'] = self.item_selected.isChecked() if _settings['selected']: cur_items = map_items[mw.current_tab] for i in mw.get_selected_rows(): selected_items[map_names[mw.current_tab]].append( cur_items[i].to_dict()) ResultCalculation(obj).process_results() RaceSplits(obj).generate() ScoreCalculation(obj).calculate_scores() races_dict = [r.to_dict() for r in races()] template = get_text_from_file( template_path, race=races_dict[get_current_race_index()], races=races_dict, current_race=get_current_race_index(), selected=selected_items) if _settings['save_to_last_file']: file_name = _settings['last_file'] else: file_name = get_save_file_name( _('Save As HTML file'), _("HTML file (*.html)"), '{}_report'.format( obj.data.get_start_datetime().strftime("%Y%m%d"))) if file_name: _settings['last_file'] = file_name with codecs.open(file_name, 'w', 'utf-8') as file: file.write(template) file.close() # Open file in your browser if _settings['open_in_browser']: webbrowser.open('file://' + file_name, new=2)
def apply_changes_impl(self): group = self.current_object assert (isinstance(group, Group)) if self.is_new: race().groups.insert(0, group) if group.name != self.item_name.text(): group.name = self.item_name.text() if group.long_name != self.item_full_name.text(): group.long_name = self.item_full_name.text() if (group.course is not None and group.course.name != self.item_course.currentText()) \ or (group.course is None and len(self.item_course.currentText()) > 0): group.course = find(race().courses, name=self.item_course.currentText()) if group.sex.get_title() != self.item_sex.currentText(): group.sex = Sex(self.item_sex.currentIndex()) if group.min_age != self.item_age_min.value(): group.min_age = self.item_age_min.value() if group.max_age != self.item_age_max.value(): group.max_age = self.item_age_max.value() if group.min_year != self.item_year_min.value(): group.min_year = self.item_year_min.value() if group.max_year != self.item_year_max.value(): group.max_year = self.item_year_max.value() if group.start_corridor != self.item_corridor.value(): group.start_corridor = self.item_corridor.value() if group.order_in_corridor != self.item_corridor_order.value(): group.order_in_corridor = self.item_corridor_order.value() if group.price != self.item_price.value(): group.price = self.item_price.value() time = time_to_otime(self.item_start_interval.time()) if group.start_interval != time: group.start_interval = time time = time_to_otime(self.item_max_time.time()) if group.max_time != time: group.max_time = time if group.ranking.is_active != self.rank_checkbox.isChecked(): group.ranking.is_active = self.rank_checkbox.isChecked() t = RaceType.get_by_name(self.type_combo.currentText()) selected_type = t if t is not None else group.get_type() if group.get_type() != selected_type: group.set_type(selected_type) group.is_any_course = self.item_is_any_course.isChecked() ResultCalculation(race()).set_rank(group) Teamwork().send(group.to_dict())
def apply_changes_impl(self): obj = race() mw = GlobalAccess().get_main_window() map_items = [obj.persons, obj.results, obj.groups, obj.courses, obj.organizations] map_names = ['persons', 'results', 'groups', 'courses', 'organizations'] selected_items = { 'persons': [], 'results': [], 'groups': [], 'courses': [], 'organizations': [], } template_path = self.item_template.currentText() _settings['last_template'] = template_path _settings['open_in_browser'] = self.item_open_in_browser.isChecked() _settings['save_to_last_file'] = self.item_save_to_last_file.isChecked() _settings['selected'] = self.item_selected.isChecked() if _settings['selected']: cur_items = map_items[mw.current_tab] for i in mw.get_selected_rows(): selected_items[map_names[mw.current_tab]].append(cur_items[i].to_dict()) ResultCalculation(obj).process_results() RaceSplits(obj).generate() ScoreCalculation(obj).calculate_scores() races_dict = [r.to_dict() for r in races()] if template_path.endswith('.docx'): # DOCX template processing full_path = config.template_dir() + template_path doc = DocxTemplate(full_path) context = {} context['race'] = races_dict[get_current_race_index()] context['name'] = config.NAME context['version'] = str(config.VERSION) doc.render(context) if _settings['save_to_last_file']: file_name = _settings['last_file'] else: file_name = get_save_file_name(_('Save As MS Word file'), _("MS Word file (*.docx)"), '{}_official'.format(obj.data.get_start_datetime().strftime("%Y%m%d"))) if file_name: doc.save(file_name) os.startfile(file_name) else: template = get_text_from_file( template_path, race=races_dict[get_current_race_index()], races=races_dict, rent_cards=list(RentCards().get()), current_race=get_current_race_index(), selected=selected_items ) if _settings['save_to_last_file']: file_name = _settings['last_file'] else: file_name = get_save_file_name(_('Save As HTML file'), _("HTML file (*.html)"), '{}_report'.format(obj.data.get_start_datetime().strftime("%Y%m%d"))) if len(file_name): _settings['last_file'] = file_name with codecs.open(file_name, 'w', 'utf-8') as file: file.write(template) file.close() # Open file in your browser if _settings['open_in_browser']: webbrowser.open('file://' + file_name, new=2)
def apply_changes_impl(self): obj = race() start_source = 'protocol' if self.item_start_station.isChecked(): start_source = 'station' elif self.item_start_cp.isChecked(): start_source = 'cp' elif self.item_start_gate.isChecked(): start_source = 'gate' finish_source = 'station' if self.item_finish_cp.isChecked(): finish_source = 'cp' elif self.item_finish_beam.isChecked(): finish_source = 'beam' assign_chip_reading = 'off' if self.chip_reading_unknown.isChecked(): assign_chip_reading = 'only_unknown_members' elif self.chip_reading_always.isChecked(): assign_chip_reading = 'always' start_cp_number = self.item_start_cp_value.value() finish_cp_number = self.item_finish_cp_value.value() old_start_cp_number = obj.get_setting('system_start_cp_number', 31) old_finish_cp_number = obj.get_setting('system_finish_cp_number', 90) if old_start_cp_number != start_cp_number or old_finish_cp_number != finish_cp_number: race().clear_results() obj.set_setting('system_port', self.item_si_port.currentText()) obj.set_setting('system_start_source', start_source) obj.set_setting('system_finish_source', finish_source) obj.set_setting('system_start_cp_number', start_cp_number) obj.set_setting('system_finish_cp_number', finish_cp_number) obj.set_setting('system_assign_chip_reading', assign_chip_reading) obj.set_setting('system_assignment_mode', self.assignment_mode.isChecked()) # result processing rp_mode = 'time' if self.rp_scores_radio.isChecked(): rp_mode = 'scores' rp_score_mode = 'rogain' if self.rp_fixed_scores_radio.isChecked(): rp_score_mode = 'fixed' rp_fixed_scores_value = self.rp_fixed_scores_edit.value() rp_scores_minute_penalty = self.rp_scores_minute_penalty_edit.value() obj.set_setting('result_processing_mode', rp_mode) obj.set_setting('result_processing_score_mode', rp_score_mode) obj.set_setting('result_processing_fixed_score_value', rp_fixed_scores_value) obj.set_setting('result_processing_scores_minute_penalty', rp_scores_minute_penalty) # marked route mr_mode = 'off' if self.mr_laps_radio.isChecked(): mr_mode = 'laps' if self.mr_time_radio.isChecked(): mr_mode = 'time' obj.set_setting('marked_route_mode', mr_mode) mr_penalty_time = time_to_otime(self.mr_time_edit.time()).to_msec() mr_if_counting_lap = self.mr_counting_lap_check.isChecked() mr_if_station_check = self.mr_lap_station_check.isChecked() mr_station_code = self.mr_lap_station_edit.value() obj.set_setting('marked_route_mode', mr_mode) obj.set_setting('marked_route_penalty_time', mr_penalty_time) obj.set_setting('marked_route_if_counting_lap', mr_if_counting_lap) obj.set_setting('marked_route_if_station_check', mr_if_station_check) obj.set_setting('marked_route_station_code', mr_station_code) # score settings scores_mode = 'off' if self.scores_array.isChecked(): scores_mode = 'array' elif self.scores_formula.isChecked(): scores_mode = 'formula' scores_array = self.scores_array_edit.text() scores_formula = self.scores_formula_edit.text() obj.set_setting('scores_mode', scores_mode) obj.set_setting('scores_array', scores_array) obj.set_setting('scores_formula', scores_formula) # time settings time_accuracy = self.time_settings_accuracy_edit.value() time_format_24 = 'less24' if self.time_settings_format_more.isChecked(): time_format_24 = 'more24' obj.set_setting('time_accuracy', time_accuracy) obj.set_setting('time_format_24', time_format_24) ResultCalculation(race()).process_results() GlobalAccess().get_main_window().refresh()
def execute(self): ResultChecker.check_all() ResultCalculation(race()).process_results() self.app.refresh()
def print_split(self, result): assert isinstance(result, Result) obj = race() assert isinstance(obj, Race) person = result.person if person is None or result.status in [ ResultStatus.DID_NOT_START, ResultStatus.DID_NOT_FINISH ]: return group = person.group if group is None: return course = obj.find_course(result) is_penalty_used = obj.get_setting('marked_route_mode', 'off') != 'off' is_relay = group.is_relay() fn = 'Lucida Console' fs_main = 3 fs_large = 4 # Information about start self.print_line(obj.data.title, fn, fs_main) self.print_line( str(obj.data.start_datetime)[:10] + ', ' + obj.data.location, fn, fs_main) # Athlete info, bib, card number, start time self.print_line(person.full_name, fn, fs_large, 700) self.print_line(_('Group') + ': ' + group.name, fn, fs_main) if person.organization: self.print_line( _('Team') + ': ' + person.organization.name, fn, fs_main) self.print_line( _('Bib') + ': ' + str(person.bib) + ' ' * 5 + _('Card') + ': ' + str(person.card_number), fn, fs_main) self.print_line( _('Start') + ': ' + result.get_start_time().to_str(), fn, fs_main) # Splits for split in result.splits: if split.is_correct: line = (' ' + str(split.course_index + 1))[-3:] + ' ' +\ (' ' + split.code)[-3:] + ' ' +\ split.relative_time.to_str()[-7:] + ' ' +\ split.leg_time.to_str()[-5:] + ' ' +\ split.speed + ' ' if not is_relay: line += (' ' + str(split.leg_place))[-3:] # Highlight correct controls of marked route ( '31' and '31(31,32,33)' => + ) if is_penalty_used: for course_cp in course.controls: if str(course_cp).startswith(split.code): line += ' +' break self.print_line(line, fn, fs_main) else: line = ' ' * 4 + ( ' ' + split.code)[-3:] + ' ' + split.relative_time.to_str()[-7:] self.print_line(line, fn, fs_main) finish_split = '' if len(result.splits) > 0: finish_split = (result.get_finish_time() - result.splits[-1].time).to_str() # Finish self.print_line( _('Finish') + ': ' + result.get_finish_time().to_str() + ' ' * 4 + finish_split, fn, fs_main) # Result if is_penalty_used: self.print_line( _('Penalty') + ': ' + result.get_penalty_time().to_str(), fn, fs_main) if result.is_status_ok(): self.print_line( _('Result') + ': ' + result.get_result() + ' ' * 4 + result.speed, fn, fs_main) else: self.print_line( _('Result') + ': ' + result.get_result(), fn, fs_main) if is_relay and person.bib > 1000: self.print_line( _('Team result') + ': ' + result.get_result_relay(), fn, fs_main) # Place if result.place > 0: place = _('Place') + ': ' + str(result.place) if not is_relay: place += ' ' + _('from') + ' ' + str(group.count_finished) + \ ' (' + _('total') + ' ' + str(group.count_person) + ')' self.print_line(place, fn, fs_main) # Info about competitors, who can win current person if result.is_status_ok() and not is_relay: if obj.get_setting('system_start_source', 'protocol') == 'protocol': if hasattr(result, 'can_win_count'): if result.can_win_count > 0: self.print_line( _('Who can win you') + ': ' + str(result.can_win_count), fn, fs_main) self.print_line( _('Final result will be known') + ': ' + result.final_result_time.to_str(), fn, fs_main) else: self.print_line(_('Result is final'), fn, fs_main) # Punch checking info if result.is_status_ok(): self.print_line(_('Status: OK'), fn, fs_large, 700) else: self.print_line(_('Status: DSQ'), fn, fs_large, 700) cp_list = '' line_limit = 35 for cp in course.controls: if len(cp_list) > line_limit: self.print_line(cp_list, fn, fs_main) cp_list = '' cp_list += cp.code.split('(')[0] + ' ' self.print_line(cp_list, fn, fs_main) # Short result list if is_relay: relay_stub = 1 else: res = ResultCalculation(obj).get_group_finishes(group) self.print_line(_('Draft results'), fn, fs_main) for cur_res in res[:10]: assert isinstance(cur_res, Result) self.print_line((' ' + str(cur_res.get_place()))[-2:] + ' ' + (cur_res.person.full_name + ' ' * 22)[:22] + ' ' + cur_res.get_result(), fn, fs_main) self.print_line(obj.data.url, fn, fs_main) self.end_page()