def connectionMade(self): """ Executes when conncetion is made to filter. """ ## Add a callback that will open up the rest of the gui when the camera is done setting up #gui = self.factory.gui # get gui for adding the callback method #d = defer.Deferred() #d.addCallback(gui.onConnectCallback) #self._deferreds["status"] = d self.gui = self.factory.gui self.gui.takeImage.filterInstance.protocol2 = self logger.info("connection made to filter") filterInstance = self.gui.takeImage.filterInstance filterInstance.filterConnection = True #self.filterWatchThread = threading.Thread(target=filterInstance.filterWatch, args=()) #self.filterWatchThread.daemon = True filterInstance.logFunction = filterInstance.logFilter logString = als.getLogString('filter connect', 'pre') filterInstance.log(filterInstance.logFunction, logString) logString = als.getLogString('filter getFilter', 'pre') filterInstance.log(filterInstance.logFunction, logString) d = self.sendCommand('getFilter') d.addCallback(filterInstance.getFilterCallback)
def clientConnectionFailed(self, transport, reason): """ Called when client connection is lost unexpectedly. """ exposureInstance = self.gui.takeImage.exposureInstance exposureInstance.logFunction = exposureInstance.logExposure logString = als.getLogString("connectFailed 1", 'post') exposureInstance.log(exposureInstance.logFunction, logString) logger.warning("connection to E. server failed on port 5502")
def clientConnectionLost(self, transport, reason): """ Called when client connection is lost normally. """ exposureInstance = self.gui.takeImage.exposureInstance exposureInstance.logFunction = exposureInstance.logExposure logString = als.getLogString("connectLost 1", 'post') exposureInstance.log(exposureInstance.logFunction, logString) logger.info("connection to E. server lost normally on port 5502")
def clientConnectionFailed(self, transport, reason): """ Executes when client has lost connection unexpectedly. """ filterInstance = self.gui.takeImage.filterInstance filterInstance.logFunction = filterInstance.logFilter logString = als.getLogString("filter connectFailed 1", 'post') filterInstance.log(filterInstance.logFunction, logString) logger.warning("connection failed on port 5503")
def clientConnectionLost(self, transport, reason): """ Executes when client has lost connection normally. """ filterInstance = self.gui.takeImage.filterInstance filterInstance.logFunction = filterInstance.logFilter logString = als.getLogString("filter connectLost 1", 'post') filterInstance.log(filterInstance.logFunction, logString) logger.info("connection lost normally on port 5503")
def callShutdown(self, msg): """ When the camera sends it has shutdown successfully then this runs and locks down the GUI. """ self.logFunction = self.logMain logString = als.getLogString("shutdown " + msg, 'post') self.logMethod(self.logFunction, logString) self.takeImage.tempInstance.isConnected = False bitmap = wx.StaticBitmap(self.stats, -1, size=(90, 17)) self.stats.AddWidget(bitmap, pos=0, horizontalalignment=EnhancedStatusBar.ESB_ALIGN_RIGHT) self.stats.SetStatusText("Current Temp: ... C", 0) self.joinThreads("temp", demonized=False) self.connection.disconnect() self.connected = False self.enableConnections(True, False, False)
def callStartup(self, msg): """ When connect is sent to the server and is done this will set the state of the GUI. """ self.logFunction = self.logMain logString = als.getLogString('connect ' + msg, 'post') self.logMethod(self.logFunction, logString) result = int(msg) self.connected = True # boolean to tell if connected to server self.enableConnections(False, True, True) # grey and un-grey camera menu options self.disableButtons("connect", False) # enable gui functionality self.takeImage.tempInstance.isConnected = True # setups infinite loop in watchTemp method t = threading.Thread(target=self.takeImage.tempInstance.watchTemp, args=(), name="temp thread") t.daemon = True t.start() self.active_threads["temp"] = t logger.info("Started up from callStartup method")
def onConnectCallback(self, msg): """ When a connection is made successfully the server sends a status which goes throught this. If the camera status is uninitialized then it runs the startup routine else it sets the state of the GUI to connect.. """ #msg = args[0] #thread = args[1] logger.debug(msg + " Startup callback entered") self.connected = True # get the number of clients status = int(msg.split(",")[0]) self.logFunction = self.logMain logString = als.getLogString('status ' + str(status), 'post') self.logMethod(self.logFunction, logString) logger.debug("status from connect callback: " + str(status)) if(status == 20075): # camera is uninitialized d = self.protocol.sendCommand("connect") d.addCallback(self.callStartup) elif(status == 20002): # if camera is already initialized then start server like regular # start temperature thread t = threading.Thread(target=self.takeImage.tempInstance.watchTemp, args=(), name="temp thread") self.takeImage.tempInstance.isConnected = True # setups infinite loop in watchTemp method t.daemon = True # Enable disconnect and shutdown and disable connect menu items self.enableConnections(False, True, True) self.disableButtons("connect", False) t.start() self.active_threads["temp"] = t else: # camera drivers are broken needs reinstall? pass