Refactored data structures to include mark names for single legs

Updated top view to display these mark names
This commit is contained in:
Simon Pamies committed 2011-06-13 13:13:42 +02:00
1 parent 3317d8d495
commit 35a424342a
4 files changed
+23 -7

No files matched your search

@@ -146,7 +146,9 @@ def eventConfiguration(configurator):
for cp in cobjects:
races = [0.0 for r in range(raceindex)]
marks = cp.marks; values = cp.values; upordown = cp.upordownwind; additional = cp.additional
marks = cp.marks; values = cp.values;
upordown = cp.upordownwind; additional = cp.additional
marknames = cp.marknames
# update races and marks - support add operation
# removal not really supported - needs complete refresh
@@ -157,6 +159,9 @@ def eventConfiguration(configurator):
if len(marks) < r+1:
marks.append([])
if len(marknames) < r+1:
marknames.append([])
if len(upordown) < r+1:
upordown.append([])
@@ -170,6 +175,9 @@ def eventConfiguration(configurator):
if len(marks[r]) < m+1:
marks[r].append(0.0)
if len(marknames[r]) < m+1:
marknames[r].append('')
if len(upordown[r]) < m+1:
upordown[r].append(False)
@@ -186,7 +194,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, additional=additional))
cp.update(dict(races=races, marks=marks, upordownwind=upordown, additional=additional, marknames=marknames))
# finally update event
dbevent.update(dict(name=event['name'],
@@ -250,6 +258,7 @@ def liveRaceInformation(configurator):
c_total_rank = comp.total
c_additional = comp.additional
c_upordown = comp.upordownwind
c_marknames = comp.marknames
# if competitor hasn't started yet we just ignore this leg
# and don't update the competitors information for the given leg
@@ -329,6 +338,9 @@ def liveRaceInformation(configurator):
c_upordown[raceindex][lcount] = leg['upordownwindleg']
# save marknames for the given leg
c_marknames[raceindex][lcount] = (leg['from'], leg['to'])
# compute total rank for competitor
rank = competitor.get('rank', 0)
@@ -340,7 +352,9 @@ def liveRaceInformation(configurator):
rank = c['rank']
break
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))
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
@@ -22,6 +22,7 @@ class CompetitorImpl(ModelBase):
default_values = {
'races': [],
'marks': [[]],
'marknames': [[]]
}
@classmethod
@@ -70,7 +70,8 @@ class Competitor(BaseDocument):
'total': float,
'current_rank': int, # current rank for given time
'races' : [float, ],
'marks' : [[float, ], ], # should be named legs but refactoring is so hard in python
'marks' : [[float, ], ], # ranks for marks
'marknames' : [[[unicode,] ]], # marknames for legs
'upordownwind' : [[bool], ], # indicates wheter the leg is up or downwind
'additional' : [[[float]]], # additional information regarding one leg (finished, started)
'values' : [[[float, ]]]
@@ -499,7 +499,7 @@ def adminLiveData(context, request):
for pos in range(len(currentlegs)):
legpos = currentlegs[pos]
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 += '\nLAST SHOWRACE CALL: %s (UPCOUNT PARAM: %s)\nLEG: %s (FROM: %s TO: %s)\nRACE-START: %s NEWEST EVENT: %s WIND: (%s %s %s)\n' % (t_up, t_upcount, legpos+1, competitors[0].marknames[racepos][legpos][0], competitors[0].marknames[racepos][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) + 'FINISHD'.ljust(9) + 'STARTD'.ljust(9) + 'UPDOWNWIND'.ljust(12)
results += '\n'
@@ -521,8 +521,8 @@ def adminLiveData(context, request):
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 += "N/A".ljust(9)
results += "N/A".ljust(9)
results += str(c.upordownwind[racepos][legpos]).ljust(12)