def doCommit( self, event ): self.grid.SetGridCursor( 0, 0, ) # Find the last row without a time. timesBibs = [] timesNoBibs = [] for row in xrange(self.grid.GetNumberRows()): tStr = self.grid.GetCellValue(row, 0).strip() if not tStr: continue bib = self.grid.GetCellValue(row, 1).strip() try: bib = int(bib) except (TypeError, ValueError): bib = 0 if bib: timesBibs.append( (tStr, bib) ) else: timesNoBibs.append( tStr ) for row in xrange(self.grid.GetNumberRows()): for column in xrange(self.grid.GetNumberCols()): self.grid.SetCellValue(row, column, '' ) ''' for row, tStr in enumerate(timesNoBibs): self.grid.SetCellValue( row, 0, tStr ) ''' self.grid.SetGridCursor( 0, 1 ) if timesBibs and Model.race: with Model.LockRace() as race: bibRaceSeconds = [] for tStr, bib in timesBibs: raceSeconds = StrToSeconds(tStr) race.addTime( bib, raceSeconds ) OutputStreamer.writeNumTime( bib, raceSeconds ) bibRaceSeconds.append( (bib, raceSeconds) ) # We had to record the photo initially with bib=0 when it was in the photo buffer. # Now that we know the actual bib, we need to rename the photo and stamp it with the the rider info. if race and race.enableUSBCamera: SendRenameRequests( bibRaceSeconds ) wx.CallAfter( Utils.refresh ) self.grid.SetGridCursor( 0, 1 )
def doCommit(self, event): self.grid.SetGridCursor( 0, 0, ) # Find the last row without a time. timesBibs = [] timesNoBibs = [] for row in xrange(self.grid.GetNumberRows()): tStr = self.grid.GetCellValue(row, 0).strip() if not tStr: continue bib = self.grid.GetCellValue(row, 1).strip() try: bib = int(bib) except (TypeError, ValueError): bib = 0 if bib: timesBibs.append((tStr, bib)) else: timesNoBibs.append(tStr) for row in xrange(self.grid.GetNumberRows()): for column in xrange(self.grid.GetNumberCols()): self.grid.SetCellValue(row, column, '') ''' for row, tStr in enumerate(timesNoBibs): self.grid.SetCellValue( row, 0, tStr ) ''' self.grid.SetGridCursor(0, 1) if timesBibs and Model.race: with Model.LockRace() as race: bibRaceSeconds = [] for tStr, bib in timesBibs: raceSeconds = StrToSeconds(tStr) race.addTime(bib, raceSeconds) OutputStreamer.writeNumTime(bib, raceSeconds) bibRaceSeconds.append((bib, raceSeconds)) wx.CallAfter(Utils.refresh) self.grid.SetGridCursor(0, 1)
def doCommit( self, event ): self.grid.SetGridCursor( 0, 0, ) # Find the last row without a time. timesBibs = [] timesNoBibs = [] for row in xrange(self.grid.GetNumberRows()): tStr = self.grid.GetCellValue(row, 0).strip() if not tStr: continue bib = self.grid.GetCellValue(row, 1).strip() try: bib = int(bib) except (TypeError, ValueError): bib = 0 if bib: timesBibs.append( (tStr, bib) ) else: timesNoBibs.append( tStr ) for row in xrange(self.grid.GetNumberRows()): for column in xrange(self.grid.GetNumberCols()): self.grid.SetCellValue(row, column, '' ) ''' for row, tStr in enumerate(timesNoBibs): self.grid.SetCellValue( row, 0, tStr ) ''' self.grid.SetGridCursor( 0, 1 ) if timesBibs and Model.race: with Model.LockRace() as race: bibRaceSeconds = [] for tStr, bib in timesBibs: raceSeconds = StrToSeconds(tStr) race.addTime( bib, raceSeconds ) OutputStreamer.writeNumTime( bib, raceSeconds ) bibRaceSeconds.append( (bib, raceSeconds) ) wx.CallAfter( Utils.refresh ) self.grid.SetGridCursor( 0, 1 )
def doCommit( self, event ): self.grid.SetGridCursor( 0, 0, ) # Find the last row without a time. timesBibs = [] timesNoBibs = [] for row in xrange(self.grid.GetNumberRows()): tStr = self.grid.GetCellValue(row, 0).strip() bib = self.grid.GetCellValue(row, 1).strip() if not tStr: continue if bib: try: bib = int(bib) except: continue timesBibs.append( (tStr, bib) ) else: timesNoBibs.append( tStr ) for row in xrange(self.grid.GetNumberRows()): for column in xrange(self.grid.GetNumberCols()): self.grid.SetCellValue(row, column, '' ) ''' for row, tStr in enumerate(timesNoBibs): self.grid.SetCellValue( row, 0, tStr ) ''' self.grid.SetGridCursor( 0, 1 ) if timesBibs and Model.race: with Model.LockRace() as race: isCamera = getattr(race, 'enableUSBCamera', False) for tStr, bib in timesBibs: raceSeconds = StrToSeconds(tStr) race.addTime( bib, raceSeconds ) if isCamera: AddBibToPhoto( Utils.getFileName(), bib, raceSeconds ) OutputStreamer.writeNumTime( bib, raceSeconds ) wx.CallAfter( Utils.refresh ) self.grid.SetGridCursor( 0, 1 )
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 and write to the log. for num in nums: try: num = int(num) except: continue race.addTime(num, t, False) OutputStreamer.writeNumTime(num, t) # 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 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 and write to the log. for num in nums: try: num = int(num) except: continue race.addTime(num, t, False) OutputStreamer.writeNumTime(num, t) # 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 logNum( self, nums ): if nums is None: return if not isinstance(nums, (list, tuple)): nums = [nums] with Model.LockRace() as race: if race is None or not race.isRunning(): return t = race.curRaceTime() # Take the picture first to reduce latency to capturing the riders as they cross the line. if getattr(race, 'enableUSBCamera', False): for num in nums: try: num = int(num) except: continue try: race.photoCount = getattr(race,'photoCount',0) + VideoBuffer.ModelTakePhoto( num, t ) except Exception as e: logException( e, sys.exc_info() ) # Add the times to the model and write to the log. for num in nums: try: num = int(num) except: continue race.addTime( num, t ) OutputStreamer.writeNumTime( num, t ) self.playBlip() mainWin = Utils.getMainWin() if mainWin: mainWin.record.keypad.numEdit.SetValue( '' ) mainWin.record.refreshLaps() wx.CallAfter( mainWin.refresh ) if getattr(race, 'ftpUploadDuringRace', False): realTimeFtpPublish.publishEntry()