當前位置: 首頁>>代碼示例>>Python>>正文


Python util.ComponentRegistry類代碼示例

本文整理匯總了Python中util.ComponentRegistry的典型用法代碼示例。如果您正苦於以下問題:Python ComponentRegistry類的具體用法?Python ComponentRegistry怎麽用?Python ComponentRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ComponentRegistry類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的util.ComponentRegistry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。