- def addTimerEntry(self, entry):
- bisect.insort(self.TimerList, entry)
- self.calcNextActivation()
+ def stateChanged(self, entry):
+ for f in self.on_state_change:
+ f(entry)
+
+ def getNextRecordingTime(self):
+ if len(self.timer_list) > 0:
+ return self.timer_list[0].begin
+ return -1
+
+ def cleanup(self):
+ self.processed_timers = [entry for entry in self.processed_timers if entry.disabled]
+
+ def addTimerEntry(self, entry, noRecalc=0):
+ entry.processRepeated()
+
+ # when the timer has not yet started, and is already passed,
+ # don't go trough waiting/running/end-states, but sort it
+ # right into the processedTimers.
+ if entry.shouldSkip() or entry.state == TimerEntry.StateEnded or (entry.state == TimerEntry.StateWaiting and entry.disabled):
+ print "already passed, skipping"
+ print "shouldSkip:", entry.shouldSkip()
+ print "state == ended", entry.state == TimerEntry.StateEnded
+ print "waiting && disabled:", (entry.state == TimerEntry.StateWaiting and entry.disabled)
+ bisect.insort(self.processed_timers, entry)
+ entry.state = TimerEntry.StateEnded
+ else:
+ bisect.insort(self.timer_list, entry)
+ if not noRecalc:
+ self.calcNextActivation()