Compare commits

..

29 Commits

Author SHA1 Message Date
c9d2c05b73 add event sequence diagram 2023-10-22 17:05:30 +02:00
c07c47385e add timeout sequence diagram 2023-10-21 18:29:00 +02:00
68fd8440fc somme comments 2023-10-21 18:28:47 +02:00
c1b4baeb2e fix image link 2023-10-21 16:07:53 +02:00
09ea237a13 convert link image on html 2023-10-21 16:03:35 +02:00
26ef097d86 test image with html 2023-10-21 15:58:28 +02:00
9b56357770 add time algorithme activity diagram in png 2023-10-21 15:49:48 +02:00
57720e50f7 test for result test picture 2023-10-21 15:45:01 +02:00
05f186188f clean algo (work for all tests) 2023-10-21 15:42:56 +02:00
20fd0631c6 algo work on test 1 2023-10-21 13:25:40 +02:00
268c270a4d some update for test algoritm 2023-10-19 14:48:10 +02:00
9059d77b3e start an non-fonctionnal algoritm 2023-10-19 11:46:19 +02:00
92c2faa858 some exemple for plantuml 2023-10-19 11:44:15 +02:00
2ee12ca042 test for plantuml 2023-10-19 11:33:18 +02:00
3d5f026a94 test for flow and sequence 2023-10-19 11:31:28 +02:00
54265d70d1 start time algoritm diagram 2023-10-19 10:42:58 +02:00
f26d9803ac ignore .idea 2023-10-19 10:39:54 +02:00
a327899e11 add result of STM 2023-10-19 10:39:31 +02:00
0978fdb7a5 init readme 2023-10-19 10:21:13 +02:00
5c889da959 move result picture 2023-10-19 09:03:53 +02:00
a1960d7f3b all test done on STM 2023-10-18 18:02:03 +02:00
a86d9b1dfc fix qt part schouldn't change before add algo) 2023-10-18 17:08:56 +02:00
e302dab670 test result 2023-10-18 17:08:20 +02:00
f809d4f647 implement STM not tested 2023-10-18 16:57:06 +02:00
208ab5ec63 remove some comments 2023-10-17 17:10:20 +02:00
08ad191f2e all test done 2023-10-17 15:52:38 +02:00
dd9498f38d test 1-3 done 2023-10-17 15:14:29 +02:00
4002757765 test 2 done 2023-10-17 15:12:51 +02:00
c1e65d41ee finish test 1 (succesfully) 2023-10-17 14:18:38 +02:00
29 changed files with 487 additions and 62 deletions

8
.gitignore vendored
View File

@ -53,3 +53,11 @@ compile_commands.json
*_qmlcache.qrc *_qmlcache.qrc
*.user *.user
test-bench/test1/ide-cubeide-test1-idf/Debug
test-bench/test5/ide-cubeide-test5-idf/.settings/language.settings.xml
test-bench/test1/ide-cubeide-test1-idf/.settings/language.settings.xml
test-bench/test2/ide-cubeide-test2-idf/.settings/language.settings.xml
test-bench/test2/ide-cubeide-test2-idf/Debug
test-bench/test4/ide-cubeide-test4-idf/.settings/language.settings.xml
test-bench/test3/ide-cubeide-test3-idf/.settings/language.settings.xml
.idea

BIN
UML/event.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

55
UML/event.puml Normal file
View File

@ -0,0 +1,55 @@
@startuml
participant Behavior as b
participant Dispatcher as d
entity Event as e
participant EventQueue as eq
queue "EventQueue::queue_" as q
== Create an Event ==
|||
?->> b ++ : GEN
b -> e ** : new
b -> b --++ : pushEvent
e -> b : getBehavior
b --> e ++: setBehavior
e --> b --
b -> d ++ : getDispatcher
d --> b
b -> d -- : pushEvent
d ->? -- : push
|||
|||
== Push Event ==
|||
?->> d ++: pushEvent
d -> eq--++: push
eq -> q ++
q --> eq
eq -> q -- : pushEndQueue
|||
|||
== Dispatch ==
|||
?->> d ++: executeOnce
d -> q : getFront
q -> e ++
e --> q
q --> d : event
d -> q : pop
deactivate q
d -> d --++ : dispatchEvent
d -> b ++ : getBehavior
b --> d
d -> b -- : process
b -> b--: processEvent
destroy e
@enduml

