aboutsummaryrefslogtreecommitdiff
path: root/operationscore
diff options
context:
space:
mode:
authorGravatar Russell Cohen <rcoh@mit.edu>2010-11-25 21:44:00 -0500
committerGravatar Russell Cohen <rcoh@mit.edu>2010-11-25 21:44:00 -0500
commit5783d6336f014c05e0e46d7bc35533e70b280582 (patch)
treeb4e0b0b2787b8fe464baadbd375ad6dc6c1dbf76 /operationscore
parentb042647b68abdc82490ca6e059993b8eba28904c (diff)
Added BehaviorChain to support chains of behaviors. Added FollowMouse
parameter to PygameInput to support following of mice. Added component registry to Util which allows any component to access any other component. Some changes to the structure of LightInstallation.
Diffstat (limited to 'operationscore')
-rw-r--r--operationscore/Behavior.py12
-rw-r--r--operationscore/Input.py12
2 files changed, 20 insertions, 4 deletions
diff --git a/operationscore/Behavior.py b/operationscore/Behavior.py
index f29430f..198c4b2 100644
--- a/operationscore/Behavior.py
+++ b/operationscore/Behavior.py
@@ -21,8 +21,16 @@ class Behavior(SmootCoreObject):
self.outGoingQueue = []
def processResponse(self, sensorInputs, recursiveInputs):
pass
- def addInput(self, sensorInputs):
- self.sensorResponseQueue.append(sensorInputs)
+ def addInput(self, sensorInput):
+ self.sensorResponseQueue.append(sensorInput)
+ #used for behavior chaining
+ def immediateProcessInput(self, sensorInputs):
+ return self.processResponse(sensorInputs, [])
+ def addInputs(self, sensorInputs):
+ if type(sensorInputs) == type([]):
+ [self.addInput(sensorInput) for sensorInput in sensorInputs]
+ else:
+ self.addInput(sensorInputs)
def recursiveReponse(self, args):
self.responseQueue.append(args)
def timeStep(self):
diff --git a/operationscore/Input.py b/operationscore/Input.py
index 1ba4528..67a7bb0 100644
--- a/operationscore/Input.py
+++ b/operationscore/Input.py
@@ -13,14 +13,22 @@ class Input(threading.Thread):
self.eventQueue = []
self.parentScope = argDict['parentScope']
self.argDict = argDict
- if not 'InputId' in argDict:
- raise Exception('InputId must be defined in config xml')
if not 'RefreshInterval' in argDict:
print 'RefreshInterval not defined. Defaulting to .5s.'
self.argDict['RefreshInterval'] = 500
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()