| 1 | 
//where I am | 
| 2 | 
#include "R2_FAFE_State.h" | 
| 3 | 
//manager | 
| 4 | 
#include "StateManager.h" | 
| 5 | 
//home | 
| 6 | 
#include "R0_Init_State.h" | 
| 7 | 
//a step after | 
| 8 | 
#include "R3_FAFEDE_State.h" | 
| 9 | 
 | 
| 10 | 
namespace PamOffLineSW | 
| 11 | 
{ | 
| 12 | 
R2_FAFE_State R2_FAFE_State::instance; | 
| 13 | 
 | 
| 14 | 
R2_FAFE_State::R2_FAFE_State() | 
| 15 | 
{ | 
| 16 | 
} | 
| 17 | 
 | 
| 18 | 
R2_FAFE_State::~R2_FAFE_State() | 
| 19 | 
{ | 
| 20 | 
} | 
| 21 | 
void R2_FAFE_State::readInput(char inputbyte) | 
| 22 | 
{ | 
| 23 | 
//the two bytes before this one are 0xFA 0xFE, searching byte 0xDE       | 
| 24 | 
                if((unsigned char)inputbyte==CODE_DE) | 
| 25 | 
                { | 
| 26 | 
                //changing state to R3 | 
| 27 | 
                        StateManager::getInstance().changeState(&R3_FAFEDE_State::getInstance()); | 
| 28 | 
                } | 
| 29 | 
                else | 
| 30 | 
                { | 
| 31 | 
                        //Return to state R0, restart search     | 
| 32 | 
                        StateManager::getInstance().changeState(&R0_Init_State::getInstance()); | 
| 33 | 
                } | 
| 34 | 
 | 
| 35 | 
         | 
| 36 | 
         | 
| 37 | 
} | 
| 38 | 
 | 
| 39 | 
} |