Пример #1
0
    def fin_trig(self, t):
        """Register finish trigger."""
        if self.timerstat == 'running':
            if self.fl.getstatus() == 'armfin':
                bib = self.fl.bibent.get_text()
                series = self.fl.serent.get_text()
                i = self.getiter(bib, series)
                if i is not None:
                    self.settimes(i, tst=self.riders.get_value(i,
                                                COL_TODSTART), tft=t)
                    self.fl.tofinish()
                    ft = self.getelapsed(i)
                    if ft is not None:
                        self.fl.set_time(ft.timestr(2))
                        self.meet.scratch_log(' '.join([
                           strops.bibser2bibstr(bib, series).ljust(5),
                           strops.truncpad(self.riders.get_value(i,
                                  COL_NAMESTR), 20),
                           ft.timestr(2),
                           '(' + str(self.results.rank(bib, series) + 1) + ')'
                                                      ]))
                    else:
                        self.fl.set_time('[err]')

                else:
                    self.log.error('Missing rider at finish')
                    self.sl.toidle()
        elif self.timerstat == 'armstart':
            self.set_syncstart(t)
Пример #2
0
    def tod_context_edit_activate_cb(self, menuitem, data=None):
        """Run edit time dialog."""
#!!!@ require road race specific editor dialog?
        sel = self.view.get_selection().get_selected()
        if sel is not None:
            i = sel[1]	# grab off row iter and read in cur times
            tst = self.riders.get_value(i, COL_TODSTART)
            tft = self.riders.get_value(i, COL_TODFINISH)

            # prepare text entry boxes
            st = ''
            if tst is not None:
                st = tst.timestr()
            ft = ''
            if tft is not None:
                ft = tft.timestr()

            # run the dialog
            (ret, st, ft) = uiutil.edit_times_dlg(self.meet.window, st, ft)
            if ret == 1:
                stod = tod.str2tod(st)
                ftod = tod.str2tod(ft)
                bib = self.riders.get_value(i, COL_BIB)
                series = self.riders.get_value(i, COL_SERIES)
                self.settimes(i, tst=stod, tft=ftod) # update model
                self.log.info('Race times manually adjusted for rider '
                               + strops.bibser2bibstr(bib, series))
            else:
                self.log.info('Edit race times cancelled.')
Пример #3
0
    def settimes(self, iter, wst=None, tst=None, tft=None, doplaces=True):
        """Transfer race times into rider model."""
        bib = self.riders.get_value(iter, COL_BIB)
        series = self.riders.get_value(iter, COL_SERIES)

        # clear result for this bib
        self.results.remove(bib, series)

        # assign tods
        if wst is not None:	# Don't clear a set wall start time!
            self.riders.set_value(iter, COL_WALLSTART, wst)
        else:
            wst = self.riders.get_value(iter, COL_WALLSTART)
        self.unstart(bib, series, wst)	# reg ignorer
        # but allow others to be cleared no worries
        self.riders.set_value(iter, COL_TODSTART, tst)
        self.riders.set_value(iter, COL_TODFINISH, tft)

        # save result
        if tft is not None:
            if tst is not None:		# got a start trigger
                self.results.insert(tft - tst, bib, series)
            elif wst is not None:	# start on wall time
                self.results.insert(tft - wst, bib, series)
            else:
                self.log.error('No start time for rider '
                                + strops.bibser2bibstr(bib, series))
        elif tst is not None:
            self.oncourse(bib, series)	# started but not finished

        # if reqd, do places
        if doplaces:
            self.placexfer()
Пример #4
0
    def settimes(self, iter, wst=None, tst=None, tft=None, doplaces=True):
        """Transfer race times into rider model."""
        bib = self.riders.get_value(iter, COL_BIB)
        series = self.riders.get_value(iter, COL_SERIES)

        # clear result for this bib
        self.results.remove(bib, series)

        # assign tods
        if wst is not None:  # Don't clear a set wall start time!
            self.riders.set_value(iter, COL_WALLSTART, wst)
        else:
            wst = self.riders.get_value(iter, COL_WALLSTART)
        self.unstart(bib, series, wst)  # reg ignorer
        # but allow others to be cleared no worries
        self.riders.set_value(iter, COL_TODSTART, tst)
        self.riders.set_value(iter, COL_TODFINISH, tft)

        # save result
        if tft is not None:
            if tst is not None:  # got a start trigger
                self.results.insert(tft - tst, bib, series)
            elif wst is not None:  # start on wall time
                self.results.insert(tft - wst, bib, series)
            else:
                self.log.error('No start time for rider ' +
                               strops.bibser2bibstr(bib, series))
        elif tst is not None:
            self.oncourse(bib, series)  # started but not finished

        # if reqd, do places
        if doplaces:
            self.placexfer()
