예제 #1
0
    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
        self.gui.takeImage.filterInstance.statusBar = self.gui.stats

        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 = log_utils.get_log_str('filter connect', 'pre')
        filterInstance.log(filterInstance.logFunction, logString)

        self.gui.stats.SetStatusText("Filter: NEED HOMING", 3)
예제 #2
0
    def clientConnectionFailed(self, transport, reason):
        """
        Executes when client has lost connection unexpectedly.
        """
        filterInstance = self.gui.takeImage.filterInstance
        filterInstance.logFunction = filterInstance.logFilter
        logString = log_utils.get_log_str("filter connectFailed 1", 'post')
        filterInstance.log(filterInstance.logFunction, logString)

        logger.warning("connection failed on port 5503")
예제 #3
0
    def clientConnectionLost(self, transport, reason):
        """
        Executes when client has lost connection normally.
        """
        filterInstance = self.gui.takeImage.filterInstance
        filterInstance.logFunction = filterInstance.logFilter
        logString = log_utils.get_log_str("filter connectLost 1", 'post')
        filterInstance.log(filterInstance.logFunction, logString)

        logger.info("connection lost normally on port 5503")
예제 #4
0
    def clientConnectionFailed(self, transport, reason):
        """
        Called when client connection is lost unexpectedly.
        """
        exposureInstance = self.gui.takeImage.exposureInstance
        exposureInstance.logFunction = exposureInstance.logExposure
        logString = log_utils.get_log_str("connectFailed 1", 'post')
        exposureInstance.log(exposureInstance.logFunction, logString)

        logger.warning("connection to E. server failed on port 5502")
예제 #5
0
    def clientConnectionLost(self, transport, reason):
        """
        Called when client connection is lost normally.
        """
        exposureInstance = self.gui.takeImage.exposureInstance
        exposureInstance.logFunction = exposureInstance.logExposure
        logString = log_utils.get_log_str("connectLost 1", 'post')
        exposureInstance.log(exposureInstance.logFunction, logString)

        logger.info("connection to E. server lost normally on port 5502")
예제 #6
0
    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 = log_utils.get_log_str('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
예제 #7
0
    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 = log_utils.get_log_str('connect ' + msg, 'post')
        self.logMethod(self.logFunction, logString)

        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")
예제 #8
0
    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 = log_utils.get_log_str("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=enhanced_status_bar.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)
        self.takeImage.tempInstance.current_mode = None