Ejemplo n.º 1
0
def invoke_event(*args):
    print "invoked"
    ev_name = tt.get_top(args)
    splited = tt.split(args, 1)
    striped_args = splited[1]
    if striped_args:
        event.bang(ev_name, *striped_args)
    else:
        event.bang(ev_name)
Ejemplo n.º 2
0
def bang(adr, *args):
    obj = seek(adr) #get stored data
    ms = obj[1]
    state = obj[2]
    if state:
        ev.bang(adr, *args)
        ev.bang("/update_with_false", ms, adr)
        delay.bang(ms, "/update_with_true" , ms, adr)
    else:
        return False
Ejemplo n.º 3
0
 def run(self):
     while (self.cycle):
         for i in range(self.times):
             self.doing = True
             #if set new param, break now repeat
             if self.interrupt == True:
                 self.interrupt = False
                 self.doing = False
                 event.bang(self.end_event)
                 break
             #bang event
             event.bang(self.event_name)
             time.sleep(self.interval)
             # Finalize process
             if i == (self.times - 1):
                 if self.end_event != None:
                     event.bang(self.end_event)
                 self.times = 0
                 self.doing = False
Ejemplo n.º 4
0
import event


def foo():
    print("foo1 was invoked")


def foo2(num):
    print("foo2 is {0}".format(num))


event.add("foo1", foo)
event.add("foo2", foo2)
event.bang("foo1")
event.bang("foo2", 137)  #add arg
Ejemplo n.º 5
0
#START TEST1
print "---------------------"
print "Star test1 ..."
print "foo() gate opens every", FOO_GATE_TIME, "ms."
print "bar() gate opens every", BAR_GATE_TIME, "ms."
time.sleep(2.0)

#set test1 end timer
delay.bang(3600.0, "/test_end")
#execute test 1
while do_test:
    tg.bang("/foo", 137)
    tg.bang("/bar", 138)
    if metro.update():
        print "+++"
        print threading.enumerate()

print "--------------"
print "start test2..."
event.bang("/test_start")
#set timer to end the next test
delay.bang(7.0, "/test_end")
#Youcan set event and its interval and bang at once with setbang()
tg.setbang(1.0, "/baz", 139)
while do_test:
    tg.bang("/baz", 140)

print "--------------"
print "ALL TEST is finished."
Ejemplo n.º 6
0
 	def callback(self, add, tags, stuff, source):
		print add
		event.bang(add, stuff)
Ejemplo n.º 7
0
import event


def foo():
    print("foo1 was invoked")


def foo2(num):
    print("foo2 is {0}".format(num))


event.add("foo1", foo)
event.add("foo2", foo2)
event.bang("foo1")
event.bang("foo2", 137)  # add arg
Ejemplo n.º 8
0
 def test(self):
     event.bang(self.event_name)
Ejemplo n.º 9
0
 def stop(self):
     event.bang(self.end_event)
     self.cycle = False
     self.interrupt = True
Ejemplo n.º 10
0
 def callback(self, add, tags, stuff, source):
     print(add)
     event.bang(add, stuff)
Ejemplo n.º 11
0
 def timer_bang(self):
     #         tev.bang(self.event_name, self.args)
     event.bang(self.event_name, *self.args)
Ejemplo n.º 12
0
 def dump(self):
     while len(self.deq):
         elm = self.deq.popleft()
         event.bang(elm[0], *elm[1])