def show_brt(self): msg = (strops.truncpad(self.bib, 3) + chr(unt4.STX) + strops.truncpad(str(self.rank),1) + ' ' # the 'h:' padding + self.time.rjust(5)) self.send_msg(msg)
def update(self): """If time or avg change, copy new value onto overlay.""" if not self.paused: flush = False if self.curtime != self.nexttime: #self.scb.postxt(3, self.scb.linelen - 13, #strops.truncpad(self.nexttime,12,'r'), chan=u'#anascb') self.scb.setline( 3, strops.truncpad(self.timepfx, self.scb.linelen - 13, 'r') + strops.truncpad(self.nexttime, 13, 'r'), chan=u'#anascb') self.curtime = self.nexttime flush = True if self.curavg != self.nextavg: self.scb.setline( 4, strops.truncpad(self.avgpfx, self.scb.linelen - 13, 'r') + strops.truncpad(self.nextavg, 12, 'r'), chan=u'#anascb') # timestr above provides 4places? self.curavg = self.nextavg flush = True self.count += 1 if flush: self.scb.flush()
def show_dual(self): line0 = (strops.truncpad(self.bib, 3) + chr(unt4.STX) + strops.truncpad(self.time, 12, 'r', elipsis=False)) line1 = (strops.truncpad(self.bib1, 3) + chr(unt4.STX) + strops.truncpad(self.time1, 12, 'r', elipsis=False)) #self.send_msg(line0, 'R', '2',msg1=line1) # xxx-5:02.6-x self.send_msg(line0, 'R', '3',msg1=line1) # xxx-5:02.6-x
def update(self): # if time field set and not a round number of rows, append # time line to last row of last page if self.count % 2 == 0 and self.count > PAGE_INIT: # wait ~1/2 sec lclk = (self.count - PAGE_INIT) // 2 cpage = (lclk // self.delay) % self.nrpages pclk = lclk % self.delay flush = False if pclk < self.pagesz + 1: if pclk != self.pagesz: self.scb.clrline(self.rowoft + pclk, chan=u'#anascb') flush = True else: # end of page if self.nrpages == 1: self.count += 1 self.paused = True # no further animate on single page if self.timestr is not None: self.scb.setline( self.rowoft + pclk, strops.truncpad(self.timepfx, self.scb.linelen - 13, 'r') + u' ' + self.timestr[0:12], chan=u'#anascb') flush = True if pclk != 0: roft = self.pagesz * cpage + pclk - 1 if roft < len(self.rows): self.scb.setline(self.rowoft + pclk - 1, self.rows[roft], chan=u'#anascb') flush = True if flush: self.scb.flush() if not self.paused: self.count += 1
def update(self): """If any time or ranks change, copy new value onto overlay.""" if not self.paused: flush = False if self.curr1 != self.nextr1 or self.curt1 != self.nextt1: self.scb.setline( 3 + self.singleoft, strops.truncpad(self.nextr1, self.scb.linelen - 13, 'r') + u' ' + self.nextt1, chan=u'#anascb') self.curr1 = self.nextr1 self.curt1 = self.nextt1 flush = True if self.curr2 != self.nextr2 or self.curt2 != self.nextt2: self.scb.setline( 5, strops.truncpad(self.nextr2, self.scb.linelen - 13, 'r') + u' ' + self.nextt2, chan=u'#anascb') self.curr2 = self.nextr2 self.curt2 = self.nextt2 flush = True if self.line1 != self.nextline1: self.line1 = self.nextline1 self.scb.setline(2 + self.singleoft, self.nextline1, chan=u'#anascb') flush = True if self.line2 != self.nextline2: self.line2 = self.nextline2 self.scb.setline(4 + self.singleoft, self.nextline2, chan=u'#anascb') flush = True self.count += 1 if flush: self.scb.flush()
def delayed_announce(self): """Initialise the announcer's screen after a delay.""" if self.winopen: self.meet.announce.clrall() self.meet.ann_title(' '.join([ 'Event', self.evno, ':', self.event[u'pref'], self.event[u'info'], self.standingstr() ])) self.meet.announce.linefill(1, '_') ha = [' ', ' #', 'Rider'.ljust(25), ' Pt '] for n in self.nicknames: # configurable error? ha.append(strops.truncpad(n, 4, 'r')) ha.append('Tot Time'.rjust(10)) self.meet.announce.setline(3, ' '.join(ha)) l = 4 for r in self.riders: plstr = '' if r[COL_PLACE] != '': plstr = r[COL_PLACE] if plstr.isdigit(): plstr += '.' plstr = strops.truncpad(plstr, 3, 'l') bibstr = strops.truncpad(r[COL_BIB], 3, 'r') clubstr = '' if r[COL_CLUB] != '': clubstr = ' (' + r[COL_CLUB] + ')' namestr = strops.truncpad( strops.fitname(r[COL_FIRST], r[COL_LAST], 25 - len(clubstr)) + clubstr, 25) ptsstr = ' ' if r[COL_TOTAL] > 0: ptsstr = strops.truncpad(str(r[COL_TOTAL]), 4, 'r') ol = [plstr, bibstr, namestr, ptsstr] for c in range(0, len(self.nicknames)): if len(r[COL_POINTS]) > c: ol.append(strops.truncpad(r[COL_POINTS][c], 4, 'r')) else: ol.append(' ') if r[COL_TIME] != tod.ZERO: ol.append(strops.truncpad(r[COL_TIME].rawtime(3), 10, 'r')) else: ol.append(' ') self.meet.announce.setline(l, ' '.join(ol)) l += 1 return False
def loadrows(self, coldesc=None, rows=None): self.rows = [] if coldesc is not None and rows is not None: for row in rows: nr = u'' oft = 0 for col in coldesc: if type(col) in [unicode, str]: # HACK py<3.0 nr += col else: if len(row) > oft: # space pad 'short' rows nr += strops.truncpad(row[oft], col[0], col[1]) else: nr += u' ' * col[0] oft += 1 self.rows.append(nr) # truncation in sender ok self.nrpages = len(self.rows) // self.pagesz + 1 if self.nrpages > 1 and len(self.rows) % self.pagesz == 0: self.nrpages -= 1 # avoid hanging residual by scooting 2nd last entry onto # last page with a 'dummy' row, or scoot single line down by one if len(self.rows) % self.pagesz == 1: self.rows.insert(len(self.rows) - 2, u' ')
def delayed_announce(self): """Initialise the announcer's screen after a delay.""" if self.winopen: self.meet.announce.clrall() self.meet.ann_title(' '.join([ self.meet.event_string(self.evno), ':', self.event[u'pref'], self.event[u'info'] ])) lapstring = strops.lapstring(self.event[u'laps']) substr = u' '.join( [lapstring, self.event[u'dist'], self.event[u'prog']]).strip() if substr: self.meet.announce.postxt(1, 0, substr.center(80)) self.meet.announce.linefill(2, '_') self.meet.announce.linefill(8, '_') # announce current contest i = self.current_contest_combo.get_active_iter() if i is not None: # contest selected ok cid = self.contests.get_value(i, COL_CONTEST) self.meet.announce.postxt(4, 0, u'Contest: ' + cid) ano = self.contests.get_value(i, COL_A_NO).rjust(3) astr = self.contests.get_value(i, COL_A_STR).decode('utf-8') aplace = self.contests.get_value(i, COL_A_PLACE).ljust(3) bni = self.contests.get_value(i, COL_B_NO) bno = bni.rjust(3) bstr = self.contests.get_value(i, COL_B_STR).decode('utf-8') bplace = self.contests.get_value(i, COL_B_PLACE).ljust(3) if self.contests.get_value(i, COL_WINNER) == bni: self.meet.announce.postxt( 6, 0, bplace + u' ' + bno + u' ' + bstr) self.meet.announce.postxt( 7, 0, aplace + u' ' + ano + u' ' + astr) else: self.meet.announce.postxt( 6, 0, aplace + u' ' + ano + u' ' + astr) self.meet.announce.postxt( 7, 0, bplace + u' ' + bno + u' ' + bstr) ft = self.contests.get_value(i, COL_200M) if ft is not None: self.meet.announce.postxt( 6, 60, u'200m: ' + ft.rawtime(2).rjust(10)) self.meet.announce.postxt( 7, 60, u' Avg: ' + ft.speedstr().strip().rjust(10)) # show 'leaderboard' lof = 10 for c in self.contests: cid = (c[COL_CONTEST] + u':').ljust(8) win = c[COL_WINNER] lr = u'' rr = u'' sep = u' v ' if win: if c[COL_CONTEST] == u'bye': sep = ' ' else: sep = 'def' if win == c[COL_B_NO]: lr = (c[COL_B_NO].rjust(3) + u' ' + strops.truncpad(c[COL_B_STR].decode('utf-8'), 29)) rr = (c[COL_A_NO].rjust(3) + u' ' + strops.truncpad(c[COL_A_STR].decode('utf-8'), 29)) else: lr = (c[COL_A_NO].rjust(3) + u' ' + strops.truncpad(c[COL_A_STR].decode('utf-8'), 29)) rr = (c[COL_B_NO].rjust(3) + u' ' + strops.truncpad(c[COL_B_STR].decode('utf-8'), 29)) self.meet.announce.postxt(lof, 0, u' '.join([cid, lr, sep, rr])) lof += 1 return False
def set_right(self, msg): msg = strops.truncpad(msg, 8, align='r', elipsis=False) self.obuf[1] = msg self.setline(1)
def set_left(self, msg): msg = strops.truncpad(msg, 8, align='r', elipsis=False) self.obuf[0] = msg self.setline(0)
def show_runtime(self): msg = (strops.truncpad(self.bib, 3) + chr(unt4.STX) + strops.truncpad(self.time, 12, 'r', elipsis=False)) self.send_msg(msg, 'R', '2') # xxx-5:02.6-x
def show_clock(self): msg = (' ' # bib padding + chr(unt4.STX) + strops.truncpad(self.time, 12, 'r', elipsis=False)) self.send_msg(msg, 'R') # -2:34:56xxxx
def show_lap(self): self.lmsg = '' # always write out lap to allow redraw lstr = strops.truncpad(self.lap, 3, 'r') msg = (lstr + chr(unt4.STX) + lstr[0:2] + ':' + lstr[2] + lstr[0] + ':' + lstr[1:3] + '. ') self.send_msg(msg)
def setline(self, line, msg, chan=None): """Set the specified DHI database line to msg.""" # set line should also clear, used to have ERL, but not now? msg = strops.truncpad(msg, self.linelen, 'l', False) #msg = msg[0:self.linelen].ljust(self.linelen) self.sendmsg(unt4.unt4(xx=0, yy=int(line), text=msg))