def checkOut(): """ function to prompt for location password to retrieve vehicle and vacate location """ leave = "abcdef" print("\nCheck-out selected.") parkedCars = allParkingSpots.values() currentCars = [car.MAC for car in parkedCars if car.MAC != "0"] if currentCars: print("please have customer enter in their confirmation number") selectCar = LCDandKeypad.exit() for key, value in allParkingSpots.items(): if selectCar == value.Confirmation: LCDandKeypad.exitWrite("retrieving car") currentCar = allParkingSpots[key] car = BLE(defaultAddr="0", defaultName="0") try: car.Connect(MAC=currentCar.MAC) except Exception as e: print("something went wrong: ", e) break if car.addr != "0": print("connected\n") totalPrice = getPrice(currentCar.StartTime) print("Customer total is ${:.2f}".format(totalPrice)) LCDandKeypad.exitWrite("Amount owed:", "${:.2f}".format(totalPrice)) if not queryYesNo("Has the customer paid? "): LCDandKeypad.exitWrite("NO $ NO CAR") print("Customer must pay to retrieve vehicle") break try: print("\nRetrieving vehicle from location {}.".format(key)) arduinoCom(leave[int(key)-1]) car.sendMessage('b') arduinoCom('x') car.sendMessage('g') except Exception as e: print("something went wrong:", e) blankSpot = [key, "0", "0", "0", "0", "0"] dictBlankSpot = dict(zip(parkingSpot.allowedAttributes, blankSpot)) allParkingSpots[key] = parkingSpot(dictBlankSpot) print("Location {} is now vacant.".format(key)) car.Disconnect() del car saveCustomerInfo() break else: print("couldn't connect to device") break else: print("Parking pass is invalid") LCDandKeypad.exitWrite("Parking pass", "is invalid") else: print("There are currently no cars parked")
def checkIn(): """ function for selecting parking location and receiving location password """ print("\nCheck-in selected") try: car = BLE(defaultAddr="0", defaultName="0") parkedCars = allParkingSpots.values() currentCars = [car.MAC for car in parkedCars if car.MAC != "0"] car.newConnect(currentCars) except Exception as e: print("something went wrong: ", e) if car.addr != "0": print("connected\n") carAttr = ["0", car.name, car.addr, str(datetime.now()), "0"] dictCar = dict(zip(parkingSpot.allowedAttributes, carAttr)) newCar = parkingSpot(dictCar) while True: print("vacant locations: ") for key, value in allParkingSpots.items(): if value.MAC == '0': print(key) selectSpot = input("Please select a location: ") currentSpot = allParkingSpots[selectSpot] if selectSpot in allParkingSpots.keys() and currentSpot.MAC == "0": print("You have selected location {}.".format(selectSpot)) arduinoCom(selectSpot) car.sendMessage('g') print("Generating parking pass...") newCar.Spot = selectSpot rand = newCar.Confirmation = str(randint(10000000, 99999999)) print("Your confirmation number is {}.".format(rand)) LCDandKeypad.entranceWrite("Confirmation #:", str(rand)) allParkingSpots[selectSpot] = newCar saveCustomerInfo() if queryYesNo("Would you like an email or text confirmation? "): sendConfirmation(newCar.Confirmation) break print("\nInvalid. Parking location is occupied or non-existant.") car.Disconnect() del car