-
Notifications
You must be signed in to change notification settings - Fork 0
/
TangibleEvents.py
48 lines (40 loc) · 1.29 KB
/
TangibleEvents.py
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
#!/usr/bin/env python
import json
from PropertyUtils import prop
ROTATE, BUTTONDOWN, BUTTONUP, TAGENTRY, \
TAGEXIT, SLIDE, SWITCH, POINT = range(8)
class Event(object):
def __init__(self, handle = '', source=None, type=-99, value=-99):
self.handle = handle
self.source = source
self.type = type
self.value = value
self._id = None
self._time_stamp = None
self._skew = None
#TODO: change 'value' to 'state' b/c value is a C# reserved word
def toJSONFormattedMessage(self):
try:
return json.write(self.__dict__)
except json.WriteException:
return ""
def fromJSONFormattedMessage(self, json_msg):
msg_dict = json.read(json_msg)
self.handle = msg_dict['handle']
self.source = msg_dict['source']
self.type = msg_dict['type']
self.value = msg_dict['value']
self._skew = msg_dict['_skew']
self._time_stamp = msg_dict['_time_stamp']
self._id = msg_dict['_id']
return self
@prop
def id(): pass
@prop
def time_stamp(): pass
@prop
def skew(): pass
class EventListener(object):
def handleEvent(self, event):
''' Unimplemented method to handle events on event's source '''
pass