本文整理匯總了Python中util.ComponentRegistry.getComponent方法的典型用法代碼示例。如果您正苦於以下問題:Python ComponentRegistry.getComponent方法的具體用法?Python ComponentRegistry.getComponent怎麽用?Python ComponentRegistry.getComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類util.ComponentRegistry
的用法示例。
在下文中一共展示了ComponentRegistry.getComponent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: processResponse
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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)
示例2: processResponse
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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, [])
示例3: transitionOut
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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 = []
示例4: configureInstallation
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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])
示例5: makeListener
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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
示例6: startBehavior
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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()
示例7: test_modify_components
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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
示例8: processResponse
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
def processResponse(self,inputDict, responseDict):
inputId = inputDict['Id']
boundBehaviorIds = self.inputBehaviorRegistry[inputId]
try:
[compReg.getComponent(b).addInput(responseDict) for b in boundBehaviorIds]
except:
pass
示例9: behaviorInit
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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
示例10: processResponse
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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
示例11: processResponse
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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()
示例12: behaviorInit
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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
示例13: behaviorInit
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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]]
示例14: processResponse
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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)
示例15: processResponse
# 需要導入模塊: from util import ComponentRegistry [as 別名]
# 或者: from util.ComponentRegistry import getComponent [as 別名]
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)