6 Commits

Author SHA1 Message Date
a141b01380 Comments for modified part of XF 2023-11-28 07:54:55 +01:00
821df428e9 fix miss order Timeout bug 2023-11-27 21:30:11 +01:00
dac64a2d64 add comments on XFState.h 2023-11-27 17:16:13 +01:00
262b89fe45 Merge branch 'enhancement' 2023-11-27 17:09:53 +01:00
2c5fa52b9f Implement unscheduleTimeout & XFInitialState 2023-11-27 17:07:15 +01:00
0ccfd522ee Improve CallBacks 2023-11-27 08:06:53 +01:00
14 changed files with 237 additions and 237 deletions

View File

@ -9,8 +9,13 @@
#include "trace/trace.h" #include "trace/trace.h"
#include "ButtonEvent.h" #include "ButtonEvent.h"
ButtonEventsLogger::ButtonEventsLogger() { ButtonEventsLogger::ButtonEventsLogger()
curentState_ = state::initial; : stWait(this) {
stInitial.addInitialTransition(&stWait);
stWait.addTransition(event::evButtonShortPressed, &stWait);
stWait.addTransition(event::evButtonLongPressed, &stWait);
stWait.registerOnEntry((XFState::callbackEv)&ButtonEventsLogger::logOnTrace);
} }
void ButtonEventsLogger::onButtonShortPressed(ButtonIndex buttonIndex) { void ButtonEventsLogger::onButtonShortPressed(ButtonIndex buttonIndex) {
@ -21,62 +26,13 @@ void ButtonEventsLogger::onButtonLongPressed(ButtonIndex buttonIndex) {
GEN(ButtonEvent(event::evButtonLongPressed, this, buttonIndex)); GEN(ButtonEvent(event::evButtonLongPressed, this, buttonIndex));
} }
XFEventStatus ButtonEventsLogger::processEvent() { void ButtonEventsLogger::logOnTrace(const XFEvent* ev) {
eEventStatus eventStatus = XFEventStatus::NotConsumed; ButtonEvent* buttonEvent = (ButtonEvent*)ev;
int evid = buttonEvent->getId();
ButtonEvent* ev = (ButtonEvent*)getCurrentEvent();
XFEvent::XFEventType evType = ev->getEventType();
int evid = ev->getId();
oldState_ = curentState_;
changeXFState = false;
switch (curentState_) { //on state
case state::initial:
if(evType == XFEvent::Initial) {
curentState_ = state::waitButtonPressed;
changeXFState = true;
eventStatus = XFEventStatus::Consumed;
}
break;
case state::waitButtonPressed:
if(evid == event::evButtonShortPressed){ if(evid == event::evButtonShortPressed){
Trace::out("ButtonEventLogger: Button %d short pressed", ev->getButtonId()); Trace::out("ButtonEventLogger: Button %d short pressed", buttonEvent->getButtonId());
curentState_ = state::waitButtonPressed;
changeXFState = true;
eventStatus = XFEventStatus::Consumed;
} }
if(evid == event::evButtonLongPressed){ if(evid == event::evButtonLongPressed){
Trace::out("ButtonEventLogger: Button %d long pressed", ev->getButtonId()); Trace::out("ButtonEventLogger: Button %d long pressed", buttonEvent->getButtonId());
curentState_ = state::waitButtonPressed;
changeXFState = true;
eventStatus = XFEventStatus::Consumed;
} }
break;
}
if(changeXFState) {
switch (oldState_) { // onExit
case state::initial:
break;
case state::waitButtonPressed:
break;
}
switch (curentState_) { // onEntry
case state::initial:
break;
case state::waitButtonPressed:
break;
}
changeXFState = false;
}
return eventStatus;
} }

View File

@ -21,20 +21,14 @@ public:
protected: protected:
XFEventStatus processEvent() override; void logOnTrace(const XFEvent* ev);
typedef enum { typedef enum {
evButtonShortPressed = 1, evButtonShortPressed = 10,
evButtonLongPressed evButtonLongPressed
} event; } event;
typedef enum { XFState stWait;
initial,
waitButtonPressed
} state;
state curentState_;
state oldState_;
}; };

View File

