mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-06-12 01:25:59 +00:00
74 lines
1.1 KiB
C++
74 lines
1.1 KiB
C++
/*
|
|
* 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_ */
|