def ping(): while True: if self.interlocking: self.logger.debug("Pinging back interlocking server") try: self.interlocking.remotePing() except Pyro4.errors.CommunicationError: self.interlocking = None else: # Try to reestablish connection to interlocking server self.logger.debug("Trying to reestablish connection to interlocking server...") try: self.interlocking = Pyro4.Proxy(self.interlocking_pyroname) self.interlocking.remotePing() self.interlocking.registerSwitchboard(self) except Pyro4.errors.PyroError: self.logger.debug("Unsuccessfully tried to reestablish connection to interlocking server.") self.interlocking = None if self.interlocking: tpub.sendMessage("InterlockingCom.connection.established") else: tpub.sendMessage("InterlockingCom.connection.error") time.sleep(self.pingInterval)
def readConfig(self): logger.info("Opening config file {}".format(CONFIG_FILE)) # Load the configuration file if len(self.configParser.read(CONFIG_FILE)) == 0: tpub.sendMessage('model.config.file.error') logger.critical("Could NOT open config file {}".format(CONFIG_FILE)) return try: for name in self.options: self.options[name] = self.configParser.get('projector', name) logger.debug('config: %-15s = %r' % (name, self.options[name])) except ConfigParser.Error as e: tpub.sendMessage('model.config.file.error') logger.critical("Error while parsing config file {}: {}".format(CONFIG_FILE, e)) self.configured = False return self.configured = True tpub.sendMessage('model.config.file.ok') logger.info("config file {} parsed sucessfully".format(CONFIG_FILE))
def callback(self, topic, **kwargs): tpub.sendMessage(topic, **kwargs)
def announce_cooling(self): tpub.sendMessage('model.cooling.inprogress') logger.debug("Announcing: Cooling")
def announce_coolingFinished(self): tpub.sendMessage('model.cooling.finished') logger.debug("Announcing: Cooling finished")
def announce_shutterClosed(self): tpub.sendMessage('model.shutter.closed') logger.debug("Announcing: Shutter closed")
def announce_shutterOpen(self): tpub.sendMessage('model.shutter.open') logger.debug("Announcing: Shutter open")
def announce_unpowered(self): tpub.sendMessage('model.power.off') logger.debug("Announcing: Power OFF")
def announce_powered(self): tpub.sendMessage('model.power.on') logger.debug("Announcing: Power ON")
def announce_erroneousResponse(self): tpub.sendMessage('model.response.error') logger.debug("Announcing: Error in projector response")
def announce_connection(self): tpub.sendMessage('model.connection.ok') logger.debug("Announcing: connection established")
def announce_noConnection(self): tpub.sendMessage('model.connection.error') logger.debug("Announcing: no connection established")