2020-10-29 17:52:28 +01:00
|
|
|
#ifndef FSFW_HEALTH_HEALTHTABLE_H_
|
|
|
|
#define FSFW_HEALTH_HEALTHTABLE_H_
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
#include "../ipc/MutexIF.h"
|
|
|
|
#include "../objectmanager/SystemObject.h"
|
|
|
|
#include "HealthTableIF.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
class HealthTable : public HealthTableIF, public SystemObject {
|
|
|
|
public:
|
2022-07-25 22:36:53 +02:00
|
|
|
explicit HealthTable(object_id_t objectid);
|
|
|
|
~HealthTable() override;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
void setMutexTimeout(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs);
|
2020-11-02 15:00:01 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
/** HealthTableIF overrides */
|
|
|
|
virtual ReturnValue_t registerObject(
|
|
|
|
object_id_t object, HasHealthIF::HealthState initilialState = HasHealthIF::HEALTHY) override;
|
2022-06-05 12:52:55 +02:00
|
|
|
ReturnValue_t removeObject(object_id_t object) override;
|
2022-02-02 10:29:30 +01:00
|
|
|
virtual size_t getPrintSize() override;
|
|
|
|
virtual void printAll(uint8_t* pointer, size_t maxSize) override;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
/** ManagesHealthIF overrides */
|
|
|
|
virtual bool hasHealth(object_id_t object) override;
|
|
|
|
virtual void setHealth(object_id_t object, HasHealthIF::HealthState newState) override;
|
|
|
|
virtual HasHealthIF::HealthState getHealth(object_id_t) override;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
protected:
|
|
|
|
using HealthMap = std::map<object_id_t, HasHealthIF::HealthState>;
|
|
|
|
using HealthEntry = std::pair<object_id_t, HasHealthIF::HealthState>;
|
2020-10-29 17:52:28 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
MutexIF* mutex;
|
|
|
|
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
|
|
|
|
uint32_t mutexTimeoutMs = 20;
|
2020-11-02 15:00:01 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
HealthMap healthMap;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
HealthMap::iterator mapIterator;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
virtual ReturnValue_t iterate(HealthEntry* value, bool reset = false) override;
|
2016-06-15 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
2020-10-29 17:52:28 +01:00
|
|
|
#endif /* FSFW_HEALTH_HEALTHTABLE_H_ */
|