The field version of the solarnano grid on the ionQubes

Fork of SolarNanoGridv3 by SONG Project

Committer:
defrost
Date:
Fri Jun 10 21:06:52 2016 +0000
Revision:
15:e719c1cb0ea2
Parent:
13:de43f28c0365
- Added ifndef/def blockers in some headers

Who changed what in which revision?

UserRevisionLine numberNew contents of line
epgmdm 11:87ab310924f0 1 /**
epgmdm 11:87ab310924f0 2 *@section DESCRIPTION
epgmdm 11:87ab310924f0 3 * mbed SolarNanogrid Library
epgmdm 11:87ab310924f0 4 * Hmi extends SolarNanoGrid.
epgmdm 11:87ab310924f0 5 * Hmi does the human interface and talks to the lockers.
epgmdm 11:87ab310924f0 6 * The ID must be in FF 00.
epgmdm 11:87ab310924f0 7 *@section LICENSE
epgmdm 11:87ab310924f0 8 * Copyright (c) 2016, Malcolm McCulloch
epgmdm 11:87ab310924f0 9 *
epgmdm 11:87ab310924f0 10 * Permission is hereby granted, free of charge, to any person obtaining a copy
epgmdm 11:87ab310924f0 11 * of this software and associated documentation files (the "Software"), to deal
epgmdm 11:87ab310924f0 12 * in the Software without restriction, including without limitation the rights
epgmdm 11:87ab310924f0 13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
epgmdm 11:87ab310924f0 14 * copies of the Software, and to permit persons to whom the Software is
epgmdm 11:87ab310924f0 15 * furnished to do so, subject to the following conditions:
epgmdm 11:87ab310924f0 16 *
epgmdm 11:87ab310924f0 17 * The above copyright notice and this permission notice shall be included in
epgmdm 11:87ab310924f0 18 * all copies or substantial portions of the Software.
epgmdm 11:87ab310924f0 19 *
epgmdm 11:87ab310924f0 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
epgmdm 11:87ab310924f0 21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
epgmdm 11:87ab310924f0 22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
epgmdm 11:87ab310924f0 23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
epgmdm 11:87ab310924f0 24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
epgmdm 11:87ab310924f0 25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
epgmdm 11:87ab310924f0 26 * THE SOFTWARE.
epgmdm 11:87ab310924f0 27 * @file "Hmi.h"
epgmdm 11:87ab310924f0 28 */
epgmdm 11:87ab310924f0 29
defrost 15:e719c1cb0ea2 30 #ifndef HMI_H
defrost 15:e719c1cb0ea2 31 #define HMI_H
epgmdm 11:87ab310924f0 32 #include "mbed.h"
epgmdm 11:87ab310924f0 33 //#include "NRF2401P.h"
epgmdm 11:87ab310924f0 34 //#include "nRF24l01.h"
epgmdm 11:87ab310924f0 35 #include "MFRC522.h"
epgmdm 11:87ab310924f0 36 #include "SPI_TFT_ILI9341.h"
epgmdm 11:87ab310924f0 37 #include "Arial24x23.h"
epgmdm 11:87ab310924f0 38 //#include "SDFileSystem.h"
epgmdm 11:87ab310924f0 39 #include "HubUser.h"
epgmdm 11:87ab310924f0 40 #include "HubLogging.h"
epgmdm 11:87ab310924f0 41 #include "SolarNanoGrid.h"
epgmdm 11:87ab310924f0 42
defrost 13:de43f28c0365 43
epgmdm 11:87ab310924f0 44
epgmdm 11:87ab310924f0 45
epgmdm 11:87ab310924f0 46 /** \brief Hmi manages the human interface and talks to the lockers.
epgmdm 11:87ab310924f0 47 *
epgmdm 11:87ab310924f0 48 * ## Config file
epgmdm 11:87ab310924f0 49 * The config.ini must start with H
epgmdm 11:87ab310924f0 50 * poshoInit.txt
epgmdm 11:87ab310924f0 51 *
epgmdm 11:87ab310924f0 52 * ## Hardware
epgmdm 11:87ab310924f0 53 * ### Buttons
epgmdm 11:87ab310924f0 54 * - Button one interrupt (PTC3)
epgmdm 11:87ab310924f0 55 * - Button two interrupt (PTC2)
epgmdm 11:87ab310924f0 56 * - Button three interrupt (PTA2)
epgmdm 11:87ab310924f0 57 * - Button four interrupt (PTB23)
epgmdm 11:87ab310924f0 58 *
epgmdm 11:87ab310924f0 59 * ### RFID (SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_CS, MF_RESET)
epgmdm 11:87ab310924f0 60 * - Battery reader : (PTD2, PTD3, PTD1, PTB2, PTB3)
epgmdm 11:87ab310924f0 61 * - Posho reader : (PTD2, PTD3, PTD1, PTB10, PTB11);
epgmdm 11:87ab310924f0 62 * - Incubator : (PTD2, PTD3, PTD1, PTC11, PTC10)
epgmdm 11:87ab310924f0 63 *
epgmdm 11:87ab310924f0 64 * ### Screen SPI_TFT_ILI9341
epgmdm 11:87ab310924f0 65 * - (PTD2, PTD3, PTD1, PTE25, PTB20, PTB18,"TFT")
epgmdm 11:87ab310924f0 66 *
epgmdm 11:87ab310924f0 67 */
epgmdm 11:87ab310924f0 68 class Hmi : public SolarNanoGrid
epgmdm 11:87ab310924f0 69 {
epgmdm 11:87ab310924f0 70 public:
epgmdm 11:87ab310924f0 71
epgmdm 11:87ab310924f0 72 // *********************
epgmdm 11:87ab310924f0 73 // * Public variables: *
epgmdm 11:87ab310924f0 74 // *********************
epgmdm 11:87ab310924f0 75
epgmdm 11:87ab310924f0 76
epgmdm 11:87ab310924f0 77 // *********************
epgmdm 11:87ab310924f0 78 // * Public functions: *
epgmdm 11:87ab310924f0 79 // *********************
epgmdm 11:87ab310924f0 80 /**
epgmdm 11:87ab310924f0 81 * Constructor
epgmdm 11:87ab310924f0 82 * param: fp is the link to the config file.
epgmdm 11:87ab310924f0 83 */
epgmdm 11:87ab310924f0 84 Hmi(FILE* fp, Serial *pc);
epgmdm 11:87ab310924f0 85 /**
epgmdm 11:87ab310924f0 86 * Loops through slow routines
epgmdm 11:87ab310924f0 87 */
epgmdm 11:87ab310924f0 88
epgmdm 11:87ab310924f0 89 void loopHub();
defrost 13:de43f28c0365 90
defrost 13:de43f28c0365 91 /**
defrost 13:de43f28c0365 92 * calls loopHub()
defrost 13:de43f28c0365 93 */
defrost 13:de43f28c0365 94 virtual void loop();
epgmdm 11:87ab310924f0 95
epgmdm 11:87ab310924f0 96
epgmdm 11:87ab310924f0 97 protected:
epgmdm 11:87ab310924f0 98 // *********************
epgmdm 11:87ab310924f0 99 // * Protected hardware: *
epgmdm 11:87ab310924f0 100 // *********************
epgmdm 11:87ab310924f0 101
epgmdm 11:87ab310924f0 102
epgmdm 11:87ab310924f0 103 // RFID Readers MFRC522 RfChip (SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_CS, MF_RESET);
epgmdm 11:87ab310924f0 104 MFRC522 *BatteryRfChipH; /**< Battery Rfid */
epgmdm 11:87ab310924f0 105 MFRC522 *PoshoRfChipH; /**< Posho Rfid */
epgmdm 11:87ab310924f0 106 MFRC522 *IncubatorRfChipH; /**< Incubator Rfid */
epgmdm 11:87ab310924f0 107
epgmdm 11:87ab310924f0 108 InterruptIn *buttonOneH; /**< Button one interrupt (PTC3) */
epgmdm 11:87ab310924f0 109 InterruptIn *buttonTwoH; /**< Button two interrupt (PTC2)*/
epgmdm 11:87ab310924f0 110 InterruptIn *buttonThreeH; /**< Button three interrupt (PTA2) */
epgmdm 11:87ab310924f0 111 InterruptIn *buttonFourH; /**< Button four interrupt (PTB23)*/
epgmdm 11:87ab310924f0 112
epgmdm 11:87ab310924f0 113
epgmdm 11:87ab310924f0 114 SPI_TFT_ILI9341 *TFT_H; /**< LCD Display */
epgmdm 11:87ab310924f0 115
epgmdm 11:87ab310924f0 116 // Tickers
epgmdm 11:87ab310924f0 117 Ticker *tick1sHub; /**< Every second time check */
epgmdm 11:87ab310924f0 118 Ticker *tickBatteryRfidH; /**< Battery Rfid check */
epgmdm 11:87ab310924f0 119 Ticker *tickIncubatorRfidH; /**< Incubator Rfid check */
epgmdm 11:87ab310924f0 120 Ticker *tickPoshoRfidH; /**< Posho Rfid check */
epgmdm 11:87ab310924f0 121 Ticker *tickTimeCheckH; /**< Time check for terminal display */
epgmdm 11:87ab310924f0 122 Ticker *tickerUpdateUserTableH; /**< Update user table to SD card ticker (every 30 min) */
epgmdm 11:87ab310924f0 123
epgmdm 11:87ab310924f0 124 // *********************
epgmdm 11:87ab310924f0 125 // * Protected flags: *
epgmdm 11:87ab310924f0 126 // *********************
epgmdm 11:87ab310924f0 127
epgmdm 11:87ab310924f0 128 char flagBatteryRfidH; /**< Battery Rfid flag */
epgmdm 11:87ab310924f0 129 char flagButtonOneH; /**< Button one flag */
epgmdm 11:87ab310924f0 130 char flagButtonTwoH; /**< Button two flag */
epgmdm 11:87ab310924f0 131 char flagButtonThreeH; /**< Button three flag */
epgmdm 11:87ab310924f0 132 char flagButtonFourH; /**< Button four flag */
epgmdm 11:87ab310924f0 133
epgmdm 11:87ab310924f0 134 char flagPoshoRfidH; /**< Posho Rfid flag */
epgmdm 11:87ab310924f0 135 char flagIncubatorRfidH; /**< Incubator Rfid flag */
epgmdm 11:87ab310924f0 136 char flagTimeCheckH; /**< Time check flag */
epgmdm 11:87ab310924f0 137 char flagUpdateUserTableH; /**< Update user table to SD card ticker */
epgmdm 11:87ab310924f0 138 unsigned char flag1sH; /**< Every second flag */
epgmdm 11:87ab310924f0 139
epgmdm 11:87ab310924f0 140 //State
epgmdm 11:87ab310924f0 141 /*
epgmdm 11:87ab310924f0 142 * The hub display screen can involve multiple stages that are enumerated here.
epgmdm 11:87ab310924f0 143 * All user action waiting stages also listen for the user selecting to cancel/exit
epgmdm 11:87ab310924f0 144 */
epgmdm 11:87ab310924f0 145 enum HubScreenStageH {
epgmdm 11:87ab310924f0 146 initialScanRfid, /**< Waiting for RFID with clearing and text display */
epgmdm 11:87ab310924f0 147 waitForRfid, /**< Listening for all interrupts */
epgmdm 11:87ab310924f0 148 batterySelectAction, /**< Listening for either battery drop off or pick up */
epgmdm 11:87ab310924f0 149 batterySelectNumberForPickup, /**< Listening for number of batteries to drop off */
epgmdm 11:87ab310924f0 150 batterySelectNumberForDropoff, /**< Listening for number of batteries to pick up */
epgmdm 11:87ab310924f0 151 poshoSelectKilograms /**< Listening for number of kgs of material to posho */
epgmdm 11:87ab310924f0 152 };
epgmdm 11:87ab310924f0 153
epgmdm 11:87ab310924f0 154
epgmdm 11:87ab310924f0 155 enum HubScreenStageH currentScreenH ; /**< Globally accessible screen selector */
epgmdm 11:87ab310924f0 156
epgmdm 11:87ab310924f0 157 // *********************
epgmdm 11:87ab310924f0 158 // * Protected variables: *
epgmdm 11:87ab310924f0 159 // *********************
epgmdm 11:87ab310924f0 160
epgmdm 11:87ab310924f0 161 float currentMaxH; /**< Maximum current that each cube can consume. */
epgmdm 11:87ab310924f0 162
epgmdm 11:87ab310924f0 163 HubUser *allUsersH; /**< Array to be dynamically allocated storing all users */
epgmdm 11:87ab310924f0 164 int userCountH; /**< Number of active users on this hub mbed */
epgmdm 11:87ab310924f0 165 int currentUserH; /**< Index of the current user */
epgmdm 11:87ab310924f0 166
epgmdm 11:87ab310924f0 167 int poshoPricePerKgH; /**< price per kg of material to be used with the posho */
epgmdm 11:87ab310924f0 168 int timeForOneKgH; /**< time for one kg of material to be used with the posho */
epgmdm 11:87ab310924f0 169 int timeForTwoKgH; /**< time for two kg of material to be used with the posho */
epgmdm 11:87ab310924f0 170 int timeForThreeKgH; /**< time for three kg of material to be used with the posho */
epgmdm 11:87ab310924f0 171
epgmdm 11:87ab310924f0 172 Ticker tickPoshoInUseClearH; /**< ticker to clear posho in use flag after a specific time */
epgmdm 11:87ab310924f0 173 char flagPoshoAlreadyInUseH;
epgmdm 11:87ab310924f0 174
epgmdm 11:87ab310924f0 175 long long baseAddr; /**< Base address of community to tell for pickup or drop off*/
epgmdm 11:87ab310924f0 176 long long lockerAddr; /**< Address of locker to transmit to tell for pickup or drop off*/
epgmdm 11:87ab310924f0 177 long long utilityAddr; /**< Address of locker to transmit to tell for pickup or drop off*/
epgmdm 11:87ab310924f0 178
epgmdm 11:87ab310924f0 179 // *********************
epgmdm 11:87ab310924f0 180 // * Protected functions: *
epgmdm 11:87ab310924f0 181 // *********************
epgmdm 11:87ab310924f0 182
epgmdm 11:87ab310924f0 183 /**
epgmdm 11:87ab310924f0 184 * Creates a new user by defining user attributes.
epgmdm 11:87ab310924f0 185 * @param rfid - uint32_t corresponding to unique id of the RFID tag
epgmdm 11:87ab310924f0 186 * @param accountCredit - int32 for user account balance (can be negative)
epgmdm 11:87ab310924f0 187 * @param locker - int32_t for which locker (originaly 1-4) user is assigned
epgmdm 11:87ab310924f0 188 * @param batterySubscription - int32_t max batteries user can get (can be 0)
epgmdm 11:87ab310924f0 189 * @param batteriesOut - int32_t number of batteries user has out (usually 0 initially)
epgmdm 11:87ab310924f0 190 * @param pod - int32_t pod associated with the user (originally 0-15) *must be 0 indexed*
epgmdm 11:87ab310924f0 191 */
epgmdm 11:87ab310924f0 192 void createNewUserH(uint32_t rfid, int32_t accountCredit, int32_t locker,
epgmdm 11:87ab310924f0 193 int32_t batterySubscription, int32_t batteriesOut, int32_t pod, char* name);
epgmdm 11:87ab310924f0 194 /**
epgmdm 11:87ab310924f0 195 * Initialize Global User Table Variable with malloc
epgmdm 11:87ab310924f0 196 * @param users - int representing how many users you want the system to hold
epgmdm 11:87ab310924f0 197 */
epgmdm 11:87ab310924f0 198 void initializeGlobalUserTableH(int users);
epgmdm 11:87ab310924f0 199 /**
epgmdm 11:87ab310924f0 200 * Initialize posho functionality
epgmdm 11:87ab310924f0 201 */
epgmdm 11:87ab310924f0 202 void initializePoshoFunctionalityH();
epgmdm 11:87ab310924f0 203 /**
epgmdm 11:87ab310924f0 204 * Initialize system with users from users.txt on SD card
epgmdm 11:87ab310924f0 205 */
epgmdm 11:87ab310924f0 206 void initializeUsersFromSD_H();
epgmdm 11:87ab310924f0 207
epgmdm 11:87ab310924f0 208
epgmdm 11:87ab310924f0 209 /* ************************************************************************************************/
epgmdm 11:87ab310924f0 210 /* Set a flag when an interrupt is detected */
epgmdm 11:87ab310924f0 211 /* ************************************************************************************************/
epgmdm 11:87ab310924f0 212
epgmdm 11:87ab310924f0 213 /**
epgmdm 11:87ab310924f0 214 * Time check interrupt
epgmdm 11:87ab310924f0 215 */
epgmdm 11:87ab310924f0 216 void interruptTimeCheckH();
epgmdm 11:87ab310924f0 217 /**
epgmdm 11:87ab310924f0 218 * Update user table interrupt
epgmdm 11:87ab310924f0 219 */
epgmdm 11:87ab310924f0 220 void interruptUpdateUserTableH();
epgmdm 11:87ab310924f0 221 /**
epgmdm 11:87ab310924f0 222 * Battery RFID reader interrupt
epgmdm 11:87ab310924f0 223 */
epgmdm 11:87ab310924f0 224 void interruptBatteryRfidH();
epgmdm 11:87ab310924f0 225 /**
epgmdm 11:87ab310924f0 226 * Posho RFID reader interrupt
epgmdm 11:87ab310924f0 227 */
epgmdm 11:87ab310924f0 228 void interruptPoshoRfidH();
epgmdm 11:87ab310924f0 229 /**
epgmdm 11:87ab310924f0 230 * Incubator RFID reader interrupt
epgmdm 11:87ab310924f0 231 */
epgmdm 11:87ab310924f0 232 void interruptIncubatorRfidH();
epgmdm 11:87ab310924f0 233 /**
epgmdm 11:87ab310924f0 234 * button one interrupt
epgmdm 11:87ab310924f0 235 */
epgmdm 11:87ab310924f0 236 void interruptButtonOneH();
epgmdm 11:87ab310924f0 237 /**
epgmdm 11:87ab310924f0 238 * button two interrupt
epgmdm 11:87ab310924f0 239 */
epgmdm 11:87ab310924f0 240 void interruptButtonTwoH();
epgmdm 11:87ab310924f0 241 /**
epgmdm 11:87ab310924f0 242 * button three interrupt
epgmdm 11:87ab310924f0 243 */
epgmdm 11:87ab310924f0 244 void interruptButtonThreeH();
epgmdm 11:87ab310924f0 245 /**
epgmdm 11:87ab310924f0 246 * button four interrupt
epgmdm 11:87ab310924f0 247 */
epgmdm 11:87ab310924f0 248 void interruptButtonFourH();
epgmdm 11:87ab310924f0 249 /**
epgmdm 11:87ab310924f0 250 * Fast interrupt routine for every 1 second
epgmdm 11:87ab310924f0 251 */
epgmdm 11:87ab310924f0 252 void int1sH();
epgmdm 11:87ab310924f0 253 /**
epgmdm 11:87ab310924f0 254 * interrupt to clear the posho is in use flag after a designated time
epgmdm 11:87ab310924f0 255 */
epgmdm 11:87ab310924f0 256 void interruptPoshoInUseClearH();
epgmdm 11:87ab310924f0 257
epgmdm 11:87ab310924f0 258 /*************************************************************************************************/
epgmdm 11:87ab310924f0 259 /*
epgmdm 11:87ab310924f0 260 * Reset all user initiated flags. Useful after sequences of events where flags may have
epgmdm 11:87ab310924f0 261 * piled up from misc inputs and you don't want the system to act seemingly sporadically.
epgmdm 11:87ab310924f0 262 */
epgmdm 11:87ab310924f0 263 void clearAllUserInitiatedFlagsH();
epgmdm 11:87ab310924f0 264
epgmdm 11:87ab310924f0 265
epgmdm 11:87ab310924f0 266
epgmdm 11:87ab310924f0 267 /*
epgmdm 11:87ab310924f0 268 * User presses the button corresponding to an exit. Returns to home screen
epgmdm 11:87ab310924f0 269 * after logging the action.
epgmdm 11:87ab310924f0 270 * @param userIndex - int representing index of user in user table
epgmdm 11:87ab310924f0 271 */
epgmdm 11:87ab310924f0 272 void cancelPressedH(int userIndex);
epgmdm 11:87ab310924f0 273 /**
epgmdm 11:87ab310924f0 274 * Do if time check flag is set
epgmdm 11:87ab310924f0 275 * reads the unix time, converts into human readable format, and displays on PC
epgmdm 11:87ab310924f0 276 */
epgmdm 11:87ab310924f0 277 void doTimeCheckH();
epgmdm 11:87ab310924f0 278 /**
epgmdm 11:87ab310924f0 279 * Do if update user table flag is set
epgmdm 11:87ab310924f0 280 */
epgmdm 11:87ab310924f0 281 void doUpdateUserTableH();
epgmdm 11:87ab310924f0 282
epgmdm 11:87ab310924f0 283 /* ************************************************************************************************/
epgmdm 11:87ab310924f0 284 /* RFID support */
epgmdm 11:87ab310924f0 285 /* ************************************************************************************************/
epgmdm 11:87ab310924f0 286 /*
epgmdm 11:87ab310924f0 287 * Read Rfid card and parse out the tag id into a single integer. Log if tag is either known
epgmdm 11:87ab310924f0 288 * or unknown. Sets the global variable for the current user if a user is found.
epgmdm 11:87ab310924f0 289 * @param rfidReader - MFRC522* of the RFID reader
epgmdm 11:87ab310924f0 290 * @param source - HubLoggingRfidSource enum for which RFID reader (battery, posho, incubator)
epgmdm 11:87ab310924f0 291 * @return int representing the userIndex of the HubUser found by the RFID tag. If no user is
epgmdm 11:87ab310924f0 292 found, returns a -1.
epgmdm 11:87ab310924f0 293 */
epgmdm 11:87ab310924f0 294 int rfidReadHelper(MFRC522 *rfidReader, enum HubLoggingRfidSource source);
epgmdm 11:87ab310924f0 295 /*************************************************************************************************/
epgmdm 11:87ab310924f0 296 /* Battery Services */
epgmdm 11:87ab310924f0 297 /*************************************************************************************************/
epgmdm 11:87ab310924f0 298 /**
epgmdm 11:87ab310924f0 299 * Do if Battery RFID flag is set. Read RFID tag and check user status.
epgmdm 11:87ab310924f0 300 * If there's a valid battery subscription, display drop off and/or pick up.
epgmdm 11:87ab310924f0 301 * Otherwise, returns to initial screen.
epgmdm 11:87ab310924f0 302 */
epgmdm 11:87ab310924f0 303 void doBatteryRfidH();
epgmdm 11:87ab310924f0 304 /**
epgmdm 11:87ab310924f0 305 * Do if user selects to pickup a battery. Determines how many batteries
epgmdm 11:87ab310924f0 306 * a user can pickup based off user info and displays corresponding text
epgmdm 11:87ab310924f0 307 * @param userIndex - int representing index of user in user table
epgmdm 11:87ab310924f0 308 */
epgmdm 11:87ab310924f0 309 void batteryPickUpScreenH(int userIndex);
epgmdm 11:87ab310924f0 310 /**
epgmdm 11:87ab310924f0 311 * Do if user selects to dropoff a battery. Determines how many batteries
epgmdm 11:87ab310924f0 312 * a user can pickup based off user info and displays corresponding text
epgmdm 11:87ab310924f0 313 * @param userIndex - int representing index of user in user table
epgmdm 11:87ab310924f0 314 */
epgmdm 11:87ab310924f0 315 void batteryDropOffScreenH(int userIndex);
epgmdm 11:87ab310924f0 316
epgmdm 11:87ab310924f0 317 /**
epgmdm 11:87ab310924f0 318 * Do after user selects number of batteries to drop off.
epgmdm 11:87ab310924f0 319 * Logs the action, changes user info, transmits instructions to other systems
epgmdm 11:87ab310924f0 320 * @param numBatteries - int for number of batteries selected to drop off
epgmdm 11:87ab310924f0 321 * @param userIndex - int representing index of user in user table
epgmdm 11:87ab310924f0 322 */
epgmdm 11:87ab310924f0 323 void batteryDropOffH(int numBatteries, int userIndex);
epgmdm 11:87ab310924f0 324 /**
epgmdm 11:87ab310924f0 325 * Do after user selects number of batteries to pick up.
epgmdm 11:87ab310924f0 326 * Logs the action, changes user info, transmits instructions to other systems
epgmdm 11:87ab310924f0 327 * @param numBatteries - int for number of batteries selected to pick up
epgmdm 11:87ab310924f0 328 * @param userIndex - int representing index of user in user table
epgmdm 11:87ab310924f0 329 */
epgmdm 11:87ab310924f0 330 void batteryPickUpH(int numBatteries, int userIndex);
epgmdm 11:87ab310924f0 331
epgmdm 11:87ab310924f0 332 /* ************************************************************************************************/
epgmdm 11:87ab310924f0 333 /* Misc Services */
epgmdm 11:87ab310924f0 334 /* ************************************************************************************************/
epgmdm 11:87ab310924f0 335 /**
epgmdm 11:87ab310924f0 336 * Do if Posho RFID flag is set. Reads rfid and checks user table for a positive balance
epgmdm 11:87ab310924f0 337 * capable of paying for the posho. Displays screen info for selecting posho amount to process.
epgmdm 11:87ab310924f0 338 */
epgmdm 11:87ab310924f0 339 void doPoshoRfidH();
epgmdm 11:87ab310924f0 340
epgmdm 11:87ab310924f0 341 /**
epgmdm 11:87ab310924f0 342 * Prepare to active the posho and husker for serial use. Change user balance as necessary
epgmdm 11:87ab310924f0 343 * and send corresponding signal. Also sets posho flag to in use and sets an interrupt
epgmdm 11:87ab310924f0 344 * to clear that flag after a specified time.
epgmdm 11:87ab310924f0 345 * @param numKilograms - int for number of kilograms to be processed
epgmdm 11:87ab310924f0 346 * @param userIndex - int representing index of user in user table
epgmdm 11:87ab310924f0 347 */
epgmdm 11:87ab310924f0 348 void poshoSerialUseH(int numKilograms, int userIndex);
epgmdm 11:87ab310924f0 349 /**
epgmdm 11:87ab310924f0 350 * Do if Incubator RFID flag is set. Add incubator functionality later.
epgmdm 11:87ab310924f0 351 */
epgmdm 11:87ab310924f0 352 void doIncubatorRfidH();
epgmdm 11:87ab310924f0 353
epgmdm 11:87ab310924f0 354
epgmdm 11:87ab310924f0 355 void logActionWithUserInfo(enum HubActionForLogging action, HubUser *user);
epgmdm 11:87ab310924f0 356 void logErrorUnknownRfidScanned(uint32_t unknownRfid, enum HubLoggingRfidSource source);
epgmdm 11:87ab310924f0 357
epgmdm 11:87ab310924f0 358 /**
epgmdm 11:87ab310924f0 359 * Sends a signal to a locker that the current user is picking up numBatteries batteries
epgmdm 11:87ab310924f0 360 * @param userid - the numer in the all users array.
epgmdm 11:87ab310924f0 361 * @param numBatteries - int representing number of batteries user is picking up
epgmdm 11:87ab310924f0 362 */
epgmdm 11:87ab310924f0 363 void txBatteryPickUp(int usedid, int numBatteries);
epgmdm 11:87ab310924f0 364
epgmdm 11:87ab310924f0 365 /**
epgmdm 11:87ab310924f0 366 * Sends a signal to a locker that the current user is dropping off numBatteries batteries
epgmdm 11:87ab310924f0 367 * @param userid - the numer in the all users array.
epgmdm 11:87ab310924f0 368 * @param numBatteries - int representing number of batteries user is dropping off
epgmdm 11:87ab310924f0 369 */
epgmdm 11:87ab310924f0 370 void txBatteryDropOff(int usedid, int numBatteries);
epgmdm 11:87ab310924f0 371
epgmdm 11:87ab310924f0 372 /**
epgmdm 11:87ab310924f0 373 * Sends a signal to a services mbed to schedule the posho/husker for use for x kilograms
epgmdm 11:87ab310924f0 374 * @param numKilograms - int representing number of kilograms user is processing
epgmdm 11:87ab310924f0 375 */
epgmdm 11:87ab310924f0 376 void txPoshoSerialUse(int numKilograms);
epgmdm 11:87ab310924f0 377
epgmdm 11:87ab310924f0 378
epgmdm 11:87ab310924f0 379 };
epgmdm 11:87ab310924f0 380
epgmdm 11:87ab310924f0 381
defrost 15:e719c1cb0ea2 382 #endif