Displaying more information in top view

This commit is contained in:
Simon Pamies committed 2011-06-12 22:45:42 +02:00
1 parent 4c382b21e8
commit 8535877b22
4 files changed
+35 -6

No files matched your search

@@ -144,7 +144,7 @@ def eventConfiguration(configurator):
for cp in cobjects:
races = [0.0 for r in range(raceindex)]
marks = cp.marks; values = cp.values; upordown = cp.upordownwind
marks = cp.marks; values = cp.values; upordown = cp.upordownwind; additional = cp.additional
# update races and marks - support add operation
# removal not really supported - needs complete refresh
@@ -161,6 +161,9 @@ def eventConfiguration(configurator):
if len(values) < r+1:
values.append([])
if len(additional) < r+1:
additional.append([])
for m in range(len(rcmarks[r])):
if len(marks[r]) < m+1:
marks[r].append(0.0)
@@ -171,6 +174,9 @@ def eventConfiguration(configurator):
if len(values[r]) < m+1:
values[r].append([])
if len(additional[r]) < m+1:
additional[r].append([])
# recognize if races and/or marks changed
if cp.races and len(cp.races) != len(races):
log.error('Difference between races for competitor %s found. Old: %s New: %s' % (cp.name, cp.races, races))
@@ -178,7 +184,7 @@ def eventConfiguration(configurator):
if cp.marks and len(cp.marks) != len(marks):
log.error('Difference between marks for competitor %s found. Old: %s New: %s' % (cp.name, cp.marks, marks))
cp.update(dict(races=races, marks=marks, upordownwind=upordown))
cp.update(dict(races=races, marks=marks, upordownwind=upordown, additional=additional))
# finally update event
dbevent.update(dict(name=event['name'],
@@ -240,6 +246,8 @@ def liveRaceInformation(configurator):
c_marks = comp.marks
c_values = comp.values
c_total_rank = comp.total
c_additional = comp.additional
c_upordown = comp.upordownwind
# if competitor hasn't started yet we just ignore this leg
# and don't update the competitors information for the given leg
@@ -311,6 +319,14 @@ def liveRaceInformation(configurator):
c_values[raceindex][lcount][attr[0]] = k
if len(c_additional[raceindex][lcount]) == 0:
c_additional[raceindex][lcount] = [0, 0]
c_additional[raceindex][lcount][0] = competitor['started']
c_additional[raceindex][lcount][1] = competitor['finished']
c_upordown[raceindex][lcount] = leg['upordownwindleg']
# compute total rank for competitor
rank = competitor.get('rank', 0)
@@ -322,7 +338,7 @@ def liveRaceInformation(configurator):
rank = c['rank']
break
comp.update(dict(current_rank=rank,races=c_races, marks=c_marks, values=c_values, total=c_total_rank))
comp.update(dict(current_rank=rank,races=c_races, marks=c_marks, values=c_values, additional=c_additional, upordownwind=c_upordown, total=c_total_rank))
# next leg
lcount += 1
@@ -21,7 +21,7 @@ class CompetitorImpl(ModelBase):
default_values = {
'races': [],
'marks': [[]]
'marks': [[]],
}
@classmethod
@@ -72,6 +72,7 @@ class Competitor(BaseDocument):
'races' : [float, ],
'marks' : [[float, ], ], # should be named legs but refactoring is so hard in python
'upordownwind' : [[bool], ], # indicates wheter the leg is up or downwind
'additional' : [[[float]]], # additional information regarding one leg (finished, started)
'values' : [[[float, ]]]
}
@@ -461,13 +461,16 @@ def adminLiveData(context, request):
# always show the last leg
currentlegs.insert(0, currentlegs[0]-1)
t_up = threaded_listener.values()[0].last_update.strftime('%H:%M:%S')
t_upcount = threaded_listener.values()[0].updatecount
results = ''
for pos in range(len(currentlegs)):
legpos = currentlegs[pos]
results += '\nLEG: %s RACE-START: %s NEWEST: %s WIND: (%s %s %s)\n' % (legpos+1, view.millisToDatetime(race.start), view.millisToDatetime(race.timeofnewestevent), race.wind_source, race.wind_bearing, race.wind_speed)
results += '\nLAST SHOWRACE CALL: %s (UPCOUNT PARAM: %s)\nLEG: %s RACE-START: %s NEWEST: %s WIND: (%s %s %s)\n' % (t_up, t_upcount, legpos+1, view.millisToDatetime(race.start), view.millisToDatetime(race.timeofnewestevent), race.wind_source, race.wind_bearing, race.wind_speed)
results += 'NAME'.ljust(16) + 'TOTAL'.ljust(7) + 'CRANK'.ljust(7) + 'RRANK'.ljust(7)
results += 'MRANK'.ljust(7) + 'LRANK'.ljust(9) + 'SPD'.ljust(9) + 'DSTTRV'.ljust(9) + 'VMG'.ljust(9) + 'AVMG'.ljust(9) + 'SGAP'.ljust(9) + 'ETA'.ljust(9) + 'DSTGO'.ljust(9)
results += 'MRANK'.ljust(7) + 'LRANK'.ljust(9) + 'SPD'.ljust(9) + 'DSTTRV'.ljust(9) + 'VMG'.ljust(9) + 'AVMG'.ljust(9) + 'SGAP'.ljust(9) + 'ETA'.ljust(9) + 'DSTGO'.ljust(9) + 'FINISHD'.ljust(9) + 'STARTD'.ljust(9) + 'UPDOWNWIND'.ljust(12)
results += '\n'
# sort competitors by rank in current leg
@@ -483,6 +486,15 @@ def adminLiveData(context, request):
else:
results += str('%.2f' % v).ljust(9)
try:
results += str(c.additional[racepos][legpos][0]).ljust(9)
results += str(c.additional[racepos][legpos][1]).ljust(9)
except:
results += "False".ljust(9)
results += "False".ljust(9)
results += str(c.upordownwind[racepos][legpos]).ljust(12)
results += '\n'
if not results: