blob: 9c700ae1cde97f5af700c88ec11290b785d1c77d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# fake-enigma
import fake_time
class slot:
def __init__(self):
self.list = [ ]
def get(self):
return self.list
def __call__(self):
for x in self.list:
x()
timers = set()
import time
##################### ENIGMA BASE
class eTimer:
def __init__(self):
self.timeout = slot()
self.next_activation = None
def start(self, msec, singleshot = False):
self.next_activation = time.time() + msec / 1000.0
self.msec = msec
self.singleshot = singleshot
timers.add(self)
def stop():
timers.remove(self)
def __repr__(self):
return "<eTimer timeout=%s next_activation=%s singleshot=%s>" % (repr(self.timeout), repr(self.next_activation), repr(self.singleshot))
def do(self):
if self.singleshot:
self.stop()
self.next_activation += self.msec / 1000.0
print "next activation now %d " % self.next_activation
self.timeout()
def runIteration():
running_timers = list(timers)
assert len(running_timers), "no running timers, so nothing will ever happen!"
running_timers.sort(key=lambda x: x.next_activation)
print running_timers
next_timer = running_timers[0]
now = time.time()
delay = next_timer.next_activation - now
if delay > 0:
time.sleep(delay)
now += delay
while len(running_timers) and running_timers[0].next_activation <= now:
running_timers[0].do()
running_timers = running_timers[1:]
stopped = False
def stop():
global stopped
# print "STOP NOW"
# stopped = True
def run():
stoptimer = eTimer()
stoptimer.start(10000)
stoptimer.timeout.get().append(stop)
while not stopped:
runIteration()
##################### ENIGMA GUI
eSize = None
ePoint = None
gFont = None
eWindow = None
eLabel = None
ePixmap = None
eWindowStyleManager = None
loadPNG = None
addFont = None
gRGB = None
eWindowStyleSkinned = None
##################### ENIGMA CONFIG
import Components.config
my_config = [
"config.skin.primary_skin=None\n"
]
Components.config.config.unpickle(my_config)
|