mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-06-10 16:45:59 +00:00
feat: user definable callback on state transition
This commit is contained in:
parent
7152baca2a
commit
9f4d99191d
@ -66,6 +66,7 @@
|
|||||||
#include <sta/rtos/event.hpp>
|
#include <sta/rtos/event.hpp>
|
||||||
#include <sta/event.hpp>
|
#include <sta/event.hpp>
|
||||||
#include <sta/debug/assert.hpp>
|
#include <sta/debug/assert.hpp>
|
||||||
|
#include <sta/lang.hpp>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@ -278,6 +279,18 @@ namespace sta
|
|||||||
*/
|
*/
|
||||||
std::vector<std::shared_ptr<TacosThread>> threads_[STA_TACOS_NUM_STATES];
|
std::vector<std::shared_ptr<TacosThread>> threads_[STA_TACOS_NUM_STATES];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Callback that is called when a state transition occurs.
|
||||||
|
*
|
||||||
|
* @param from The state we transitioned from.
|
||||||
|
* @param to The state we transitioned to.
|
||||||
|
* @param lockout The lockout time after the transition.
|
||||||
|
*
|
||||||
|
* @ingroup tacos_statemachine
|
||||||
|
*/
|
||||||
|
STA_WEAK
|
||||||
|
void onStateTransition(uint16_t from, uint16_t to, uint32_t lockout){}
|
||||||
} // namespace tacos
|
} // namespace tacos
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
|
@ -71,6 +71,9 @@ namespace sta
|
|||||||
HeapStats_t stats;
|
HeapStats_t stats;
|
||||||
vPortGetHeapStats(&stats);
|
vPortGetHeapStats(&stats);
|
||||||
|
|
||||||
|
// Execute the user-defined callback.
|
||||||
|
sta::tacos::onStateTransition(transition.from, transition.to, transition.lockout);
|
||||||
|
|
||||||
// Start all new tasks and stop all the tasks that aren't supposed to be running.
|
// Start all new tasks and stop all the tasks that aren't supposed to be running.
|
||||||
updateThreads();
|
updateThreads();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user