aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-02-16 18:20:36 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-02-16 18:20:36 -0500
commit2df9e408a0ff74539862c4a4e562a878cc11a329 (patch)
treef9388ceb03bf4fe5166c2c474b68e08733a4a54a
parent83242972c09032eb89dd547f3ff3c4dcc2693555 (diff)
Code cleanup. Made Oval behavior (circle with h/w).
-rwxr-xr-xLightInstallation.py1
-rw-r--r--behaviors/Circle.py2
-rw-r--r--behaviors/ModifyParam.py3
-rw-r--r--behaviors/Oval.py36
-rw-r--r--behaviors/VerticalBar.py1
-rw-r--r--config/C5Sign.xml6
-rw-r--r--operationscore/PixelAssembler.py4
-rw-r--r--pixelmappers/SimpleMapper.py4
-rw-r--r--util/ComponentRegistry.py3
9 files changed, 45 insertions, 15 deletions
diff --git a/LightInstallation.py b/LightInstallation.py
index 91be752..19d6c54 100755
--- a/LightInstallation.py
+++ b/LightInstallation.py
@@ -181,7 +181,6 @@ class LightInstallation(object):
def processResponse(self,inputDict, responseDict):
inputId = inputDict['Id']
- #coming from.
boundBehaviorIds = self.inputBehaviorRegistry[inputId]
try:
[compReg.getComponent(b).addInput(responseDict) for b in boundBehaviorIds]
diff --git a/behaviors/Circle.py b/behaviors/Circle.py
index f3e103b..24d71f1 100644
--- a/behaviors/Circle.py
+++ b/behaviors/Circle.py
@@ -15,7 +15,7 @@ class Circle(Behavior):
data[self['Id']+'Radius'] = self['Radius']
rad = data[self['Id']+'Radius']
cond = '>=' if self['Outside'] else '<='
- circleStr = 'math.sqrt(({x}-'+str(xLoc)+')**2+(({y}-'+str(yLoc)+')**2)*2)'+cond+str(rad)
+ circleStr = 'math.sqrt(({x}-'+str(xLoc)+')**2+(({y}-'+str(yLoc)+')**2))'+cond+str(rad)
if self['Combine']:
data['Location'] += ',' + circleStr
else:
diff --git a/behaviors/ModifyParam.py b/behaviors/ModifyParam.py
index ebcb98f..6f81383 100644
--- a/behaviors/ModifyParam.py
+++ b/behaviors/ModifyParam.py
@@ -1,6 +1,5 @@
from operationscore.Behavior import *
import math
-import pdb
#Class to perform a given operation on some element of an argDict. Designed to be used a recursive hook, but can serve sensor-based functions as well. Specify ParamType (Sensor or Recurse), ParamName, and ParamOp, (a valid python statement with the old value represented as {val})
class ModifyParam(Behavior):
"""ModifyParam is a powerful class to perform an action on a specified key in the Argument
@@ -30,8 +29,6 @@ class ModifyParam(Behavior):
#TODO: move elsewhere
paramOp = paramOp.replace('{y}', "behaviorInput['Location'][1]")
paramOp = paramOp.replace('{x}', "behaviorInput['Location'][0]")
- if eval(paramOp) == None:
- import pdb; pdb.set_trace()
behaviorInput[paramName] = eval(paramOp)
if paramType == 'Sensor': #return accordingly
return (searchSet, recursiveInputs)
diff --git a/behaviors/Oval.py b/behaviors/Oval.py
new file mode 100644
index 0000000..b7486f5
--- /dev/null
+++ b/behaviors/Oval.py
@@ -0,0 +1,36 @@
+from operationscore.Behavior import *
+class Oval(Behavior):
+ def processResponse(self, sensors, recurs):
+ ret = []
+ for data in sensors:
+ #import pdb; pdb.set_trace()
+ height = width = 1
+ if 'Height' in self:
+ height = 1/float(self['Height'])
+ if 'Width' in self:
+ width = 1/float(self['Width'])
+ if 'CenterLoc' in data:
+ xLoc = data['CenterLoc'][0]
+ yLoc = data['CenterLoc'][1]
+ else:
+ data['CenterLoc'] = tuple(data['Location'])
+ xLoc = data['Location'][0]
+ yLoc = data['Location'][1]
+ if not self['Id']+'Radius' in data:
+ data[self['Id']+'Radius'] = self['Radius']
+ rad = data[self['Id']+'Radius']
+ cond = '>=' if self['Outside'] else '<='
+ circleStr = \
+ 'math.sqrt((({x}-%(xLoc)d))**2*%(width)d+(({y}-%(yLoc)d)**2)*%(height)d)%(cond)s%(rad)d' % \
+ locals()
+ if self['Combine']:
+ data['Location'] += ',' + circleStr
+ else:
+ data['Location'] = circleStr
+ ret.append(data)
+ return (ret, [])
+ def setLastOutput(self, output):
+ coutput = Behavior.deepCopyPacket(output)
+ for data in coutput:
+ data['Location'] = data['CenterLoc']
+ return coutput
diff --git a/behaviors/VerticalBar.py b/behaviors/VerticalBar.py
index 66c8e56..85960cb 100644
--- a/behaviors/VerticalBar.py
+++ b/behaviors/VerticalBar.py
@@ -5,7 +5,6 @@ class VerticalBar(Behavior):
ret = []
inputs = list(inputs)
for inputset in inputs:
- #import pdb; pdb.set_trace()
inputset = dict(inputset)
if 'xLoc' not in inputset:
inputset['xLoc'] = inputset['Location'][0]
diff --git a/config/C5Sign.xml b/config/C5Sign.xml
index a05cb1e..024f0d8 100644
--- a/config/C5Sign.xml
+++ b/config/C5Sign.xml
@@ -208,7 +208,7 @@
<Id>centerleft</Id>
<Id>center</Id>
</Inputs>
- <TimeMap>{'scanningbars':10,'runcolordecay':10,'expandingcircles':10}</TimeMap>
+ <TimeMap>{'scanningbars':0,'runcolordecay':10,'expandingcircles':10}</TimeMap>
<InputMap>{'scanningbars':'centerleft', 'runcolordecay':'center',\
'expandingcircles':'center'}</InputMap>
<RenderToScreen>True</RenderToScreen>
@@ -266,7 +266,7 @@
</Args>
</Behavior>
<Behavior>
- <Class>behaviors.Circle</Class>
+ <Class>behaviors.Oval</Class>
<Args>
<Id>innercircle</Id>
<Radius>0</Radius>
@@ -274,7 +274,7 @@
</Args>
</Behavior>
<Behavior>
- <Class>behaviors.Circle</Class>
+ <Class>behaviors.Oval</Class>
<Args>
<Id>outercircle</Id>
<Radius>3</Radius>
diff --git a/operationscore/PixelAssembler.py b/operationscore/PixelAssembler.py
index 582b59d..8ae27c9 100644
--- a/operationscore/PixelAssembler.py
+++ b/operationscore/PixelAssembler.py
@@ -19,10 +19,10 @@ class PixelAssembler(SmootCoreObject):
defined or improperly defined.')
if Geo.dist(newLocation, locations[-1]) > \
self['pixelToPixelSpacing']:
- import pdb; pdb.set_trace()
raise Exception('Illegal pixel location. Distance \
between adjacent pixels must be less than \
- pixelToPixelSpacing.')
+ pixelToPixelSpacing. Illegal distance is between '+str(pixelIndex) + ' and'\
+ + str(pixelIndex+1))
locations.append(newLocation)
if self['Reverse']:
locations.reverse()
diff --git a/pixelmappers/SimpleMapper.py b/pixelmappers/SimpleMapper.py
index 6603c98..1decdd1 100644
--- a/pixelmappers/SimpleMapper.py
+++ b/pixelmappers/SimpleMapper.py
@@ -44,7 +44,7 @@ class SimpleMapper(PixelMapper):
if pixelValid:
ret.append((pixel, 1))
except Exception as exp:
- import pdb; pdb.set_trace()
- raise Exception('Bad event condition')
+ exp.message += 'Bad Event Condition'
+ raise exp
return ret
diff --git a/util/ComponentRegistry.py b/util/ComponentRegistry.py
index 3036138..1db5135 100644
--- a/util/ComponentRegistry.py
+++ b/util/ComponentRegistry.py
@@ -1,4 +1,3 @@
-import pdb
import hashlib
from logger import main_log
import thread
@@ -41,7 +40,7 @@ def registerComponent(component, cid=None):
component['Id'] = cid
main_log.debug(cid + 'automatically assigned')
if cid in Registry:
- import pdb; pdb.set_trace()
+ main_log.warn(cid + 'overwritten.')
Registry[cid] = component
return cid