コード例 #1
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 )
コード例 #2
0
ファイル: ChipReader.py プロジェクト: scottwedge/CrossMgr
	def reset( self, chipReaderType=None ):
		if self.chipReaderType is not None:
			JChip.StopListener()
			RaceResult.StopListener()
			Ultra.StopListener()
		
		self.chipReaderType = (chipReaderType or ChipReader.JChip)
		
		if self.chipReaderType == ChipReader.RaceResult:
			self.StartListener = RaceResult.StartListener
			self.GetData = RaceResult.GetData
			self.StopListener = RaceResult.StopListener
			self.CleanupListener = RaceResult.CleanupListener
			self.IsListening = RaceResult.IsListening
			
		elif self.chipReaderType == ChipReader.Ultra:
			self.StartListener = Ultra.StartListener
			self.GetData = Ultra.GetData
			self.StopListener = Ultra.StopListener
			self.CleanupListener = Ultra.CleanupListener
			self.IsListening = Ultra.IsListening
			
		else: # self.chipReaderType == ChipReader.JChip:
			self.StartListener = JChip.StartListener
			self.GetData = JChip.GetData
			self.StopListener = JChip.StopListener
			self.CleanupListener = JChip.CleanupListener
			self.IsListening = JChip.IsListening
コード例 #3
0
ファイル: Actions.py プロジェクト: zbanga/abundata
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 )
コード例 #4
0
ファイル: JChipImport.py プロジェクト: ZigmundRat/CrossMgr
def parseTagTime( line, lineNo, errors ):
	try:
		fields = line.split()
		tag = fields[0][1:]
		tStr = fields[1]
	except IndexError:
		errors.append( 'line {}: unrecognised input'.format(lineNo) )
		return None, None
	
	try:
		day = int(fields[2][1:2])
	except:
		day = 0
	
	try:
		t = JChip.parseTime(tStr, day)
	except (IndexError, ValueError):
		errors.append( 'line {}: invalid time: "{}"'.format(lineNo, tStr) )
		return None, None
	
	return tag, t
コード例 #5
0
ファイル: JChipImport.py プロジェクト: pythonthings/CrossMgr
def parseTagTime(line, lineNo, errors):
    try:
        fields = line.split()
        tag = fields[0][1:]
        tStr = fields[1]
    except IndexError:
        errors.append('line {}: unrecognised input'.format(lineNo))
        return None, None

    try:
        day = int(fields[2][1:2])
    except:
        day = 0

    try:
        t = JChip.parseTime(tStr, day)
    except (IndexError, ValueError):
        errors.append('line {}: invalid time: "{}"'.format(lineNo, tStr))
        return None, None

    return tag, t
コード例 #6
0
ファイル: ChipImport.py プロジェクト: esitarski/CrossMgr
def DoChipImport(	fname, parseTagTime, startTime = None,
					clearExistingData = True, timeAdjustment = None ):
	
	race = Model.race
	if race and race.isRunning():
		Utils.MessageOK( Utils.getMainWin(), u'\n\n'.join( [_('Cannot Import into a Running Race.'), _('Wait until you have a complete data set, then import the full data into a New race.')] ),
						title = _('Cannot Import into Running Race'), iconMask = wx.ICON_ERROR )
		return
	
	# If startTime is None, the first time will be taken as the start time.
	# All first time's for each rider will then be ignored.
	
	if timeAdjustment is None:
		timeAdjustment = datetime.timedelta(seconds=0.0)
	
	errors = []
	raceStart = None
	
	with io.open(fname, encoding='utf-8') as f, Model.LockRace() as race:
		year, month, day = [int(n) for n in race.date.split('-')]
		raceDate = datetime.date( year=year, month=month, day=day )
		JChip.reset( raceDate )
		if startTime:
			raceStart = datetime.datetime.combine( raceDate, startTime )
			race.resetStartClockOnFirstTag = False
		else:
			race.resetStartClockOnFirstTag = True
		
		tagNums = GetTagNums( True )
		race.missingTags = set()
		
		tFirst, tLast = None, None
		lineNo = 0
		riderRaceTimes = {}
		for line in f:
			lineNo += 1
			
			line = line.strip()
			if not line or line[0] in '#;':
				continue
			
			tag, t = parseTagTime( line, lineNo, errors )
			if tag is None:
				continue
			if raceStart and t < raceStart:
				errors.append( u'{} {}: {} ({})'.format(_('line'), lineNo, _('time is before race start'), t.strftime('%H:%M:%S.%f')) )
				continue
			
			tag = tag.lstrip('0').upper()
			t += timeAdjustment
			
			if not tFirst:
				tFirst = t
			tLast = t
			try:
				num = tagNums[tag]
				riderRaceTimes.setdefault( num, [] ).append( t )
			except KeyError:
				if tag not in race.missingTags:
					errors.append( u'{} {}: {}: {}'.format(_('line'), lineNo, _('tag missing from Excel sheet'), tag) )
					race.missingTags.add( tag )
				continue

		#------------------------------------------------------------------------------
		# Populate the race with the times.
		if not riderRaceTimes:
			errors.insert( 0, _('No matching tags found in Excel link.  Import aborted.') )
			return errors
		
		# Put all the rider times into the race.
		if clearExistingData:
			race.clearAllRiderTimes()
			
		if not raceStart:
			raceStart = tFirst
			
		race.startTime = raceStart
		
		for num, lapTimes in six.iteritems(riderRaceTimes):
			for t in lapTimes:
				raceTime = (t - raceStart).total_seconds()
				if not race.hasTime(num, raceTime):
					race.addTime( num, raceTime )
			
		if tLast:
			race.finishTime = tLast + datetime.timedelta( seconds = 0.0001 )
			
		# Figure out the race minutes from the recorded laps.
		if riderRaceTimes:
			lapNumMax = max( len(ts) for ts in six.itervalues(riderRaceTimes) )
			if lapNumMax > 0:
				tElapsed = min( ts[-1] for ts in six.itervalues(riderRaceTimes) if len(ts) == lapNumMax )
				raceMinutes = int((tElapsed - raceStart).total_seconds() / 60.0) + 1
				race.minutes = raceMinutes
		
	return errors
