def exceptionMethod(self): ''' Python implementation of IDL method. void exceptionMethod() raises (LampUnavailable); ''' raise demo.LampUnavailable() return
def monitorLampBrightness(self): ''' Python implementation of IDL method. double monitorLampBrightness() raises (LampUnavailable); ''' if self.brightness == None: #method failed or hasn't been called before try: lamp = self.getComponent("LAMP1") self.brightness = lamp._get_brightness() self.cb = CBdouble(name="brightness", archive=1) self.monitor = None except Exception, e: raise demo.LampUnavailable()
def stopMonitor(self): ''' Python implementation of IDL method. void stopMonitor() raises (LampUnavailable); ''' print "brightness monitor values were:", self.cb.values if self.monitor != None: self.monitor.destroy() #destroy the CORBA monitor self.monitor = None #reset self.cb.values = [] #reset else: raise demo.LampUnavailable() return
def getLampBrightness(self): ''' Python implementation of IDL method. double getLampBrightness() raises (LampUnavailable); ''' self.getLogger().logInfo("called...") #raise the CORBA exception is the lamp doesn't exist if not self.brightness: raise demo.LampUnavailable() #get the brightness value along with the completion (realValue, completion) = self.brightness.get_sync() #return what the developer is interested in return realValue
def setLampBrightness(self, brightness): ''' Python implementation of IDL method. void setLampBrightness(in double brightness) raises (LampUnavailable); ''' self.getLogger().logInfo("called...") #raise the CORBA exception if the lamp doesn't exist if self.brightness == None: raise demo.LampUnavailable() #set the brightness #first create a CBvoid class to be used with the set asynchronous command joe = CBvoid() self.brightness.set_async( float(brightness), #double value for the property self.activateOffShoot( joe), #create the CORBA servant for callback instance ACS.CBDescIn(0L, 0L, 0L)) #just cut and paste this code=) #Nothing to return return