def start():
    global counter
    global user_id
    time_start = 0
    read0 = 1
    logcount = count_people()
    while True:

        time.sleep(0.1)
        read1 = wiringpi.digitalRead(GPIO_SW)
        #        print "read1= %d" % read1
        if read0 == read1:
            continue

        time.sleep(0.05)
        read2 = wiringpi.digitalRead(GPIO_SW)
        now = datetime.now()
        current_date = now.strftime("%Y:%m:%d")
        current_time = now.strftime("%H:%M:%S")
        end = datetime.now()

        #        print "read0= %d" % read0
        if read1 == read2:
            if read1 == 1:

                logcount = logcount + 1
                print "person count:" + str(logcount)
                time_start = time.monotonic()
                print now
                print("男子トイレ使用開始\n")
                start_waiting()
                wiringpi.digitalWrite(
                    GPIO_LED, 0)  # switch on LED. Sets port 12 to 1 (3V3, on)
                store_log(str(logcount) + "男子 トイレ使用開始\n")
                status("Busy")

                user_id = logTable.insert_table(1, current_date, current_time,
                                                1, "Boy Busy", duration)

            else:
                stop_waiting()
                time_end = time.monotonic()
                duration = time_end - time_start
                wiringpi.digitalWrite(
                    GPIO_LED, 1)  # switch off LED. Sets port 12 to 0 (0V, off)
                pygame.mixer.Channel(0).stop()
                store_log("男子トイレ使用終了\n")
                user_id = logTable.insert_table(1, current_date, current_time,
                                                2, "Boy Free", duration)
                status("Free")
                print "\n男子トイレ使用終了"
                print end

        read0 = read1
示例#2
0
def start():
    global counter
    global user_id
    global dur
    read0 = 1
    log2count = count2_people()
    while True:
        time.sleep(0.1)
        read1 = wiringpi.digitalRead(GPIO_SW)
        #        print "read1= %d" % read1


        if read0 == read1:

            continue

        time.sleep(0.05)
        read2 = wiringpi.digitalRead(GPIO_SW)
        now = datetime.now()
        current_date = now.strftime("%Y:%m:%d")
        current_time = now.strftime("%H:%M:%S")
        end = datetime.now()
        #        print "read0= %d" % read0
        if read1 == read2:
            if read1 == 1:
                log2count = log2count + 1
                print "person count:" + str(log2count)
                print now
                print " 女子トイレ使用開始\n"
                start_waiting()
                wiringpi.digitalWrite(GPIO_LED, 0) # switch on LED. Sets port 18 to 0 (3V3, on)
                store2_log( str(log2count) + "女子 トイレ使用開始\n")

                user_id = logTable.insert_table(2, current_date, current_time, 1, "Girl Busy", 1.0)
                status2("Busy")





            else:
                stop_waiting()
                wiringpi.digitalWrite(GPIO_LED, 1) # switch off LED. Sets port 18 to 1 (0V, off)
                pygame.mixer.Channel(1).stop()
                store2_log("女子 トイレ使用終了\n")
                user_id = logTable.insert_table(2,current_date, current_time, 2, "Girl Free", 0.0)
                status2("Free")
                print "\n女子トイレ使用終了"
                print end

                

        read0 = read1