Пример #5
0
def coltxtbibser(col, cr, model, iter, data):
    """Display a bib.ser string in a tree view."""
    (bibcol, sercol) = data
    cr.set_property(
        'text',
        strops.bibser2bibstr(model.get_value(iter, bibcol),
                             model.get_value(iter, sercol)))
Пример #6
0
 def rfid_trig(self, e):
     """Register RFID crossing."""
     r = self.meet.rdb.getrefid(e.refid)
     #!!! COPY FROM ROADRACE(old-scbdo)
     if r is not None:
         bib = self.meet.rdb.getvalue(r, riderdb.COL_BIB)
         series = self.meet.rdb.getvalue(r, riderdb.COL_SERIES)
         lr = self.getrider(bib, series)
         if lr is not None:
             #!!!
             bibstr = strops.bibser2bibstr(lr[COL_BIB], lr[COL_SERIES])
             self.meet.scratch_log(' '.join(
                 [bibstr.ljust(5),
                  strops.truncpad(lr[COL_NAMESTR], 30)]))
             if self.fl.getstatus() in ['idle', 'finish']:
                 if bibstr in self.recent_starts:
                     self.fl.setrider(lr[COL_BIB], lr[COL_SERIES])
                     self.fl.toload()
                     del self.recent_starts[bibstr]
                 else:
                     self.log.info('Ignoring unseen rider: ' + bibstr +
                                   '@' + e.rawtime(1))
         else:
             self.log.info('Non start rider: ' + bib + '.' + series + '@' +
                           e.rawtime(1))
     else:
         self.log.info('Unkown tag: ' + e.refid + '@' + e.rawtime(1))
Пример #7
0
    def tod_context_edit_activate_cb(self, menuitem, data=None):
        """Run edit time dialog."""
        #!!!@ require road race specific editor dialog?
        sel = self.view.get_selection().get_selected()
        if sel is not None:
            i = sel[1]  # grab off row iter and read in cur times
            tst = self.riders.get_value(i, COL_TODSTART)
            tft = self.riders.get_value(i, COL_TODFINISH)

            # prepare text entry boxes
            st = ''
            if tst is not None:
                st = tst.timestr()
            ft = ''
            if tft is not None:
                ft = tft.timestr()

            # run the dialog
            (ret, st, ft) = uiutil.edit_times_dlg(self.meet.window, st, ft)
            if ret == 1:
                stod = tod.str2tod(st)
                ftod = tod.str2tod(ft)
                bib = self.riders.get_value(i, COL_BIB)
                series = self.riders.get_value(i, COL_SERIES)
                self.settimes(i, tst=stod, tft=ftod)  # update model
                self.log.info('Race times manually adjusted for rider ' +
                              strops.bibser2bibstr(bib, series))
            else:
                self.log.info('Edit race times cancelled.')
Пример #8
0
    def rfid_trig(self, e):
        """Register RFID crossing."""
        r = self.meet.rdb.getrefid(e.refid)
#!!! COPY FROM ROADRACE(old-scbdo)
        if r is not None:
            bib = self.meet.rdb.getvalue(r, riderdb.COL_BIB)
            series = self.meet.rdb.getvalue(r, riderdb.COL_SERIES)
            lr = self.getrider(bib, series)
            if lr is not None:
#!!!
                bibstr = strops.bibser2bibstr(lr[COL_BIB], lr[COL_SERIES])
                self.meet.scratch_log(' '.join([
                   bibstr.ljust(5),
                   strops.truncpad(lr[COL_NAMESTR], 30)
                                              ]))
                if self.fl.getstatus() in ['idle', 'finish']:
                    if bibstr in self.recent_starts:
                        self.fl.setrider(lr[COL_BIB], lr[COL_SERIES])
                        self.fl.toload()
                        del self.recent_starts[bibstr]
                    else:
                        self.log.info('Ignoring unseen rider: ' + bibstr
                                      + '@' + e.rawtime(1))
            else:
                self.log.info('Non start rider: ' + bib + '.' + series + '@'
                               + e.rawtime(1))
        else:
            self.log.info('Unkown tag: ' + e.refid + '@' + e.rawtime(1))