BIN
UML/timeAlgorithme.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

27
UML/timeAlgorithme.puml Normal file
View File

@ -0,0 +1,27 @@
@startuml
start
:newTime = 0
totalTime = 0
isEnd = it == list.end()
lastTime = 0;
#tomato:if (!isEnd) then (not end)
#tomato:totalTime += it.getRelTicks();
endif
while ( !isEnd && (totalTime <= newTime) ) is (goForward)
:isEnd = (++it == list.end());
:lastTime = totalTime;
#tomato:if (!isEnd) then (not end)
#tomato:totalTime += it.getRelTicks();
endif
endwhile
#tomato:if (!isEnd) then (not end)
#tomato:subRelTicks(newTime- lastTime);
endif
:it.setRelTicks(newTime - lastTime);
:insert(it, newTimeout);
@enduml

BIN
UML/timeout.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

62
UML/timeout.puml Normal file
View File

@ -0,0 +1,62 @@
@startuml
participant "Behavior::StateMachine" as sm
participant Dispatcher as d
participant TimeoutManager as tm
entity "Event::Timeout" as t
queue "TimeoutManager::timeouts_" as timeouts
autoactivate off
|||
|||
== Schedule timeout ==
|||
sm -> sm++ : scheduleTimeout
sm -> d ++: getDispatcher
d --> sm --: dispatcher
sm -> d --++ : scheduleTimeout
d -> tm ++: getTimeoutManager
tm --> d --: timeoutManager
d -> tm --++ : scheduleTimeout
tm -> t ** : new
t --> tm
tm -> timeouts --++: insert
|||
|||
== Decrement timeout (and dispatch) ==
|||
loop every tickInterval
?->> tm ++: tick
tm -> timeouts : getFront
timeouts -> t ++
t --> timeouts
timeouts --> tm : timeout
tm -> t --: decrement
end
|||
note left t
When timeout is 0,
dispatch event
end note
t -> timeouts : pop
deactivate timeouts
t ->? --: pushEvent
|||
|||
== Unschedule timeout ==
|||
sm -> sm++ : unscheduleTimeout
sm -> d ++: getDispatcher
d --> sm --: dispatcher
sm -> d --++ : unscheduleTimeout
d -> tm ++: getTimeoutManager
tm --> d --: timeoutManager
d -> tm --++ : unscheduleTimeout
tm -> timeouts --: erase
timeouts -> t !!
@enduml

119
readme.md Normal file
View File

