Пример #1
0
    def onFinishRace(self, event):
        if Model.race is None or not Utils.MessageOKCancel(
                self, _('Finish Race Now?'), _('Finish Race')):
            return

        with Model.LockRace() as race:
            race.finishRaceNow()
            if race.numLaps is None:
                race.numLaps = race.getMaxLap()
            SetNoDataDNS()
            Model.resetCache()

        Utils.writeRace()
        self.refresh()
        mainWin = Utils.getMainWin()
        if mainWin:
            mainWin.refresh()

        OutputStreamer.writeRaceFinish()
        OutputStreamer.StopStreamer()
        try:
            ChipReader.chipReaderCur.StopListener()
        except:
            pass

        if getattr(Model.race, 'ftpUploadDuringRace', False):
            realTimeFtpPublish.publishEntry(True)
Пример #2
0
def StartRaceNow():
	global undoResetTimer
	if undoResetTimer and undoResetTimer.IsRunning():
		undoResetTimer.Stop()
	undoResetTimer = None
	JChip.reset()
	
	undo.clear()
	undo.pushState()
	with Model.LockRace() as race:
		if race is None:
			return
		
		if not getattr(race, 'enableJChipIntegration', False):
			race.resetStartClockOnFirstTag = False
		Model.resetCache()
		race.startRaceNow()
		
	OutputStreamer.writeRaceStart()
	VideoBuffer.ModelStartCamera()
	
	# Refresh the main window and switch to the Record pane.
	mainWin = Utils.getMainWin()
	if mainWin is not None:
		mainWin.showPageName( _('Record') )
		mainWin.refresh()
	
	# For safety, clear the undo stack after 8 seconds.
	undoResetTimer = wx.CallLater( 8000, undo.clear )
	
	if getattr(race, 'ftpUploadDuringRace', False):
		realTimeFtpPublish.publishEntry( True )
Пример #3
0
	def onFinishRace( self, event ):
		if Model.race is None or not Utils.MessageOKCancel(self, _('Finish Race Now?'), _('Finish Race')):
			return
			
		with Model.LockRace() as race:
			race.finishRaceNow()
			if race.numLaps is None:
				race.numLaps = race.getMaxLap()
			SetNoDataDNS()
			Model.resetCache()
		
		Utils.writeRace()
		self.refresh()
		mainWin = Utils.getMainWin()
		if mainWin:
			mainWin.refresh()
		
		OutputStreamer.writeRaceFinish()
		OutputStreamer.StopStreamer()
		try:
			ChipReader.chipReaderCur.StopListener()
		except:
			pass

		if getattr(Model.race, 'ftpUploadDuringRace', False):
			realTimeFtpPublish.publishEntry( True )
Пример #4
0
	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 )
Пример #5
0
    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)
Пример #6
0
    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()
Пример #7
0
	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()
Пример #8
0
	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 )
Пример #9
0
	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 )
Пример #10
0
	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()
Пример #11
0
	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()
			
			# 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 )
				
			# 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()
		
		mainWin = Utils.getMainWin()
		if mainWin:
			mainWin.record.keypad.numEdit.SetValue( u'' )
			mainWin.record.refreshLaps()
			wx.CallAfter( mainWin.refresh )
		if race.ftpUploadDuringRace:
			realTimeFtpPublish.publishEntry()
Пример #12
0
def StartRaceNow(page=_('Record')):
    global undoResetTimer
    if undoResetTimer and undoResetTimer.IsRunning():
        undoResetTimer.Stop()
    undoResetTimer = None
    ChipReader.chipReaderCur.reset(
        Model.race.chipReaderType if Model.race else None)

    undo.clear()
    undo.pushState()
    with Model.LockRace() as race:
        if race is None:
            return

        if not race.enableJChipIntegration:
            race.resetStartClockOnFirstTag = False

        Model.resetCache()
        race.startRaceNow()
        isTimeTrial = race.isTimeTrial

    OutputStreamer.writeRaceStart()

    # Refresh the main window and switch to the specified pane.
    mainWin = Utils.getMainWin()
    if mainWin is not None:
        mainWin.showPageName(page)
        mainWin.updateLapCounter()
        mainWin.refresh()

        if isTimeTrial:
            mainWin.menuPublishHtmlTTStart()

    # For safety, clear the undo stack after 8 seconds.
    undoResetTimer = wx.CallLater(8000, undo.clear)

    if race.ftpUploadDuringRace:
        realTimeFtpPublish.publishEntry(True)
Пример #13
0
def StartRaceNow():
	global undoResetTimer
	if undoResetTimer and undoResetTimer.IsRunning():
		undoResetTimer.Stop()
	undoResetTimer = None
	JChip.reset()
	
	undo.clear()
	undo.pushState()
	with Model.LockRace() as race:
		if race is None:
			return
		
		if not race.enableJChipIntegration:
			race.resetStartClockOnFirstTag = False
		
		Model.resetCache()
		race.startRaceNow()
		isTimeTrial = race.isTimeTrial
		
	OutputStreamer.writeRaceStart()
	
	# Refresh the main window and switch to the Record pane.
	mainWin = Utils.getMainWin()
	if mainWin is not None:
		mainWin.showPageName( _('Record') )
		mainWin.updateLapCounter()
		mainWin.refresh()
		
		if isTimeTrial and Utils.MessageOKCancel( mainWin, _('Create TTStart HTML Page?'), _('Create TTStart HTML Page?') ):
			mainWin.menuPublishHtmlTTStart()
	
	# For safety, clear the undo stack after 8 seconds.
	undoResetTimer = wx.CallLater( 8000, undo.clear )
	
	if race.ftpUploadDuringRace:
		realTimeFtpPublish.publishEntry( True )