Skip to content

Commit

Permalink
Add billing code to UserData.py, import and added library code for DC…
Browse files Browse the repository at this point in the history
… & Stepper motor Pi Hat to Actuator.py
  • Loading branch information
Blaze Sanders committed Jun 15, 2019
1 parent c522027 commit 6d3f8f0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 23 deletions.
1 change: 1 addition & 0 deletions Adafruit-CircuitPython-MotorKit-2019.06.14
Submodule Adafruit-CircuitPython-MotorKit-2019.06.14 added at ec13af
5 changes: 4 additions & 1 deletion CafeBeepKiosk-0.1/Actuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__email__ = "b@cafebeep.com"
__company__ = "BEEP BEEP Technologies Inc"
__status__ = "Development"
__date__ = "Late Updated: 2019-05-21"
__date__ = "Late Updated: 2019-06-14"
__doc__ = "Class to operate at least 8 servos, 4 relays, and 4 motors at once with latency less then 100 ms"

# Useful documentation:
Expand All @@ -19,6 +19,9 @@
# https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/circuitpython-raspi
# https://learn.adafruit.com/adafruit-dc-and-stepper-motor-hat-for-raspberry-pi

# CircuitPython library for the DC & Stepper Motor Pi Hat kits using I2C interface
from adafruit_motorkit import MotorKit

# Allow control of input devices such as Buttons
from gpiozero import Button

Expand Down
65 changes: 43 additions & 22 deletions CafeBeepKiosk-0.1/UserData.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__email__ = "b@cafebeep.com"
__company__ = "BEEP BEEP Technologies Inc"
__status__ = "Development"
__date__ = "Late Updated: 2019-05-31"
__date__ = "Late Updated: 2019-06-14"
__doc__ = "Class to locally search user information, with ability to pull and push data from servers and flashdrives"

# Useful system jazz to do the following:
Expand All @@ -31,21 +31,25 @@ class UserData:

DEBUG_STATEMENTS_ON = True

# Useful function return error codes
OK = 0
FILEPATH_ERROR = -1
DATA_CONNECTION_ERROR = -2
BAD_USER_INPUT_ERROR = -3
INVALID_USER_ERROR = -4
# Function return error code CONSTANTS for catching program flow errors
OK = 0 # No errors
FILEPATH_ERROR = -1 # Bad or misformed filepath used
DATA_CONNECTION_ERROR = -2 # No or bad connection to celluar or wifi connections
BAD_USER_INPUT_ERROR = -3 # Bad user input, what else did you expect :)
INVALID_USER_ERROR = -4 # User not found in local database

MAX_USERS_PER_KIOSK = 4000 # TODO Determine this limit via testing
PHONE_NUMBER = "15558675309" # Constant for fixing user input, which is ALWAYS bad
FIRST_NAME = "Jane"

# Input sanitizing CONSTANTS for fixing user input, which is ALWAYS bad
PHONE_NUMBER = -1
FIRST_NAME = -2

# Database CONTSANTS for storing data locally and in the cloud
AWS_DATABASE_SERIVCE = "DynamodB" # Name of AWS database service in use
USB_FLASHDRIVE = "64GB" # Max USB flahsdrive size supported is 64 GigaBytes
PI_SD_CARD = "32GB" # Max microSD card size supported in 32 GigaBytes
ONLINE_AWS_DYNAMO_DB_URL = "arn:aws:dynamodb:us-west-1:076571243942:table/UserData"
DYNAMO_TABLE_NAME = "UserData" # TODO Database service MUST be named as class they are in
DYNAMO_TABLE_NAME = "UserData" # TODO Database service MUST be named same as class they are used in

# Allow users to select font for kiosk display (Customize all the things!)
SOURCE_SANS_PRO = "Source Sans Pro"
Expand All @@ -56,19 +60,24 @@ class UserData:
nextUserIDtoAssign = 0 #TODO c_unit(0) Ctype Unsigned Integer to give max number of userID's

###
# Constructor to initialize an UserData object, which holds Drink() object
# Constructor to initialize an UserData object, which holds a Drink() object internally
#
# @self - Newly created object
# @firstName -First name of user. Last name not require to protect privacy
# @userID - Internal BEEP BEEP Technology Inc ID number up to 4,294,967,295 (32-bit unsigned interger)
# @phoneNUmber - First user phone number to connected to a specific userID

