fix taskMgr formatting, fix bug with delayed doLater tasks

This commit is contained in:
David Rose 2006-10-18 22:37:55 +00:00
parent b92660bf13
commit 3c0d5e6342

View File

@ -410,6 +410,7 @@ class TaskManager:
# Removing the tasks during the for loop is a bad idea # Removing the tasks during the for loop is a bad idea
# Instead we just flag them as removed # Instead we just flag them as removed
# Later, somebody else cleans them out # Later, somebody else cleans them out
currentTime = self.__getTime()
while self.__doLaterList: while self.__doLaterList:
# Check the first one on the list to see if it is ready # Check the first one on the list to see if it is ready
dl = self.__doLaterList[0] dl = self.__doLaterList[0]
@ -419,7 +420,7 @@ class TaskManager:
continue continue
# If the time now is less than the start of the doLater + delay # If the time now is less than the start of the doLater + delay
# then we are not ready yet, continue to next one # then we are not ready yet, continue to next one
elif task.time < dl.wakeTime: elif currentTime < dl.wakeTime:
# Since the list is sorted, the first one we get to, that # Since the list is sorted, the first one we get to, that
# is not ready to go, we can return # is not ready to go, we can return
break break
@ -898,6 +899,7 @@ class TaskManager:
+ 'priority'.rjust(priorityWidth) + 'priority'.rjust(priorityWidth)
+ '\n') + '\n')
str += '-------------------------------------------------------------------------\n' str += '-------------------------------------------------------------------------\n'
dtfmt = '%%%d.2f' % (dtWidth)
for taskPriList in self.taskList: for taskPriList in self.taskList:
priority = `taskPriList.getPriority()` priority = `taskPriList.getPriority()`
for task in taskPriList: for task in taskPriList:
@ -908,13 +910,12 @@ class TaskManager:
else: else:
taskName = task.name taskName = task.name
if self.taskTimerVerbose: if self.taskTimerVerbose:
import fpformat
totalDt = totalDt + task.dt totalDt = totalDt + task.dt
totalAvgDt = totalAvgDt + task.avgDt totalAvgDt = totalAvgDt + task.avgDt
str += (taskName.ljust(taskNameWidth) str += (taskName.ljust(taskNameWidth)
+ fpformat.fix(task.dt*1000, 2).rjust(dtWidth) + dtfmt % (task.dt*1000)
+ fpformat.fix(task.avgDt*1000, 2).rjust(dtWidth) + dtfmt % (task.avgDt*1000)
+ fpformat.fix(task.maxDt*1000, 2).rjust(dtWidth) + dtfmt % (task.maxDt*1000)
+ priority.rjust(priorityWidth) + priority.rjust(priorityWidth)
+ '\n') + '\n')
else: else:
@ -934,15 +935,25 @@ class TaskManager:
else: else:
taskName = '(P)' + task.name taskName = '(P)' + task.name
if (self.taskTimerVerbose): if (self.taskTimerVerbose):
import fpformat
str += (' ' + taskName.ljust(taskNameWidth-2) str += (' ' + taskName.ljust(taskNameWidth-2)
+ fpformat.fix(pri, 2).rjust(dtWidth) + dtfmt % (pri)
+ '\n') + '\n')
else: else:
str += (' ' + taskName.ljust(taskNameWidth-2) str += (' ' + taskName.ljust(taskNameWidth-2)
+ '----'.rjust(dtWidth) + '----'.rjust(dtWidth)
+ '\n') + '\n')
str += '-------------------------------------------------------------------------\n' str += '-------------------------------------------------------------------------\n'
if (self.taskTimerVerbose):
str += ('total'.ljust(taskNameWidth)
+ dtfmt % (totalDt*1000)
+ dtfmt % (totalAvgDt*1000)
+ '\n')
else:
str += ('total'.ljust(taskNameWidth)
+ '----'.rjust(dtWidth)
+ '----'.rjust(dtWidth)
+ '\n')
str += '-------------------------------------------------------------------------\n'
str += ('doLaterList'.ljust(taskNameWidth) str += ('doLaterList'.ljust(taskNameWidth)
+ 'waitTime(s)'.rjust(dtWidth) + 'waitTime(s)'.rjust(dtWidth)
+ '\n') + '\n')
@ -959,27 +970,10 @@ class TaskManager:
taskName = '(R)' + task.name taskName = '(R)' + task.name
else: else:
taskName = task.name taskName = task.name
if (self.taskTimerVerbose): str += (' ' + taskName.ljust(taskNameWidth-2)
import fpformat + dtfmt % (remainingTime)
str += (' ' + taskName.ljust(taskNameWidth-2) + '\n')
+ fpformat.fix(remainingTime, 2).rjust(dtWidth)
+ '\n')
else:
str += (' ' + taskName.ljust(taskNameWidth-2)
+ '----'.rjust(dtWidth)
+ '\n')
str += '-------------------------------------------------------------------------\n' str += '-------------------------------------------------------------------------\n'
if (self.taskTimerVerbose):
import fpformat
str += ('total'.ljust(taskNameWidth)
+ fpformat.fix(totalDt*1000, 2).rjust(dtWidth)
+ fpformat.fix(totalAvgDt*1000, 2).rjust(dtWidth)
+ '\n')
else:
str += ('total'.ljust(taskNameWidth)
+ '----'.rjust(dtWidth)
+ '----'.rjust(dtWidth)
+ '\n')
str += "End of taskMgr info\n" str += "End of taskMgr info\n"
return str return str
@ -1024,7 +1018,6 @@ class TaskManager:
def doOsd(self, task): def doOsd(self, task):
if not onScreenDebug.enabled: if not onScreenDebug.enabled:
return return
import fpformat
prefix = TaskManager.OsdPrefix prefix = TaskManager.OsdPrefix
onScreenDebug.removeAllWithPrefix(prefix) onScreenDebug.removeAllWithPrefix(prefix)
taskNameWidth = 32 taskNameWidth = 32
@ -1055,15 +1048,15 @@ class TaskManager:
onScreenDebug.add( onScreenDebug.add(
('%s%02i.%s' % (prefix, i, task.name)).ljust(taskNameWidth), ('%s%02i.%s' % (prefix, i, task.name)).ljust(taskNameWidth),
'%s %s %s %s' % ( '%s %s %s %s' % (
fpformat.fix(task.dt*1000, 2).rjust(dtWidth), dtfmt % (task.dt*1000),
fpformat.fix(task.avgDt*1000, 2).rjust(dtWidth), dtfmt % (task.avgDt*1000),
fpformat.fix(task.maxDt*1000, 2).rjust(dtWidth), dtfmt % (task.maxDt*1000),
priority.rjust(priorityWidth))) priority.rjust(priorityWidth)))
i += 1 i += 1
onScreenDebug.add(('%s%02i.total' % (prefix, i)).ljust(taskNameWidth), onScreenDebug.add(('%s%02i.total' % (prefix, i)).ljust(taskNameWidth),
'%s %s' % ( '%s %s' % (
fpformat.fix(totalDt*1000, 2).rjust(dtWidth), dtfmt % (totalDt*1000),
fpformat.fix(totalAvgDt*1000, 2).rjust(dtWidth),)) dtfmt % (totalAvgDt*1000),))
return cont return cont