def start():
    global counter
    durationStop = datetime.now() - timedelta(days=1)
    duration1 = 0
    status_toilet = "free"
    start_d = datetime.now()
    global user_id
    global start
    global end
    global status_blink
    global stop_threads
    global stop_blink
    global start_blink

    start_time = datetime.now()
    read0 = 1
    logcount = count_people()
    temp_count = logcount
    while True:

        time.sleep(0.1)
        read1 = wiringpi.digitalRead(GPIO_SW)
        #        print "read1= %d" % read1

        if status_blink and (status_toilet == "free"):
            if (datetime.now() - durationStop).seconds > 3:
                print("stop blink")
                stop_threads = True
                start_blink.join()
                status_blink = False
                duration = (datetime.now() - start_time).seconds / 60
                start_time = datetime.now()
                duration = str(duration)
                #store_log(duration + "\n 男子トイレ使用終了\n")
                #user_id = logTable.insert_table(1, current_date, current_time, 2, "Boy Free", duration=duration)
                status("Free")
                print(duration)
                print("\n男子トイレ使用終了")
                temp_count = logcount
                status_toilet = "free"

        elif (not status_blink) and status_toilet == "busy":
            if (datetime.now() - start_time).seconds > 60:
                stop_threads = False
                print("start blink")
                start_blink = threading.Thread(target=blink_led, args=())
                start_blink.start()
                status_blink = True
        if read0 == read1:
            continue

        time.sleep(0.05)
        read2 = wiringpi.digitalRead(GPIO_SW)
        now = datetime.now()
        #        date_time = now.strftime("[%Y/%m/%d  %H:%M:%S]")
        current_date = now.strftime("%Y:%m:%d")
        current_time = now.strftime("%H:%M:%S")
        end = datetime.now()

        #        print "read0= %d" % read0

        if status_blink:
            #if (datetime.now() - durationStop).seconds>3:

            stop_blink = False
            start_blink.start()

            stop_blink = True
            start_blink.join()
            status_blink = False

        if read1 == read2:
            if read1 == 1:
                duration1 = datetime.now() - durationStop
                if (duration1.seconds < 3):
                    thAnn5()
                    start_d = datetime.now()
                    status_toilet = "busy"
                    wiringpi.digitalWrite(
                        GPIO_LED,
                        0)  # switch on LED. Sets port 12 to 1 (3V3, on)
                    # status("Busy")
                    # print ("\n Boybusy")
                    # store_log(str(logcount) + "男子 トイレ使用開始\n")
                    user_id = logTable.insert_table(1,
                                                    current_date,
                                                    current_time,
                                                    2,
                                                    "Boy Busy",
                                                    duration=duration)

                else:
                    # stop_thAnn5()
                    start_time = datetime.now()
                    status_toilet = "busy"
                    logcount = logcount + 1
                    start_d = datetime.now()

                    # tt = start_d.time()
                    #if tt > 1.0:
                    #    stop_threads = False
                    #    start_blink = threading.Thread(target=blink_led, args=())
                    #    start_blink.start()
                    #    status_blink = True

                    start_waiting()
                    print("person count:" + str(logcount))
                    wiringpi.digitalWrite(
                        GPIO_LED,
                        0)  # switch on LED. Sets port 12 to 1 (3V3, on)
                    store_log(str(logcount) + "男子 トイレ使用開始\n")
                    status("Busy")
                    print("\n Boybusy")
                    user_id = logTable.insert_table(1,
                                                    current_date,
                                                    current_time,
                                                    1,
                                                    "Boy Busy",
                                                    duration=duration)


#

            else:
                stop_waiting()

                status_toilet = "free"

                durationStop = datetime.now()
                time_end = datetime.now()
                duration = time_end - start_d
                duration = duration.seconds / 60.0
                wiringpi.digitalWrite(
                    GPIO_LED, 1)  # switch off LED. Sets port 12 to 0 (0V, off)
                pygame.mixer.Channel(0).stop()

                print("\n男子トイレ使用終了")
                duration = str(duration)
                store_log(duration + "\n 男子トイレ使用終了\n")
                # if temp_count<logcount:
                #     duration = str(duration)

                #     store_log(duration + "\n 男子トイレ使用終了\n")
                #     user_id = logTable.insert_table(1, current_date, current_time, 2, "Boy Free", duration=duration)
                #     status("Free")
                #     print (duration)
                #     print ("\n男子トイレ使用終了")
                #     temp_count = logcount
                # else:

                if temp_count < logcount:
                    duration = str(duration)

                    user_id = logTable.insert_table(1,
                                                    current_date,
                                                    current_time,
                                                    2,
                                                    "Boy Free",
                                                    duration=duration)
                    status("Free")
                    print(duration)
                    print("\n男子トイレ使用終了")
                    store_log(duration + "\n 男子トイレ使用終了\n")
                    temp_count = logcount
                else:

                    logTable.update_table(user_id, duration)
                    temp_count = logcount
        read0 = read1
