def main(): config = ConfigParser.RawConfigParser() config.read("posconfig.txt") waitSecs = config.getint("general","seconds_lights_on") #sets up the socket host = config.get("database", "host") port = config.getint("database", "port") responseSize = config.getint("database","responseSize") greenLight = light(config.getint("light", "greenPin")) redLight = light(config.getint("light", "redPin")) (rfidKeyboard, magneticKeyboard) = getKeyboards() greenLight.off() redLight.off() #print("Connecting to ", host) #posSocket.connect((host, port)) while rfidKeyboard and magneticKeyboard: idInput = readKeyboards(rfidKeyboard, magneticKeyboard) currentStudent = Student(0, 0, False, 'students.db') #process to allow id input in any order and validates the student does not have a G2G container greenLight.off() redLight.off() #student number first workflow if(currentStudent.isInputStudentId(idInput)): #sets studentNumber to scanned card currentStudent.setStudentNumber(idInput) print("Connecting to ", host) posSocket = socket.socket() posSocket.connect((host, port)) currentStudent.setHasG2G(reportId(idInput,posSocket, host, port, responseSize)) if(currentStudent.hasG2G): #Red light redLight.on() greenLight.off() else: #scan RFID idInput = readKeyboards(rfidKeyboard, magneticKeyboard) while(not(currentStudent.isInputRFID(idInput))): redLight.on() greenLight.on() idInput = readKeyboards(rfidKeyboard, magneticKeyboard) redLight.off() greenLight.on() reportRfid(idInput, posSocket, host, port) #RFID first workflow elif(currentStudent.isInputRFID(idInput)): currentStudent.setRFIDCode(idInput) idInput=readKeyboards(rfidKeyboard, magneticKeyboard) while(not(currentStudent.isInputStudentId(idInput))): redLight.on() greenLight.on() idInput = readKeyboards(rfidKeyboard, magneticKeyboard) print("Connecting to ", host) posSocket = socket.socket() posSocket.connect((host, port)) currentStudent.setStudentNumber(idInput) currentStudent.setHasG2G(reportId(idInput, posSocket, host, port, responseSize)) if(currentStudent.hasG2G): greenLight.off() redLight.on() else: redLight.off() greenLight.on() reportRfid(currentStudent.RFIDCode,posSocket, host, port) else: redLight.on() greenLight.on() print("closing connection with", host) posSocket.close()