################################################################################ # Function: get_user_id # Description: This function waits for the user to swipe their card. It gets # the raw id from stdin. # Arguments: none # Returns: raw_id # Notes: This function is currently Hampshire ID specific. The card reader # should be set to only read track 2 which is where the id is stored. # I need to verify that the new id's are the same. # # This function is also *nix specific. In order for the ID to not show # up on the screen, `stty -echo` is used. # # Gotta figure out GUI stuff which may affect this and all sorts of other # stuff ################################################################################ ################################################################################ # Function: verify_user_id # Description: Verifies that the raw id is in the right format: ;2345671? # Arguments: raw_id # Returns: bool - true if raw id matches format # Notes: This function is Hampshire ID specific. For some reason, it appears the # Hampshire ID has the first character '0' stripped of the beginning and # added to the end. Or so it appears. # The reg exp is currently very broad, it will match any 7 numbers in a # row. ################################################################################ ################################################################################ # Function: clean_user_id # Description: strips the identifying characters from the beginning and end of # the id. Then puts the '0' at the end of the id back at the # beginning (from the end). # Arguments: raw_id # Returns: clean id # Notes: Hampshire ID Specific. ################################################################################ ################################################################################ # Function: check_user_account_status # Description: Checks the user table to see if the user's account is enabled # Arguments: user_id # Returns: bool - true if the user account is set to enabled # Notes: ################################################################################ ################################################################################ # Function: check_user_has_vehicle # Description: Searches the availability field of the vehicle table to see if # the user already has a vehicle assigned to them. # Arguments: user_id # Returns: bool - true if user already has vehicle (that's sort of backwards and # confusing but I can't think of a better function name.) ################################################################################ ################################################################################ # Function: look_up_user_id # Description: Connects to user database to authenticate user # Arguments: # Returns: bool - depending on whether the user was present. # Notes: This function depends on what type of database is being used and what # the schema is. # For now, it's hard coded to verify my id only. ################################################################################ ################################################################################ # Function: unlock_vehicle # Description: Unlocks a particular lock # Arguments: rack_id, lock_id # Returns: bool - success or failure ################################################################################ ################################################################################ # Function: get_next_available_dock # Description: looks at a particular rack and determines which dock to unlock. # For example, when a vehicle is unlocked for a user, we need to # look at the status of the docks and unlock one that has a vehicle # in it, and ideally, one that is close to the check out spot. # Arguments: rack_id # Returns: dock_id ################################################################################ ################################################################################ # Function: look_up_vehicle_id # Description: Look in dock table at specified dock_id to determine the # vechicle_id which is in it. # Arguments: # Returns: ################################################################################ ################################################################################ # Function: add_events_entry # Description: Gathers all the variables and makes an entry in the events table # Arguments: action, user_id, rack_id, dock_id, vehicle_id, [elapsed_time] # Returns: ################################################################################ ################################################################################ # Function: update_dock_status # Description: updates status of dock_status # Arguments: dock_id, rack_id, dock_status (empty or vehicle_id) # Returns: bool - true on success ################################################################################ ################################################################################ # Function: update_vehicle_availablity # Description: updates availability of specified vehicle # Arguments: vehicle_id, availability (available, unavailable, or user_id) # Returns: bool - true on success ################################################################################ ################################################################################ # Function: vehicle_return # Description: # Arguments: # Returns: ################################################################################ ################################################################################ # Function: calc_elapsed_time # Description: Looks at the events table to determine when the user signed out # the vehicle and when they signed it in. Then calculates the # elapsed time. # Arguments: user_id, vehicle_id # Returns: ################################################################################