mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-08-06 09:37:34 +00:00
Combined watchdog code with latest changes.
This commit is contained in:
74
include/sta/tacos/watchdog.hpp
Normal file
74
include/sta/tacos/watchdog.hpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef STA_TACOS_WATCHDOG_HPP
|
||||
#define STA_TACOS_WATCHDOG_HPP
|
||||
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_TACOS_WATCHDOG_ENABLED
|
||||
|
||||
#ifndef STA_TACOS_WATCHDOG_PRIORITY
|
||||
# error "TACOS watchdog priority was not specified!"
|
||||
#endif // STA_TACOS_WATCHDOG_PRIORITY
|
||||
|
||||
#ifndef STA_TACOS_WATCHDOG_FREQUENCY
|
||||
# error "TACOS watchdog frequency was not specified!"
|
||||
#endif // STA_TACOS_WATCHDOG_FREQUENCY
|
||||
|
||||
|
||||
#include <sta/tacos/thread.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
namespace tacos
|
||||
{
|
||||
/**
|
||||
* @brief Watchdog class for TACOS using singleton pattern.
|
||||
*
|
||||
*/
|
||||
class Watchdog: public TacosThread
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Getter for the singleton instance. Constructs the instance if no exists.
|
||||
*
|
||||
* @return Watchdog*
|
||||
*/
|
||||
static Watchdog* instance()
|
||||
{
|
||||
static CGuard g;
|
||||
|
||||
if (!_instance)
|
||||
{
|
||||
// Create the watchdog singleton instance.
|
||||
Watchdog::_instance = new Watchdog();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void func() override;
|
||||
private:
|
||||
static Watchdog* _instance;
|
||||
|
||||
class CGuard
|
||||
{
|
||||
public:
|
||||
~CGuard()
|
||||
{
|
||||
if( NULL != Watchdog::_instance )
|
||||
{
|
||||
delete Watchdog::_instance;
|
||||
Watchdog::_instance = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Watchdog(const Watchdog&);
|
||||
|
||||
Watchdog();
|
||||
};
|
||||
} // namespace tacos
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_TACOS_WATCHDOG_ENABLED
|
||||
|
||||
#endif // STA_TACOS_WATCHDOG_HPP
|
Reference in New Issue
Block a user