Beispiel #1
0
class Round(EstadoTimer):
    gong = QSound('sounds/gong.wav')
    beep = QSound('sounds/beep-7.wav')
    next_beep = 10
	
    def __init__(self, numero=1, minutos=2, segundos=0, label=None, window=None):
        self.numero = numero
        super(Round, self).__init__(minutos=minutos, segundos=segundos, label=label, window=window)
        
    def __str__(self):
        return "Round "+str(self.numero)
    
    def timerEvent(self, event):
        elapsed_time = time.time() - self.start_time
        segundos = self.segundos - elapsed_time
        
        if segundos <= self.next_beep and self.next_beep > 0:
            self.next_beep -= 1
            self.beep.play()
        
        if segundos < 0:
            segundos = 0
        self.set_text(segundos/60, segundos%60, (segundos%1)*100)
        
        if segundos == 0:
            self.gong.play()
            self.emit(SIGNAL("ESTADO_TIMER_FINALIZADO"))
            self.timer.stop()
Beispiel #2
0
class Descanso(EstadoTimer):
    beep_descanso = QSound('sounds/beep-9.wav')
    rest_beep = 10
    play_beep = True
	
    def __init__(self, minutos=1, segundos=0, label=None, window=None):
        super(Descanso, self).__init__(minutos=minutos, segundos=segundos, label=label, window=window)
        
    def __str__(self):
        return "Descanso"
		
    def timerEvent(self, event):
        elapsed_time = time.time() - self.start_time
        segundos = self.segundos - elapsed_time

        if segundos <= self.rest_beep and self.play_beep == True:
            self.play_beep = False
            self.beep_descanso.play()
        
        if segundos < 0:
            segundos = 0
        self.set_text(segundos/60, segundos%60, (segundos%1)*100)
        
        if segundos == 0:
            self.emit(SIGNAL("ESTADO_TIMER_FINALIZADO"))
            self.timer.stop()
Beispiel #3
0
    def timed_job(self):

        conn = sqlite3.connect('serm.db')

        with conn:
            
            df = pd.read_sql_query("SELECT * from data", conn);
            df.humidity = np.array(df.humidity.astype(float))
            df.temperature = np.array(df.temperature.astype(float))
            df.smoke = np.array(df.smoke.astype(float))
            df.co = np.array(df.co.astype(float))
            df.lpg = np.array(df.lpg.astype(float))
            df.windspeed = np.array(df.windspeed.astype(float)) 
            df.ffwi = np.array(df.ffwi.astype(float))                    
            datetm = calendar.timegm(time.strptime(str(time.strftime('%Y-%m-%d %H:%M:%S')), '%Y-%m-%d %H:%M:%S'))
            datedt = time.strftime('%Y-%m-%d %H:%M:%S')
            winddir = df.winddir.tail(1).iget(0)

            predict_risk.input['FFWI'] = df.ffwi.mean()
            predict_risk.input['SMOKE'] = df.smoke.mean()
            predict_risk.compute()
            
            risk = predict_risk.output['RISK']
            
            conn.execute("INSERT INTO data_means(timestamp,datetime,smoke,lpg,co,temperature,humidity,windspeed,winddir,ffwi,risk) VALUES (?,?,?,?,?,?,?,?,?,?,?)", (datetm,datedt,round(df.smoke.mean(),3),round(df.lpg.mean(),3),round(df.co.mean(),3),round(df.temperature.mean(),3),round(df.humidity.mean(),3),round(df.windspeed.mean(),3),winddir,round(df.ffwi.mean(),3),round(risk,3)))
            conn.commit()
            
            sql = "DELETE FROM data WHERE recid <= ( SELECT recid FROM (SELECT recid FROM data ORDER BY recid DESC LIMIT 1 OFFSET 20)foo)"
            conn.execute(sql)
            conn.commit()

