def __stopConnection(self): """ Disconnect from plugins. """ if self.__pluginsConnected: Logger().info("Stopping connection. Please wait...") self.setStatusbarMessage(self.tr("Stopping connection. Please wait...")) self._view.connectLabel.setPixmap(QtGui.QPixmap(":/icons/connect_creating.png").scaled(22, 22)) if config.platform != 'darwin': while QtGui.QApplication.hasPendingEvents(): QtGui.QApplication.processEvents() #QtCore.QEventLoop.ExcludeUserInputEvents) Spy().suspend() self._view.setCursor(QtGui.QCursor(QtCore.Qt.WaitCursor)) if self.__pluginsStatus is not None: pluginsConnector = PluginsConnector() pluginsConnector.stop(self.__pluginsStatus) if self.__pluginsConnected: Logger().info("Connection stopped") self.setStatusbarMessage(self.tr("Connection stopped"), 10) self._view.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) self._view.connectLabel.setPixmap(QtGui.QPixmap(":/icons/connect_no.png").scaled(22, 22)) self.__SetDisconnectedWidgetState() self.__pluginsConnected = False
def __startConnection(self): """ Connect to plugins. """ Logger().info("Starting connection. Please wait...") self.setStatusbarMessage(self.tr("Starting connection. Please wait...")) self._view.connectLabel.setPixmap(QtGui.QPixmap(":/icons/connect_creating.png").scaled(22, 22)) self._view.setCursor(QtGui.QCursor(QtCore.Qt.WaitCursor)) if config.platform != 'darwin': while QtGui.QApplication.hasPendingEvents(): QtGui.QApplication.processEvents() #QtCore.QEventLoop.ExcludeUserInputEvents) pluginsConnector = PluginsConnector() try: self.__pluginsStatus = pluginsConnector.start() finally: self._view.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) # Check connection status if self.__pluginsStatus['yawAxis']['init'] and \ self.__pluginsStatus['pitchAxis']['init'] and \ self.__pluginsStatus['shutter']['init']: if not self._view.actionHardwareSuspendSpy.isChecked(): Spy().resume() else: yaw, pitch = self._model.head.readPosition() self.__onPositionUpdate(yaw, pitch) self._view.connectLabel.setPixmap(QtGui.QPixmap(":/icons/connect_established.png").scaled(22, 22)) Logger().info("Connection started") self.setStatusbarMessage(self.tr("Connection started"), 10) self.__SetConnectedWidgetState() self.__pluginsConnected = True else: Logger().error("Connection failed to start") self.setStatusbarMessage(self.tr("Connection failed to start"), 10) controller = PluginsStatusController(self, self.__pluginsStatus) controller.exec_() controller.shutdown() self._view.actionHardwareConnect.setChecked(False)