|
|
|
|
|
## 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
|
|
// Include the event broker
|
|
// Include the event broker
|
... | @@ -22,7 +22,9 @@ void someFunction() |
... | @@ -22,7 +22,9 @@ void someFunction() |
|
sEventBroker->post({EV_ADA_READY}, TOPIC_ADA);
|
|
sEventBroker->post({EV_ADA_READY}, TOPIC_ADA);
|
|
}
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
### Delayed events
|
|
### Delayed events
|
|
|
|
|
|
The delayed events are posted in a very similar way:
|
|
The delayed events are posted in a very similar way:
|
|
```cpp
|
|
```cpp
|
|
// Include the event broker
|
|
// Include the event broker
|
... | @@ -83,10 +85,8 @@ class MyClass : public FSM<MyClass> |
... | @@ -83,10 +85,8 @@ class MyClass : public FSM<MyClass> |
|
}
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Events with payload
|
|
### 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
|
... | @@ -118,10 +118,10 @@ void someFunction() |
... | @@ -118,10 +118,10 @@ void someFunction() |
|
sEventBroker->post(ev, TOPIC_TC);
|
|
sEventBroker->post(ev, TOPIC_TC);
|
|
}
|
|
}
|
|
```
|
|
```
|
|
** ⚠️ WARNING ⚠️ **
|
|
> :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
|
|
## Troubleshooting
|
|
|
|
|
|
Check all the following points before beating your head against the wall :)
|
|
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`:
|
|
- Call the `.start()` method on all the `FSM` subclasses used and on `sEventBroker`:
|
|
|
|
|
... | | ... | |