1 from operationscore.Behavior import *
2 import util.Strings as Strings
3 from logger import main_log
5 """AddPixelEvent is a behavior to append an arbitrary PixelEvent to a behavior response. The
6 classname of the PixelEvent should be specified in the Class field of Args. All arguments normally
7 passed to the PixelEvent should also be specified in Args."""
9 [module, className] = self['Class'].split('.')
10 try:
11 exec('from ' + module+'.'+className + ' import *', globals())
12 except Exception as inst:
13 main_log.error('Error importing ' + module+'.'+className+ '. Component not\
14 initialized.')
15 main_log.error(str(inst))
16 self.eventGenerator = eval('lambda args:'+className+'(args)')
17
18
19
21 ret = []
22 for sensory in sensors:
23 outDict = {}
24 outDict[Strings.LOCATION] = sensory[Strings.LOCATION]
25 settingsDict = dict(self.argDict)
26 settingsDict['Color'] = sensory['Color']
27 outDict['PixelEvent'] = self.eventGenerator(settingsDict)
28 ret.append(outDict)
29 return (ret, recurses)
30