示例#4
0
def start():
    global counter
    durationStop = datetime.now() - timedelta(days=1)
    duration1 = 0
    start_d = datetime.now()
    global user_id
    global start
    global end
    start_time = 0
    read0 = 1
    logcount = count_people()
    while True:

        time.sleep(0.1)
        read1 = wiringpi.digitalRead(GPIO_SW)
        #        print "read1= %d" % read1
        if read0 == read1:
            continue

        time.sleep(0.05)
        read2 = wiringpi.digitalRead(GPIO_SW)
        now = datetime.now()
        #        date_time = now.strftime("[%Y/%m/%d  %H:%M:%S]")
        current_date = now.strftime("%Y:%m:%d")
        current_time = now.strftime("%H:%M:%S")
        end = datetime.now()

        #        print "read0= %d" % read0
        if read1 == read2:
            if read1 == 1:
                duration1 = datetime.now() - durationStop
                print(duration1)
                if duration1.seconds < 5:
                    thAnn5()
                    start_d = datetime.now()
                    wiringpi.digitalWrite(
                        GPIO_LED,
                        0)  # switch on LED. Sets port 12 to 1 (3V3, on)
                    status("Busy")
                    print("\n Boybusy")
                    store_log(str(logcount) + "男子 トイレUse\n")
                    user_id = logTable.insert_table(1,
                                                    current_date,
                                                    current_time,
                                                    0,
                                                    "Boy Busy",
                                                    duration=duration)

                else:
                    stop_thAnn5()
                    logcount = logcount + 1
                    start_d = datetime.now()
                    start_waiting()
                    print("person count:" + str(logcount))
                    wiringpi.digitalWrite(
                        GPIO_LED,
                        0)  # switch on LED. Sets port 12 to 1 (3V3, on)
                    store_log(str(logcount) + "男子 Busy\n")
                    status("Busy")
                    print("\n Boybusy")
                    user_id = logTable.insert_table(1,
                                                    current_date,
                                                    current_time,
                                                    1,
                                                    "Boy Busy",
                                                    duration=duration)

            else:
                stop_waiting()
                durationStop = datetime.now()
                time_end = datetime.now()
                duration = time_end - start_d
                duration = duration.seconds / 60.0
                wiringpi.digitalWrite(
                    GPIO_LED, 1)  # switch off LED. Sets port 12 to 0 (0V, off)
                pygame.mixer.Channel(0).stop()
                store_log("男子トイレ Free\n")
                user_id = logTable.insert_table(1,
                                                current_date,
                                                current_time,
                                                2,
                                                "Boy Free",
                                                duration=duration)
                status("Free")
                print(duration)
                print("\n男子トイレFree")

        read0 = read1
示例#5
0
def start():
    global counter
    global user_id
    durationStop = datetime.now() - timedelta(days = 1)
    duration2 = 0
    start_d = datetime.now()
    read0 = 1
    log2count = count2_people()
    while True:
        time.sleep(0.1)
        read1 = wiringpi.digitalRead(GPIO_SW)
        #        print "read1= %d" % read1
        if read0 == read1:

            continue

        time.sleep(0.05)
        read2 = wiringpi.digitalRead(GPIO_SW)
        now = datetime.now()
        current = datetime.now()
        current_date = now.strftime("%Y:%m:%d")
        current_time = now.strftime("%H:%M:%S")
   
        #        print "read0= %d" % read0
        if read1 == read2:
            if read1 == 1:
                duration2 = datetime.now() - durationStop
                print(duration2)
                if duration2.seconds < 5:
                    thAnn5()
                    start_d = datetime.now()
                    wiringpi.digitalWrite(GPIO_LED, 0) # switch on LED. Sets port 18 to 1 (3V3, on)
                    store2_log(str(log2count) + "女子 トイレUse\n")
                    user_id = logTable.insert_table(2, current_date, current_time,0, "Girl Busy", duration = duration)
                    status2("Busy")
    #                print ("\n 女子トイレUse")

                else:
                    stop_thAnn5()
                    log2count = log2count + 1
                    start_d = datetime.now()
                    print ("person count:" + str(log2count))
                    start_waiting()
                    wiringpi.digitalWrite(GPIO_LED, 0)  # switch on LED. Sets port 18 to 1 (3V3, on)
                    store2_log(str(log2count) + "女子 トイレBusy\n")
                    user_id = logTable.insert_table(2, current_date, current_time, 1, "Girl Busy", duration=duration)
                    status2("Busy")
                    print ("\n 女子トイレBusy\n")




            else:

                stop_waiting()
                durationStop = datetime.now()
                time_end = datetime.now()
                duration = time_end - start_d
                duration = duration.seconds/60.0
                wiringpi.digitalWrite(GPIO_LED, 1) # switch off LED. Sets port 18 to 0 (0V, off)
                pygame.mixer.Channel(1).stop()
                store2_log("女子 トイレFree\n")
                user_id = logTable.insert_table(2,current_date, current_time, 2, "Girl Free", duration= duration)
                print (duration)
                status2("Free")
                print ("\n女子トイレFree\n")



        read0 = read1
