From cb69d2e1c7ced951cbf7a31ee286b0ed92cab8a8 Mon Sep 17 00:00:00 2001 From: rcoh Date: Fri, 18 Feb 2011 16:56:43 -0500 Subject: Adding Epydoc generated docs. --- ...mootLight.behaviors.RestrictLocation-pysrc.html | 159 +++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 html/SmootLight.behaviors.RestrictLocation-pysrc.html (limited to 'html/SmootLight.behaviors.RestrictLocation-pysrc.html') diff --git a/html/SmootLight.behaviors.RestrictLocation-pysrc.html b/html/SmootLight.behaviors.RestrictLocation-pysrc.html new file mode 100644 index 0000000..8cdae37 --- /dev/null +++ b/html/SmootLight.behaviors.RestrictLocation-pysrc.html @@ -0,0 +1,159 @@ + + + + + SmootLight.behaviors.RestrictLocation + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Package SmootLight :: + Package behaviors :: + Module RestrictLocation + + + + + + +
[hide private]
[frames] | no frames]
+
+

Source Code for Module SmootLight.behaviors.RestrictLocation

+
+ 1  from operationscore.Behavior import * 
+ 2  import util.ComponentRegistry as compReg 
+ 3  from behaviors.ModifyParam import * 
+ 4  import util.Geo as Geo 
+ 5  import util.Strings as Strings 
+ 6  import random 
+ 7  import pdb 
+
8 -class RestrictLocation(Behavior): +
9 """RestrictLocation is a Behavior which does an action -- A ModifyParam, actually, when a certain +10 location based condition is met. It takes arguments as follows: +11 +12 <Action> -- Operation to perform, using ModifyParam syntax. Use {val} to reference the variable +13 specified by ParamName. +14 <ParamName> -- the name of the parameter to modify. +15 <LocationRestriction> -- either a tuple of (xmin,ymin,xmax,ymax) or a python-correct conditional. Use {x} and +16 {y} to reference x and y. Use &lt; and &gt; to get < and > in XML. EG: +17 <LocationRestriction>{x}&lt;0 or {x}&gt;800</LocationRestriction>""" +18 +
19 - def behaviorInit(self): +
20 action = self['Action'] +21 modifyParamArgs = {'ParamType': 'Sensor', +22 'ParamName':self['ParamName'],'ParamOp':self['Action']} +23 self.locBounds = self['LocationRestriction'] +24 self.paramModifier = ModifyParam(modifyParamArgs) +25 if isinstance(self.locBounds, str): +26 self.locBounds = self.locBounds.replace('{x}', 'l[0]') +27 self.locBounds = self.locBounds.replace('{y}', 'l[1]') +28 self.locEval = eval('lambda l:'+self.locBounds) +29 elif isinstance(self.locBounds, tuple): +30 if len(self.locBounds) != 4: +31 raise Exception('Must be in form (xmin,yin,xmax,ymax)') +32 else: +33 self.locEval = lambda l:Geo.pointWithinBoundingBox(l,\ +34 self.LocBounds) +
35 - def processResponse(self, sensorInputs, recursiveInputs): +
36 ret = [] +37 for data in sensorInputs: +38 if self.locEval(data['Location']): +39 (dataOut, recur) = self.paramModifier.immediateProcessInput([data], []) +40 #behaviors expect lists ^[] +41 ret += dataOut +42 else: +43 ret.append(data) +44 return (ret, []) +
45 +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + -- cgit v1.2.3