示例#1
0
    def __init__(self, parent = None):
        super(MainWindow, self).__init__(parent)
        self.temps = 0
        self.secondesEcoulees = 0
        self.minuteEcoulees = 0
        self.SECONDES_PAR_MINUTE = 59
        self.MINUTES_PAR_HOUR = 59
        self.setupUi(self)
        self.chronoLCD.display("0:00")
        self.painteur = QPainter()

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.Time)

        self.startTimerButton.clicked.connect(self.Start)
        self.stopTimerButton.clicked.connect(self.Stop)
        self.resetTimerButton.clicked.connect(self.Reset)


        self.rafraichissementTimer = QTimer(self)
        self.rafraichissementTimer.start(50)
        self.rafraichissementTimer.timeout.connect(self.rafraichirImage)
        self.rafraichissementTimer.timeout.connect(self.rafraichirUi)

        self.cyclePrincipaleThread = StationDeBase()
        self.detectionEtAffichageThread = DetectionEtAffichageThread()
        self.cyclePrincipaleThread.start()
        self.detectionEtAffichageThread.start()
示例#2
0
class MainWindow(QMainWindow, StationDeBase_UI.Ui_MainWindow):

    def __init__(self, parent = None):
        super(MainWindow, self).__init__(parent)
        self.temps = 0
        self.secondesEcoulees = 0
        self.minuteEcoulees = 0
        self.SECONDES_PAR_MINUTE = 59
        self.MINUTES_PAR_HOUR = 59
        self.setupUi(self)
        self.chronoLCD.display("0:00")
        self.painteur = QPainter()

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.Time)

        self.startTimerButton.clicked.connect(self.Start)
        self.stopTimerButton.clicked.connect(self.Stop)
        self.resetTimerButton.clicked.connect(self.Reset)


        self.rafraichissementTimer = QTimer(self)
        self.rafraichissementTimer.start(50)
        self.rafraichissementTimer.timeout.connect(self.rafraichirImage)
        self.rafraichissementTimer.timeout.connect(self.rafraichirUi)

        self.cyclePrincipaleThread = StationDeBase()
        self.detectionEtAffichageThread = DetectionEtAffichageThread()
        self.cyclePrincipaleThread.start()
        self.detectionEtAffichageThread.start()



    def rafraichirImage(self):
        try:
            if(self.detectionEtAffichageThread.estVerouillee):
                return

            #Nous sommes conscient que le absolute path n'est pas la meilleur solution mais nous avons eu
            #des probleme avec les path relatif et donc cette solution est temporaire.
            pixmap = QPixmap("C:\Users\phili_000\Desktop\Design 3\Design3\Code\Projet\photos\\table_iles_robot_MOD.jpg").scaled(self.imageDisplay.size(), Qt.KeepAspectRatio)
            self.imageDisplay.setPixmap(pixmap)

        except Exception as e:
            print "Probleme dans le rafraishirImage: {0}".format(e.message)


    def rafraichirUi(self):
        #Affichage de l'ile cible
        indexIleCible = self.cyclePrincipaleThread.ileCible
        if indexIleCible > 0:
            forme = self.detectionEtAffichageThread.listeFormesThread[indexIleCible]
            couleurs = self.detectionEtAffichageThread.listeCouleursThread[indexIleCible]
            self.afficherIleCible(forme + " " + couleurs)

        #Affichage du voltage restant
        self.afficherVoltageRestant(str(self.cyclePrincipaleThread.voltageRestant))

        #Affichage du code decode
        self.afficherCodeDecode(self.cyclePrincipaleThread.code)

    def Reset(self):
        self.timer.stop()

        self.secondesEcoulees = 0
        self.minuteEcoulees = 0

        temps = "{0}:{1}".format(self.minuteEcoulees, self.secondesEcoulees)

        self.cyclePrincipaleThread.reset = True
        self.detectionEtAffichageThread.reset = True
        self.chronoLCD.setDigitCount(len(temps))
        self.chronoLCD.display(temps)

    def Start(self):
        self.timer.start(1000)
        self.cyclePrincipaleThread.pause = False

    def Stop(self):
        self.timer.stop()
        self.cyclePrincipaleThread.pause = True

    def Time(self):
        if self.secondesEcoulees < self.SECONDES_PAR_MINUTE:
            self.secondesEcoulees += 1
        else:
            if self.minuteEcoulees < self.MINUTES_PAR_HOUR:
                self.secondesEcoulees = 0
                self.minuteEcoulees += 1
            else:
                self.timer.stop()

        if(self.secondesEcoulees < 10):
            temps = "{0}:0{1}".format(self.minuteEcoulees, self.secondesEcoulees)
        else:
            temps = "{0}:{1}".format(self.minuteEcoulees, self.secondesEcoulees)

        self.chronoLCD.setDigitCount(len(temps))
        self.chronoLCD.display(temps)

    def afficherCodeDecode(self, codeDecode):
        self.textCodeDecode.setText(codeDecode)

    def afficherIleCible(self, ileCible):
        self.textIleCible.setText(ileCible)

    def afficherVoltageRestant(self, voltageRestant):
        self.textVoltageRestant.setText(voltageRestant)

    def deImageOpenCv2AQImage (self):
        height, width, bytesPerComponent = self.photo.shape
        bytesPerLine = bytesPerComponent * width
        cv2.cvtColor(self.photo, cv2.COLOR_RGB2BGRA, self.photo)
        return QImage(self.photo.data, width, height, bytesPerLine, QImage.Format_RGB888)#.scaled(self.imageDisplay.size(), Qt.KeepAspectRatio)
