aboutsummaryrefslogtreecommitdiffstats
path: root/examples/signal_test.py
blob: 0f3dc9c135a0c74cba06c54e1e818ce6c3c0ea9f (plain) (blame)
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
# -*- coding: UTF-8 -*-

from base.eodefault import *
from eobase import EoBase
from signals.signals_py import Simple

def cb_del(o):
  print "OBJECT DELETED"

def cb_free(o):
  print "OBJECT FREED"

def cb_a_changed(o):
  print "A_CHANGED"

def cb_a_changed_stop(o):
  print "A_CHANGED_STOP"
  return CALLBACK_STOP

def cb_add(o):
  print "CALBACK_ADD"
def cb_del(o):
  print "CALBACK_DEL"


print "Creating Simple object"
sobj = Simple(None)


print "adding event on EV_DELETING"
sobj.event_callback_priority_add(EoBase.DEL, 0, cb_del)

print "adding event on CHANGING"
sobj.event_callback_priority_add(Simple.A_CHANGED, 0, cb_a_changed)

print "adding event on EV_ADDING"
sobj.event_callback_priority_add(EoBase.CALLBACK_ADD, 0, cb_add)

print "adding 2 events on EV_DELETING"
sobj.event_callback_priority_add(EoBase.CALLBACK_DEL, 0, cb_del)
sobj.event_callback_priority_add(EoBase.CALLBACK_DEL, 0, cb_del)

print "adding event on CHANGING"
sobj.event_callback_priority_add(Simple.A_CHANGED, 0, cb_a_changed)

print "adding 2nd event on ADDING"
sobj.event_callback_priority_add(EoBase.CALLBACK_ADD, 0, cb_add)

sobj.a_set(4)

print "deleting event on EV_ADDING"
sobj.event_callback_del(EoBase.CALLBACK_ADD, cb_add)

print "deleting event on EV_DELETING"
sobj.event_callback_del(EoBase.CALLBACK_DEL, cb_del)

print "adding 4 events on CHANGING, second is STOP"
sobj.event_callback_priority_add(Simple.A_CHANGED, 0, cb_a_changed)
sobj.event_callback_priority_add(Simple.A_CHANGED, 0, cb_a_changed_stop)
sobj.event_callback_priority_add(Simple.A_CHANGED, 0, cb_a_changed)
sobj.event_callback_priority_add(Simple.A_CHANGED, 0, cb_a_changed)

sobj.a_set(5)


print "deleting event on CHANGING"
res = sobj.event_callback_del(Simple.A_CHANGED, cb_a_changed)
print "Res:", res

print "explicitly calling ON_CHANGE"
res = sobj.event_callback_call(Simple.A_CHANGED, (123,123))
print "Res:", res


sobj.event_global_freeze()

sobj.a_set(89)
#sobj.b_set(8)

#res = sobj.c_get()
#print "Res:", res

del sobj