kh
Dependencies: mbed PinDetect Servo
Diff: open.cpp
- Revision:
- 2:04bbd14722bd
- Parent:
- 1:2c365f6da61d
--- a/open.cpp Sat Nov 10 20:08:46 2018 +0000 +++ b/open.cpp Mon Nov 12 23:36:11 2018 +0000 @@ -1,42 +1,43 @@ -/* -* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga -* Purpose: Controls the OPEN state of the machine -* Language: C -*/ -#include "open.h" -#include "authentication.h" -#include "actuators.h" -#include "parameters.h" +/* +* Authors: Group 4 Adam Elghor, Brian Kaplan, Sayak Chatterjee, Moraa Onwonga +* Purpose: Controls the OPEN state of the machine +* Language: C +*/ +#include "open.h" +#include "authentication.h" +#include "actuators.h" +#include "parameters.h" + +/* +* Function: OPEN +* -------------------- +* Calls the functions needed to for the open state +* +* +* returns: the next state in the state machine +* LOCK: if closed properly +* ALARM: if cup is not found after searching in a full circle +* +*/ +enum states open() { + if (authenticateOpen()) { + return OPEN; + } else { + lockSafe(); + wait(5); + return LOCK; + } +} + +/* +* Function: authenticate +* ---------------------------- +* Checks whether a cup was found through the sonar sensor +* +* returns: true if cup found else false +*/ +bool authenticateOpen() { + return CorrectEntrySequenceAttempt(); +} + -/* -* Function: OPEN -* -------------------- -* Calls the functions needed to for the open state -* -* -* returns: the next state in the state machine -* LOCK: if closed properly -* ALARM: if cup is not found after searching in a full circle -* -*/ -enum states open() { - if (authenticateOpen()) { - return OPEN; - } else { - lockSafe(); - wait(5000); - return LOCK; - } -} - -/* -* Function: authenticate -* ---------------------------- -* Checks whether a cup was found through the sonar sensor -* -* returns: true if cup found else false -*/ -bool authenticateOpen() { - return CorrectEntrySequenceAttempt(); -} -