示例#3
0
class MainWindow(QMainWindow, StationDeBase_UI.Ui_MainWindow):

    def __init__(self, parent = None):
        super(MainWindow, self).__init__(parent)
        self.temps = 0
        self.secondesEcoulees = 0
        self.minuteEcoulees = 0
        self.SECONDES_PAR_MINUTE = 59
        self.MINUTES_PAR_HOUR = 59
        self.setupUi(self)
        self.chronoLCD.display("0:00")
        self.painteur = QPainter()
        self.departAction = 0
        self.finAction = 0

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.Time)

        self.startTimerButton.clicked.connect(self.Start)
        self.stopTimerButton.clicked.connect(self.Stop)
        self.resetTimerButton.clicked.connect(self.Reset)


        self.rafraichissementImageTimer = QTimer(self)
        self.rafraichissementImageTimer.start(50)
        self.rafraichissementImageTimer.timeout.connect(self.rafraichirImage)

        self.cyclePrincipaleThread = StationDeBase()
        self.detectionEtAffichageThread = DetectionEtAffichageThread()
        self.cyclePrincipaleThread.start()
        self.detectionEtAffichageThread.start()

        self.cycleDemarre = False
        self.startTimerButton.setDisabled(True)


    def rafraichirImage(self):
        try:
            if(self.detectionEtAffichageThread.estVerouillee):
                return

            #Nous sommes conscient que le absolute path n'est pas la meilleur solution mais nous avons eu
            #des probleme avec les path relatif et donc cette solution est temporaire.
            pixmap = QPixmap("C:\Users\phili_000\Desktop\Design 3\Design3\Code\Projet\photos\\table_iles_robot_MOD.jpg").scaled(self.imageDisplay.size(), Qt.KeepAspectRatio)
            self.imageDisplay.setPixmap(pixmap)
            self.rafraichirUi()
            if self.cyclePrincipaleThread.finCycle == True:
                self.Stop()
                self.cyclePrincipaleThread.finCycle = False

        except Exception as e:
            print "Probleme dans le rafraishirImage: {0}".format(e.message)


    def rafraichirUi(self):
        #Affichage de l'ile cible
        indexIleCible = self.cyclePrincipaleThread.ileCible
        if indexIleCible >= 0:
            forme = self.detectionEtAffichageThread.listeFormesThread[indexIleCible]
            couleurs = self.detectionEtAffichageThread.listeCouleursThread[indexIleCible]
            self.afficherIleCible(forme + " " + couleurs)

        #Affichage du voltage restant
        self.afficherVoltageRestant(str(self.cyclePrincipaleThread.voltageRestant))

        #Affichage du code decode
        self.afficherCodeDecode(self.cyclePrincipaleThread.code)

        if self.cyclePrincipaleThread.connected == True:
            text = "Le Robot est pres"
            self.log.appendPlainText(text)
            self.startTimerButton.setDisabled(False)
            self.cyclePrincipaleThread.connected = False

        if self.cyclePrincipaleThread.noPathFound == True:
            text = "Pas de chemin. Reduction de Diametre"
            self.log.appendPlainText(text)
            self.cyclePrincipaleThread.noPathFound = False

        if self.cyclePrincipaleThread.nouvelleAction == True:
            if self.departAction == 0 and self.finAction == 0:
                self.ajouterDebutTacheAuLog(self.cyclePrincipaleThread.actionCourrante)
                self.departAction = time.time()
            else:
                self.finAction = time.time()
                self.ajouterFinTacheAuLog(self.cyclePrincipaleThread.actionPrecedente,self.finAction - self.departAction)
                self.ajouterDebutTacheAuLog(self.cyclePrincipaleThread.actionCourrante)
                self.departAction = time.time()
            self.cyclePrincipaleThread.nouvelleAction = False

    def Reset(self):
        self.timer.stop()

        self.secondesEcoulees = 0
        self.minuteEcoulees = 0

        temps = "{0}:{1}".format(self.minuteEcoulees, self.secondesEcoulees)

        self.cyclePrincipaleThread.reset = True
        self.detectionEtAffichageThread.reset = True
        self.chronoLCD.setDigitCount(len(temps))
        self.chronoLCD.display(temps)

    def Start(self):
        self.timer.start(1000)
        self.cyclePrincipaleThread.pause = False
        self.detectionEtAffichageThread.startCycle = True

    def Stop(self):
        self.timer.stop()
        self.cyclePrincipaleThread.pause = True

    def Time(self):
        if self.secondesEcoulees < self.SECONDES_PAR_MINUTE:
            self.secondesEcoulees += 1
        else:
            if self.minuteEcoulees < self.MINUTES_PAR_HOUR:
                self.secondesEcoulees = 0
                self.minuteEcoulees += 1
            else:
                self.timer.stop()

        if(self.secondesEcoulees < 10):
            temps = "{0}:0{1}".format(self.minuteEcoulees, self.secondesEcoulees)
        else:
            temps = "{0}:{1}".format(self.minuteEcoulees, self.secondesEcoulees)

        self.chronoLCD.setDigitCount(len(temps))
        self.chronoLCD.display(temps)

    def afficherCodeDecode(self, codeDecode):
        self.textCodeDecode.setText(codeDecode)

    def afficherIleCible(self, ileCible):
        self.textIleCible.setText(ileCible)

    def afficherVoltageRestant(self, voltageRestant):
        self.textVoltageRestant.setText(voltageRestant)

    def ajouterDebutTacheAuLog(self, tache):
        text = "{0} : EN EXECUTION".format(tache)
        self.log.appendPlainText(text)

    def ajouterFinTacheAuLog(self, tache, tempsDexecutionSecondes):
        text = "{0} : TERMINE en {1:.2f} secondes".format(tache, tempsDexecutionSecondes)
        self.log.appendPlainText(text)