aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--behaviors/MobileShakeBehavior.py17
-rw-r--r--behaviors/MoveBehavior.py16
-rw-r--r--config/MobileTest.xml28
3 files changed, 52 insertions, 9 deletions
diff --git a/behaviors/MobileShakeBehavior.py b/behaviors/MobileShakeBehavior.py
new file mode 100644
index 0000000..e25e929
--- /dev/null
+++ b/behaviors/MobileShakeBehavior.py
@@ -0,0 +1,17 @@
+from operationscore.Behavior import *
+import util.Strings as Strings
+
+class MobileShakeBehavior(Behavior):
+ def processResponse(self, sensorInputs, recursiveInputs):
+ #print sensorInputs
+ ret = []
+ for sInput in sensorInputs:
+ outDict = dict(sInput)
+ if 'type' in sInput and sInput['type'] == 2:
+ outDict['Location'] = '{x}>' + str(0) + ',{y}>' + str(0)
+ outDict['Color'] = [sInput['r'], sInput['g'], sInput['b']]
+ else: # dumb invisible pixel
+ outDict['Location'] = (-1, -1)
+ outDict['Color'] = [0, 0, 0]
+ ret.append(outDict)
+ return (ret, recursiveInputs)
diff --git a/behaviors/MoveBehavior.py b/behaviors/MoveBehavior.py
index d2f60a0..e504ca9 100644
--- a/behaviors/MoveBehavior.py
+++ b/behaviors/MoveBehavior.py
@@ -1,7 +1,7 @@
from operationscore.Behavior import *
-import util.ComponentRegistry as compReg
-import util.Geo as Geo
-import util.Strings as Strings
+#import util.ComponentRegistry as compReg
+#import util.Geo as Geo
+#import util.Strings as Strings
class MoveBehavior(Behavior):
"""Moves current location by the x and y components of sensorInput. Uses recurrences to track
@@ -18,9 +18,13 @@ class MoveBehavior(Behavior):
for currRecLoc in currRecLocs:
currDict = dict(currRecLoc)
for sensorInput in sensorInputs:
- currDict['Location'] = (currDict['Location'][0] - sensorInput['x'] * self['XStep'], \
- currDict['Location'][1] + sensorInput['y'] * self['YStep'])
- currDict['Color'] = [sensorInput['r'], sensorInput['g'], sensorInput['b']]
+ if 'type' in sensorInput and sensorInput['type'] == 1:
+ currDict['Location'] = (currDict['Location'][0] - sensorInput['x'] * self['XStep'], \
+ currDict['Location'][1] + sensorInput['y'] * self['YStep'])
+ currDict['Color'] = [sensorInput['r'], sensorInput['g'], sensorInput['b']]
+ #elif sensorInput['type'] == 2:
+ # currDict['Shake'] = 1
+ # currDict['Force'] = sensorInput['force']
ret.append(currDict)
#print ret
return (ret, ret)
diff --git a/config/MobileTest.xml b/config/MobileTest.xml
index a318069..af94c25 100644
--- a/config/MobileTest.xml
+++ b/config/MobileTest.xml
@@ -207,10 +207,17 @@
<Class>behaviors.MoveBehavior</Class>
<Args>
<Id>move</Id>
- <XStep>5</XStep>
- <YStep>5</YStep>
+ <XStep>3</XStep>
+ <YStep>3</YStep>
</Args>
</Behavior>
+ <Behavior>
+ <Class>behaviors.MobileShakeBehavior</Class>
+ <Args>
+ <Id>mobileshake</Id>
+ <SizeMult>3</SizeMult>
+ </Args>
+ </Behavior>
<Behavior>
<Class>behaviors.BehaviorChain</Class>
<Args>
@@ -222,9 +229,24 @@
<Id>move</Id>
<Id>decay</Id>
</ChainedBehaviors>
- <RenderToScreen>True</RenderToScreen>
+ <RenderToScreen>True</RenderToScreen>
<Mapper>gaussmap</Mapper>
</Args>
</Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>shakeanddecay</Id>
+ <Inputs>
+ <Id>tcp</Id>
+ </Inputs>
+ <ChainedBehaviors>
+ <Id>mobileshake</Id>
+ <Id>slowdecay</Id>
+ </ChainedBehaviors>
+ <RenderToScreen>True</RenderToScreen>
+ <Mapper>simplemap</Mapper>
+ </Args>
+ </Behavior>
</BehaviorConfiguration>
</LightInstallation>