Compare commits
No commits in common. "820aff5af420413b0f0eceb9e85f732bc7c66fbb" and "6bfe6ee059480fe4f4019fb96b7ab2a5737b3299" have entirely different histories.
820aff5af4
...
6bfe6ee059
@ -42,11 +42,9 @@ const XFTimeout *XFBehavior::getCurrentTimeout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void XFBehavior::setCurrentEvent(const XFEvent *pEvent) {
|
void XFBehavior::setCurrentEvent(const XFEvent *pEvent) {
|
||||||
pCurrentEvent_ = pEvent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XFBehavior::TerminateBehavior XFBehavior::process(const XFEvent *pEvent) {
|
XFBehavior::TerminateBehavior XFBehavior::process(const XFEvent *pEvent) {
|
||||||
setCurrentEvent(pEvent);
|
|
||||||
processEvent();
|
|
||||||
return deleteOnTerminate_;
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
#include "xf/customevent.h"
|
#include "xf/customevent.h"
|
||||||
|
|
||||||
// TODO done: Implement code for XFCustomEvent class
|
// TODO: Implement code for XFCustomEvent class
|
||||||
|
|
||||||
|
|
||||||
XFCustomEvent::XFCustomEvent(int id, interface::XFBehavior *pBehavior):
|
|
||||||
XFEvent(XFEventType::Unknown, id){
|
|
||||||
setBehavior(pBehavior);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,3 @@
|
|||||||
#include "xf/defaulttransition.h"
|
#include "xf/defaulttransition.h"
|
||||||
|
|
||||||
// TODO done: Implement code for XFDefaultTransition class
|
// TODO: Implement code for XFDefaultTransition class
|
||||||
|
|
||||||
XFDefaultTransition::XFDefaultTransition():
|
|
||||||
XFEvent(XFEventType::DefaultTransition) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XFDefaultTransition::deleteAfterConsume() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -1,12 +1,3 @@
|
|||||||
#include "xf/initialevent.h"
|
#include "xf/initialevent.h"
|
||||||
|
|
||||||
// TODO done: Implement code for XFInitialEvent class
|
// TODO: Implement code for XFInitialEvent class
|
||||||
|
|
||||||
XFInitialEvent::XFInitialEvent():
|
|
||||||
XFEvent(XFEventType::Initial) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XFInitialEvent::deleteAfterConsume() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
XFTimeout::XFTimeout(int id, int interval, interface::XFBehavior *pBehavior):
|
XFTimeout::XFTimeout(int id, int interval, interface::XFBehavior *pBehavior):
|
||||||
XFEvent(XFEventType::Timeout, id), interval_(interval) {
|
XFEvent(XFEventType::Timeout, id), interval_(interval) {
|
||||||
setBehavior(pBehavior);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XFTimeout::operator ==(const XFTimeout &timeout) const {
|
bool XFTimeout::operator ==(const XFTimeout &timeout) const {
|
||||||
|
@ -35,7 +35,7 @@ XFDispatcher::~XFDispatcher() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void XFDispatcher::dispatchEvent(const XFEvent *pEvent) const {
|
void XFDispatcher::dispatchEvent(const XFEvent *pEvent) const {
|
||||||
pEvent->getBehavior()->startBehavior();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFDispatcher::pushEvent(XFEvent *pEvent) {
|
void XFDispatcher::pushEvent(XFEvent *pEvent) {
|
||||||
@ -43,11 +43,13 @@ void XFDispatcher::pushEvent(XFEvent *pEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void XFDispatcher::scheduleTimeout(int timeoutId, int interval, interface::XFBehavior *pBehavior) {
|
void XFDispatcher::scheduleTimeout(int timeoutId, int interval, interface::XFBehavior *pBehavior) {
|
||||||
XFTimeoutManager::getInstance()->scheduleTimeout(timeoutId, interval, pBehavior);
|
XFTimeoutManager* timeoutManager = XFTimeoutManager::getInstance();
|
||||||
|
timeoutManager->scheduleTimeout(timeoutId, interval, pBehavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFDispatcher::unscheduleTimeout(int timeoutId, interface::XFBehavior *pBehavior) {
|
void XFDispatcher::unscheduleTimeout(int timeoutId, interface::XFBehavior *pBehavior) {
|
||||||
XFTimeoutManager::getInstance()->unscheduleTimeout(timeoutId, pBehavior);
|
XFTimeoutManager* timeoutManager = XFTimeoutManager::getInstance();
|
||||||
|
timeoutManager->unscheduleTimeout(timeoutId, pBehavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFDispatcher::executeOnce() {
|
void XFDispatcher::executeOnce() {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
#include "common/dispatcher.h"
|
|
||||||
#include <config/xf-config.h>
|
#include <config/xf-config.h>
|
||||||
|
|
||||||
#if (USE_XF_COMMON_TIMEOUTMANAGER_CLASS != 0)
|
#if (USE_XF_COMMON_TIMEOUTMANAGER_CLASS != 0)
|
||||||
@ -21,27 +20,21 @@ interface::XFTimeoutManager * interface::XFTimeoutManager::getInstance() {
|
|||||||
return &timeoutManager;
|
return &timeoutManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO done: Implement code for XFTimeoutManager class
|
// TODO: Implement code for XFTimeoutManager class
|
||||||
|
|
||||||
XFTimeoutManager::XFTimeoutManager() {
|
XFTimeoutManager::XFTimeoutManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
XFTimeoutManager::~XFTimeoutManager() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void XFTimeoutManager::addTimeout(XFTimeout *pNewTimeout) {
|
void XFTimeoutManager::addTimeout(XFTimeout *pNewTimeout) {
|
||||||
pMutex_->lock();
|
|
||||||
timeouts_.push_front(pNewTimeout);
|
timeouts_.push_front(pNewTimeout);
|
||||||
pMutex_->unlock();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFTimeoutManager::returnTimeout(XFTimeout *pTimeout) {
|
void XFTimeoutManager::returnTimeout(XFTimeout *pTimeout) {
|
||||||
pMutex_->lock();
|
|
||||||
XFDispatcher::getInstance()->pushEvent(pTimeout);
|
|
||||||
timeouts_.remove(pTimeout);
|
timeouts_.remove(pTimeout);
|
||||||
pMutex_->unlock();
|
}
|
||||||
|
|
||||||
|
XFTimeoutManager::~XFTimeoutManager() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFTimeoutManager::start(std::function<void (uint32_t)> startTimeoutManagerTimer) {
|
void XFTimeoutManager::start(std::function<void (uint32_t)> startTimeoutManagerTimer) {
|
||||||
|
@ -7,19 +7,23 @@
|
|||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include "eventqueue.h"
|
#include "eventqueue.h"
|
||||||
|
|
||||||
XFEventQueue::XFEventQueue() {
|
XFEventQueue::XFEventQueue()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
XFEventQueue::~XFEventQueue() {
|
XFEventQueue::~XFEventQueue()
|
||||||
|
{
|
||||||
newEvents_.wakeAll();
|
newEvents_.wakeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XFEventQueue::empty() const {
|
bool XFEventQueue::empty() const
|
||||||
|
{
|
||||||
return queue_.isEmpty();
|
return queue_.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XFEventQueue::push(const XFEvent * pEvent, bool fromISR) {
|
bool XFEventQueue::push(const XFEvent * pEvent, bool fromISR)
|
||||||
(void)fromISR; // Just for don't have the warning
|
{
|
||||||
|
(void)fromISR;
|
||||||
QMutexLocker locker(&mutex_);
|
QMutexLocker locker(&mutex_);
|
||||||
queue_.enqueue(pEvent);
|
queue_.enqueue(pEvent);
|
||||||
// Tell waiting thread(s) there is again an event present
|
// Tell waiting thread(s) there is again an event present
|
||||||
@ -27,16 +31,19 @@ bool XFEventQueue::push(const XFEvent * pEvent, bool fromISR) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const XFEvent * XFEventQueue::front() {
|
const XFEvent * XFEventQueue::front()
|
||||||
|
{
|
||||||
return queue_.front();
|
return queue_.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFEventQueue::pop() {
|
void XFEventQueue::pop()
|
||||||
|
{
|
||||||
QMutexLocker locker(&mutex_);
|
QMutexLocker locker(&mutex_);
|
||||||
queue_.dequeue();
|
queue_.dequeue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XFEventQueue::pend() {
|
bool XFEventQueue::pend()
|
||||||
|
{
|
||||||
QMutexLocker locker(&mutex_);
|
QMutexLocker locker(&mutex_);
|
||||||
// Wait for new events. Mutex needs to be in lock-state
|
// Wait for new events. Mutex needs to be in lock-state
|
||||||
// prior to call wait()!
|
// prior to call wait()!
|
||||||
|
@ -10,21 +10,26 @@
|
|||||||
*/
|
*/
|
||||||
StateMachine01::StateMachine01(int repeatInterval, string text)
|
StateMachine01::StateMachine01(int repeatInterval, string text)
|
||||||
: repeatInterval_(repeatInterval),
|
: repeatInterval_(repeatInterval),
|
||||||
text_(text) {
|
text_(text)
|
||||||
|
{
|
||||||
currentState_ = STATE_INITIAL;
|
currentState_ = STATE_INITIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
StateMachine01::~StateMachine01() {
|
StateMachine01::~StateMachine01()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XFEventStatus StateMachine01::processEvent() {
|
XFEventStatus StateMachine01::processEvent()
|
||||||
|
{
|
||||||
eEventStatus eventStatus = XFEventStatus::Unknown;
|
eEventStatus eventStatus = XFEventStatus::Unknown;
|
||||||
|
|
||||||
switch (currentState_) {
|
switch (currentState_)
|
||||||
|
{
|
||||||
case STATE_INITIAL:
|
case STATE_INITIAL:
|
||||||
{
|
{
|
||||||
if (getCurrentEvent()->getEventType() == XFEvent::Initial) {
|
if (getCurrentEvent()->getEventType() == XFEvent::Initial)
|
||||||
|
{
|
||||||
GEN(XFDefaultTransition());
|
GEN(XFDefaultTransition());
|
||||||
|
|
||||||
currentState_ = STATE_SAY_HELLO;
|
currentState_ = STATE_SAY_HELLO;
|
||||||
|
@ -2,26 +2,31 @@
|
|||||||
#include "trace/trace.h"
|
#include "trace/trace.h"
|
||||||
#include "testfactory01.h"
|
#include "testfactory01.h"
|
||||||
|
|
||||||
void Factory_initialize() {
|
void Factory_initialize()
|
||||||
|
{
|
||||||
TestFactory01::initialize();
|
TestFactory01::initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Factory_build() {
|
void Factory_build()
|
||||||
|
{
|
||||||
TestFactory01::build();
|
TestFactory01::build();
|
||||||
}
|
}
|
||||||
|
|
||||||
StateMachine01 TestFactory01::task01_(1000, "Say Hello");
|
StateMachine01 TestFactory01::task01_(1000, "Say Hello");
|
||||||
StateMachine01 TestFactory01::task02_(500, "Echo");
|
StateMachine01 TestFactory01::task02_(500, "Echo");
|
||||||
|
|
||||||
TestFactory01::TestFactory01() {
|
TestFactory01::TestFactory01()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void TestFactory01::initialize() {
|
void TestFactory01::initialize()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void TestFactory01::build() {
|
void TestFactory01::build()
|
||||||
|
{
|
||||||
Trace::out("Starting test1...");
|
Trace::out("Starting test1...");
|
||||||
Trace::out("---------------------");
|
Trace::out("---------------------");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user