mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-08-06 17:47:34 +00:00
Added reworked manager / statemachine tasks, thread implementation and new directory layout
This commit is contained in:
73
Tacos/include/sta/tacos/statemachine.hpp
Normal file
73
Tacos/include/sta/tacos/statemachine.hpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* statemachine.hpp
|
||||
*
|
||||
* Created on: Sep 14, 2023
|
||||
* Author: Dario
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_TACOS_STATEMACHINE_HPP_
|
||||
#define INCLUDE_TACOS_STATEMACHINE_HPP_
|
||||
|
||||
#include <sta/config.hpp>
|
||||
|
||||
#include <sta/tacos/thread.hpp>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
namespace tacos
|
||||
{
|
||||
class Statemachine : public TacosThread
|
||||
{
|
||||
public:
|
||||
static Statemachine* instance()
|
||||
{
|
||||
static CGuard g;
|
||||
|
||||
if (!_instance)
|
||||
{
|
||||
// Create a the manager singleton instance.
|
||||
Statemachine::_instance = new Statemachine();
|
||||
|
||||
// Start the manager task as a tacos task.
|
||||
Statemachine::_instance->start();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void init() override;
|
||||
|
||||
void func() override;
|
||||
|
||||
uint16_t getCurrentState();
|
||||
|
||||
private:
|
||||
class CGuard
|
||||
{
|
||||
public:
|
||||
~CGuard()
|
||||
{
|
||||
if( NULL != Statemachine::_instance )
|
||||
{
|
||||
delete Statemachine::_instance;
|
||||
Statemachine::_instance = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Statemachine();
|
||||
|
||||
Statemachine(const Statemachine&);
|
||||
|
||||
~Statemachine() {}
|
||||
|
||||
static Statemachine * _instance;
|
||||
|
||||
uint16_t currentState_;
|
||||
};
|
||||
} // namespace tacos
|
||||
} // namespace sta
|
||||
|
||||
|
||||
|
||||
#endif /* INCLUDE_TACOS_STATEMACHINE_HPP_ */
|
Reference in New Issue
Block a user