Пример #9
0
    def fin_trig(self, t):
        """Register finish trigger."""
        if self.timerstat == 'running':
            if self.fl.getstatus() == 'armfin':
                bib = self.fl.bibent.get_text()
                series = self.fl.serent.get_text()
                i = self.getiter(bib, series)
                if i is not None:
                    self.settimes(i,
                                  tst=self.riders.get_value(i, COL_TODSTART),
                                  tft=t)
                    self.fl.tofinish()
                    ft = self.getelapsed(i)
                    if ft is not None:
                        self.fl.set_time(ft.timestr(2))
                        self.meet.scratch_log(' '.join([
                            strops.bibser2bibstr(bib, series).ljust(5),
                            strops.truncpad(
                                self.riders.get_value(i, COL_NAMESTR), 20),
                            ft.timestr(2),
                            '(' + str(self.results.rank(bib, series) + 1) + ')'
                        ]))
                    else:
                        self.fl.set_time('[err]')

                else:
                    self.log.error('Missing rider at finish')
                    self.sl.toidle()
        elif self.timerstat == 'armstart':
            self.set_syncstart(t)
Пример #10
0
 def result_export(self, f):
     """Export results to supplied file handle."""
     # TODO
     cr = csv.writer(f)
     cr.writerow(['rank', 'bib', 'rider', 'time'])
     for r in self.riders:
         bibstr = strops.bibser2bibstr(r[COL_BIB], r[COL_SERIES])
         i = self.getiter(r[COL_BIB], r[COL_SERIES])
         ft = self.getelapsed(i)
         fs = ''
         if ft is not None:
             fs = "'" + ft.rawtime(2, zeros=True)
         cr.writerow([r[COL_PLACE], bibstr, r[COL_NAMESTR], fs])
Пример #11
0
 def result_export(self, f):
     """Export results to supplied file handle."""
     # TODO
     cr = csv.writer(f)
     cr.writerow(['rank', 'bib', 'rider', 'time'])
     for r in self.riders:
         bibstr = strops.bibser2bibstr(r[COL_BIB], r[COL_SERIES])
         i = self.getiter(r[COL_BIB], r[COL_SERIES])
         ft = self.getelapsed(i)
         fs = ''
         if ft is not None:
             fs = "'" + ft.rawtime(2, zeros=True)
         cr.writerow([r[COL_PLACE], bibstr, r[COL_NAMESTR], fs])
Пример #12
0
 def placexfer(self):
     """Transfer places into model."""
     self.clearplaces()
     count = 0
     place = 1
     lt = None
     for t in self.results:
         i = self.getiter(t.refid, t.index)
         if i is not None:
             if lt is not None:
                 if lt != t:
                     place = count + 1
             self.riders.set_value(i, COL_PLACE, str(place))
             self.riders.swap(self.riders.get_iter(count), i)
             count += 1
             lt = t
         else:
             self.log.error('Extra result for rider' 
                             + strops.bibser2bibstr(t.refid, t.index))
Пример #13
0
 def placexfer(self):
     """Transfer places into model."""
     self.clearplaces()
     count = 0
     place = 1
     lt = None
     for t in self.results:
         i = self.getiter(t.refid, t.index)
         if i is not None:
             if lt is not None:
                 if lt != t:
                     place = count + 1
             self.riders.set_value(i, COL_PLACE, str(place))
             self.riders.swap(self.riders.get_iter(count), i)
             count += 1
             lt = t
         else:
             self.log.error('Extra result for rider' +
                            strops.bibser2bibstr(t.refid, t.index))
