blob: 7f134e1970e684725b1d88bcd19f11843948d675 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
from operationscore.Behavior import *
import util.Strings as Strings
from logger import main_log
class AddPixelEvent(Behavior):
def behaviorInit(self):
[module, className] = self['Class'].split('.')
try:
exec('from ' + module+'.'+className + ' import *', globals())
except Exception as inst:
main_log.error('Error importing ' + module+'.'+className+ '. Component not\
initialized.')
main_log.error(str(inst))
self.eventGenerator = eval('lambda args:'+className+'(args)')
#^lambda function to do generate new event (takes args)
def processResponse(self, sensors, recurses):
ret = []
for sensory in sensors:
outDict = {}
outDict[Strings.LOCATION] = sensory[Strings.LOCATION]
settingsDict = dict(self.argDict)
settingsDict['Color'] = sensory['Color']
outDict['PixelEvent'] = self.eventGenerator(settingsDict)
ret.append(outDict)
return (ret, recurses)
|