init
Dependencies: MPU6050 PinDetect circular_buffer
CaseFSM/CaseFsm.cpp@0:b416214256cd, 2017-11-07 (annotated)
- Committer:
- OsmanKameric
- Date:
- Tue Nov 07 16:35:14 2017 +0000
- Revision:
- 0:b416214256cd
FIRST
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OsmanKameric | 0:b416214256cd | 1 | #include <DeviceEmpty.h> |
OsmanKameric | 0:b416214256cd | 2 | #include <DeviceFull.h> |
OsmanKameric | 0:b416214256cd | 3 | #include <PhoneUndetected.h> |
OsmanKameric | 0:b416214256cd | 4 | #include <PhoneDetected.h> |
OsmanKameric | 0:b416214256cd | 5 | #include <CaseFsm.h> |
OsmanKameric | 0:b416214256cd | 6 | |
OsmanKameric | 0:b416214256cd | 7 | CaseFsmStates::CaseFsmStates() : deviceEmptyState_(new DeviceEmpty(*this,timer)), |
OsmanKameric | 0:b416214256cd | 8 | deviceFullState_(new DeviceFull(*this,timer)), |
OsmanKameric | 0:b416214256cd | 9 | phoneUndetectedState_(new PhoneUndetected(*this,timer)), |
OsmanKameric | 0:b416214256cd | 10 | phoneDetectedState_(new PhoneDetected(*this,timer)) |
OsmanKameric | 0:b416214256cd | 11 | { |
OsmanKameric | 0:b416214256cd | 12 | currentState(deviceEmptyState()); |
OsmanKameric | 0:b416214256cd | 13 | } |
OsmanKameric | 0:b416214256cd | 14 | |
OsmanKameric | 0:b416214256cd | 15 | |
OsmanKameric | 0:b416214256cd | 16 | CaseState* CaseFsmStates::deviceEmptyState() |
OsmanKameric | 0:b416214256cd | 17 | { |
OsmanKameric | 0:b416214256cd | 18 | return deviceEmptyState_; |
OsmanKameric | 0:b416214256cd | 19 | } |
OsmanKameric | 0:b416214256cd | 20 | |
OsmanKameric | 0:b416214256cd | 21 | void CaseFsm::timerCallback(){ |
OsmanKameric | 0:b416214256cd | 22 | printf("Odoh u DEVICE EMPTY STATE\r\n"); |
OsmanKameric | 0:b416214256cd | 23 | states_.currentState(states_.deviceEmptyState()); |
OsmanKameric | 0:b416214256cd | 24 | } |
OsmanKameric | 0:b416214256cd | 25 | |
OsmanKameric | 0:b416214256cd | 26 | CaseState* CaseFsmStates::deviceFullState() |
OsmanKameric | 0:b416214256cd | 27 | { |
OsmanKameric | 0:b416214256cd | 28 | return deviceFullState_; |
OsmanKameric | 0:b416214256cd | 29 | } |
OsmanKameric | 0:b416214256cd | 30 | CaseState* CaseFsmStates::phoneUndetectedState() |
OsmanKameric | 0:b416214256cd | 31 | { |
OsmanKameric | 0:b416214256cd | 32 | return phoneUndetectedState_; |
OsmanKameric | 0:b416214256cd | 33 | } |
OsmanKameric | 0:b416214256cd | 34 | CaseState* CaseFsmStates::phoneDetectedState() |
OsmanKameric | 0:b416214256cd | 35 | { |
OsmanKameric | 0:b416214256cd | 36 | return phoneDetectedState_; |
OsmanKameric | 0:b416214256cd | 37 | } |
OsmanKameric | 0:b416214256cd | 38 | |
OsmanKameric | 0:b416214256cd | 39 | CaseState* CaseFsmStates::currentState() |
OsmanKameric | 0:b416214256cd | 40 | { |
OsmanKameric | 0:b416214256cd | 41 | return currentState_; |
OsmanKameric | 0:b416214256cd | 42 | } |
OsmanKameric | 0:b416214256cd | 43 | void CaseFsmStates::currentState(CaseState* state) |
OsmanKameric | 0:b416214256cd | 44 | { |
OsmanKameric | 0:b416214256cd | 45 | currentState_ = state; |
OsmanKameric | 0:b416214256cd | 46 | } |
OsmanKameric | 0:b416214256cd | 47 | |
OsmanKameric | 0:b416214256cd | 48 | CaseFsmStates::~CaseFsmStates() |
OsmanKameric | 0:b416214256cd | 49 | { |
OsmanKameric | 0:b416214256cd | 50 | delete deviceEmptyState_; |
OsmanKameric | 0:b416214256cd | 51 | delete deviceFullState_; |
OsmanKameric | 0:b416214256cd | 52 | delete phoneUndetectedState_; |
OsmanKameric | 0:b416214256cd | 53 | delete phoneDetectedState_; |
OsmanKameric | 0:b416214256cd | 54 | } |
OsmanKameric | 0:b416214256cd | 55 | |
OsmanKameric | 0:b416214256cd | 56 | CaseFsm::CaseFsm() : states_() |
OsmanKameric | 0:b416214256cd | 57 | { |
OsmanKameric | 0:b416214256cd | 58 | |
OsmanKameric | 0:b416214256cd | 59 | |
OsmanKameric | 0:b416214256cd | 60 | } |
OsmanKameric | 0:b416214256cd | 61 | |
OsmanKameric | 0:b416214256cd | 62 | |
OsmanKameric | 0:b416214256cd | 63 |