@ -0,0 +1,119 @@
# Goal of this project
- Design an algorithm which lets the `XFTimeoutManager` behave in the same timely manner independent of whether it handles one or nn timeouts
- Implement the core classes of the XF
- Implement the port classes for following ports: *common*, *idf-qt*, *idf-stm32*
- Test and comment the code of the XF
- The tests provided need to run using Qt and on the *Embedded System* platform
- Demonstrate the right functioning of the XF by comparing and documenting the output created by the tests running on the *Embedded System*
# Time Algorithm
<img src="./UML/timeAlgorithme.png">
# Sequence Diagrams
## Timeout
<img src="./UML/timeout.png">
## Event
<img src="./UML/event.png">
# Tests
## Test 1
This test launches an instance of the Task01Tm class and produces some output. Optionally, multiple instances of Task01Tm can be created to test the XF.
The Test Factory (TestFactory01) instantiates 2 objects:
- An object of Task01Tm which outputs the text "Say Hello" every second
- An object of Task01Tm which outputs the text "Echo" every half second
<details>
<summary>QT result ✅</summary>
<img src="./test-bench/test1/ide-qtcreator-test1-idf/result.PNG">
This test is successfully passed
</details>
<details>
<summary>STM result ✅</summary>
<img src="./test-bench/test1/ide-cubeide-test1-idf/result.png">
</details>
## Test 2
This test checks again timeout handling and proper termination of a state machine. In case the state machine was statically/globally created, the XF must not delete the object, when requested to terminate the behavior. If the state-machine was created on the heap (dynamic allocation), the XF must delete the state machine upon request to terminate.
Weather or not the state machine should be deleted is handled with the 'deleteOnTerminate()' method provided by the XFReactive interface.
<details>
<summary>QT result ✅</summary>
<img src="./test-bench/test2/ide-qtcreator-test2-idf/result.PNG">
This test is successfully passed
</details>
<details>
<summary>STM result ✅</summary>
<img src="./test-bench/test2/ide-cubeide-test2-idf/result.png">
</details>
## Test 3
This test checks basic event handling in state machines. In this example the StateMachine03 class sends itself an evRestart event to change from one state to another.
<details>
<summary>QT result ✅</summary>
<img src="./test-bench/test3/ide-qtcreator-test3-idf/result.PNG">
This test is successfully passed
</details>
<details>
<summary>STM result ✅</summary>
<img src="./test-bench/test3/ide-cubeide-test3-idf/result.png">
</details>
## Test 4
Tests if timeouts are correctly cancelled. When leaving a state with a transition having a timeout, without the timeout raises, the timeout must be cancelled (unscheduled).
<details>
<summary>QT result ✅</summary>
<img src="./test-bench/test4/ide-qtcreator-test4-idf/result.PNG">
This test is successfully passed
</details>
<details>
<summary>STM result ✅</summary>
<img src="./test-bench/test4/ide-cubeide-test4-idf/result.png">
</details>
## Test 5
With this test multiple timeouts are added to the XFTimeoutManager list at the same time. This tests the way how new timeouts are added in relation to other timeouts (with the same timeout value) already added to the list. For more details how the objects are created, please refere to the implementation of the TestFactory05 class.
<details>
<summary>QT result ✅</summary>
<img src="./test-bench/test5/ide-qtcreator-test5-idf/result.PNG">
This test is successfully passed
</details>
<details>
<summary>STM result ✅</summary>
<img src="./test-bench/test5/ide-cubeide-test5-idf/result.png">
</details>

View File