#        self.lcdNumber_ffwi.display(str(round(df.ffwi.mean(),-1)))           
        self.lcdNumber_ffwi.display(str(df.ffwi.mean()))
        self.lcdNumber_risk.display((risk))
        
        palette = QtGui.QPalette()

        if risk < 10:
            palette.setColor(QtGui.QPalette.Foreground,QtCore.Qt.green)
            self.lbl_RiskStateValue.setPalette(palette)
            self.lbl_RiskStateValue.setText("LOW")
        elif risk >= 10 and risk < 30:
            palette.setColor(QtGui.QPalette.Foreground,QtCore.Qt.yellow)
            self.lbl_RiskStateValue.setPalette(palette)
            self.lbl_RiskStateValue.setText("AVERAGE")
        else:
            palette.setColor(QtGui.QPalette.Foreground,QtCore.Qt.red)
            self.lbl_RiskStateValue.setPalette(palette)
            self.lbl_RiskStateValue.setText("HIGH")
            sound = QSound("smoke-detector-1.wav")
            sound.play() 
Beispiel #4
0
 def play(self):
     (opened, file) = tempfile.mkstemp()
     os.close(opened)
     if self.captured_area_container.is_released:
         self._played_start = self.captured_area_container.start
         wave_state = self.wave_state.get_part(self._played_start,
                                               len(self.wave_state))
     else:
         self._played_start = 0
         wave_state = self.wave_state
     wave_state.save_to_file(file)
     self._q_sound_object = QSound(file)
     self._temp_sound_file = file
     self._q_sound_object.play()
     self._time_of_start = time.time()
     self._play_sound_timer.start(Track.UPDATE_PLAYING_TRACK_TIME)
Beispiel #5
0
 def setupSounds(self):
     self.beep = QSound("sounds/beep.wav")
     self.buzzer = QSound("sounds/buzzer.wav")
