aboutsummaryrefslogtreecommitdiff
path: root/operationscore/Input.py
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2010-12-08 16:39:50 -0500
committerGravatar rcoh <rcoh@mit.edu>2010-12-08 16:39:50 -0500
commitb335b746523ffd59db1402b097a802b3fd99eaac (patch)
tree74333be1820f3d2666358c3b009beb14bf929256 /operationscore/Input.py
parent353ab16db64c86122c0fcb9e1852b85c14b354b8 (diff)
Code for the demo. Everything works afaik. Contains a couple more optimizations. Contains modify param behavior. Improved support for recursive hooks. Modifications to SmootCoreObject to get us closer to a fully multi-threaded system. This should be the last commit directly to master. All further commits should be on subranches and get merged.
Diffstat (limited to 'operationscore/Input.py')
-rw-r--r--operationscore/Input.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/operationscore/Input.py b/operationscore/Input.py
index 9ee59f8..2144678 100644
--- a/operationscore/Input.py
+++ b/operationscore/Input.py
@@ -1,4 +1,5 @@
import threading,time,Util
+from operationscore.SmootCoreObject import *
#Abstract class for inputs. Inheriting classes should call "respond" to raise
#their event. Inheriting classes MUST define sensingLoop. Called at the
#interval specified in RefreshInterval while the input is active. For example, if you are writing
@@ -6,7 +7,7 @@ import threading,time,Util
#Inheriting classes MAY define inputInit. This is called before the loop
#begins.
import pdb
-class Input(threading.Thread):
+class Input(SmootCoreObject):
#Event scope is a function pointer the function that will get called when
#an Parent is raised.
def __init__(self, argDict):
@@ -19,16 +20,6 @@ class Input(threading.Thread):
self.inputInit()
threading.Thread.__init__(self)
self.daemon = True #This kills this thread when the main thread stops
- #CHEATING until I can get multiple inheritence working
- def __setitem__(self,k, item):
- self.argDict[k] = item
- def __getitem__(self, item):
- if item in self.argDict:
- return self.argDict[item]
- else:
- return None
- def __getiter__(self):
- return self.argDict.__getiter__()
def respond(self, eventDict):
#if eventDict != []:
#pdb.set_trace()
@@ -48,7 +39,9 @@ class Input(threading.Thread):
def run(self):
while self.parentAlive():
time.sleep(self.argDict['RefreshInterval']/float(1000))
+ self.acquireLock()
self.sensingLoop()
+ self.releaseLock()
def sensingLoop(self):
pass
def inputInit(self):