fsfw/health/HealthTable.h

48 lines
1.4 KiB
C
Raw Normal View History

2020-09-23 17:44:22 +02:00
#ifndef FSFW_HEALTH_HEALTHTABLE_H_
#define FSFW_HEALTH_HEALTHTABLE_H_
2020-08-28 18:33:29 +02:00
2020-09-23 17:44:22 +02:00
#include "HealthTableIF.h"
2020-08-28 18:33:29 +02:00
#include "../objectmanager/SystemObject.h"
#include "../ipc/MutexIF.h"
#include <map>
class HealthTable: public HealthTableIF, public SystemObject {
public:
HealthTable(object_id_t objectid);
virtual ~HealthTable();
2020-11-02 15:47:09 +01:00
void setMutexTimeout(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs);
2020-09-23 17:44:22 +02:00
/** HealthTableIF overrides */
virtual ReturnValue_t registerObject(object_id_t object,
HasHealthIF::HealthState initilialState =
HasHealthIF::HEALTHY) override;
virtual size_t getPrintSize() override;
virtual void printAll(uint8_t *pointer, size_t maxSize) override;
2020-08-28 18:33:29 +02:00
2020-09-23 17:44:22 +02: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;
2020-08-28 18:33:29 +02:00
protected:
2020-10-10 17:49:50 +02:00
using HealthMap = std::map<object_id_t, HasHealthIF::HealthState>;
using HealthEntry = std::pair<object_id_t, HasHealthIF::HealthState>;
2020-08-28 18:33:29 +02:00
MutexIF* mutex;
2020-11-02 15:47:09 +01:00
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t mutexTimeoutMs = 20;
2020-08-28 18:33:29 +02:00
HealthMap healthMap;
HealthMap::iterator mapIterator;
2020-09-23 17:44:22 +02:00
virtual ReturnValue_t iterate(
HealthEntry* value,
bool reset = false) override;
2020-08-28 18:33:29 +02:00
};
2020-09-23 17:44:22 +02:00
#endif /* FSFW_HEALTH_HEALTHTABLE_H_ */