def start(self): self._log.debug( 'starting' ) BaseHandler.start(self) self._upnpcfg['controlpoint'] = 'yes' # force it self._controlpoint = ControlPointWB() # subscribe to gateway events that are of interest self._localRouter.subscribe( self._subscribeTime, self, 'http://id.webbrick.co.uk/events/time/runtime' ) # subscribe to media control events self._localRouter.subscribe( self._subscribeTime, self, 'http://id.webbrick.co.uk/events/upnp/debug' ) self._localRouter.subscribe( self._subscribeTime, self, 'http://id.webbrick.co.uk/events/av/transport/control' ) self._localRouter.subscribe( self._subscribeTime, self, 'http://id.webbrick.co.uk/events/av/connection/control' ) # subscribe to brisa events events self._controlpoint.subscribe('new_device_event', self.on_new_device) self._controlpoint.subscribe('removed_device_event', self.on_removed_device) # start the control point self._controlpoint.start() # TODO: Does this have to be doen here or can we do this in the stop function? reactor.add_after_stop_func(self._controlpoint.destroy) # start seperate thread for brisa reactor threading.Thread.start(self)
def __init__ (self, localRouter): threading.Thread.__init__(self) self.setDaemon( True ) # when main thread exits stop server as well self._log = _log # so BaseHandler uses correct logger, self._taskList = Queue() BaseHandler.__init__(self, localRouter)
def configure( self, cfgDict ): """ called with an XmlDom that contains the configuration for self """ if cfgDict.has_key('serialPort'): self.serialPort = cfgDict['serialPort'] _log.debug( "serialPort %s" % self.serialPort ) BaseHandler.configure( self, cfgDict )
def __init__ (self, localRouter): BaseHandler.__init__(self, localRouter) self.__running = False threading.Thread.__init__(self) self.setDaemon( True ) self._debug = False self._reactor = "select" pass
def __init__ (self, localRouter): BaseHandler.__init__(self, localRouter) global _log _log = self._log threading.Thread.__init__(self) self.setDaemon( True ) # when main thread exits stop server as well self._taskList = Queue() self._heatmisers = dict() # keyed by name
def __init__ (self, localRouter ): threading.Thread.__init__(self) BaseHandler.__init__(self, localRouter) global _log _log = self._log self.setDaemon( True ) # when main thread exits stop server as well self.running = False self.LOCALHOST = '' self.listenPORT = 4573 # default from webbrick.
def __init__ (self, localRouter): BaseHandler.__init__(self, localRouter) self._devicesFound = {} self._devicesIncluded = {} self._renderers = {} self._includeList = None self._excludeList = None self._controlpoint = None threading.Thread.__init__(self) self.setDaemon( True )
def start(self): _log.debug( 'start' ) BaseHandler.start(self) self.__running = True # subscribe to runtime so we can update manifest self._localRouter.subscribe( self._subscribeTime, self, 'http://id.webbrick.co.uk/events/time/runtime' ) _log.debug( 'subscribed to runtime' ) threading.Thread.start(self)
def start(self): _log.debug( 'start' ) BaseHandler.start(self) # subscribe to media control events self._localRouter.subscribe( self._subscribeTime, self, 'http://id.webbrick.co.uk/events/av/render/control' ) self._localRouter.subscribe( self._subscribeTime, self, 'http://id.webbrick.co.uk/events/av/transport/control' ) self._localRouter.subscribe( self._subscribeTime, self, 'http://id.webbrick.co.uk/events/av/connection/control' ) self.running = True self._thread = threading.Thread( target=self.run ) self._thread.setDaemon(True) self._thread.start()
def stop(self): _log.debug( 'stop' ) self.running = False self.sendEvent( Event( "http://id.webbrick.co.uk/events/av/client", "upnp/%s"%(self.name), { 'udn':self.udn, 'name': self.name, 'active': 'False' } ) ) self._localRouter.unsubscribe( self, 'http://id.webbrick.co.uk/events/av/render/control' ) self._localRouter.unsubscribe( self, 'http://id.webbrick.co.uk/events/av/transport/control' ) self._localRouter.unsubscribe( self, 'http://id.webbrick.co.uk/events/av/connection/control' ) BaseHandler.stop(self)
def start(self): _log.debug( 'start' ) BaseHandler.start(self) self.running = True if not self._inFile or not self._outFile: # open serial port try: self._inFile = serial.Serial( port=self.serialPort, baudrate=4800, timeout=1 ) self._outFile = self._inFile except Exception, ex: self._inFile = None _log.exception( ex )
def stop(self): self._log.debug( 'stop' ) self._localRouter.unsubscribe( self, 'http://id.webbrick.co.uk/events/upnp/debug' ) self._localRouter.unsubscribe( self, 'http://id.webbrick.co.uk/events/av/transport/control' ) self._localRouter.unsubscribe( self, 'http://id.webbrick.co.uk/events/av/connection/control' ) # unsubscribe from brisa events events self._controlpoint.unsubscribe('new_device_event', self.on_new_device) self._controlpoint.unsubscribe('removed_device_event', self.on_removed_device) # stop the control point # TODO: Atm done in start by adding after_stop_func to raector # self._controlpoint.stop() BaseHandler.stop(self) print "about to stop" reactor.main_quit()
def configure( self, cfgDict ): self._portName = cfgDict["serialPort"] try: # is it a numeric string? self._portName = int(self._portName) except Exception: pass BaseHandler.configure( self, cfgDict ) self._heatmiserDriver = HeatmiserDriver( self._portName ) # load heatmisers if isinstance( cfgDict["heatmiser"], list ): for hm in cfgDict["heatmiser"]: self.doAddHeatmiser( hm ) else: self.doAddHeatmiser( cfgDict["heatmiser"] )
def __init__ (self, localRouter, wfile = None, rfile = None ): # rfile and wfile are allowed mainly for testing purposes. self._log = _log # so BaseHandler uses correct logger, threading.Thread.__init__(self) BaseHandler.__init__(self, localRouter) self.setDaemon( True ) # when main thread exits stop server as well self.running = False self._inFile = rfile self._outFile = wfile if rfile: _log.debug( "rFile %s " % (rfile.getvalue()) ) if wfile: _log.debug( "wFile %s " % (wfile.getvalue()) ) self.serialPort = "com1" self._taskList = Queue() self._csum = 0 # current checksum being calculated self.rxHouseCode = None self.rxDeviceCodes = None
def __init__ (self, localRouter ): BaseHandler.__init__(self, localRouter) _log = self._log self._webbrickConfigs = dict() # keyed by IP address and contains WbConfig objects. self._webbrickStati = dict() # keyed by IP address and contains WbStatus objects. self._readFailCount = dict() # keyed by IP address and contains a count of read errors
def start(self): BaseHandler.start(self) threading.Thread.start(self) self._LedLightingDriver.open() self._taskList.put( ("start",) )
def stop(self): self._taskList.put( ("quit",) ) self._LedLightingDriver.close() BaseHandler.stop(self)
def configure( self, cfgDict ): self._portName = cfgDict["serialPort"] BaseHandler.configure( self, cfgDict ) self._LedLightingDriver = LedLightingDriver( self._portName )
def stop(self): _log.debug( 'stop' ) self.running = False self._taskList.put( ("stop",) ) BaseHandler.stop(self)
def start(self): BaseHandler.start(self) threading.Thread.start(self) self._heatmiserDriver.open() self._taskList.put( ("start",) )
def stop(self): self._taskList.put( ("quit",) ) self._heatmiserDriver.close() BaseHandler.stop(self)