The field version of the solarnano grid on the ionQubes
Fork of SolarNanoGridv3 by
Hmi/HubUser.h@11:87ab310924f0, 2016-06-08 (annotated)
- Committer:
- epgmdm
- Date:
- Wed Jun 08 22:12:52 2016 +0000
- Revision:
- 11:87ab310924f0
Utility up
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
epgmdm | 11:87ab310924f0 | 1 | /** |
epgmdm | 11:87ab310924f0 | 2 | * HubUser.h |
epgmdm | 11:87ab310924f0 | 3 | * |
epgmdm | 11:87ab310924f0 | 4 | * HubUser class. A HubUser is an object containing a uid number, an rfid |
epgmdm | 11:87ab310924f0 | 5 | * number, a max number of batteries that can be checked out, a locker |
epgmdm | 11:87ab310924f0 | 6 | * number, and a pod within a locker. |
epgmdm | 11:87ab310924f0 | 7 | * |
epgmdm | 11:87ab310924f0 | 8 | * Author: Daniel Yang |
epgmdm | 11:87ab310924f0 | 9 | */ |
epgmdm | 11:87ab310924f0 | 10 | |
epgmdm | 11:87ab310924f0 | 11 | #ifndef HUBUSER_H |
epgmdm | 11:87ab310924f0 | 12 | #define HUBUSER_H |
epgmdm | 11:87ab310924f0 | 13 | |
epgmdm | 11:87ab310924f0 | 14 | #include "mbed.h" |
epgmdm | 11:87ab310924f0 | 15 | |
epgmdm | 11:87ab310924f0 | 16 | class HubUser { |
epgmdm | 11:87ab310924f0 | 17 | public: |
epgmdm | 11:87ab310924f0 | 18 | /** |
epgmdm | 11:87ab310924f0 | 19 | * Generic constructor. Initializies all values with 0. |
epgmdm | 11:87ab310924f0 | 20 | */ |
epgmdm | 11:87ab310924f0 | 21 | HubUser(); |
epgmdm | 11:87ab310924f0 | 22 | |
epgmdm | 11:87ab310924f0 | 23 | /** |
epgmdm | 11:87ab310924f0 | 24 | * Constructor that allows for specific initializiation of all values |
epgmdm | 11:87ab310924f0 | 25 | * @param uid - uint32_t corresponding to unique id of the RFID tag |
epgmdm | 11:87ab310924f0 | 26 | * @param rfid - uint32_t corresponding to unique id of the RFID tag |
epgmdm | 11:87ab310924f0 | 27 | * @param accountCredit - int32 for user account balance (can be negative) |
epgmdm | 11:87ab310924f0 | 28 | * @param locker - int32_t for which locker (originaly 1-4) user is assigned |
epgmdm | 11:87ab310924f0 | 29 | * @param pod - int32_t pod associated with the user (originally 0-15) *must be 0 indexed* |
epgmdm | 11:87ab310924f0 | 30 | * @param batteriesOut - int32_t number of batteries user has out |
epgmdm | 11:87ab310924f0 | 31 | * @param batterySubscription - int32_t max batteries user can get (can be 0) |
epgmdm | 11:87ab310924f0 | 32 | */ |
epgmdm | 11:87ab310924f0 | 33 | HubUser(uint32_t uid, uint32_t rfid, int32_t accountCredit, |
epgmdm | 11:87ab310924f0 | 34 | int32_t locker, int32_t pod, int32_t batteriesOut, |
epgmdm | 11:87ab310924f0 | 35 | int32_t batterySubscription, char* name); |
epgmdm | 11:87ab310924f0 | 36 | |
epgmdm | 11:87ab310924f0 | 37 | /** |
epgmdm | 11:87ab310924f0 | 38 | * Get the uid |
epgmdm | 11:87ab310924f0 | 39 | */ |
epgmdm | 11:87ab310924f0 | 40 | uint32_t getUid(); |
epgmdm | 11:87ab310924f0 | 41 | |
epgmdm | 11:87ab310924f0 | 42 | /** |
epgmdm | 11:87ab310924f0 | 43 | * Get the rfid |
epgmdm | 11:87ab310924f0 | 44 | */ |
epgmdm | 11:87ab310924f0 | 45 | uint32_t getRfid(); |
epgmdm | 11:87ab310924f0 | 46 | |
epgmdm | 11:87ab310924f0 | 47 | /** |
epgmdm | 11:87ab310924f0 | 48 | * Get the account balance |
epgmdm | 11:87ab310924f0 | 49 | */ |
epgmdm | 11:87ab310924f0 | 50 | int32_t getCredit(); |
epgmdm | 11:87ab310924f0 | 51 | |
epgmdm | 11:87ab310924f0 | 52 | /** |
epgmdm | 11:87ab310924f0 | 53 | * Get the locker number |
epgmdm | 11:87ab310924f0 | 54 | */ |
epgmdm | 11:87ab310924f0 | 55 | int32_t getLocker(); |
epgmdm | 11:87ab310924f0 | 56 | |
epgmdm | 11:87ab310924f0 | 57 | /** |
epgmdm | 11:87ab310924f0 | 58 | * Get the pod (0 indexed) |
epgmdm | 11:87ab310924f0 | 59 | */ |
epgmdm | 11:87ab310924f0 | 60 | int32_t getPod(); |
epgmdm | 11:87ab310924f0 | 61 | |
epgmdm | 11:87ab310924f0 | 62 | /** |
epgmdm | 11:87ab310924f0 | 63 | * Get the number of batteries currently out |
epgmdm | 11:87ab310924f0 | 64 | */ |
epgmdm | 11:87ab310924f0 | 65 | int32_t getBatteriesOut(); |
epgmdm | 11:87ab310924f0 | 66 | |
epgmdm | 11:87ab310924f0 | 67 | /** |
epgmdm | 11:87ab310924f0 | 68 | * Get the max number of batteries, aka the subscription |
epgmdm | 11:87ab310924f0 | 69 | */ |
epgmdm | 11:87ab310924f0 | 70 | int32_t getBatteriesMax(); |
epgmdm | 11:87ab310924f0 | 71 | |
epgmdm | 11:87ab310924f0 | 72 | /** |
epgmdm | 11:87ab310924f0 | 73 | * Returns the hub user name |
epgmdm | 11:87ab310924f0 | 74 | */ |
epgmdm | 11:87ab310924f0 | 75 | |
epgmdm | 11:87ab310924f0 | 76 | char* getName(); |
epgmdm | 11:87ab310924f0 | 77 | /** |
epgmdm | 11:87ab310924f0 | 78 | * Set the uid |
epgmdm | 11:87ab310924f0 | 79 | * @param uid |
epgmdm | 11:87ab310924f0 | 80 | */ |
epgmdm | 11:87ab310924f0 | 81 | void setUid(uint32_t uid); |
epgmdm | 11:87ab310924f0 | 82 | |
epgmdm | 11:87ab310924f0 | 83 | /** |
epgmdm | 11:87ab310924f0 | 84 | * Set the rfid |
epgmdm | 11:87ab310924f0 | 85 | * @param rfid |
epgmdm | 11:87ab310924f0 | 86 | */ |
epgmdm | 11:87ab310924f0 | 87 | void setRfid(uint32_t rfid); |
epgmdm | 11:87ab310924f0 | 88 | |
epgmdm | 11:87ab310924f0 | 89 | /** |
epgmdm | 11:87ab310924f0 | 90 | * Set the account balance |
epgmdm | 11:87ab310924f0 | 91 | * @param credit |
epgmdm | 11:87ab310924f0 | 92 | */ |
epgmdm | 11:87ab310924f0 | 93 | void setCredit(int32_t credit); |
epgmdm | 11:87ab310924f0 | 94 | |
epgmdm | 11:87ab310924f0 | 95 | /** |
epgmdm | 11:87ab310924f0 | 96 | * Set the locker number |
epgmdm | 11:87ab310924f0 | 97 | * @param locker |
epgmdm | 11:87ab310924f0 | 98 | */ |
epgmdm | 11:87ab310924f0 | 99 | void setLocker(int32_t locker); |
epgmdm | 11:87ab310924f0 | 100 | |
epgmdm | 11:87ab310924f0 | 101 | /** |
epgmdm | 11:87ab310924f0 | 102 | * Set the pod (0 indexed) |
epgmdm | 11:87ab310924f0 | 103 | * @param pod |
epgmdm | 11:87ab310924f0 | 104 | */ |
epgmdm | 11:87ab310924f0 | 105 | void setPod(int32_t pod); |
epgmdm | 11:87ab310924f0 | 106 | |
epgmdm | 11:87ab310924f0 | 107 | /** |
epgmdm | 11:87ab310924f0 | 108 | * Set the number of batteries currently out |
epgmdm | 11:87ab310924f0 | 109 | * @param batteries |
epgmdm | 11:87ab310924f0 | 110 | */ |
epgmdm | 11:87ab310924f0 | 111 | void setBatteriesOut(int32_t batteries); |
epgmdm | 11:87ab310924f0 | 112 | |
epgmdm | 11:87ab310924f0 | 113 | /** |
epgmdm | 11:87ab310924f0 | 114 | * Set the max number of batteries, aka the subscription |
epgmdm | 11:87ab310924f0 | 115 | * @param batteries |
epgmdm | 11:87ab310924f0 | 116 | */ |
epgmdm | 11:87ab310924f0 | 117 | void setBatteriesMax(int32_t batteries); |
epgmdm | 11:87ab310924f0 | 118 | |
epgmdm | 11:87ab310924f0 | 119 | /** |
epgmdm | 11:87ab310924f0 | 120 | * Drop off x number of batteries |
epgmdm | 11:87ab310924f0 | 121 | * @param batteries - number of batteries being dropped off |
epgmdm | 11:87ab310924f0 | 122 | */ |
epgmdm | 11:87ab310924f0 | 123 | void dropOffBattery(int32_t batteries); |
epgmdm | 11:87ab310924f0 | 124 | |
epgmdm | 11:87ab310924f0 | 125 | /** |
epgmdm | 11:87ab310924f0 | 126 | * Pick up x number of batteries |
epgmdm | 11:87ab310924f0 | 127 | * @param batteries - number of batteries being picked up |
epgmdm | 11:87ab310924f0 | 128 | */ |
epgmdm | 11:87ab310924f0 | 129 | void pickUpBattery(int32_t batteries); |
epgmdm | 11:87ab310924f0 | 130 | |
epgmdm | 11:87ab310924f0 | 131 | /** |
epgmdm | 11:87ab310924f0 | 132 | * Decrease account credit after a transaction |
epgmdm | 11:87ab310924f0 | 133 | * @param credit - amount to decrease balance by |
epgmdm | 11:87ab310924f0 | 134 | */ |
epgmdm | 11:87ab310924f0 | 135 | void decreaseCredit(int32_t credit); |
epgmdm | 11:87ab310924f0 | 136 | |
epgmdm | 11:87ab310924f0 | 137 | protected: |
epgmdm | 11:87ab310924f0 | 138 | uint32_t uid; /**< uid - uint32_t corresponding to unique id of the RFID tag. */ |
epgmdm | 11:87ab310924f0 | 139 | uint32_t rfid; /**< rfid - uint32_t corresponding to unique id of the RFID tag. */ |
epgmdm | 11:87ab310924f0 | 140 | int32_t accountCredit; /**< accountCredit - int32 for user account balance (can be negative). */ |
epgmdm | 11:87ab310924f0 | 141 | int32_t locker; /**< locker - int32_t for which locker (originaly 1-4) user is assigned. */ |
epgmdm | 11:87ab310924f0 | 142 | int32_t pod; /**< pod - int32_t pod associated with the user (originally 0-15) *must be 0 indexed*. */ |
epgmdm | 11:87ab310924f0 | 143 | int32_t batteriesOut; /**< batteriesOut - int32_t number of batteries user has out. */ |
epgmdm | 11:87ab310924f0 | 144 | int32_t batterySubscription; /**< batterySubscription - int32_t max batteries user can get (can be 0). */ |
epgmdm | 11:87ab310924f0 | 145 | char* name; /**< Name of the user */ |
epgmdm | 11:87ab310924f0 | 146 | }; |
epgmdm | 11:87ab310924f0 | 147 | |
epgmdm | 11:87ab310924f0 | 148 | #endif |