aboutsummaryrefslogtreecommitdiff
path: root/operationscore
diff options
context:
space:
mode:
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()