Suad Suljic / Mbed OS KOPIRANO_cell_locker

Dependencies:   MPU6050_SIM5320_TEST

Fork of MPU_SDCARD by Suad Suljic

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Fsm.h Source File

Fsm.h

00001 #ifndef MOTIONFSM_FSM_H_
00002 #define MOTIONFSM_FSM_H_
00003 #include <State.h>
00004 #include "mbed.h"
00005 
00006 #include <Events.h>
00007 
00008 struct Stop;
00009 struct Move;
00010 
00011 class FsmStates {
00012   public:
00013   FsmStates();
00014   
00015   State* movingState();
00016   State* stacionaryState();
00017   State* currentState();
00018   
00019   void currentState(State* state);
00020 
00021   ~FsmStates();
00022 
00023   private:
00024   
00025   State* movingState_;
00026   State* stacionaryState_;
00027   State* currentState_;
00028   
00029   Timer timer;
00030   
00031 };
00032 
00033 class Fsm {
00034   public:
00035   Fsm();
00036   template <typename Event> 
00037   void handle(Event& event){
00038     State* state = states_.currentState()->handle(event);
00039     states_.currentState(state);
00040   }
00041   
00042   virtual ~Fsm() {}
00043   FsmStates states_;
00044   private:
00045   
00046 
00047 };
00048 #endif /* ifndef MOTIONFSM_FSM_H_ */