def logNum(self, nums): if not nums: return race = Model.race if not race or not race.isRunning(): return t = race.curRaceTime() if not isinstance(nums, (list, tuple)): nums = [nums] # Add the times to the model. numTimes = [] for num in nums: try: num = int(num) except: continue race.addTime(num, t, False) numTimes.append((num, t)) # Write to the log. OutputStreamer.writeNumTimes(numTimes) # Schedule a photo. if race.enableUSBCamera: for num in nums: try: num = int(num) except: continue race.photoCount += TakePhoto(num, t) if okTakePhoto(num, t) else 0 self.playBlip() race.setChanged() mainWin = Utils.getMainWin() if mainWin: mainWin.record.keypad.numEdit.SetValue(u'') mainWin.record.refreshLaps() wx.CallAfter(mainWin.refresh) if race.ftpUploadDuringRace: realTimeFtpPublish.publishEntry()
def doRecordTime(self, event): t = Model.race.curRaceTime() # Trigger the camera. with Model.LockRace() as race: if not race: return if race.enableUSBCamera: race.photoCount += TakePhoto(0, StrToSeconds(formatTime(t))) # Find the last row without a time. self.grid.SetGridCursor( 0, 0, ) emptyRow = self.grid.GetNumberRows() + 1 success = False for i in xrange(2): for row in xrange(self.grid.GetNumberRows()): if not self.grid.GetCellValue(row, 0): emptyRow = row break if emptyRow >= self.grid.GetNumberRows(): self.doCommit(event) else: success = True break if not success: Utils.MessageOK( self, u'\n'.join([ _('Insufficient space to Record Time.'), _('Enter Bib numbers and press Commit.'), _('Or delete some entries') ]), _('Record Time Failed.')) return self.grid.SetCellValue(emptyRow, 0, formatTime(t)) # Set the edit cursor at the first empty bib position. for row in xrange(self.grid.GetNumberRows()): text = self.grid.GetCellValue(row, 1) if not text or text == '0': self.grid.SetGridCursor(row, 1) break