2018-07-12 16:29:32 +02:00
|
|
|
#ifndef FRAMEWORK_DEVICEHANDLERS_DEVICEHANDLERFAILUREISOLATION_H_
|
|
|
|
#define FRAMEWORK_DEVICEHANDLERS_DEVICEHANDLERFAILUREISOLATION_H_
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../fdir/FaultCounter.h"
|
|
|
|
#include "../fdir/FailureIsolationBase.h"
|
2020-08-27 19:58:35 +02:00
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
namespace Factory{
|
|
|
|
void setStaticFrameworkObjectIds();
|
|
|
|
}
|
|
|
|
|
|
|
|
class DeviceHandlerFailureIsolation: public FailureIsolationBase {
|
|
|
|
friend void (Factory::setStaticFrameworkObjectIds)();
|
|
|
|
friend class Heater;
|
2016-06-15 23:48:41 +02:00
|
|
|
public:
|
2018-07-12 16:29:32 +02:00
|
|
|
DeviceHandlerFailureIsolation(object_id_t owner, object_id_t parent);
|
|
|
|
~DeviceHandlerFailureIsolation();
|
2016-06-15 23:48:41 +02:00
|
|
|
ReturnValue_t initialize();
|
2018-07-12 16:29:32 +02:00
|
|
|
void triggerEvent(Event event, uint32_t parameter1 = 0,
|
|
|
|
uint32_t parameter2 = 0);bool isFdirActionInProgress();
|
2016-06-15 23:48:41 +02:00
|
|
|
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
|
|
|
ParameterWrapper *parameterWrapper,
|
|
|
|
const ParameterWrapper *newValues, uint16_t startAtIndex);
|
|
|
|
protected:
|
|
|
|
FaultCounter strangeReplyCount;
|
|
|
|
FaultCounter missedReplyCount;
|
|
|
|
FaultCounter recoveryCounter;
|
|
|
|
enum FDIRState {
|
2018-07-12 16:29:32 +02:00
|
|
|
NONE, RECOVERY_ONGOING, DEVICE_MIGHT_BE_OFF, AWAIT_SHUTDOWN
|
2016-06-15 23:48:41 +02:00
|
|
|
};
|
|
|
|
FDIRState fdirState;
|
2020-08-27 19:58:35 +02:00
|
|
|
MessageQueueId_t powerConfirmation = MessageQueueIF::NO_QUEUE;
|
2018-07-12 16:29:32 +02:00
|
|
|
static object_id_t powerConfirmationId;
|
2020-08-08 13:28:59 +02:00
|
|
|
// TODO: Are those hardcoded value? How can they be changed.
|
2016-06-15 23:48:41 +02:00
|
|
|
static const uint32_t MAX_REBOOT = 1;
|
|
|
|
static const uint32_t REBOOT_TIME_MS = 180000;
|
|
|
|
static const uint32_t MAX_STRANGE_REPLIES = 10;
|
|
|
|
static const uint32_t STRANGE_REPLIES_TIME_MS = 10000;
|
|
|
|
static const uint32_t MAX_MISSED_REPLY_COUNT = 5;
|
|
|
|
static const uint32_t MISSED_REPLY_TIME_MS = 10000;
|
2018-07-12 16:29:32 +02:00
|
|
|
virtual ReturnValue_t eventReceived(EventMessage* event);
|
|
|
|
virtual void eventConfirmed(EventMessage* event);
|
|
|
|
void wasParentsFault(EventMessage* event);
|
|
|
|
void decrementFaultCounters();
|
2016-06-15 23:48:41 +02:00
|
|
|
void handleRecovery(Event reason);
|
|
|
|
virtual void clearFaultCounters();
|
|
|
|
void setFdirState(FDIRState state);
|
|
|
|
void startRecovery(Event reason);
|
|
|
|
void setFaulty(Event reason);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
bool isFdirInActionOrAreWeFaulty(EventMessage* event);
|
2016-06-15 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
#endif /* FRAMEWORK_DEVICEHANDLERS_DEVICEHANDLERFAILUREISOLATION_H_ */
|