Ejemplo n.º 1
0
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")
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
etc.
"""

import serial
from joblib import load
import BLE as blec

# Configuration of the serial port
serialPortName = 'COM4'
serialBaudRate = 230400
serialDataBits = serial.EIGHTBITS
serialParity = serial.PARITY_NONE
serialByteOrder = 'littleEndian'
serialStopBits = serial.STOPBITS_ONE
serialTimeout = None
ble = blec.BLE()

# ADC parameter
dacRef = 2.5  # Reference voltage of the DAC/ADC on the microcontroller
dacRefOffset = dacRef / 2  # The measurement voltage is shifted up by this voltage to be able to measure negative voltage differences down to (-1) * dacRefOffset.
dacNMax = 4095  # Maximum value of a digital conversion

# Sensor array parameter
sensor_num_x = 6  # Size of the sensor matrix in x direction
sensor_num_y = 6  # Size of the sensor matrix in y direction
xMin = 0  # Minimum x index of the sensors that shall be measured
xMax = 5  # Maximum x index
yMin = 0  # Minimum y index
yMax = 5  # Maximum y index

# Get sensor parameter