@ -2,61 +2,98 @@
#include "xf/timeout.h" #include "xf/timeout.h"
#include "xf/initialevent.h" #include "xf/initialevent.h"
#include "xf/behavior.h" #include "xf/behavior.h"
#include "trace/trace.h"
// TODO done: Implement code for XFBehavior class
XFBehavior::XFBehavior() { XFBehavior::XFBehavior() {
this->deleteOnTerminate_ = false;
} }
XFBehavior::~XFBehavior() { XFBehavior::~XFBehavior() {
} }
void XFBehavior::startBehavior() { void XFBehavior::startBehavior() {
GEN(XFInitialEvent()); GEN(XFInitialEvent());
} }
/**
* @brief Pushes the given event to the dispatcher.
*
* If the event has no behavior assigned, the behavior of this object is assigned.
* @param pEvent Event to push to the dispatcher.
*/
void XFBehavior::pushEvent(XFEvent *pEvent) { void XFBehavior::pushEvent(XFEvent *pEvent) {
pEvent->setBehavior(this); if(pEvent->getBehavior()==nullptr) {
pEvent->setBehavior(this);
}
this->getDispatcher()->pushEvent(pEvent); this->getDispatcher()->pushEvent(pEvent);
} }
bool XFBehavior::deleteOnTerminate() const { bool XFBehavior::deleteOnTerminate() const {
return deleteOnTerminate_; return this->deleteOnTerminate_;
} }
void XFBehavior::setDeleteOnTerminate(bool deleteBehaviour) { void XFBehavior::setDeleteOnTerminate(bool deleteBehaviour) {
deleteOnTerminate_ = deleteBehaviour; this->deleteOnTerminate_ = deleteBehaviour;
} }
const XFEvent *XFBehavior::getCurrentEvent() const { const XFEvent *XFBehavior::getCurrentEvent() const {
return pCurrentEvent_; return this->pCurrentEvent_;
} }
interface::XFDispatcher *XFBehavior::getDispatcher() { interface::XFDispatcher *XFBehavior::getDispatcher() {
return interface::XFDispatcher::getInstance(); return interface::XFDispatcher::getInstance();
} }
/**
* @brief Returns a reference to the actually processed timeout.
*
* Will work only if the current event is of type IXFEvent::Timeout.
*
* @return Pointer to the currently processed timeout or nullptr if the current event is not a timeout.
*/
const XFTimeout *XFBehavior::getCurrentTimeout() { const XFTimeout *XFBehavior::getCurrentTimeout() {
if(pCurrentEvent_->getEventType() == XFEvent::Timeout) { if(pCurrentEvent_->getEventType() == XFEvent::Timeout) {
return (XFTimeout*) pCurrentEvent_; return (XFTimeout*) this->pCurrentEvent_;
} else { } else {
return nullptr; return nullptr;
} }
} }
void XFBehavior::setCurrentEvent(const XFEvent *pEvent) { void XFBehavior::setCurrentEvent(const XFEvent *pEvent) {
pCurrentEvent_ = pEvent; this->pCurrentEvent_ = pEvent;
} }
/**
* @brief Processes the given event.
*
* The dispatcher calls this method every time a new event
* or timeout arrives. The process method stores the actual
* event using the #_pCurrentEvent and then calls
* processEvent().
*
* In case you intend to call process() inside your state machine you
* are doing something wrong! Call GEN() or pushEvent() instead!
*
* @param pEvent Event to process
* @return if the behavior is terminated (basically a boolean)
*/
XFBehavior::TerminateBehavior XFBehavior::process(const XFEvent *pEvent) { XFBehavior::TerminateBehavior XFBehavior::process(const XFEvent *pEvent) {
setCurrentEvent(pEvent); this->setCurrentEvent(pEvent);
// Get status of the event processing
XFEventStatus status = XFEventStatus::Unknown; XFEventStatus status = XFEventStatus::Unknown;
status = processEvent(); status = this->processEvent();
if(status == XFEventStatus::Consumed) {
return deleteOnTerminate_; // Check if event was consumed and if it should be deleted
} else { if(status == XFEventStatus::Consumed && pEvent->deleteAfterConsume()) {
return false; delete pEvent;
} }
// Check if the behavior is terminated and return the result
XFBehavior::TerminateBehavior terminateBehavior = false;
if(status == XFEventStatus::Terminate) {
terminateBehavior = true;
}
return terminateBehavior;
} }

View File

@ -1,10 +1,8 @@
#include "xf/customevent.h" #include "xf/customevent.h"
// TODO done: Implement code for XFCustomEvent class
XFCustomEvent::XFCustomEvent(int id, interface::XFBehavior *pBehavior): XFCustomEvent::XFCustomEvent(int id, interface::XFBehavior *pBehavior):
XFEvent(XFEventType::Unknown, id){ XFEvent(XFEventType::Event, id){
setBehavior(pBehavior); setBehavior(pBehavior);
} }

View File