Пример #14
0
    def saveconfig(self):
        """Save race to disk."""
        if self.readonly:
            self.log.error('Attempt to save readonly ob.')
            return
        cw = ConfigParser.ConfigParser()

        # save basic race properties
        cw.add_section('race')
        tstr = ''
        if self.start is not None:
            tstr = self.start.rawtime()
        lstr = ''
        if self.lstart is not None:
            lstr = self.lstart.rawtime()
        cw.set('race', 'start', tstr)
        cw.set('race', 'lstart', lstr)
        cw.set('race', 'startlist', self.get_startlist())
        #!!! places?

        # save out all starters
        cw.add_section('riders')
        for r in self.riders:
            if r[COL_BIB] != '':
                # place is saved for info only
                wst = ''
                #if r[COL_WALLSTART] is not None:
                #wst = r[COL_WALLSTART].rawtime()
                tst = ''
                #if r[COL_TODSTART] is not None:
                #tst = r[COL_TODSTART].rawtime()
                tft = ''
                #if r[COL_TODFINISH] is not None:
                #tft = r[COL_TODFINISH].rawtime()
                slice = [r[COL_COMMENT], wst, tst, tft, r[COL_PLACE]]
                cw.set(
                    'riders', strops.bibser2bibstr(r[COL_BIB], r[COL_SERIES]),
                    ','.join(map(lambda i: str(i).replace(',', '\\,'), slice)))
        self.log.debug('Saving race config to: ' + self.configpath)
        with open(self.configpath, 'wb') as f:
            cw.write(f)
Пример #15
0
    def saveconfig(self):
        """Save race to disk."""
        if self.readonly:
            self.log.error('Attempt to save readonly ob.')
            return
        cw = ConfigParser.ConfigParser()

        # save basic race properties
        cw.add_section('race')
        tstr = ''
        if self.start is not None:
            tstr = self.start.rawtime()
        lstr = ''
        if self.lstart is not None:
            lstr = self.lstart.rawtime()
        cw.set('race', 'start', tstr)
        cw.set('race', 'lstart', lstr)
        cw.set('race', 'startlist', self.get_startlist())
#!!! places?

        # save out all starters
        cw.add_section('riders')
        for r in self.riders:
            if r[COL_BIB] != '':
                # place is saved for info only
                wst = ''
                #if r[COL_WALLSTART] is not None:
                    #wst = r[COL_WALLSTART].rawtime()
                tst = ''
                #if r[COL_TODSTART] is not None:
                    #tst = r[COL_TODSTART].rawtime()
                tft = ''
                #if r[COL_TODFINISH] is not None:
                    #tft = r[COL_TODFINISH].rawtime()
                slice = [r[COL_COMMENT], wst, tst, tft, r[COL_PLACE]]
                cw.set('riders', strops.bibser2bibstr(r[COL_BIB], r[COL_SERIES]),
                    ','.join(map(lambda i: str(i).replace(',', '\\,'), slice)))
        self.log.debug('Saving race config to: ' + self.configpath)
        with open(self.configpath, 'wb') as f:
            cw.write(f)
Пример #16
0
def coltxtbibser(col, cr, model, iter, data):
    """Display a bib.ser string in a tree view."""
    (bibcol, sercol) = data
    cr.set_property('text', 
                    strops.bibser2bibstr(model.get_value(iter, bibcol),
                                         model.get_value(iter, sercol)))
Пример #17
0
 def unstart(self, bib='', series='', wst=None):
     """Register a rider as not yet started."""
     idx = strops.bibser2bibstr(bib, series)
     self.unstarters[idx] = wst
Пример #18
0
 def get_startlist(self):
     """Return a list of bibs in the rider model as b.s."""
     ret = ''
     for r in self.riders:
         ret += ' ' + strops.bibser2bibstr(r[COL_BIB], r[COL_SERIES])
     return ret.strip()
Пример #19
0
 def oncourse(self, bib='', series=''):
     """Remove rider from the not yet started list."""
     idx = strops.bibser2bibstr(bib, series)
     if idx in self.unstarters:
         del(self.unstarters[idx])
Пример #20
0
 def log_clear(self, bib, series):
     """Print clear time log."""
     self.log.info('Time cleared for rider ' +
                   strops.bibser2bibstr(bib, series))
Пример #21
0
 def log_clear(self, bib, series):
     """Print clear time log."""
     self.log.info('Time cleared for rider ' + strops.bibser2bibstr(bib, series))
Пример #22
0
 def oncourse(self, bib='', series=''):
     """Remove rider from the not yet started list."""
     idx = strops.bibser2bibstr(bib, series)
     if idx in self.unstarters:
         del (self.unstarters[idx])
Пример #23
0
 def unstart(self, bib='', series='', wst=None):
     """Register a rider as not yet started."""
     idx = strops.bibser2bibstr(bib, series)
     self.unstarters[idx] = wst
Пример #24
0
 def get_startlist(self):
     """Return a list of bibs in the rider model as b.s."""
     ret = ''
     for r in self.riders:
         ret += ' ' + strops.bibser2bibstr(r[COL_BIB], r[COL_SERIES])
     return ret.strip()