Added reworked manager / statemachine tasks, thread implementation and new directory layout

This commit is contained in:
dario
2023-09-22 15:07:15 +02:00
parent adeec2f3f9
commit 503d874a6e
13 changed files with 652 additions and 26 deletions

View 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_ */