Ejemplo n.º 1
0
def aClock():
    currentTime = time.strftime('%Y-%m-%d,%H:%M', time.localtime(time.time()))
    weatherInfo = WeatherHelper.getCityWeather_RealTime(
        ConfigHelper.GetIni("city"))

    SpeakHelper.Speak("zh-CN", ConfigHelper.GetWord("nowt"))  #现在时间是
    SpeakHelper.SpeakOneTime("zh-CN", currentTime + "," + weatherInfo)
Ejemplo n.º 2
0
def CheckInfrared(talk, cnt=3):
    flag = True
    count = 0

    GPIO.output(16, GPIO.HIGH)
    while flag and count < int(ConfigHelper.GetIni("infrared", "60")):
        if (GPIO.input(12) == True):
            GPIO.output(16, GPIO.LOW)
            SpeakHelper.soundStart(talk, cnt)
            #time.sleep(3)
            flag = False
            count = int(ConfigHelper.GetIni("infrared", "60"))

        count += 1
        time.sleep(1)

    if flag:
        SpeakHelper.Speak("zh-CN", ConfigHelper.GetWord("unfind"))  #未扫描到对象
Ejemplo n.º 3
0
def soundStart(talk, cnt = 3):
    dt = list(time.localtime())
    hour = dt[3]
            
    Speak("zh-CN", talk)
    
    count = 0

    if hour < int(ConfigHelper.GetIni("quiettime","6")):
        Speak("zh-CN",ConfigHelper.GetWord("toolate"))#太晚了
        return

    IsPlay = int(ConfigHelper.GetIni("isplay","0"))

    if IsPlay == 1:
        Speak("zh-CN","正在播放")#正在播放
        return
    else:
        while(count<cnt):
            try:
                ConfigHelper.SetValue("base","IsPlay","1")
                #获取音乐信息
                songInfo = (MusicLoader.GetMusic())
                song = songInfo.split("|")
        
                Speak("zh-CN",ConfigHelper.GetWord("exsonginfo"))#即将播放
            
                SpeakOneTime("zh-CN",song[0]+"。歌手:"+song[1])
                """
                rec = subprocess.call([player2, song[2]],
                                      shell=False,
                                      stdout=subprocess.PIPE,
                                      stderr=subprocess.PIPE)
                                      """
                
                rec = play(player2,song[2])
                if(rec == 1 or rec == 0):
                    count += 1
            except Exception,e:
                Speak("zh-CN",ConfigHelper.GetWord("musicerror"))#音乐播放异常
                print e
                pass
        Speak("zh-CN",ConfigHelper.GetWord("musicend"))#音乐结束
        ConfigHelper.SetValue("base","IsPlay","0")
Ejemplo n.º 4
0
def main():
    threadWifiCheck = None
    #定义问候语
    jday = ConfigHelper.GetWord("jday")

    eday = ConfigHelper.GetWord("eday")

    vday = ConfigHelper.GetWord("vday")

    #aClock();
    SpeakHelper.Speak("zh-CN", ConfigHelper.GetWord("start"))

    #定义闹钟时间
    while (not_executed):
        try:
            dt = list(time.localtime())
            hour = dt[3]
            minute = dt[4]
            wday = dt[6]

            if (wday == 5 or wday == 6):
                if hour == 8 and minute == 00:
                    aClock()
                    SpeakHelper.soundStart(eday)

                if hour == 8 and minute == 30:
                    aClock()
                    SpeakHelper.soundStart(eday)

            else:
                if hour == 6 and minute == 40:
                    aClock()
                    SpeakHelper.soundStart(jday, 3)

                if hour == 7 and minute == 00:
                    aClock()
                    SpeakHelper.soundStart(jday)

                if hour == 7 and minute == 30:
                    aClock()
                    SpeakHelper.soundStart(ConfigHelper.GetWord("bcdl"), 3)

                if hour == 8 and minute == 00:
                    aClock()
                    SpeakHelper.soundStart(ConfigHelper.GetWord("bcdl"), 3)

            if hour == 22 and minute == 00:
                aClock()
                SpeakHelper.soundStart(ConfigHelper.GetWord("mlyt"))

            if hour == 20 and minute == 00:
                aClock()
                SpeakHelper.soundStart(ConfigHelper.GetWord("dsgb"))

            if (hour > int(ConfigHelper.GetIni("aclock", "8"))
                    and minute == 00):
                aClock()
                #避免同一分钟之内多次报时
                time.sleep(int(ConfigHelper.GetIni("smjg", "30")))

            if threadWifiCheck is None:
                print "thread begin"
                threadWifiCheck = CheckWifiGuest.CheckGuest()
                threadWifiCheck.start()

        except Exception, e:
            print e
            pass
        finally:
Ejemplo n.º 5
0
                    SpeakHelper.soundStart(ConfigHelper.GetWord("bcdl"), 3)

            if hour == 22 and minute == 00:
                aClock()
                SpeakHelper.soundStart(ConfigHelper.GetWord("mlyt"))

            if hour == 20 and minute == 00:
                aClock()
                SpeakHelper.soundStart(ConfigHelper.GetWord("dsgb"))

            if (hour > int(ConfigHelper.GetIni("aclock", "8"))
                    and minute == 00):
                aClock()
                #避免同一分钟之内多次报时
                time.sleep(int(ConfigHelper.GetIni("smjg", "30")))

            if threadWifiCheck is None:
                print "thread begin"
                threadWifiCheck = CheckWifiGuest.CheckGuest()
                threadWifiCheck.start()

        except Exception, e:
            print e
            pass
        finally:
            time.sleep(int(ConfigHelper.GetIni("smjg", "30")))


if __name__ == '__main__':
    main()