Beispiel #6
0
    def __init__(self):
        super().__init__()
        self.setGeometry(200, 100, 1024, 768)
        self.setWindowTitle('BoBlo - Bottle Blocks')
        self.setWindowIcon(QIcon(get_absolute_path('images/icon2.png')))
        self.screenShape = QDesktopWidget().screenGeometry()
        self.bg_width = 1280
        self.bg_height = 990
        # self.resize(self.screenShape.width(), self.screenShape.height())

        self.combinations = list()

        self.plastic = 0

        self.button_stylesheet = "QPushButton {background-color: #8FCBF4;" \
                                 "border-style: outset;" \
                                 "border-width: 2px;" \
                                 "border-radius: 10px;" \
                                 "border-color: #C6E2FF;" \
                                 "font: bold 15pt \"Comic Sans MS\";" \
                                 "min-width: 10em;" \
                                 "padding: 6px;}" \
                                 "QPushButton:pressed {background-color: #4F94CD}"

        self.background = QLabel(self)
        self.background.setGeometry(375, 0, self.bg_width, self.bg_height)
        self.background.setPixmap(
            QPixmap(get_absolute_path("./images/background.jpg")).scaled(
                self.bg_width, self.bg_height))

        self.label_grs1 = QLabel(str(self.plastic), self)
        self.label_grs1.setFont(QFont("Comic Sans MS", 40, QFont.Bold))
        self.label_grs1.setGeometry(640, 270, 310, 120)
        self.label_grs1.setAlignment(Qt.AlignRight)
        self.label_grs1.hide()

        self.label_grs2 = QLabel(str(self.plastic), self)
        self.label_grs2.setFont(QFont("Comic Sans MS", 40, QFont.Bold))
        self.label_grs2.setGeometry(820, 58, 310, 120)
        self.label_grs2.setAlignment(Qt.AlignCenter)
        self.label_grs2.hide()

        self.label_blocks = QLabel(str(plastic_to_blocks(self.plastic)), self)
        self.label_blocks.setFont(QFont("Comic Sans MS", 50, QFont.Bold))
        self.label_blocks.setGeometry(700, 330, 310, 150)
        self.label_blocks.setAlignment(Qt.AlignRight)
        self.label_blocks.hide()

        self.text_dato = QLabel(self)
        self.text_dato.move(570, 550)
        self.text_dato.setPixmap(
            QPixmap(get_absolute_path("./images/dato1.png")))

        self.text1 = QLabel(self)
        self.text1.move(570, 100)
        self.text1.setPixmap(QPixmap(get_absolute_path("./images/text1.png")))

        self.pic1 = QLabel(self)
        self.pic1.move(1070, 400)
        self.pic1.setPixmap(
            QPixmap(get_absolute_path("./images/image_step1.png")))

        self.text2 = QLabel(self)
        self.text2.move(570, 50)
        self.text2.setPixmap(QPixmap(get_absolute_path("./images/text2.png")))
        self.text2.hide()

        self.text3 = QLabel(self)
        self.text3.move(930, 260)
        self.text3.setPixmap(QPixmap(get_absolute_path("./images/text3.png")))
        self.text3.hide()

        self.text4 = QLabel(self)
        self.text4.move(570, 50)
        self.text4.setPixmap(QPixmap(get_absolute_path("./images/text4.png")))
        self.text4.hide()

        self.pic2 = QLabel(self)
        self.pic2.move(1070, 350)
        self.pic2.setPixmap(QPixmap(get_absolute_path("./images/boblo1.png")))
        self.pic2.hide()

        self.text5 = QLabel(self)
        self.text5.move(570, 50)
        self.text5.setPixmap(QPixmap(get_absolute_path("./images/text5.png")))
        self.text5.hide()

        self.to_step3 = QPushButton("&Quiero mis piezas", self)
        self.to_step3.setGeometry(1120, 570, 300, 90)
        self.to_step3.setStyleSheet(self.button_stylesheet)
        self.to_step3.hide()

        self.icon_arrow = QIcon(get_absolute_path("./images/arrow.png"))
        self.to_step4 = QPushButton("", self)
        self.to_step4.setIcon(self.icon_arrow)
        self.to_step4.setIconSize(QSize(250, 60))
        self.to_step4.setGeometry(1120, 570, 300, 90)
        self.to_step4.setStyleSheet(self.button_stylesheet)
        self.to_step4.hide()

        self.icon_arrowi = QIcon(get_absolute_path("./images/arrowi.png"))
        self.back_to_step2 = QPushButton("", self)
        self.back_to_step2.setIcon(self.icon_arrowi)
        self.back_to_step2.setIconSize(QSize(250, 60))
        self.back_to_step2.setGeometry(644, 570, 300, 90)
        self.back_to_step2.setStyleSheet(self.button_stylesheet)
        self.back_to_step2.hide()

        self.to_step5 = QPushButton("", self)
        self.to_step5.setIcon(self.icon_arrow)
        self.to_step5.setIconSize(QSize(250, 60))
        self.to_step5.setGeometry(1140, 610, 300, 90)
        self.to_step5.setStyleSheet(self.button_stylesheet)
        self.to_step5.hide()

        # self.options = OptionsList(self)
        self.options = OptionsTable(self)
        self.options.setGeometry(620, 170, 824, 430)
        self.options.hide()

        self.text6 = QLabel(self)
        self.text6.move(570, 100)
        self.text6.setPixmap(QPixmap(get_absolute_path("./images/text6.png")))
        self.text6.hide()

        self.text7 = QLabel(self)
        self.text7.move(570, 480)
        self.text7.setPixmap(QPixmap(get_absolute_path("./images/text7.png")))
        self.text7.hide()

        self.text_process = QLabel(self)
        self.text_process.move(570, 480)
        self.text_process.setPixmap(
            QPixmap(get_absolute_path("./images/process1.png")))
        self.text_process.hide()

        self.restart = QPushButton("&OK", self)
        self.restart.setGeometry(1120, 570, 300, 90)
        self.restart.setStyleSheet(self.button_stylesheet)
        self.restart.hide()

        self.audio = QSound(get_absolute_path("./audio/boblo.wav"))

        # threading
        self.start_thread()