git.cweiske.de
/
enigma2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add filename to record prepare
[enigma2.git]
/
timer.py
diff --git
a/timer.py
b/timer.py
index 294102b7c1720789c6d1985e0e8f1e76c5897da5..ad248e1872865d28402c942e97b72487210bf608 100644
(file)
--- a/
timer.py
+++ b/
timer.py
@@
-14,47
+14,47
@@
class TimerEntry:
StateEnded = 3
def __init__(self, begin, end):
StateEnded = 3
def __init__(self, begin, end):
- self.
B
egin = begin
- self.
Prepar
e = 10
- self.
E
nd = end
- self.
S
tate = 0
+ self.
b
egin = begin
+ self.
prepare_tim
e = 10
+ self.
e
nd = end
+ self.
s
tate = 0
def getTime(self):
def getTime(self):
- if self.
State == 0
:
- return self.
Begin - self.Prepar
e
- elif self.
State == 1
:
- return self.
B
egin
+ if self.
state == self.StateWait
:
+ return self.
begin - self.prepare_tim
e
+ elif self.
state == self.StatePrepare
:
+ return self.
b
egin
else:
else:
- return self.
E
nd
+ return self.
e
nd
def __lt__(self, o):
return self.getTime() < o.getTime()
def activate(self, event):
def __lt__(self, o):
return self.getTime() < o.getTime()
def activate(self, event):
- print "timer %s got activated (%d)!" % (self.
D
escription, event)
+ print "timer %s got activated (%d)!" % (self.
d
escription, event)
class Timer:
MaxWaitTime = 100
def __init__(self):
class Timer:
MaxWaitTime = 100
def __init__(self):
- self.
TimerL
ist = [ ]
- self.
ProcessedT
imers = [ ]
+ self.
timer_l
ist = [ ]
+ self.
processed_t
imers = [ ]
- self.
T
imer = eTimer()
- self.
T
imer.timeout.get().append(self.calcNextActivation)
+ self.
t
imer = eTimer()
+ self.
t
imer.timeout.get().append(self.calcNextActivation)
self.calcNextActivation()
def addTimerEntry(self, entry):
self.calcNextActivation()
def addTimerEntry(self, entry):
- bisect.insort(self.
TimerL
ist, entry)
+ bisect.insort(self.
timer_l
ist, entry)
self.calcNextActivation()
def setNextActivation(self, when):
delay = int((when - time()) * 1000)
self.calcNextActivation()
def setNextActivation(self, when):
delay = int((when - time()) * 1000)
- print "next activation: %d (in %d
second
s)" % (when, delay)
+ print "next activation: %d (in %d
m
s)" % (when, delay)
- self.
T
imer.start(delay, 1)
+ self.
t
imer.start(delay, 1)
self.next = when
def calcNextActivation(self):
self.next = when
def calcNextActivation(self):
@@
-63,28
+63,32
@@
class Timer:
min = int(time()) + self.MaxWaitTime
# calculate next activation point
min = int(time()) + self.MaxWaitTime
# calculate next activation point
- if len(self.
TimerL
ist):
- w = self.
TimerL
ist[0].getTime()
+ if len(self.
timer_l
ist):
+ w = self.
timer_l
ist[0].getTime()
if w < min:
min = w
self.setNextActivation(min)
if w < min:
min = w
self.setNextActivation(min)
+ def timeChanged(self, timer):
+ self.timer_list.remove(timer)
+ bisect.insort(self.timer_list, timer)
+
def doActivate(self, w):
def doActivate(self, w):
- w.activate(w.
S
tate)
- self.
TimerL
ist.remove(w)
- w.
S
tate += 1
- if w.
S
tate < TimerEntry.StateEnded:
- bisect.insort(self.
TimerL
ist, w)
+ w.activate(w.
s
tate)
+ self.
timer_l
ist.remove(w)
+ w.
s
tate += 1
+ if w.
s
tate < TimerEntry.StateEnded:
+ bisect.insort(self.
timer_l
ist, w)
else:
else:
- bisect.insort(self.
ProcessedT
imers, w)
+ bisect.insort(self.
processed_t
imers, w)
def processActivation(self):
t = int(time()) + 1
# we keep on processing the first entry until it goes into the future.
def processActivation(self):
t = int(time()) + 1
# we keep on processing the first entry until it goes into the future.
- while len(self.
TimerList) and self.TimerL
ist[0].getTime() < t:
- self.doActivate(self.
TimerL
ist[0])
+ while len(self.
timer_list) and self.timer_l
ist[0].getTime() < t:
+ self.doActivate(self.
timer_l
ist[0])
#t = Timer()
#base = time() + 5
#t = Timer()
#base = time() + 5