|
|
|
|
|
|
## Post events
|
|
## Post events
|
|
|
Two types of events can be posted: "standard" events are posted at the moment of the function call, while delayed events are posted after a specified amount of time.
|
|
Two types of events can be posted: "standard" events are posted at the moment of the function call, while delayed events are posted after a specified amount of time.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Standard events
|
|
### Standard events
|
|
|
To post a "standard" event the following code is used:
|
|
To post a "standard" event the following code is used:
|
|
|
```cpp
|
|
```cpp
|
| ... | @@ -79,7 +82,11 @@ class MyClass : public FSM<MyClass> |
... | @@ -79,7 +82,11 @@ class MyClass : public FSM<MyClass> |
|
|
|
|
|
|
|
}
|
|
}
|
|
|
```
|
|
```
|
|
|
### Events with parameters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Events with payload
|
|
|
If the event has some parameter associated (a typical example is a remote command from the ground station) the event has to be manually instanciated
|
|
If the event has some parameter associated (a typical example is a remote command from the ground station) the event has to be manually instanciated
|
|
|
```cpp
|
|
```cpp
|
|
|
// Include the event broker
|
|
// Include the event broker
|
| ... | @@ -113,3 +120,20 @@ void someFunction() |
... | @@ -113,3 +120,20 @@ void someFunction() |
|
|
```
|
|
```
|
|
|
** ⚠️ WARNING ⚠️ **
|
|
** ⚠️ WARNING ⚠️ **
|
|
|
The `postDelayed` function does not work with "non-standard" events, all the payload is lost!
|
|
The `postDelayed` function does not work with "non-standard" events, all the payload is lost!
|
|
|
|
|
|
|
|
## Troubleshooting
|
|
|
|
Check all the following points before beating your head against the wall :)
|
|
|
|
- Call the `.start()` method on all the `FSM` subclasses used and on `sEventBroker`:
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
#include <events/EventBroker.h>
|
|
|
|
|
|
|
|
ADA ada;
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
sEventBroker->start();
|
|
|
|
ada.start();
|
|
|
|
}
|
|
|
|
```
|
|
|
|
- Don't post events with payload using `postDelayed`(see warning above) |