Пример #1
0
def action3():
    if GPIO.input(act3):        
        GPIO.output(act3,False)
        gsm.Sendmsg(number,"act3 OFF")
        print ("act3 false")
        ser.flushInput()
        
    elif act3 != 1:
        GPIO.output(act3,True)
        gsm.Sendmsg(number,"act3 ON")
        print("act3 true")
        ser.flushInput()
Пример #2
0
def action2():
    if GPIO.input(act2):        
        GPIO.output(act2,False)
        gsm.Sendmsg(number,"act2 OFF")
        print ("act2 false")
        ser.flushInput()
        
    elif act2 != 1:
        GPIO.output(act2,True)
        gsm.Sendmsg(number,"act2 ON")
        print("act2 true")
        ser.flushInput()
Пример #3
0
def action4():
    if GPIO.input(act4):        
        GPIO.output(act4,False)
        gsm.Sendmsg(number,"act4 OFF")
        print ("act4 false")
        ser.flushInput()
        
    elif act4 != 1:
        GPIO.output(act4,True)
        gsm.Sendmsg(number,"act4 ON")
        print("act4 true")
        ser.flushInput()
Пример #4
0
def action1():
    if GPIO.input(act1):        
        GPIO.output(act1,False)
        gsm.Sendmsg(number,"act1 OFF")
        os.system('mpg321 1.mp3 &')
        print ("act1 false")
        ser.flushInput()
                                        
    elif act1 != 1:        
        GPIO.output(act1,True)
        gsm.Sendmsg(number,"act1 ON")
        os.system('mpg321 1.mp3 &')
        print("act1 true")
        ser.flushInput()
Пример #5
0
def action3():
    if GPIO.input(act3):
        GPIO.output(act3, False)
        gsm.Sendmsg(number, "Water")
        os.system('mpg321 water.mp3 &')
        print("act3 false")
        ser1.flushInput()

    elif act3 != 1:
        GPIO.output(act3, True)
        gsm.Sendmsg(number, "Water")
        print("act3 true")
        os.system('mpg321 water.mp3 &')
        ser1.flushInput()
Пример #6
0
def action7():
    if GPIO.input(act7):
        GPIO.output(act7, False)
        gsm.Sendmsg(number, "Doctor")
        print("act7 false")
        os.system('mpg321 Doctor.mp3 &')
        ser1.flushInput()

    elif act7 != 1:
        GPIO.output(act7, True)
        gsm.Sendmsg(number, "Doctor")
        print("act7 true")
        os.system('mpg321 Doctor.mp3 &')
        ser1.flushInput()
Пример #7
0
def action4():
    if GPIO.input(act4):
        GPIO.output(act4, False)
        gsm.Sendmsg(number, "Food")
        print("act4 false")
        os.system('mpg321 Food.mp3 &')
        ser1.flushInput()

    elif act4 != 1:
        GPIO.output(act4, True)
        gsm.Sendmsg(number, "Food")
        print("act4 true")
        os.system('mpg321 Food.mp3 &')
        ser1.flushInput()
Пример #8
0
def function7():
    r61 = 0        
    p61= 0
    p62 =0
    rfun7 =0
    pfun7=0


    while (1):
        

        line = ser.readline()
        line = line.replace("#YPR=","")
        line = line.replace("#YPRAMG=","")   # Delete "#YPR="
        #f.write(line)                     # Write to the output log file
        words = string.split(line[4:],",")
        
    
            
    
        if len(words) > 2:                                          
                    try:
                        pfun7 = -float(words[1])*grad2rad
                        rfun7 = -float(words[2])*grad2rad                                                             
                    except Exception as e:                   
                        print e
        
        print ("7",rfun7,pfun7,p2)
        
        if (rfun7 > 0.5):
            r61 +=1
        else:
            r61=0   
        
        if (pfun7 > 0.5):
            p61 +=1
        else:
            p61=0
        if (pfun7 < -0.5):
            p62 +=1
        else:
            p62=0
        if r61 > 3:
            r61=0
            print ("Water")
            lcd.stringlcd(0xC0,"Water")
            gsm.Sendmsg(number,"Water")

        if (p61 >= 3):
            p61 = 0
            print ("fun8")
            lcd.stringlcd(0xC0,"Changed to Function8")
            function8()
        if (p62 >= 3):
            p62 = 0
            print ("fun6")
            lcd.stringlcd(0xC0,"Changed to Function6")
            function6()
        ser.flushInput()
        time.sleep(1)