示例#6
0
def start():
    global counter
    global user_id
    global start
    global end 
    global status2_blink
    global start2_blink
    global stop2_threads
    
    durationStop2 = datetime.now() - timedelta(days = 1)
    duration2 = 0
    status2_toilet = "free"
    start_d = datetime.now()
    start_time = datetime.now()
    read0 = 1
    log2count = count2_people()
    temp2_count = log2count

    while True:
        time.sleep(0.1)
        read1 = wiringpi.digitalRead(GPIO_SW)
        #        print "read1= %d" % read1

        if status2_blink and (status2_toilet == "free"):
            if (datetime.now() - durationStop2).seconds > 1:
                print("stop blink")
                stop2_threads = True
                start2_blink.join()
                status2_blink = False
                duration = (datetime.now() - start_time).seconds /60  #For 1 min
                start_time = datetime.now()
                duration =str(duration)
                store2_log(duration + "\n 男子トイレ使用終了\n")
                status2("free")
                print (duration)
                print("\n男子トイレ使用終了")
                temp2_count = log2count
                status2_toilet = "free"
            
        elif (not status2_blink) and status2_toilet == "busy":
            if(datetime.now() - start_time).seconds > 60 :
                stop2_threads = False
                print("start blink")
                start2_blink = threading.Thread(target = blink_led, args = ())
                start2_blink.start()
                status2_blink = True
        if read0 == read1:

            continue

        time.sleep(0.05)
        read2 = wiringpi.digitalRead(GPIO_SW)
        now = datetime.now()
        current = datetime.now()
        current_date = now.strftime("%Y/%m/%d %H:%M:%f")
        current_time = now.strftime("%H:%M:%f")
        end = datetime.now()

        #        print "read0= %d" % read0
        if read1 == read2:
            if read1 == 1:
                duration2 = datetime.now() - durationStop2
    #            print(duration2)
                if (duration2.seconds) < 5:
                    thAnn5()
                    start_d = datetime.now()
                    status2_toilet = "busy"
                    wiringpi.digitalWrite(GPIO_LED, 0) # switch on LED. Sets port 18 to 1 (3V3, on)
                    user_id = logTable.insert_table(2, current_date, current_time,2, "Girl Busy", duration = duration)
            #        status2("Busy")
    #                print ("\n 女子トイレUse")

                else:
                #    stop_thAnn5()
                    start_time = datetime.now()
                    start_d = datetime.now()
                    status2_toilet = "busy"
                    log2count = log2count + 1
                    print ("person count:" + str(log2count))
                    start_waiting()
                    wiringpi.digitalWrite(GPIO_LED, 0)  # switch on LED. Sets port 18 to 1 (3V3, on)
                    store2_log(str(log2count) + "女子 トイレBusy\n")
                    
                    status2("Busy")
                    print ("\n 女子トイレBusy\n")
                    user_id = logTable.insert_table(2, current_date, current_time, 1, "Girl Busy", duration=duration)



            else:

                stop_waiting()
                status2_toilet = "free"
                durationStop2 = datetime.now()
                time_end = datetime.now()
                duration = time_end - start_d
                duration = duration.seconds/60.0
                wiringpi.digitalWrite(GPIO_LED, 1) # switch off LED. Sets port 18 to 0 (0V, off)
                pygame.mixer.Channel(1).stop()
            #    store2_log("女子 トイレFree\n")
                user_id = logTable.insert_table(2,current_date, current_time, 2, "Girl Free", duration= duration)
            #    print (duration)
             #   status2("Free")
             #   print ("\n女子トイレFree\n")
                if temp2_count > log2count:
                    logTable.update_table(user_id , duration)
                    temp2_count = log2count


        read0 = read1