def getLastEntry():
    tagdata = read()
    tag = mysql.getuserName(tagdata)
    print(tag)
    lastentry=mysql.getLastReading(tag)
    print("Hi!",tag)
    print(lastentry)
    lcd.clear()
    lcd.message("Last Entry \n " + lastentry)
Beispiel #2
0
def readNfc(action):
    if(action==55):#7 - Incomming
        onScreen("Logging In...")
        display.lcdWriteFirstLine("Prichod...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId=read()
        logging.info("Incomming - %s",cardId)
        name = mysql.insertReading(cardId,Actions.incomming)
        display.lcdWriteSecondLine(name)
    if(action==57):#9 - outcomming
        onScreen("...")
        display.lcdWriteFirstLine("Logging out...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId=read()
        logging.info("Outcomming - %s",cardId)
        name = mysql.insertReading(cardId,Actions.outcomming)
        display.lcdWriteSecondLine(name)
    if(action==49):#1 - break start
        onScreen("Zacatek pauzy...")
        display.lcdWriteFirstLine("Pauza zacatek...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId=read()
        logging.info("Break start - %s",cardId)
        name = mysql.insertReading(cardId,Actions.breakstart)
        display.lcdWriteSecondLine(name)
    if(action==51):#3 - break end
        onScreen("Konec pauzy...")
        display.lcdWriteFirstLine("Pauza konec...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId=read()
        logging.info("Break end - %s",cardId)
        name = mysql.insertReading(cardId,Actions.breakend)
        display.lcdWriteSecondLine(name)
    if(action==53):#5 - Deletion of last inserted action
        onScreen("Delete the last entry...")
        display.lcdWriteFirstLine("Deleting...")
        display.lcdWriteSecondLine("")
        cardId=read()
        logging.info("Deleting last action - %s",cardId)
        (lastTime,lastAction)=mysql.getLastReading(cardId) or (None, None)

        if(lastTime == None or lastAction == None):
            display.lcdWriteSecondLine("Unknown Event")
            logging.info("Action not found")
            time.sleep(1)

        else:
            display.lcdWriteFirstLine("Delete Event?")
            if(lastAction==Actions.incomming):
                display.lcdWriteSecondLine("Check In")
            elif(lastAction==Actions.outcomming):
                display.lcdWriteSecondLine("Check Out")
            elif(lastAction==Actions.breakstart):
                display.lcdWriteSecondLine("Pauza zacatek")
            elif(lastAction==Actions.breakend):
                display.lcdWriteSecondLine("End of Pause?")
            a=getOneKey()
            if(a==49):#1
                onScreen("Mazu")
                logging.info(" - Deleting action %s (cas: %s)",lastAction, lastTime)
                mysql.deleteLastReading(cardId)
                display.lcdWriteSecondLine("Deleted!")
            else:
                onScreen("Not Deleted")
                logging.info(" - Deleting canceled")
                display.lcdWriteSecondLine("Not deleted!")

    #Sleep a little, so the information about last action on display is readable by humans
    time.sleep(1)
Beispiel #3
0
def readNfc(action):
    if (action == 55):  #7 - Incomming
        onScreen("Logging In...")
        display.lcdWriteFirstLine("Prichod...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId = read()
        logging.info("Incomming - %s", cardId)
        name = mysql.insertReading(cardId, Actions.incomming)
        display.lcdWriteSecondLine(name)
    if (action == 57):  #9 - outcomming
        onScreen("...")
        display.lcdWriteFirstLine("Logging out...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId = read()
        logging.info("Outcomming - %s", cardId)
        name = mysql.insertReading(cardId, Actions.outcomming)
        display.lcdWriteSecondLine(name)
    if (action == 49):  #1 - break start
        onScreen("Zacatek pauzy...")
        display.lcdWriteFirstLine("Pauza zacatek...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId = read()
        logging.info("Break start - %s", cardId)
        name = mysql.insertReading(cardId, Actions.breakstart)
        display.lcdWriteSecondLine(name)
    if (action == 51):  #3 - break end
        onScreen("Konec pauzy...")
        display.lcdWriteFirstLine("Pauza konec...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId = read()
        logging.info("Break end - %s", cardId)
        name = mysql.insertReading(cardId, Actions.breakend)
        display.lcdWriteSecondLine(name)
    if (action == 53):  #5 - Deletion of last inserted action
        onScreen("Delete the last entry...")
        display.lcdWriteFirstLine("Deleting...")
        display.lcdWriteSecondLine("")
        cardId = read()
        logging.info("Deleting last action - %s", cardId)
        (lastTime, lastAction) = mysql.getLastReading(cardId) or (None, None)

        if (lastTime == None or lastAction == None):
            display.lcdWriteSecondLine("Unknown Event")
            logging.info("Action not found")
            time.sleep(1)

        else:
            display.lcdWriteFirstLine("Delete Event?")
            if (lastAction == Actions.incomming):
                display.lcdWriteSecondLine("Check In")
            elif (lastAction == Actions.outcomming):
                display.lcdWriteSecondLine("Check Out")
            elif (lastAction == Actions.breakstart):
                display.lcdWriteSecondLine("Pauza zacatek")
            elif (lastAction == Actions.breakend):
                display.lcdWriteSecondLine("End of Pause?")
            a = getOneKey()
            if (a == 49):  #1
                onScreen("Mazu")
                logging.info(" - Deleting action %s (cas: %s)", lastAction,
                             lastTime)
                mysql.deleteLastReading(cardId)
                display.lcdWriteSecondLine("Deleted!")
            else:
                onScreen("Not Deleted")
                logging.info(" - Deleting canceled")
                display.lcdWriteSecondLine("Not deleted!")

    #Sleep a little, so the information about last action on display is readable by humans
    time.sleep(1)
Beispiel #4
0
def readNfc(action):
    if(action==55):#7 - Incomming
        onScreen("Prichod...")
        display.lcdWriteFirstLine("Prichod...")
        display.lcdWriteSecondLine("Prilozte kartu")
        cardId=read()
        logging.info("Incomming - %s",cardId)
        name = mysql.insertReading(cardId,Actions.incomming)
        display.lcdWriteSecondLine(name)
    if(action==57):#9 - outcomming
        onScreen("Odchod...")
        display.lcdWriteFirstLine("Odchod...")
        display.lcdWriteSecondLine("Prilozte kartu")
        cardId=read()
        logging.info("Outcomming - %s",cardId)
        name = mysql.insertReading(cardId,Actions.outcomming)
        display.lcdWriteSecondLine(name)
    if(action==49):#1 - break start
        onScreen("Zacatek pauzy...")
        display.lcdWriteFirstLine("Pauza zacatek...")
        display.lcdWriteSecondLine("Prilozte kartu")
        cardId=read()
        logging.info("Break start - %s",cardId)
        name = mysql.insertReading(cardId,Actions.breakstart)
        display.lcdWriteSecondLine(name)
    if(action==51):#3 - break end
        onScreen("Konec pauzy...")
        display.lcdWriteFirstLine("Pauza konec...")
        display.lcdWriteSecondLine("Prilozte kartu")
        cardId=read()
        logging.info("Break end - %s",cardId)
        name = mysql.insertReading(cardId,Actions.breakend)
        display.lcdWriteSecondLine(name)
    if(action==53):#5 - Deletion of last inserted action
        onScreen("Smazat posledni akci...")
        display.lcdWriteFirstLine("Mazani...")
        display.lcdWriteSecondLine("")
        cardId=read()
        logging.info("Deleting last action - %s",cardId)
        (lastTime,lastAction)=mysql.getLastReading(cardId) or (None, None)

        if(lastTime == None or lastAction == None):
            display.lcdWriteSecondLine("Akce nenalezena")
            logging.info("Action not found")
            time.sleep(1)

        else:
            display.lcdWriteFirstLine("Smazat akci?")
            if(lastAction==Actions.incomming):
                display.lcdWriteSecondLine("Prichod")
            elif(lastAction==Actions.outcomming):
                display.lcdWriteSecondLine("Odchod")
            elif(lastAction==Actions.breakstart):
                display.lcdWriteSecondLine("Pauza zacatek")
            elif(lastAction==Actions.breakend):
                display.lcdWriteSecondLine("Pauza konec")
            a=getOneKey()
            if(a==49):#1
                onScreen("Mazu")
                logging.info(" - Deleting action %s (cas: %s)",lastAction, lastTime)
                mysql.deleteLastReading(cardId)
                display.lcdWriteSecondLine("Smazano!")
            else:
                onScreen("Nemazu")
                logging.info(" - Deleting canceled")
                display.lcdWriteSecondLine("Nemazu nic!")

    #Sleep a little, so the information about last action on display is readable by humans
    time.sleep(1)