Пример #9
0
def function6():
    r51 = 0        
    p51= 0
    p52 =0
    rfun6 =0
    pfun6=0


    while (1):
        

        line = ser.readline()
        line = line.replace("#YPR=","")
        line = line.replace("#YPRAMG=","")   # Delete "#YPR="
        #f.write(line)                     # Write to the output log file
        words = string.split(line[4:],",")
        
    
            
    
        if len(words) > 2:                                          
                    try:
                        pfun6 = -float(words[1])*grad2rad
                        rfun6 = -float(words[2])*grad2rad                                                             
                    except Exception as e:                   
                        print e
        
        print ("6",rfun6,pfun6,p2)
        
        if (rfun6 > 0.5):
            r51 +=1
        else:
            r51=0   
        
        if (pfun6 > 0.5):
            p51 +=1
        else:
            p51=0
        if (pfun6 < -0.5):
            p52 +=1
        else:
            p52=0
        if r51 > 3:
            r51=0
            print ("Medicine")
            gsm.Sendmsg(number,"Medicine")
            lcd.stringlcd(0xC0,"Medicine")

        if (p51 >= 3):
            p51 = 0
            print ("fun7")
            lcd.stringlcd(0xC0,"Changed to Function7")
            function7()
        if (p52 >= 3):
            p52 = 0
            print ("fun5")
            lcd.stringlcd(0xC0,"Changed to Function5")
            function5()
        ser.flushInput()
        time.sleep(1)
Пример #10
0
def action8():
    if GPIO.input(act8):
        GPIO.output(act8, False)
        gsm.Sendmsg(number, "Emergency")
        print("act8 false")
        os.system('mpg321 Emergency.mp3 &')
        DA()
        ser1.flushInput()

    elif act8 != 1:
        GPIO.output(act8, True)
        gsm.Sendmsg(number, "Emergency")
        print("act8 true")
        os.system('mpg321 Emergency.mp3 &')
        ser1.flushInput()
        DA()
Пример #11
0
def function8():
    r71 = 0        
    p71= 0
    p72 =0
    rfun8 =0
    pfun8=0


    while (1):
        

        line = ser.readline()
        line = line.replace("#YPR=","")
        line = line.replace("#YPRAMG=","")   # Delete "#YPR="
        #f.write(line)                     # Write to the output log file
        words = string.split(line[4:],",")
        
    
            
    
        if len(words) > 2:                                          
                    try:
                        pfun8 = -float(words[1])*grad2rad
                        rfun8 = -float(words[2])*grad2rad                                                             
                    except Exception as e:                   
                        print e
        
        print ("8",rfun8,pfun8,p2)
        
        if (rfun8 > 0.5):
            r71 +=1
        else:
            r71=0   
        
        if (pfun8 > 0.5):
            p71 +=1
        else:
            p71=0
        if (pfun8 < -0.5):
            p72 +=1
        else:
            p72=0
        if r71 > 3:
            r71=0
            print ("Food")
            lcd.stringlcd(0xC0,"FOOD")
            gsm.Sendmsg(number,"FOOD")
        if (p71 >= 3):
            p71 = 0
            print ("fun1")
            lcd.stringlcd(0xC0,"Changed to Function1")
            function1()
        if (p72 >= 3):
            p72 = 0
            print ("fun7")
            lcd.stringlcd(0xC0,"Changed to Function7")
            function7()
        ser.flushInput()
        time.sleep(1)
Пример #12
0
def function5():
    r41 = 0        
    p41= 0
    p42 =0
    rfun5 =0
    pfun5=0


    while (1):
        

        line = ser.readline()
        line = line.replace("#YPR=","")
        line = line.replace("#YPRAMG=","")   # Delete "#YPR="
        #f.write(line)                     # Write to the output log file
        words = string.split(line[4:],",")
        
    
            
    
        if len(words) > 2:                                          
                    try:
                        pfun5 = -float(words[1])*grad2rad
                        rfun5 = -float(words[2])*grad2rad                                                             
                    except Exception as e:                   
                        print e
        
        print ("5",rfun5,pfun5,p2)
        
        if (rfun5 > 0.5):
            r41 +=1
        else:
            r41=0   
        
        if (pfun5 > 0.5):
            p41 +=1
        else:
            p41=0
        if (pfun5 < -0.5):
            p42 +=1
        else:
            p42=0
        if r41 > 3:
            r41=0
            print ("Doctor")
            gsm.Sendmsg(number,"Doctor")

        if (p41 >= 3):
            p41 = 0
            print ("fun6")
            lcd.stringlcd(0xC0,"Changed to Function6")
            function6()
        if (p42 >= 3):
            p42 = 0
            print ("fun4")
            lcd.stringlcd(0xC0,"Changed to Function4")
            function4()
        ser.flushInput()
        time.sleep(1)