@ -15,7 +15,6 @@ Factory::Factory() {
void Factory::initialize() { void Factory::initialize() {
Trace::initialize(); Trace::initialize();
// TODO: Initialize factory attributes here
#if defined(TOUCHGFX_ENABLED) && (TOUCHGFX_ENABLED != 0) #if defined(TOUCHGFX_ENABLED) && (TOUCHGFX_ENABLED != 0)
@ -27,24 +26,21 @@ void Factory::initialize() {
void Factory::build() { void Factory::build() {
Trace::out("Factory: Creating app components..."); Trace::out("Factory: Creating app components...");
// Start state machine(s) // Start SM of ButtonEventLogger & ButtonsController
buttonEventLogger_.startBehavior(); buttonEventLogger_.startBehavior();
ButtonsController::getInstance()->startBehavior(); ButtonsController::getInstance()->startBehavior();
// Register CallBack of ButtonController with himself for the provider and onButtonChangeState for the CallBack Method
ButtonsController::getInstance()->registerCallback ( ButtonsController::getInstance()->registerCallback (
ButtonEventsHandler::getInstance(), ButtonEventsHandler::getInstance(),
(interface::ButtonsControllerCallbackProvider::CallbackMethod) &ButtonEventsHandler::onButtonChangeState (interface::ButtonsControllerCallbackProvider::CallbackMethod) &ButtonEventsHandler::onButtonChangeState
); );
buttonEventLogger_.startBehavior(); // Subscribe ButtonEventLogger to ButtonEventsHandler & start SM of ButtonEventsHandler
ButtonEventsHandler::getInstance()->subscribe(&buttonEventLogger_); ButtonEventsHandler::getInstance()->subscribe(&buttonEventLogger_);
ButtonEventsHandler::getInstance()->startBehavior(); ButtonEventsHandler::getInstance()->startBehavior();
// TODO: Start state-machines here
#if defined(TOUCHGFX_ENABLED) && (TOUCHGFX_ENABLED != 0) #if defined(TOUCHGFX_ENABLED) && (TOUCHGFX_ENABLED != 0)
getTouchGfxTask().start(); getTouchGfxTask().start();
#endif #endif

View File

@ -11,8 +11,6 @@
#include "platform/f7-disco-gcc/board/ButtonsController.h" #include "platform/f7-disco-gcc/board/ButtonsController.h"
#include "mdw/button/ButtonEventsHandler.h" #include "mdw/button/ButtonEventsHandler.h"
// TODO: Add C++ specific includes here
namespace app { namespace app {
/** /**
@ -30,7 +28,6 @@ public:
#endif #endif
protected: protected:
// TODO: Add static attributes here
static ButtonEventsLogger buttonEventLogger_; static ButtonEventsLogger buttonEventLogger_;
}; };

View File

@ -16,12 +16,12 @@ ButtonEventsHandler::ButtonEventsHandler()
observer_[i] = nullptr; observer_[i] = nullptr;
} }
stInitial.setNextState(&stRun); stInitial.addInitialTransition(&stRun);
stRun.registerOnEntry((XFState::callback)&ButtonEventsHandler::startButtonSM); stRun.registerOnEntry((XFState::callback)&ButtonEventsHandler::startButtonSM);
} }
void ButtonEventsHandler::startButtonSM(const XFEvent* ev) { void ButtonEventsHandler::startButtonSM() {
buttonStateSm_[0].startBehavior(); buttonStateSm_[0].startBehavior();
buttonStateSm_[1].startBehavior(); buttonStateSm_[1].startBehavior();
buttonStateSm_[2].startBehavior(); buttonStateSm_[2].startBehavior();

View File

@ -31,7 +31,7 @@ public:
protected: protected:
ButtonEventsHandler(); ButtonEventsHandler();
void startButtonSM(const XFEvent* ev); void startButtonSM();
XFState stRun; XFState stRun;

View File

@ -8,10 +8,26 @@
#include <button/ButtonStateSm.h> #include <button/ButtonStateSm.h>
#include "mdw/button/ButtonEventsHandler.h" #include "mdw/button/ButtonEventsHandler.h"
//TODO start State Machine. For that, turn ButtonEventsHandler to a State Machine (Initial, run)
ButtonStateSm::ButtonStateSm() ButtonStateSm::ButtonStateSm()
: buttonIndex_(getNbInstance()) { : buttonIndex_(getNbInstance()),
currentState_ = state::initial; stWaitButtonPressed(this),
stButtonPressed(this),
stButtonShortPressed(this),
stButtonLongPressed(this) {
stInitial.addInitialTransition(&stWaitButtonPressed);
stWaitButtonPressed.addTransition(event::evButtonPressed, &stButtonPressed);
stButtonPressed.setTimeout(1000, &stButtonLongPressed);
stButtonPressed.addTransition(event::evButtonReleased, &stButtonShortPressed);
stButtonPressed.registerOnExit((XFState::callback)&ButtonStateSm::genNullTransition);
stButtonShortPressed.registerOnEntry((XFState::callback)&ButtonStateSm::notifyShortPress);
stButtonShortPressed.addTransition(event::evReturn, &stWaitButtonPressed);
stButtonLongPressed.registerOnEntry((XFState::callback)&ButtonStateSm::notifyLongPress);
stButtonLongPressed.addTransition(event::evReturn, &stWaitButtonPressed);
} }
uint8_t ButtonStateSm::getNbInstance(){ uint8_t ButtonStateSm::getNbInstance(){
@ -26,102 +42,14 @@ void ButtonStateSm::genButtonReleased() {
GEN(XFEvent(XFEvent::Event, event::evButtonReleased, this)); GEN(XFEvent(XFEvent::Event, event::evButtonReleased, this));
} }
XFEventStatus ButtonStateSm::processEvent() { void ButtonStateSm::notifyShortPress() {
eEventStatus eventStatus = XFEventStatus::Unknown;
const XFEvent* ev = getCurrentEvent();
XFEvent::XFEventType evType = ev->getEventType();
int evid = ev->getId();
oldState_ = currentState_;
changeState_ = false;
switch (currentState_) {
case state::initial:
if(evType == XFEvent::Initial) {
currentState_ = state::waitButtonPressed;
changeState_ = true;
eventStatus = XFEventStatus::Consumed;
}
break;
case state::waitButtonPressed:
if(evid == event::evButtonPressed) {
currentState_ = state::buttonPressed;
changeState_ = true;
eventStatus = XFEventStatus::Consumed;
scheduleTimeout(event::evTimeout, 1000);
}
break;
case state::buttonPressed:
if(evid == event::evButtonReleased) {
currentState_ = state::buttonShortPressed;
changeState_ = true;
eventStatus = XFEventStatus::Consumed;
unscheduleTimeout(event::evTimeout);
}
if(evid == event::evTimeout) {
currentState_ = state::buttonLongPressed;
changeState_ = true;
eventStatus = XFEventStatus::Consumed;
}
GEN(XFNullTransition(this));
break;
case state::buttonShortPressed:
if(evType == XFEvent::XFEventType::NullTransition) {
currentState_ = state::waitButtonPressed;
changeState_ = true;
eventStatus = XFEventStatus::Consumed;
}
break;
case state::buttonLongPressed:
if(evType == XFEvent::XFEventType::NullTransition) {
currentState_ = state::waitButtonPressed;
changeState_ = true;
eventStatus = XFEventStatus::Consumed;
}
break;
}
if(changeState_) {
switch (oldState_) { // onExit
case state::initial:
break;
case state::waitButtonPressed:
break;
case state::buttonPressed:
break;
case state::buttonShortPressed:
break;
case state::buttonLongPressed:
break;
}
switch (currentState_) {
case state::initial:
break;
case state::waitButtonPressed:
break;
case state::buttonPressed:
break;
case state::buttonShortPressed:
ButtonEventsHandler::getInstance()->notifyButtonShortPressed(buttonIndex_); ButtonEventsHandler::getInstance()->notifyButtonShortPressed(buttonIndex_);
break; }
case state::buttonLongPressed: void ButtonStateSm::notifyLongPress() {
ButtonEventsHandler::getInstance()->notifyButtonLongPressed(buttonIndex_); ButtonEventsHandler::getInstance()->notifyButtonLongPressed(buttonIndex_);
break; }
}
} void ButtonStateSm::genNullTransition() {
return eventStatus; GEN(XFEvent(XFEvent::Event, event::evReturn, this));
} }

View File

@ -18,27 +18,23 @@ public:
void genButtonReleased(); void genButtonReleased();
protected: protected:
XFEventStatus processEvent(); void notifyShortPress();
void notifyLongPress();
void genNullTransition();
typedef enum { typedef enum {
evButtonPressed, evButtonPressed = 10,
evButtonReleased, evButtonReleased,
evTimeout evReturn
} event; } event;
typedef enum {
initial,
waitButtonPressed,
buttonPressed,
buttonShortPressed,
buttonLongPressed
} state;
state currentState_;
state oldState_;
bool changeState_;
const uint8_t buttonIndex_; const uint8_t buttonIndex_;
XFState stWaitButtonPressed;
XFState stButtonPressed;
XFState stButtonShortPressed;
XFState stButtonLongPressed;
private: private:
static uint8_t getNbInstance(); static uint8_t getNbInstance();

View File

@ -16,8 +16,8 @@ ButtonsController::ButtonsController()
cbProvider = nullptr; cbProvider = nullptr;
cbMethod = nullptr; cbMethod = nullptr;
stInitial.setNextState(&stCheckButtons); stInitial.addInitialTransition(&stCheckButtons);
stCheckButtons.setNextState(event::evButtonIrq, &stDebounce); stCheckButtons.addTransition(event::evButtonIrq, &stDebounce);
stCheckButtons.registerOnEntry((XFState::callback)&ButtonsController::fctCheckButtons); stCheckButtons.registerOnEntry((XFState::callback)&ButtonsController::fctCheckButtons);
stDebounce.setTimeout(20, &stCheckButtons); stDebounce.setTimeout(20, &stCheckButtons);
@ -45,7 +45,7 @@ bool ButtonsController::registerCallback(
return true; return true;
} }
void ButtonsController::fctCheckButtons(const XFEvent* ev) { void ButtonsController::fctCheckButtons() {
if(cbProvider != nullptr) { if(cbProvider != nullptr) {
newState[0] = HAL_GPIO_ReadPin(BUTTON0_GPIO_Port, BUTTON0_Pin); newState[0] = HAL_GPIO_ReadPin(BUTTON0_GPIO_Port, BUTTON0_Pin);

View File

@ -30,8 +30,7 @@ protected:
bool newState[4]; bool newState[4];
bool buttonState[4]; bool buttonState[4];
void fctCheckButtons(const XFEvent* ev); void fctCheckButtons();
void fctScheduleTimeout(const XFEvent* ev);
XFState stCheckButtons; XFState stCheckButtons;
XFState stDebounce; XFState stDebounce;

View File

@ -13,57 +13,96 @@
XFState::XFState(XFBehavior* behavior) XFState::XFState(XFBehavior* behavior)
: pBehavior(behavior) { : pBehavior(behavior) {
/*
* Initialise behavior of this state on the constructor.
* Can't be null !
*/
assert(behavior != nullptr); assert(behavior != nullptr);
} }
void XFState::setNextState(const int evid, const int time, XFEvent::XFEventType type, XFState* state) { void XFState::addTransition(XFEvent::XFEventType type, const int evid, const int time, XFState* state) {
assert(state != nullptr); assert(state != nullptr);
/*
* Create a transition with his Type, ID, time if Timeout and the state to be set when this transition happen
* Push the transition on the list of transition of the event
* Pointer State can't be null
*/
transition t; transition t;
t.evType = type;
t.evid = evid; t.evid = evid;
t.time = time; t.time = time;
t.evType = type;
t.nextState = state; t.nextState = state;
transitions_.push_back(t); transitions_.push_back(t);
} }
XFEventStatus XFState::changeState(XFState* state) {
// Change current state of the behavior
pBehavior->currentXFState_ = state;
// Set state is changed
pBehavior->changeXFState = true;
// Return the event status as consumed
return XFEventStatus::Consumed;
}
XFEventStatus XFState::onState(const XFEvent* ev) { XFEventStatus XFState::onState(const XFEvent* ev) {
assert(ev != nullptr); // Execute onState callBack without parameter if it's defined
assert(pBehavior != nullptr); if(cbState_ != nullptr) {
(pBehavior->*cbState_)();
}
// Execute onState callBack with event as parameter if it's defined
if(cbEvState_ != nullptr) {
(pBehavior->*cbEvState_)(ev);
}
// Test each transition and change state if one is actual transition
for(transition t : transitions_) { for(transition t : transitions_) {
assert(t.nextState != nullptr);
if(t.evType == XFEvent::XFEventType::Initial){ switch(ev->getEventType()) {
pBehavior->curentXFState_ = t.nextState;
pBehavior->changeXFState = true; case XFEvent::XFEventType::Initial:
return XFEventStatus::Consumed; if(t.evType == XFEvent::XFEventType::Initial) {
return changeState(t.nextState);
} }
break;
case XFEvent::XFEventType::Timeout:
if(t.evType == XFEvent::XFEventType::Timeout) { if(t.evType == XFEvent::XFEventType::Timeout) {
pBehavior->curentXFState_ = t.nextState; return changeState(t.nextState);
pBehavior->changeXFState = true;
return XFEventStatus::Consumed;
} }
break;
case XFEvent::XFEventType::Event:
if(t.evid == ev->getId()) { if(t.evid == ev->getId()) {
pBehavior->curentXFState_ = t.nextState; return changeState(t.nextState);
pBehavior->changeXFState = true; }
return XFEventStatus::Consumed; break;
} }
} }
// Return event status as notConsumed if actual event isn't on the list of transitions
return XFEventStatus::NotConsumed; return XFEventStatus::NotConsumed;
} }
void XFState::onEntry(const XFEvent* ev) { void XFState::onEntry(const XFEvent* ev) {
// Execute onEntry callBack without parameter if it's defined
if(cbEntry_ != nullptr) { if(cbEntry_ != nullptr) {
(pBehavior->*cbEntry_)(ev); (pBehavior->*cbEntry_)();
} }
// Execute onExit callBack with event as parameter if it's defined
if(cbEvEntry_ != nullptr) {
(pBehavior->*cbEvEntry_)(ev);
}
// If a timeout is on the list of transition start it with is own delay
for(transition t : transitions_) { for(transition t : transitions_) {
assert(t.nextState != nullptr);
if(t.evType == XFEvent::XFEventType::Timeout) { if(t.evType == XFEvent::XFEventType::Timeout) {
pBehavior->scheduleTimeout(XFEvent::Timeout, t.time); pBehavior->scheduleTimeout(XFEvent::Timeout, t.time);
@ -72,7 +111,24 @@ void XFState::onEntry(const XFEvent* ev) {
} }
} }
void XFState::onExit(const XFEvent* ev) { void XFState::onExit(const XFEvent* ev) {
// Execute onExit callBack without parameter if it's defined
if(cbExit_ != nullptr) { if(cbExit_ != nullptr) {
(pBehavior->*cbExit_)(ev); (pBehavior->*cbExit_)();
}
// Execute onExit callBack with event as parameter if it's defined
if(cbEvExit_ != nullptr) {
(pBehavior->*cbEvExit_)(ev);
}
// If a timeout is on the list of transition and isn't the actual event, stop it
for(transition t: transitions_) {
if(t.evType == XFEvent::XFEventType::Timeout) {
if(ev->getEventType() != XFEvent::XFEventType::Timeout) {
pBehavior->unscheduleTimeout(XFEvent::Timeout);
}
}
} }
} }

View File

@ -84,16 +84,21 @@ XFBehavior::TerminateBehavior XFBehavior::process(const XFEvent * pEvent)
} }
XFEventStatus XFBehavior::processEvent(){ XFEventStatus XFBehavior::processEvent(){
/*
* Basic double switch pattern but not switch on an enum but on Object XFState
*/
XFEventStatus eventStatus = XFEventStatus::Unknown; XFEventStatus eventStatus = XFEventStatus::Unknown;
const XFEvent * ev = getCurrentEvent(); const XFEvent * ev = getCurrentEvent();
oldXFState_ = curentXFState_; oldXFState_ = currentXFState_;
eventStatus = curentXFState_->onState(ev); eventStatus = currentXFState_->onState(ev);
if(changeXFState){ if(changeXFState){
oldXFState_->onExit(ev); oldXFState_->onExit(ev);
curentXFState_->onEntry(ev); currentXFState_->onEntry(ev);
} }
return eventStatus; return eventStatus;

View File

@ -21,21 +21,68 @@ class XFBehavior;
class XFState { class XFState {
friend class XFBehavior; friend class XFBehavior;
public: public:
/**
* Create and initialise a State for the behavior.
* Have to be initialized in the constructor of the behavior.
* @param behavior Pointer to the behavior class. Use the keyword this
*/
XFState(XFBehavior* behavior); XFState(XFBehavior* behavior);
~XFState() = default; ~XFState() = default;
inline void setNextState(XFState* state) { setNextState(XFEvent::Initial, XFEvent::XFEventType::Initial, state); }; /**
inline void setNextState(const int evid, XFState* state) { setNextState(evid, XFEvent::XFEventType::Event, state); }; * Set the conditional state of an custom event.
* @param evid Id of the event for set the next State
* @param state Pointer to the next state
*/
inline void addTransition(const int evid, XFState* state) { addTransition(XFEvent::XFEventType::Event, evid, 0, state); };
inline void setTimeout(int time, XFState* nextState) { setNextState(XFEvent::Timeout, time, XFEvent::XFEventType::Timeout, nextState); }; /**
typedef void (XFBehavior::*callback)(const XFEvent* ev); * Set a new timer with a certain duration on every entry of this state.
* Set next state after
* @param time Time duration of the timeout
* @param nextState Pointer to the next state
*/
inline void setTimeout(int time, XFState* nextState) { addTransition(XFEvent::XFEventType::Timeout, XFEvent::Timeout, time, nextState); };
// Callback typedef for callback without parameter
typedef void (XFBehavior::*callback)();
//inline void registerOnState(callback cbState) { cbState_ = cbState; };
/**
* Register the method for the entry callback without parameter
* @param cbEntry Callback automatically called when the state is onEntry
*/
inline void registerOnEntry(callback cbEntry) { cbEntry_ = cbEntry; }; inline void registerOnEntry(callback cbEntry) { cbEntry_ = cbEntry; };
/**
* Register the method for the exit callback without parameter
* @param cbExit Callback automatically called when the state is onExit
*/
inline void registerOnExit(callback cbExit) { cbExit_ = cbExit; }; inline void registerOnExit(callback cbExit) { cbExit_ = cbExit; };
protected:
inline void setNextState(const int evid, XFEvent::XFEventType type, XFState* state) {setNextState(evid, 0, type, state); };
void setNextState(const int evid, const int time, XFEvent::XFEventType type, XFState* state);
//Callback typedef for callback with event in parameter
typedef void (XFBehavior::*callbackEv)(const XFEvent* ev);
//inline void registerOnState(callbackEv cbState) { cbEvState_ = cbState; };
/**
* Register the method for the entry callback with event in parameter.
* @param cbEntry Callback automatically called when the state is onEntry
*/
inline void registerOnEntry(callbackEv cbEntry) { cbEvEntry_ = cbEntry; };
/**
* Register the method for the exit callback with event in parameter
* @param cbExit Callback automatically called when the state is onExit
*/
inline void registerOnExit(callbackEv cbExit) { cbEvExit_ = cbExit; };
protected:
void addTransition(XFEvent::XFEventType type, const int evid, const int time, XFState* state);
XFEventStatus changeState(XFState* state);
XFEventStatus onState(const XFEvent* ev); XFEventStatus onState(const XFEvent* ev);
void onEntry(const XFEvent* ev); void onEntry(const XFEvent* ev);
void onExit(const XFEvent* ev); void onExit(const XFEvent* ev);
@ -50,9 +97,24 @@ protected:
} transition; } transition;
std::list<transition> transitions_; std::list<transition> transitions_;
callback cbEntry_; callback cbState_ = nullptr;
callback cbExit_; callback cbEntry_ = nullptr;
callback cbExit_ = nullptr;
callbackEv cbEvState_ = nullptr;
callbackEv cbEvEntry_ = nullptr;
callbackEv cbEvExit_ = nullptr;
}; };
class XFInitialState : public XFState {
public:
/**
* Use for set next state of the Initial State.
* @param state Pointer to the next state
*/
inline XFInitialState(XFBehavior* behavior) : XFState(behavior) {};
~XFInitialState() = default;
inline void addInitialTransition(XFState* state) { addTransition(XFEvent::XFEventType::Initial, XFEvent::Initial, 0, state); };
};
#endif /* XFSTATE_H_ */ #endif /* XFSTATE_H_ */

View File

@ -55,7 +55,7 @@ public:
protected: protected:
/** /**
* Executes the current event in its implemented behavior. * Executes the current event in its implemented behavior.
* This method needs to be overridden to implement the * This method can be overridden to implement the
* behavior (i.e. state machine) needed. * behavior (i.e. state machine) needed.
*/ */
virtual XFEventStatus processEvent(); virtual XFEventStatus processEvent();
@ -100,9 +100,20 @@ protected:
const XFEvent * pCurrentEvent_; ///< Reference to actually processed event. const XFEvent * pCurrentEvent_; ///< Reference to actually processed event.
protected: protected:
XFState stInitial; /**
XFState* curentXFState_ = &stInitial; * Behavior have at least an Initial State.
*/
XFInitialState stInitial;
/**
* Pointer for the curent and old state of this behavior
*/
XFState* currentXFState_ = &stInitial;
XFState* oldXFState_ = &stInitial; XFState* oldXFState_ = &stInitial;
/**
* Keep in trace when state is changed (have to be set to true in every processEvent
*/
bool changeXFState = false; bool changeXFState = false;
}; };