fsfw/health/ManagesHealthIF.h

54 lines
1.5 KiB
C
Raw Permalink Normal View History

2020-10-29 17:52:28 +01:00
#ifndef FSFW_HEALTH_MANAGESHEALTHIF_H_
#define FSFW_HEALTH_MANAGESHEALTHIF_H_
2020-08-13 20:53:35 +02:00
#include "HasHealthIF.h"
#include "../objectmanager/ObjectManagerIF.h"
2020-10-29 17:52:28 +01:00
class ManagesHealthIF {
public:
virtual ~ManagesHealthIF() {
}
virtual bool hasHealth(object_id_t object) = 0;
virtual void setHealth(object_id_t object,
HasHealthIF::HealthState newState) = 0;
virtual HasHealthIF::HealthState getHealth(object_id_t) = 0;
virtual bool isHealthy(object_id_t object) {
return (getHealth(object) == HasHealthIF::HEALTHY);
}
virtual bool isHealthy(HasHealthIF::HealthState health) {
return (health == HasHealthIF::HEALTHY);
}
virtual bool isFaulty(object_id_t object) {
HasHealthIF::HealthState health = getHealth(object);
return isFaulty(health);
}
virtual bool isPermanentFaulty(object_id_t object) {
HasHealthIF::HealthState health = getHealth(object);
return isPermanentFaulty(health);
}
virtual bool isPermanentFaulty(HasHealthIF::HealthState health) {
return (health == HasHealthIF::PERMANENT_FAULTY);
}
static bool isFaulty(HasHealthIF::HealthState health) {
return ((health == HasHealthIF::FAULTY)
|| (health == HasHealthIF::PERMANENT_FAULTY)
|| (health == HasHealthIF::NEEDS_RECOVERY));
}
virtual bool isCommandable(object_id_t object) {
return (getHealth(object) != HasHealthIF::EXTERNAL_CONTROL);
}
virtual bool isCommandable(HasHealthIF::HealthState health) {
return (health != HasHealthIF::EXTERNAL_CONTROL);
}
};
2020-10-29 17:52:28 +01:00
#endif /* FSFW_HEALTH_MANAGESHEALTHIF_H_ */