#
# userID = Autogenerated unsigned integer variable used for quick searching (TODO c_unit)
# phoneNumbers - Array to hold upto 8 phone numbers for a single userID
# mainPhoneNUmber - Cell phone number that definds public facing userID (TODO different then userID ???) # drinkObject - Drink() object that holds currently selected drinkName, addOnType, and addOnLevels
# mainPhoneNUmber - Cell phone number that definds public facing userID
# drinkObject - Drink() object that holds currently selected drinkName, addOnType, and addOnLevels
# preferredFont - String variable to allow users to customize the touchscreen font in v2019.1 (TODO Sept 2019)
# lastDrink - Last drink ordered from ANY cafeBEEP kiosk in the Sol Star System
# freqDrinks - An auto currated list of the three most ordered drinks by a user
# TODOv2019.0 favoriteDrinks - Array that holds five drink configurations manually favorited by user
# fullOrderHistoy - Doubly-linked list of an users entire order history from ANY cafeBEEP kiosk
# totalSpend - Total amount spent by a user including both single cup and subscription purchases
# isAccountSuspended - Boolean variable to toggle account on and off if suspicious activity is seen
###
def __init__(self, firstName, userID, phoneNumber):
self.firstName = firstName
Expand All @@ -82,11 +91,12 @@ def __init__(self, firstName, userID, phoneNumber):
self.freqDrinks = [Drink.NONE, Drink.NONE, Drink.NONE]
#TODOv2019.0 self.favoriteDrinks = [Drink.NONE, Drink.NONE, Drink.NONE, Drink.NONE, Drink.NONE]
self.fullOrderHistory = collections.deque()

self.totalSpend = 0.0
self.isAccountSuspended= False

###
# Fix TWO different type of user input (which is ALWAYS wrong)
# NOTE: Only North America cell phone numbers starting with 1 digit are allowed
# Fix two different type of user input (which is ALWAYS wrong)
# NOTE: Only North America cell phone numbers starting with a '1' digit are valid
#
# @input - User input to check for errors (which there ALWAYS are)
# @inputType - CONTSTANT used to select final target conversion of user input
Expand All @@ -97,7 +107,7 @@ def sanitizeUserInput(input, inputType):
if(inputType == PHONE_NUMBER):
inputStringPhoneNUmber = str(input)

# Rebuild phone number one character at a time by pulling out just numerical digits (0 to 9)
# Rebuild phone number one character at a time by pulling out just numerical digits (0 to 9)
for i in len(stringPhoneNumber):
character = stringPhoneNumber[i : i + 1]
if(character.isDigit()):
Expand All @@ -116,7 +126,7 @@ def sanitizeUserInput(input, inputType):
#Capitalize the first character and make the rest lowercase
return intput.capitalize()
else:
print("")
print("INVALID INPUT TYPE SLECTED FOR SANITIAZTION: USE PHONE_NUMBER or FIRST_NAME")

###
# TODOv2019.0 feature Store UserData.py objects
Expand Down Expand Up @@ -248,7 +258,7 @@ def updateLocalUserDatabase(currentLocalUserDatabase, source):
# Use phone numebr as key and then search for active phone numbers
userDataLocalDatabase = {
0: UserData("Blaze", 0, 15135109110)
1: UserData("David", 1, 151)
1: UserData("David", 1, 15104619805)
2: UserData("Murali", 2, 19499759879)
}

Expand All @@ -260,7 +270,7 @@ def updateLocalUserDatabase(currentLocalUserDatabase, source):
elif(source == PI_SD_CARD):
errorCode = readCSV('~/GitHub/CafeBeep/CafeBeepKiosk-0.1/static/UserData/')
else:
print("INVLAID SOURCE FOR USER DATABASE UPDATE: USE AWS, PI SD CARD, OR USB FLASHDRIVE")
print("INVALID SOURCE FOR USER DATABASE UPDATE: USE AWS, PI SD CARD, OR USB FLASHDRIVE")

return errorCode

Expand Down Expand Up @@ -317,11 +327,22 @@ def debugPrint(stringToPrint):

if __name__ == "__main__":

print("START USERDATA.PY MAIN")
print("START USERDATA.PY MAIN UNIT TEST")

debugPrint("TESTING DEBUG PRINT")

UserData("Elon", 42, 1-555-867-5309)

print("END USERDATA.PY MAIN")
testBadPhoneNumbers = [123-9877-657, 123456789] # All BAD input
for i in testBadPhoneNumbers:
ERROR_CODE = sanitizeUserInput(testBadPhoneNumbers[i], PHONE_NUMBER)
print("Error code for test phone number " + i + " is " + ERROR_CODE)

testGoodPhoneNumbers = [1-510-513-9110, 5105139110, 513.513.9110] # All GOOD input
for i in testBadPhoneNumbers:
ERROR_CODE = sanitizeUserInput(testGoodPhoneNumbers[i], PHONE_NUMBER)
print("Error code for test phone number " + i + " is " + ERROR_CODE)


print("END USERDATA.PY MAIN UNIT TEST")

Binary file not shown.

0 comments on commit 6d3f8f0

Please sign in to comment.