[Controller]
- refactored - added IPC for RUN, PAUSE, STOP, STIRR ON/OFF [TIMER] - fixed default minimum wait time - added duration to elapse git-svn-id: http://moon:8086/svn/projects/HendiControl@277 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
@@ -9,6 +9,7 @@ class Timer(object):
|
||||
self.mode = 'periodic'
|
||||
self.interval = 0
|
||||
self.elapseTime = 0
|
||||
self.elapseDuration = 0
|
||||
self.count = 0
|
||||
|
||||
def start(self, interval, mode='periodic'):
|
||||
@@ -29,9 +30,11 @@ class Timer(object):
|
||||
def isElapsed(self):
|
||||
result = False
|
||||
now = time.time()
|
||||
self.elapseDuration = max(0, self.elapseTime - now)
|
||||
if self.isActive:
|
||||
if self.elapseTime <= now:
|
||||
if self.elapseDuration == 0:
|
||||
result = True
|
||||
self.isActive = False
|
||||
if 'periodic' in self.mode:
|
||||
self.start(self.interval, self.mode)
|
||||
|
||||
@@ -61,7 +64,6 @@ class TimerManager(object):
|
||||
timer.count += 1
|
||||
|
||||
def getMinTimeout(self, default=1.0):
|
||||
minTimeout = default
|
||||
timeouts = []
|
||||
for timer in self.timers:
|
||||
now = time.time()
|
||||
@@ -72,7 +74,7 @@ class TimerManager(object):
|
||||
if len(timeouts) > 0:
|
||||
minTimeout = min(timeouts)
|
||||
|
||||
return minTimeout
|
||||
return max(default, minTimeout)
|
||||
|
||||
if __name__ == '__main__':
|
||||
class Test (TimerListener):
|
||||
|
||||
Reference in New Issue
Block a user