Пример #13
0
def action6():
    if GPIO.input(act6):
        GPIO.output(act6, False)
        gsm.Sendmsg(number, "Medicine")
        print("act6 Medicine false")
        os.system('mpg321 Medicine.mp3 &')
        lcd.lcd_init()
        lcd.stringlcd(0xC0, "Medicine")
        ser1.flushInput()

    elif act6 != 1:
        GPIO.output(act6, True)
        gsm.Sendmsg(number, "Medicine")
        os.system('mpg321 Medicine.mp3 &')
        lcd.lcd_init()
        lcd.stringlcd(0xC0, "Medicine")
        print("act6 Medicine true")
        ser1.flushInput()
Пример #14
0
def action5():
    if GPIO.input(act5):
        GPIO.output(act5, False)
        gsm.Sendmsg(number, "Toilet")
        os.system('mpg321 Toilet.mp3 &')
        lcd.lcd_init()
        lcd.stringlcd(0xC0, "Toilet")
        print("act5 false")
        ser1.flushInput()

    elif act5 != 1:
        GPIO.output(act5, True)
        gsm.Sendmsg(number, "Toilet")
        os.system('mpg321 Toilet.mp3 &')
        lcd.lcd_init()
        lcd.stringlcd(0xC0, "Toilet")
        print("act5 true")
        ser1.flushInput()
Пример #15
0
def action2():
    if GPIO.input(act2):
        GPIO.output(act2, False)
        gsm.Sendmsg(number, "act2 Light OFF")
        os.system('mpg321 LightOFF.mp3 &')
        print("act2 Light false")
        lcd.lcd_init()
        lcd.stringlcd(0xC0, "LIGHT OFF")
        ser1.flushInput()

    elif act2 != 1:
        GPIO.output(act2, True)
        gsm.Sendmsg(number, "act2 Light ON")
        os.system('mpg321 LightON.mp3 &')
        lcd.lcd_init()
        lcd.stringlcd(0xC0, "LIGHT ON")
        print("act2 Light true")
        ser1.flushInput()
Пример #16
0
def action1():
    if GPIO.input(act1):
        GPIO.output(act1, False)
        gsm.Sendmsg(number, "act1  Fan OFF")
        os.system('mpg321 FanOFF.mp3 &')
        lcd.lcd_init()
        lcd.stringlcd(0xC0, "FAN OFF")
        print("act1 false")
        ser1.flushInput()
        DA()

    elif act1 != 1:
        GPIO.output(act1, True)
        gsm.Sendmsg(number, "act1 Fan ON")
        os.system('mpg321 FanON.mp3 &')
        lcd.lcd_init()
        lcd.stringlcd(0xC0, "FAN ON")
        print("act1 true")
        ser1.flushInput()
        DA()
     lcd.stringlcd(0x80, "No HB")
     lcd.stringlcd(0xc0, "Temp:" + str(temperature) + "F")
 else:
     if (hbval > 110):
         lcd.stringlcd(0x80, "Sensor Problm")
         lcd.stringlcd(0xc0, "Temp:" + str(temperature) + "F")
     elif (hbval < 60):
         lcd.stringlcd(0x80, "Sensor Problm")
         lcd.stringlcd(0xc0, "Temp:" + str(temperature) + "F")
     else:
         lcd.stringlcd(0x80, "HB:" + str(hbval))
         lcd.stringlcd(0xc0, "Temp:" + str(temperature) + "F")
         if (hbval > 78):
             lcd.stringlcd(0x80, "SMS Sending")
             gsm.Sendmsg(
                 number, "High Heart Beat:" + str(hbval) +
                 " Temperature : " + str(temperature))
             time.sleep(7)
             lcd.stringlcd(0x80, "Calling")
             gsm.ser.write('ATD' + number + ';\r\n')
             time.sleep(10)
 if (temperature > 103):
     lcd.stringlcd(0x80, "SMS Sending")
     gsm.Sendmsg(
         number, "High Temperature : " + str(temperature) + "Heart Beat:" +
         str(hbval))
     time.sleep(7)
     lcd.stringlcd(0x80, "Calling")
     gsm.ser.write('ATD' + number + ';\r\n')
     time.sleep(10)
 a = datetime.datetime.now()