@ -1,7 +1,5 @@
#include "xf/defaulttransition.h" #include "xf/defaulttransition.h"
// TODO done: Implement code for XFDefaultTransition class
XFDefaultTransition::XFDefaultTransition(): XFDefaultTransition::XFDefaultTransition():
XFEvent(XFEventType::DefaultTransition) { XFEvent(XFEventType::DefaultTransition) {

View File

@ -1,7 +1,5 @@
#include "xf/initialevent.h" #include "xf/initialevent.h"
// TODO done: Implement code for XFInitialEvent class
XFInitialEvent::XFInitialEvent(): XFInitialEvent::XFInitialEvent():
XFEvent(XFEventType::Initial) { XFEvent(XFEventType::Initial) {

View File

@ -1,9 +1,8 @@
#include "xf/timeout.h" #include "xf/timeout.h"
// TODO done: Implement code for XFTimeout class
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) {
this->setRelTicks(this->getInterval());
setBehavior(pBehavior); setBehavior(pBehavior);
} }

View File

@ -24,10 +24,8 @@ interface::XFDispatcher * interface::XFDispatcher::getInstance() {
return &dispatcher; return &dispatcher;
} }
// TODO: Implement code for XFDispatcher class
XFDispatcher::XFDispatcher() { XFDispatcher::XFDispatcher() {
this->pMutex_ = interface::XFMutex::create();
} }
XFDispatcher::~XFDispatcher() { XFDispatcher::~XFDispatcher() {
@ -35,14 +33,20 @@ XFDispatcher::~XFDispatcher() {
} }
void XFDispatcher::dispatchEvent(const XFEvent *pEvent) const { void XFDispatcher::dispatchEvent(const XFEvent *pEvent) const {
if(pEvent->getBehavior()->process(pEvent)) { // TODO look weird XFBehavior::TerminateBehavior terminateBehavior;
//events_.pop(); terminateBehavior = pEvent->getBehavior()->process(pEvent);
delete pEvent; if(terminateBehavior && pEvent->getBehavior()->deleteOnTerminate()) {
delete pEvent->getBehavior();
if(pEvent->deleteAfterConsume()) {
delete pEvent;
}
} }
} }
void XFDispatcher::pushEvent(XFEvent *pEvent) { void XFDispatcher::pushEvent(XFEvent *pEvent) {
events_.push(pEvent); this->pMutex_->lock();
events_.push(pEvent, false);
this->pMutex_->unlock();
} }
void XFDispatcher::scheduleTimeout(int timeoutId, int interval, interface::XFBehavior *pBehavior) { void XFDispatcher::scheduleTimeout(int timeoutId, int interval, interface::XFBehavior *pBehavior) {
@ -54,15 +58,22 @@ void XFDispatcher::unscheduleTimeout(int timeoutId, interface::XFBehavior *pBeha
} }
void XFDispatcher::executeOnce() { void XFDispatcher::executeOnce() {
//XFEvent* event; if(!this->events_.empty()) {
dispatchEvent(events_.front());
events_.pop(); this->pMutex_->lock();
const XFEvent *ev = this->events_.front();
this->events_.pop();
this->pMutex_->unlock();
dispatchEvent(ev);
}
} }
int XFDispatcher::execute(const void *param) { int XFDispatcher::execute(const void *param) {
(void) param;
while(true){ while(true){
executeOnce(); this->executeOnce();
} }
} }

View File

@ -8,6 +8,9 @@
#include "xf/interface/behavior.h" #include "xf/interface/behavior.h"
#include "xf/interface/mutex.h" #include "xf/interface/mutex.h"
#include "timeoutmanager.h" #include "timeoutmanager.h"
#if defined(XF_TRACE_EVENT_PUSH_POP) && (XF_TRACE_EVENT_PUSH_POP != 0)
#include "trace/trace.h"
#endif // XF_TRACE_EVENT_PUSH_POP
using Mutex = interface::XFMutex; // Rename XFMutex interface class to Mutex for easier use. using Mutex = interface::XFMutex; // Rename XFMutex interface class to Mutex for easier use.
@ -21,9 +24,8 @@ interface::XFTimeoutManager * interface::XFTimeoutManager::getInstance() {
return &timeoutManager; return &timeoutManager;
} }
// TODO done: Implement code for XFTimeoutManager class
XFTimeoutManager::XFTimeoutManager() { XFTimeoutManager::XFTimeoutManager() {
this->pMutex_ = interface::XFMutex::create();
} }
XFTimeoutManager::~XFTimeoutManager() { XFTimeoutManager::~XFTimeoutManager() {
@ -31,21 +33,42 @@ XFTimeoutManager::~XFTimeoutManager() {
} }
void XFTimeoutManager::addTimeout(XFTimeout *pNewTimeout) { void XFTimeoutManager::addTimeout(XFTimeout *pNewTimeout) {
pMutex_->lock();
timeouts_.push_front(pNewTimeout); const int newTime = pNewTimeout->getInterval();
pMutex_->unlock(); int totalTime = 0;
bool isEnd = true;
int lastTime = 0;
this->pMutex_->lock();
TimeoutList::iterator it = this->timeouts_.begin();
isEnd = (it == this->timeouts_.end());
if(!isEnd) totalTime += (*it)->getRelTicks();
while(!isEnd && (totalTime <= newTime)) {
isEnd = (++it == this->timeouts_.end());
lastTime = totalTime;
if(!isEnd) totalTime += (*it)->getRelTicks();
}
if(!isEnd) (*it)->substractFromRelTicks(newTime-lastTime);
pNewTimeout->setRelTicks(newTime-lastTime);
this->timeouts_.insert(it, pNewTimeout);
this->pMutex_->unlock();
} }
void XFTimeoutManager::returnTimeout(XFTimeout *pTimeout) { void XFTimeoutManager::returnTimeout(XFTimeout *pTimeout) {
pMutex_->lock(); this->pMutex_->lock();
XFDispatcher::getInstance()->pushEvent(pTimeout); XFDispatcher::getInstance()->pushEvent(pTimeout);
timeouts_.remove(pTimeout); this->timeouts_.remove(pTimeout);
pMutex_->unlock(); this->pMutex_->unlock();
} }
void XFTimeoutManager::start(std::function<void (uint32_t)> startTimeoutManagerTimer) { void XFTimeoutManager::start(std::function<void (uint32_t)> startTimeoutManagerTimer) {
startTimeoutManagerTimer(tickInterval_); startTimeoutManagerTimer(this->tickInterval_);
} }
void XFTimeoutManager::scheduleTimeout(int32_t timeoutId, int32_t interval, interface::XFBehavior *pBehavior) { void XFTimeoutManager::scheduleTimeout(int32_t timeoutId, int32_t interval, interface::XFBehavior *pBehavior) {
@ -54,18 +77,44 @@ void XFTimeoutManager::scheduleTimeout(int32_t timeoutId, int32_t interval, inte
} }
void XFTimeoutManager::unscheduleTimeout(int32_t timeoutId, interface::XFBehavior *pBehavior) { void XFTimeoutManager::unscheduleTimeout(int32_t timeoutId, interface::XFBehavior *pBehavior) {
for(XFTimeout* timeout : timeouts_) { this->pMutex_->lock();
bool id = ( timeout->getId() == timeoutId ); TimeoutList::iterator it;
bool behavior = ( timeout->getBehavior() == pBehavior); for(it = this->timeouts_.begin(); it != this->timeouts_.end(); it++){
if( id && behavior ) {
timeouts_.remove(timeout); if((*it)->getId()==timeoutId && (*it)->getBehavior() == pBehavior) {
it = this->timeouts_.erase(it);
} }
} }
this->pMutex_->unlock();
} }
void XFTimeoutManager::tick() { void XFTimeoutManager::tick() {
for(XFTimeout* timeout : timeouts_) {
bool isEmpty = this->timeouts_.empty();
int rTime;
if(!isEmpty) {
this->pMutex_->lock();
XFTimeout* timeout = this->timeouts_.front();
timeout->substractFromRelTicks(tickInterval_); timeout->substractFromRelTicks(tickInterval_);
rTime = timeout->getRelTicks();
while (!isEmpty && (rTime <= 0) ) {
XFDispatcher::getInstance()->pushEvent(timeout);
this->timeouts_.pop_front();
timeout = this->timeouts_.front();
isEmpty = this->timeouts_.empty();
if(!isEmpty) rTime = timeout->getRelTicks();
}
this->pMutex_->unlock();
} }
} }

View File

@ -5,10 +5,40 @@
#include <cassert> #include <cassert>
#include "eventqueue.h" #include "eventqueue.h"
// TODO: Implement code for XFEventQueue class // TODO done: Implement code for XFEventQueue class
bool XFEventQueue::pend() XFEventQueue::XFEventQueue(){
{
}
XFEventQueue::~XFEventQueue(){
}
bool XFEventQueue::empty() const {
return queue_.empty();
}
bool XFEventQueue::push(const XFEvent *pEvent, bool fromISR) {
(void) fromISR;
mutex_.lock();
queue_.push(pEvent);
mutex_.unlock();
return true;
}
const XFEvent* XFEventQueue::front() {
return queue_.front();
}
void XFEventQueue::pop() {
mutex_.lock();
queue_.pop();
mutex_.unlock();
}
bool XFEventQueue::pend() {
// Method cannot be used in an IDF! Waiting within // Method cannot be used in an IDF! Waiting within
// this method would block the whole XF // this method would block the whole XF
return false; return false;

View File

@ -8,17 +8,23 @@
/** /**
* @brief Implementation of interface::XFMutex::create method. * @brief Implementation of interface::XFMutex::create method.
*/ */
interface::XFMutex * interface::XFMutex::create() interface::XFMutex * interface::XFMutex::create() {
{
return new ::XFMutex; return new ::XFMutex;
} }
void XFMutex::lock() { void XFMutex::lock() {
enterCritical();
} }
void XFMutex::unlock() { void XFMutex::unlock() {
exitCritical();
} }
// TODO: Implement code for XFMutex class bool XFMutex::tryLock(int32_t timeout) {
XFMutex::lock();
return true;
}
// TODO done: Implement code for XFMutex class
#endif // USE_XF_IDF_STM32_MUTEX_CLASS #endif // USE_XF_IDF_STM32_MUTEX_CLASS

View File

@ -9,21 +9,47 @@
using interface::XFTimeoutManager; using interface::XFTimeoutManager;
void XF_initialize(int timeInterval) void XF_initialize(int timeInterval) {
{
XF::initialize(timeInterval); XF::initialize(timeInterval);
} }
void XF_exec() void XF_exec() {
{
XF::exec(); XF::exec();
} }
void XF_execOnce() void XF_execOnce() {
{
XF::execOnce(); XF::execOnce();
} }
// TODO: Implement code for XF class // TODO: Implement code for XF class
bool XF::isInitialized_ = false;
bool XF::isRunning_ = false;
void XF::initialize(int timeInterval, int argc, char *argv[]){
if(!isInitialized_) {
interface::XFTimeoutManager::getInstance()->initialize(timeInterval);
isInitialized_ = true;
}
}
int XF::exec(){
int foo;
foo = interface::XFDispatcher::getInstance()->execute();
isRunning_ = true;
return foo;
}
int XF::execOnce() {
interface::XFDispatcher::getInstance()->executeOnce();
isRunning_ = true;
return 0;
}
bool XF::isRunning() {
return isRunning_;
}
#endif // USE_XF_IDF_STM32_XF_CLASS #endif // USE_XF_IDF_STM32_XF_CLASS

View File

@ -11,6 +11,8 @@
#define USE_XF_IDF_QT_EVENT_QUEUE_CLASS 1 #define USE_XF_IDF_QT_EVENT_QUEUE_CLASS 1
#define USE_XF_IDF_QT_MUTEX_CLASS 1 #define USE_XF_IDF_QT_MUTEX_CLASS 1
#define XF_TRACE_EVENT_PUSH_POP 1
#include "idf-qt/eventqueue.h" #include "idf-qt/eventqueue.h"
#endif // PORT_IDF_QT #endif // PORT_IDF_QT

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB