... | ... | @@ -42,7 +42,7 @@ EV_EMPTY is used internally to navigate the hierarchy of the state machine durin |
|
|
- Use braces around each *case* statement
|
|
|
- Avoid performing actions outside the switch statement in a state function.
|
|
|
Again, an exception are actions not related to the state machine operation such as logging.
|
|
|
- State functions should public, mainly to allow testing of the state machine.
|
|
|
- State functions should be public, mainly to allow testing of the state machine.
|
|
|
- State names should begin with "state_" followed by the name of the state. while "state_" should be all lower case with a trailing underscore, the rest of the name must use CamelCaseNotation.
|
|
|
For example: `void state_CuttingDrogue(...)`
|
|
|
|
... | ... | @@ -132,7 +132,7 @@ Compared to the ones described before, they take 2 additional arguments: |
|
|
- *broker*: The event broker to use to post the events. Defaults to the global event broker
|
|
|
|
|
|
### Checking if an event has been posted
|
|
|
State machines interact with the rest of the software mostly by means of events. If we want to check if an event has been posted by a state machines (or anything else, really), we can use the `EventCounter` class.
|
|
|
State machines interact with the rest of the software mostly by means of events. If we want to check if an event has been posted by a state machines (or anything else, really), we can use the [EventCounter](Event-Utils) class.
|
|
|
This class can subscribe to one or multiple topics and count how many times any event is posted to that topic.
|
|
|
The main methods to use are:
|
|
|
|
... | ... | @@ -169,7 +169,7 @@ printf("%d", counter.getCount(Event{EV_B})); // 1 |
|
|
|
|
|
### Examples:
|
|
|
An example of test for state machines can be found in skyward-boardcore at:
|
|
|
`src/tests/examples/example-test-fsm.cpp`
|
|
|
`src/tests/examples/`
|
|
|
|
|
|
|
|
|
## Links
|
... | ... | |