RWC sjekk for diska løpere

This commit is contained in:
Trygve 2023-12-07 00:00:08 +01:00
parent bbcc332166
commit 71020bc340
3 changed files with 16 additions and 4 deletions

View File

@ -110,7 +110,7 @@ def run(port='/dev/ttyUSB0', project_dir='./', xml_path='./output/'):
try:
print(otime.CardDump.from_mtr_bytes(message))
print(runner_info(event, card_dump))
except ValueError as error:
except Exception as error:
print(error)
else:
card_dump = otime.CardDump.from_mtr_bytes(message)
@ -155,7 +155,7 @@ def gen(project_dir='./', xml_path='./output/'):
def runner_info(event, card_dump):
runner = next((i for i in event.runners if str(i.card_id) == str(card_dump.card)), None)
if runner is None:
return card_dump
return f'[orange_red1]No runner with ecard {card_dump.card}! It matches these courses: {otime.find_courses_matching_controls(card_dump.controls, event.courses)}[/orange_red1] {card_dump}'
result = event.get_runner_result(runner.id)
if result is None:
return '🧐 Dette skal ikke skje...'

View File

@ -46,6 +46,9 @@ def event_from_yaml_and_csv(config_path, mtr_path, csv_path):
i[7] = i[7]
else:
i[7] = None
# Sjekk om brikkenummer er tomt
if i[5] == '':
i[5] = 0
runners = [otime.Runner(id=i[0], status_override=i[1], first=i[2][0], last=i[2][1].strip(), o_class=i[3], club=i[4], card_id=int(i[5]), fork=int(i[6]), start_time=i[7]) for i in data]
event.card_dumps = card_dumps
event.runners = runners

View File

@ -404,7 +404,8 @@ def produce_class_result(event, o_class_name) -> ClassResult:
results += [RunnerResult(i.id, i.first, i.last, event.get_runner_status(i.id), 0, event.get_runner_time(i.id), event.get_runner_splits(i.id),
event.get_runner_end_clock(i.id), i.club, 0, i.country, i.card_id, i.o_class, event.get_runner_controls(i.id),
start_time=event.get_card_dump(i.card_id).s_time,
missed_controls=find_missed_controls(event.get_runner_controls(i.id), event.get_course(o_class.course).codes[i.fork]))
missed_controls=find_missed_controls(event.get_runner_controls(i.id), event.get_course(o_class.course).codes[i.fork]),
ran_other_course=find_courses_matching_controls(event.get_card_dump(i.card_id).controls, event.courses))
for i in dsq_runners]
results += [RunnerResult(i.id, i.first, i.last, event.get_runner_status(i.id), 0, event.get_runner_time(i.id), event.get_runner_splits(i.id),
event.get_runner_end_clock(i.id), i.club, 0, i.country, i.card_id, i.o_class, event.get_runner_controls(i.id)) for i in other_runners]
@ -462,3 +463,11 @@ def contains(small, big):
def find_missed_controls(punches, codes):
return [i for i in codes if i not in punches]
def find_courses_matching_controls(controls, courses):
matches = []
for i in courses:
for fork in i.codes:
if contains(fork, controls):
matches.append(i.name)
return matches