本文整理汇总了Python中util.ComponentRegistry类的典型用法代码示例。如果您正苦于以下问题:Python ComponentRegistry类的具体用法?Python ComponentRegistry怎么用?Python ComponentRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ComponentRegistry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: processResponse
def processResponse(self, data, recurs):
for packet in data:
message = ""
#try:
if 1:
if not 'OperationType' in packet:
packet['OperationType'] = 'Update'
if packet['OperationType'] == 'Create':
raise Exception('Create is not supported')
compFactory.create(packet['Class'], packet['Args'])
elif packet['OperationType'] == 'Read':
self.doRead(packet)
elif packet['OperationType'] == 'Update':
cid = packet['ComponentId']
paramName = packet['ParamName']
newParamValue = attemptEval(str(packet['Value']))
currentObject=compReg.getComponent(cid)
self.doUpdate(cid,paramName,newParamValue,currentObject,packet['Callback'])
#TODO: consider adding lambda evaluation capabilities
elif packet['OperationType'] == 'Destroy':
raise Exception('Destroy not supported')
compReg.removeComponent(packet['ComponentId'])
try:
print 1
except Exception, e:
print str(e)
import pdb; pdb.set_trace()
开发者ID:andychen,项目名称:SmootLight,代码行数:29,代码来源:SystemConfigMutator.py
示例2: processResponse
def processResponse(self, sensorInputs, recursiveInputs):
if self.mapper == None:
try:
self.mapper = compReg.getComponent('windgaussmap')
except KeyError:
pass
if self.xymove == None:
try:
self.xymove = compReg.getComponent('xymove')
except KeyError:
pass
outs = []
for sensory in sensorInputs:
#print sensory
# input[0] is windspeed, [1] is dir
if 'WindSpeed' in sensory and 'WindDir' in sensory:
windSpeed = sensory['WindSpeed']
windDir = sensory['WindDir']
print 'speed', windSpeed
print 'dir', windDir
#self.mapper.Width = float(windSpeed)*2+15
sensory['XVel'] = float(windSpeed)+10*random.random()
sensory['YVel'] = float(windSpeed)/3.*random.uniform(-1,1)
#self.xymove.XStep = float(windSpeed)+10*random.random();
#self.xymove.YStep = float(windSpeed)/3.*random.uniform(-1,1);
#print 'Width: ' , self.mapper.Width
#print 'xymove: (' , self.xymove.XStep, ', ', self.xymove.YStep, ')'
else:
outs.append(sensory)
return (outs, [])
开发者ID:andychen,项目名称:SmootLight,代码行数:31,代码来源:SmootWind.py
示例3: transitionOut
def transitionOut (self): #switch out of fade out
print self['Id'], "transitionOut", self.transition
if self.transOnChange == 'Pause':
compReg.getComponent(self.transition).pauseInputs()
self.transition = None
self.transitionout = None
self.transoutState = []
开发者ID:andychen,项目名称:SmootLight,代码行数:7,代码来源:BehaviorSequence.py
示例4: processResponse
def processResponse(self, sensorInputs, recursiveInputs):
if self.mapper == None:
try:
self.mapper = compReg.getComponent('windgaussmap')
except KeyError:
pass
if self.xFor == None:
try:
self.xFor = compReg.getComponent('xfor')
except KeyError:
pass
for sensory in sensorInputs:
print sensory
# input[0] is windspeed, [1] is dir
if 0 in sensory and 1 in sensory:
windSpeed = sensory[0]
windDir = sensory[1]
#print self.mapper.argDict
self.mapper.argDict['Width'] = self.mapper.argDict['Width']+float(windSpeed)*2+20
self.xFor.argDict['ParamOp'] = self.xFor.argDict['ParamOp']+float(windSpeed)*3+10*random.random();
#print 'Width: ' + str(self.mapper.argDict['Width'])
#print 'xFor: ' + str(self.xFor.argDict['ParamOp'])
elif 'Key' in sensory:
if sensory['Key'] == 273:
self.mapper.argDict['Width'] = self.mapper.argDict['Width']+10;
self.xFor.argDict['ParamOp'] = self.xFor.argDict['ParamOp']+5;
elif sensory['Key'] == 274:
self.mapper.argDict['Width'] = self.mapper.argDict['Width']-10;
self.xFor.argDict['ParamOp'] = self.xFor.argDict['ParamOp']-5;
return (sensorInputs, recursiveInputs)
开发者ID:dxiao,项目名称:SmootLight,代码行数:34,代码来源:SmootWind.py
示例5: configureInstallation
def configureInstallation(self, installationConfig):
defaults = configGetter.generateArgDict(installationConfig.find('Defaults'))
for defaultSelection in defaults:
componentToMap = compReg.getComponent(defaults[defaultSelection])
compReg.registerComponent(compReg.getComponent(defaults[defaultSelection]),\
'Default'+defaultSelection)
main_log.debug('Default Set: ' + defaultSelection + 'set to ' +\
defaults[defaultSelection])
开发者ID:smootlight2,项目名称:SmootLight,代码行数:8,代码来源:LightInstallation.py
示例6: inputInit
def inputInit(self):
xvals = {}
yvals = {}
compReg.getLock().acquire()
xvals['left'], yvals['bottom'], xvals['right'], yvals['top'] = compReg.getComponent('Screen').getSize()
compReg.getLock().release()
(xvals['center'], yvals['center']) = ((xvals['left']+xvals['right']) / 2, (yvals['top']+yvals['bottom']) / 2)
self.location = (xvals[self['xloc']], yvals[self['yloc']])
开发者ID:dxiao,项目名称:SmootLight,代码行数:9,代码来源:ContinuousLocationInput.py
示例7: startBehavior
def startBehavior (self):
print self['Id'], "startBehavior", self.behavior
if self.transin:
self.transinState = \
compReg.getComponent(self.transin).behaviorInit()
if self.onChange == 'Pause':
compReg.getComponent(self.behavior).resumeInputs()
elif self.onChange == 'Restart':
compReg.getComponent(self.behavior).init()
开发者ID:andychen,项目名称:SmootLight,代码行数:9,代码来源:BehaviorSequence.py
示例8: inputInit
def inputInit(self):
compReg.getLock().acquire()
xmin, ymin, xmax, ymax = compReg.getComponent('Screen').size
compReg.getLock().release()
xlen = xmax-xmin
ylen = ymax-ymin
self.xloc = xmin + xlen * self['xPos']
self.yloc = ymin + ylen * self['yPos']
开发者ID:andychen,项目名称:SmootLight,代码行数:10,代码来源:InitialLocationInput.py
示例9: test_modify_components
def test_modify_components(self):
modifier = SystemConfigMutator({'Id':'mutate'})
modifier.immediateProcessInput({'OperationType':'Update',\
'ComponentId':'color','ParamName':'ColorList',
'Value':[(0,0,255)]})
assert compReg.getComponent('color')['ColorList'] == [(0,0,255)]
modifier.immediatedProcessInput({'OperationType':'Update',
'ComponentId':'center',
'ParamName':'RefreshInterva',
'Value':800})
assert compReg.getComponent('center')['RefreshInterval'] == 800
开发者ID:andychen,项目名称:SmootLight,代码行数:14,代码来源:TestSystemConfigMutator.py
示例10: inputInit
def inputInit(self):
self.hostname = self.argDict['Hostname']
self.port = int(self.argDict['Port'])
compReg.registerComponent(self, 'Webserver')
urls = ('/(.*)', 'WebHandler')
env = globals()
env['sys'].argv = []
app = web.application(urls, env)
self.server_thread = threading.Thread(target=app.run)
self.server_thread.daemon = True
self.server_thread.start()
webbrowser.open('http://'+self.hostname+':'+str(self.port))
开发者ID:andychen,项目名称:SmootLight,代码行数:15,代码来源:WebInput.py
示例11: behaviorInit
def behaviorInit(self):
self.xMin, self.yMin, self.xMax, self.yMax = \
compReg.getComponent('Screen').size
self.gradients = self['Gradient']
if isinstance(self.gradients,dict):
self.gradients = [self.gradients]
self.scrwid = self.xMax - self.xMin
开发者ID:andychen,项目名称:SmootLight,代码行数:7,代码来源:Gradient.py
示例12: processResponse
def processResponse(self,inputDict, responseDict):
inputId = inputDict['Id']
boundBehaviorIds = self.inputBehaviorRegistry[inputId]
try:
[compReg.getComponent(b).addInput(responseDict) for b in boundBehaviorIds]
except:
pass
开发者ID:smootlight2,项目名称:SmootLight,代码行数:7,代码来源:LightInstallation.py
示例13: processResponse
def processResponse(self, responseInfo, currentTime=None): #we need to make a new dict for
#each to prevent interference
if currentTime == None:
currentTime = timeops.time()
if type(responseInfo) != type(dict()):
pass
if 'Mapper' in responseInfo:
mapper = compReg.getComponent(responseInfo['Mapper'])
else:
mapper = compReg.getComponent(Strings.DEFAULT_MAPPER)
pixelWeightList = mapper.mapEvent(responseInfo['Location'], self)
main_log.debug('Screen processing response. ' + str(len(pixelWeightList)) + ' events\
generated')
PixelEvent.addPixelEventIfMissing(responseInfo)
for (pixel, weight) in pixelWeightList:
pixel.processInput(responseInfo['PixelEvent'], 0,weight, currentTime) #TODO: z-index
开发者ID:dxiao,项目名称:SmootLight,代码行数:16,代码来源:Screen.py
示例14: __init__
def __init__(self, configFileName):
main_log.info("System Initialization began based on: " + str(configFileName))
self.timer = clock.Stopwatch()
self.timer.start()
self.inputs = {} # dict of inputs and their bound behaviors, keyed by InputId
self.behaviors = {}
self.lock = thread.allocate_lock()
self.behaviorOutputs = {} # key: [list of output destinations]
self.behaviorInputs = {}
self.componentDict = {}
self.inputBehaviorRegistry = {} # inputid -> behaviors listening to that
self.dieNow = False
# input
self.screen = Screen()
compReg.initRegistry()
compReg.registerComponent(self.screen, "Screen") # TODO: move to constants file
bqs.initBQS() # initialize the behavior query system
# read configs from xml
config = configGetter.loadConfigFile(configFileName)
rendererConfig = config.find("RendererConfiguration")
self.initializeRenderers(rendererConfig)
pixelConfig = config.find("PixelConfiguration")
self.initializeScreen(pixelConfig)
inputConfig = config.find("InputConfiguration")
self.initializeInputs(inputConfig)
behaviorConfig = config.find("BehaviorConfiguration")
self.initializeBehaviors(behaviorConfig)
mapperConfig = config.find("PixelMapperConfiguration")
self.initializeMapper(mapperConfig)
# inits
main_log.info("All components initialized")
#
self.registerAllComponents()
installationConfig = config.find("InstallationConfiguration")
self.configureInstallation(installationConfig)
# Done initializing. Lets start this thing!
self.timer.stop()
# main_log.info('Initialization done. Time: ', self.timer.elapsed(), 'ms')
self.mainLoop()
开发者ID:mboyd,项目名称:SmootLight,代码行数:47,代码来源:LightInstallation.py
示例15: makeListener
def makeListener(self):
try:
compReg.getLock().acquire()
compReg.getComponent(self['LocSensorId']).addListener(self)
compReg.getLock().release()
return True
except Exception as ex:
compReg.getLock().release()
return False
开发者ID:andychen,项目名称:SmootLight,代码行数:9,代码来源:DirectionalPedestrians.py
示例16: behaviorInit
def behaviorInit(self):
self.keymapping = {'q':[2,19], 'w':[22,36], 'e':[37,49], 'r':[52,69], 't':[76,91], 'y':[94,105],
'u':[106,117], 'i':[123,154], 'o':[158,161], 'p':[164,167], '[':[172,184]}
screenWidth = compReg.getComponent('Screen').getSize()[2] #(minx, miny,maxx, maxy)
maxKey = max([max(self.keymapping[v]) for v in self.keymapping])
mult = screenWidth / float(maxKey)
for k in self.keymapping:
self.keymapping[k] = [int(val*mult) for val in self.keymapping[k]]
开发者ID:dxiao,项目名称:SmootLight,代码行数:8,代码来源:MITDoors.py
示例17: behaviorInit
def behaviorInit(self):
self.xy = array((0,0))
self.v_xy = array((0,0))
self.v_decay = vel_decay
self.start_hsv = [0,1,1]
self.dest_hsv = [0,1,1]
self.ssize = compReg.getComponent('Screen').getSize()[-2:] #896 x 310
开发者ID:dxiao,项目名称:SmootLight,代码行数:8,代码来源:ControllerOSC.py
示例18: processResponse
def processResponse(self, sensors, recurs):
if self.behaviorStart + self['TimeMap'][self.currentBehaviorId]*1000 <= clock.time():
self.keyIndex += 1
self.keyIndex = self.keyIndex % len(self['TimeMap'])
self.currentBehaviorId = self['TimeMap'].keys()[self.keyIndex]
self.behaviorStart = clock.time()
main_log.info('Switching behaviors')
sensors = [s for s in sensors if s['InputId'] == self['InputMap'][self.currentBehaviorId]]
return compReg.getComponent(self.currentBehaviorId).immediateProcessInput(sensors, recurs)
开发者ID:dxiao,项目名称:SmootLight,代码行数:9,代码来源:TimeSwitch.py
示例19: processResponse
def processResponse(self, sensorInputs, recursiveInputs):
self.mapper = compReg.getComponent(self.argDict["MapperId"])
# print 'CutoffDist: ' + str(self.mapper.argDict['CutoffDist']) + ', Width: ' + str(self.mapper.argDict['Width'])
# print 'CutoffDist: ' + str(self.mapper.CutoffDist) + ', Width: ' + str(self.mapper.Width)
self.mapper.CutoffDist = self.argDict["CutoffDistChange"]
self.mapper.Width = self.argDict["WidthChange"]
return (sensorInputs, recursiveInputs)
开发者ID:rcoh,项目名称:SmootLight,代码行数:9,代码来源:ModifyMapper.py
示例20: processResponse
def processResponse(self, sensorInputs, recursiveInputs):
if self.mapper == None:
try:
self.mapper = compReg.getComponent('mobilegaussmap')
except KeyError:
pass
#print sensorInputs
for sInput in sensorInputs:
if 'Shake' in sInput and sInput['Shake'] == 1:
#print 'increase!'
self.mapper.argDict['Width'] += 30
#self.mapper.argDict['CutoffDist'] += 20
sInput['Shake'] = 0
print 'Width:' + str(compReg.getComponent('mobilegaussmap').argDict['Width'])
#print 'CutoffDist: '+ str(compReg.getComponent('mobilegaussmap').argDict['CutoffDist'])
return (sensorInputs, recursiveInputs)
开发者ID:andychen,项目名称:SmootLight,代码行数:18,代码来源:MobileShakeBehavior.py
注:本文中的util.ComponentRegistry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论