コード例 #7
0
ファイル: ChipImport.py プロジェクト: Adefx/CrossMgr
def DoChipImport(	fname, parseTagTime, startTime = None,
					clearExistingData = True, timeAdjustment = None ):
	
	race = Model.race
	if race and race.isRunning():
		Utils.MessageOK( Utils.getMainWin(), u'\n\n'.join( [_('Cannot Import into a Running Race.'), _('Wait until you have a complete data set, then import the full data into a New race.')] ),
						title = _('Cannot Import into Running Race'), iconMask = wx.ICON_ERROR )
		return
	
	# If startTime is None, the first time will be taken as the start time.
	# All first time's for each rider will then be ignored.
	
	if timeAdjustment is None:
		timeAdjustment = datetime.timedelta(seconds=0.0)
	
	errors = []
	raceStart = None
	
	with open(fname) as f, Model.LockRace() as race:
		year, month, day = [int(n) for n in race.date.split('-')]
		raceDate = datetime.date( year=year, month=month, day=day )
		JChip.reset( raceDate )
		if startTime:
			raceStart = datetime.datetime.combine( raceDate, startTime )
			race.resetStartClockOnFirstTag = False
		else:
			race.resetStartClockOnFirstTag = True
		
		tagNums = GetTagNums( True )
		race.missingTags = set()
		
		tFirst, tLast = None, None
		lineNo = 0
		riderRaceTimes = {}
		for line in f:
			lineNo += 1
			
			line = line.strip()
			if not line or line[0] in '#;':
				continue
			
			tag, t = parseTagTime( line, lineNo, errors )
			if tag is None:
				continue
			if raceStart and t < raceStart:
				errors.append( u'{} {}: {} ({})'.format(_('line'), lineNo, _('time is before race start'), t.strftime('%H:%M:%S.%f')) )
				continue
			
			tag = tag.lstrip('0').upper()
			t += timeAdjustment
			
			if not tFirst:
				tFirst = t
			tLast = t
			try:
				num = tagNums[tag]
				riderRaceTimes.setdefault( num, [] ).append( t )
			except KeyError:
				if tag not in race.missingTags:
					errors.append( u'{} {}: {}: {}'.format(_('line'), lineNo, _('tag missing from Excel sheet'), tag) )
					race.missingTags.add( tag )
				continue

		#------------------------------------------------------------------------------
		# Populate the race with the times.
		if not riderRaceTimes:
			errors.insert( 0, _('No matching tags found in Excel link.  Import aborted.') )
			return errors
		
		# Put all the rider times into the race.
		if clearExistingData:
			race.clearAllRiderTimes()
			
		if not raceStart:
			raceStart = tFirst
			
		race.startTime = raceStart
		
		for num, lapTimes in riderRaceTimes.iteritems():
			for t in lapTimes:
				raceTime = (t - raceStart).total_seconds()
				if not race.hasTime(num, raceTime):
					race.addTime( num, raceTime )
			
		if tLast:
			race.finishTime = tLast + datetime.timedelta( seconds = 0.0001 )
			
		# Figure out the race minutes from the recorded laps.
		if riderRaceTimes:
			lapNumMax = max( len(ts) for ts in riderRaceTimes.itervalues() )
			if lapNumMax > 0:
				tElapsed = min( ts[-1] for ts in riderRaceTimes.itervalues() if len(ts) == lapNumMax )
				raceMinutes = int((tElapsed - raceStart).total_seconds() / 60.0) + 1
				race.minutes = raceMinutes
		
	return errors