#!/usr/bin/python
from DatabaseInterface import DatabaseInterface

def cycleContainer(DBM, boxID, studentID):
    DBM.RecordCheckOut(studentID, boxID, "TE:ST:00:00:00:00")
    DBM.RecordCheckIn(boxID, "TE:ST:00:00:TE:ST")    



def createAndCheckOutBox(DBM, boxID, studentID):
    DBM.CreateBoxInBoxTable(boxID)
    DBM.RecordCheckOut(studentID, boxID, "TE:ST:00:00:00:00")



def main():
    DBM = DatabaseInterface()
    DBM.DeleteBoxTable()
    DBM.CreateBoxesTable()
    DBM.DeleteStudentTable()
    DBM.CreateStudentTable()
    #DBM.CreateBoxInBoxTable("BOKS_00001")
    #DBM.CreateStudentInStudentTable("STUDENT_01")
    #DBM.AddComponentToSystem("08:00:27:6a:f3:d7", "receptacle", "/home/ethan/re-vend/ServerDev/ComponentConfigs/boxconfig.txt")
    i = 0
    while i < 1000:
        DBM.CreateStudentInStudentTable("STUD_" + "{0:5}".format(str(i)))
        i=i+1

    i = 0
    while i < 1000000:
        DBM.CreateBoxInBoxTable("BOKS_" + "{0:5}".format(str(i)))
        i=i+1

    j = 0
    while j < 1000:
        i = 0
        while i < 1000:
            box = "BOKS_" + "{0:5}".format(str((j*100)+i));
            student = "STUD_" + "{0:5}".format(str(j));
            #print box + ", "
            #print student + "\n"
            DBM.RecordCheckOut(student, box, "TE:ST:00:00:00:00")
            i=i+1

        i = 0
        while i < 1000:
            #DBM.RecordCheckIn("BOKS_" + "{0:5}".format(str((j*100)+i)), "TE:ST:00:00:TE:ST")
            i=i+1
            box = "BOKS_" + "{0:5}".format(str((j*100)+i));
            #print box + "\n"
            DBM.RecordCheckIn(box, "TE:ST:00:00:00:00")
            i=i+1

        j=j+1

main()