Compare commits
No commits in common. "c07c47385e635d4061e7b944d7c6f691a741861f" and "c1b4baeb2e9b6b23d59c15c0d47aceb4e7df873a" have entirely different histories.
c07c47385e
...
c1b4baeb2e
BIN
UML/timeout.png
BIN
UML/timeout.png
Binary file not shown.
Before Width: | Height: | Size: 63 KiB |
@ -1,62 +0,0 @@
|
|||||||
@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
|
|
@ -8,9 +8,6 @@
|
|||||||
|
|
||||||
# Time Algorithm
|
# Time Algorithm
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Code puml (maybe it's displayed) </summary>
|
|
||||||
|
|
||||||
```plantuml
|
```plantuml
|
||||||
@startuml
|
@startuml
|
||||||
|
|
||||||
@ -40,15 +37,9 @@ endif
|
|||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<img src="./UML/timeAlgorithme.png">
|
<img src="./UML/timeAlgorithme.png">
|
||||||
|
|
||||||
# Sequence Diagrams
|
|
||||||
## Timeout
|
|
||||||
|
|
||||||
<img src="./UML/timeout.png">
|
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
## Test 1
|
## Test 1
|
||||||
|
@ -16,12 +16,6 @@ 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) {
|
||||||
if(pEvent->getBehavior()==nullptr) {
|
if(pEvent->getBehavior()==nullptr) {
|
||||||
pEvent->setBehavior(this);
|
pEvent->setBehavior(this);
|
||||||
@ -45,13 +39,6 @@ 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*) this->pCurrentEvent_;
|
return (XFTimeout*) this->pCurrentEvent_;
|
||||||
@ -64,33 +51,13 @@ void XFBehavior::setCurrentEvent(const XFEvent *pEvent) {
|
|||||||
this->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) {
|
||||||
this->setCurrentEvent(pEvent);
|
this->setCurrentEvent(pEvent);
|
||||||
|
|
||||||
// Get status of the event processing
|
|
||||||
XFEventStatus status = XFEventStatus::Unknown;
|
XFEventStatus status = XFEventStatus::Unknown;
|
||||||
status = this->processEvent();
|
status = this->processEvent();
|
||||||
|
|
||||||
// Check if event was consumed and if it should be deleted
|
|
||||||
if(status == XFEventStatus::Consumed && pEvent->deleteAfterConsume()) {
|
if(status == XFEventStatus::Consumed && pEvent->deleteAfterConsume()) {
|
||||||
delete pEvent;
|
delete pEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the behavior is terminated and return the result
|
|
||||||
XFBehavior::TerminateBehavior terminateBehavior = false;
|
XFBehavior::TerminateBehavior terminateBehavior = false;
|
||||||
if(status == XFEventStatus::Terminate) {
|
if(status == XFEventStatus::Terminate) {
|
||||||
terminateBehavior = true;
|
terminateBehavior = true;
|
||||||
|
Reference in New Issue
Block a user