fdir update
This commit is contained in:
parent
3905b72b08
commit
6b4fa0cc04
@ -7,13 +7,15 @@
|
|||||||
|
|
||||||
object_id_t DeviceHandlerFailureIsolation::powerConfirmationId = 0;
|
object_id_t DeviceHandlerFailureIsolation::powerConfirmationId = 0;
|
||||||
|
|
||||||
DeviceHandlerFailureIsolation::DeviceHandlerFailureIsolation(object_id_t owner, object_id_t parent) :
|
DeviceHandlerFailureIsolation::DeviceHandlerFailureIsolation(object_id_t owner,
|
||||||
FailureIsolationBase(owner, parent), strangeReplyCount(MAX_STRANGE_REPLIES,
|
object_id_t parent) :
|
||||||
STRANGE_REPLIES_TIME_MS, parameterDomainBase++), missedReplyCount(
|
FailureIsolationBase(owner, parent),
|
||||||
MAX_MISSED_REPLY_COUNT, MISSED_REPLY_TIME_MS,
|
strangeReplyCount(MAX_STRANGE_REPLIES, STRANGE_REPLIES_TIME_MS,
|
||||||
parameterDomainBase++), recoveryCounter(MAX_REBOOT,
|
parameterDomainBase++),
|
||||||
REBOOT_TIME_MS, parameterDomainBase++), fdirState(NONE), powerConfirmation(
|
missedReplyCount( MAX_MISSED_REPLY_COUNT, MISSED_REPLY_TIME_MS,
|
||||||
0) {
|
parameterDomainBase++),
|
||||||
|
recoveryCounter(MAX_REBOOT, REBOOT_TIME_MS, parameterDomainBase++),
|
||||||
|
fdirState(NONE), powerConfirmation(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceHandlerFailureIsolation::~DeviceHandlerFailureIsolation() {
|
DeviceHandlerFailureIsolation::~DeviceHandlerFailureIsolation() {
|
||||||
@ -68,9 +70,11 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event)
|
|||||||
break;
|
break;
|
||||||
//****Power*****
|
//****Power*****
|
||||||
case PowerSwitchIF::SWITCH_WENT_OFF:
|
case PowerSwitchIF::SWITCH_WENT_OFF:
|
||||||
result = sendConfirmationRequest(event, powerConfirmation);
|
if(hasPowerConfirmation) {
|
||||||
if (result == RETURN_OK) {
|
result = sendConfirmationRequest(event, powerConfirmation);
|
||||||
setFdirState(DEVICE_MIGHT_BE_OFF);
|
if (result == RETURN_OK) {
|
||||||
|
setFdirState(DEVICE_MIGHT_BE_OFF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Fuse::FUSE_WENT_OFF:
|
case Fuse::FUSE_WENT_OFF:
|
||||||
@ -133,7 +137,7 @@ void DeviceHandlerFailureIsolation::decrementFaultCounters() {
|
|||||||
|
|
||||||
void DeviceHandlerFailureIsolation::handleRecovery(Event reason) {
|
void DeviceHandlerFailureIsolation::handleRecovery(Event reason) {
|
||||||
clearFaultCounters();
|
clearFaultCounters();
|
||||||
if (!recoveryCounter.incrementAndCheck()) {
|
if (not recoveryCounter.incrementAndCheck()) {
|
||||||
startRecovery(reason);
|
startRecovery(reason);
|
||||||
} else {
|
} else {
|
||||||
setFaulty(reason);
|
setFaulty(reason);
|
||||||
@ -142,7 +146,8 @@ void DeviceHandlerFailureIsolation::handleRecovery(Event reason) {
|
|||||||
|
|
||||||
void DeviceHandlerFailureIsolation::wasParentsFault(EventMessage* event) {
|
void DeviceHandlerFailureIsolation::wasParentsFault(EventMessage* event) {
|
||||||
//We'll better ignore the SWITCH_WENT_OFF event and await a system-wide reset.
|
//We'll better ignore the SWITCH_WENT_OFF event and await a system-wide reset.
|
||||||
//This means, no fault message will come through until a MODE_ or HEALTH_INFO message comes through -> Is that ok?
|
//This means, no fault message will come through until a MODE_ or
|
||||||
|
//HEALTH_INFO message comes through -> Is that ok?
|
||||||
//Same issue in TxFailureIsolation!
|
//Same issue in TxFailureIsolation!
|
||||||
// if ((event->getEvent() == PowerSwitchIF::SWITCH_WENT_OFF)
|
// if ((event->getEvent() == PowerSwitchIF::SWITCH_WENT_OFF)
|
||||||
// && (fdirState != RECOVERY_ONGOING)) {
|
// && (fdirState != RECOVERY_ONGOING)) {
|
||||||
@ -158,14 +163,17 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() {
|
|||||||
ReturnValue_t DeviceHandlerFailureIsolation::initialize() {
|
ReturnValue_t DeviceHandlerFailureIsolation::initialize() {
|
||||||
ReturnValue_t result = FailureIsolationBase::initialize();
|
ReturnValue_t result = FailureIsolationBase::initialize();
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::error << "DeviceHandlerFailureIsolation::initialize: Could not"
|
||||||
|
" initialize FailureIsolationBase." << std::endl;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
ConfirmsFailuresIF* power = objectManager->get<ConfirmsFailuresIF>(
|
ConfirmsFailuresIF* power = objectManager->get<ConfirmsFailuresIF>(
|
||||||
powerConfirmationId);
|
powerConfirmationId);
|
||||||
if (power == NULL) {
|
if (power != nullptr) {
|
||||||
return RETURN_FAILED;
|
powerConfirmation = power->getEventReceptionQueue();
|
||||||
|
hasPowerConfirmation = true;
|
||||||
}
|
}
|
||||||
powerConfirmation = power->getEventReceptionQueue();
|
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,10 @@ protected:
|
|||||||
NONE, RECOVERY_ONGOING, DEVICE_MIGHT_BE_OFF, AWAIT_SHUTDOWN
|
NONE, RECOVERY_ONGOING, DEVICE_MIGHT_BE_OFF, AWAIT_SHUTDOWN
|
||||||
};
|
};
|
||||||
FDIRState fdirState;
|
FDIRState fdirState;
|
||||||
|
bool hasPowerConfirmation = false;
|
||||||
MessageQueueId_t powerConfirmation;
|
MessageQueueId_t powerConfirmation;
|
||||||
static object_id_t powerConfirmationId;
|
static object_id_t powerConfirmationId;
|
||||||
|
// TODO: Are those hardcoded value? How can they be changed.
|
||||||
static const uint32_t MAX_REBOOT = 1;
|
static const uint32_t MAX_REBOOT = 1;
|
||||||
static const uint32_t REBOOT_TIME_MS = 180000;
|
static const uint32_t REBOOT_TIME_MS = 180000;
|
||||||
static const uint32_t MAX_STRANGE_REPLIES = 10;
|
static const uint32_t MAX_STRANGE_REPLIES = 10;
|
||||||
|
@ -5,10 +5,12 @@
|
|||||||
#include <framework/ipc/QueueFactory.h>
|
#include <framework/ipc/QueueFactory.h>
|
||||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||||
|
|
||||||
FailureIsolationBase::FailureIsolationBase(object_id_t owner, object_id_t parent, uint8_t messageDepth, uint8_t parameterDomainBase) :
|
FailureIsolationBase::FailureIsolationBase(object_id_t owner,
|
||||||
eventQueue(NULL), ownerId(
|
object_id_t parent, uint8_t messageDepth, uint8_t parameterDomainBase) :
|
||||||
owner), owner(NULL), faultTreeParent(parent), parameterDomainBase(parameterDomainBase) {
|
ownerId(owner), faultTreeParent(parent),
|
||||||
eventQueue = QueueFactory::instance()->createMessageQueue(messageDepth, EventMessage::EVENT_MESSAGE_SIZE);
|
parameterDomainBase(parameterDomainBase) {
|
||||||
|
eventQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
|
||||||
|
EventMessage::EVENT_MESSAGE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
FailureIsolationBase::~FailureIsolationBase() {
|
FailureIsolationBase::~FailureIsolationBase() {
|
||||||
@ -18,27 +20,36 @@ FailureIsolationBase::~FailureIsolationBase() {
|
|||||||
ReturnValue_t FailureIsolationBase::initialize() {
|
ReturnValue_t FailureIsolationBase::initialize() {
|
||||||
EventManagerIF* manager = objectManager->get<EventManagerIF>(
|
EventManagerIF* manager = objectManager->get<EventManagerIF>(
|
||||||
objects::EVENT_MANAGER);
|
objects::EVENT_MANAGER);
|
||||||
if (manager == NULL) {
|
if (manager == nullptr) {
|
||||||
|
sif::error << "FailureIsolationBase::initialize: Event Manager has not"
|
||||||
|
" been initialized!" << std::endl;
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
ReturnValue_t result = manager->registerListener(eventQueue->getId());
|
ReturnValue_t result = manager->registerListener(eventQueue->getId());
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (ownerId != 0) {
|
if (ownerId != objects::NO_OBJECT) {
|
||||||
result = manager->subscribeToAllEventsFrom(eventQueue->getId(), ownerId);
|
result = manager->subscribeToAllEventsFrom(eventQueue->getId(), ownerId);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
owner = objectManager->get<HasHealthIF>(ownerId);
|
owner = objectManager->get<HasHealthIF>(ownerId);
|
||||||
if (owner == NULL) {
|
if (owner == nullptr) {
|
||||||
return RETURN_FAILED;
|
sif::error << "FailureIsolationBase::intialize: Owner object "
|
||||||
|
"invalid. Make sure it implements HasHealthIF" << std::endl;
|
||||||
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (faultTreeParent != 0) {
|
if (faultTreeParent != objects::NO_OBJECT) {
|
||||||
ConfirmsFailuresIF* parentIF = objectManager->get<ConfirmsFailuresIF>(
|
ConfirmsFailuresIF* parentIF = objectManager->get<ConfirmsFailuresIF>(
|
||||||
faultTreeParent);
|
faultTreeParent);
|
||||||
if (parentIF == NULL) {
|
if (parentIF == nullptr) {
|
||||||
|
sif::error << "FailureIsolationBase::intialize: Parent object"
|
||||||
|
<< "invalid." << std::endl;
|
||||||
|
sif::error << "Make sure it implements ConfirmsFailuresIF."
|
||||||
|
<< std::endl;
|
||||||
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue());
|
eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue());
|
||||||
@ -93,9 +104,9 @@ MessageQueueId_t FailureIsolationBase::getEventReceptionQueue() {
|
|||||||
ReturnValue_t FailureIsolationBase::sendConfirmationRequest(EventMessage* event,
|
ReturnValue_t FailureIsolationBase::sendConfirmationRequest(EventMessage* event,
|
||||||
MessageQueueId_t destination) {
|
MessageQueueId_t destination) {
|
||||||
event->setMessageId(EventMessage::CONFIRMATION_REQUEST);
|
event->setMessageId(EventMessage::CONFIRMATION_REQUEST);
|
||||||
if (destination != 0) {
|
if (destination != MessageQueueIF::NO_QUEUE) {
|
||||||
return eventQueue->sendMessage(destination, event);
|
return eventQueue->sendMessage(destination, event);
|
||||||
} else if (faultTreeParent != 0) {
|
} else if (faultTreeParent != objects::NO_OBJECT) {
|
||||||
return eventQueue->sendToDefault(event);
|
return eventQueue->sendToDefault(event);
|
||||||
}
|
}
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
|
@ -17,18 +17,25 @@ public:
|
|||||||
static const Event FDIR_CHANGED_STATE = MAKE_EVENT(1, SEVERITY::INFO); //!< FDIR has an internal state, which changed from par2 (oldState) to par1 (newState).
|
static const Event FDIR_CHANGED_STATE = MAKE_EVENT(1, SEVERITY::INFO); //!< FDIR has an internal state, which changed from par2 (oldState) to par1 (newState).
|
||||||
static const Event FDIR_STARTS_RECOVERY = MAKE_EVENT(2, SEVERITY::MEDIUM); //!< FDIR tries to restart device. Par1: event that caused recovery.
|
static const Event FDIR_STARTS_RECOVERY = MAKE_EVENT(2, SEVERITY::MEDIUM); //!< FDIR tries to restart device. Par1: event that caused recovery.
|
||||||
static const Event FDIR_TURNS_OFF_DEVICE = MAKE_EVENT(3, SEVERITY::MEDIUM); //!< FDIR turns off device. Par1: event that caused recovery.
|
static const Event FDIR_TURNS_OFF_DEVICE = MAKE_EVENT(3, SEVERITY::MEDIUM); //!< FDIR turns off device. Par1: event that caused recovery.
|
||||||
FailureIsolationBase(object_id_t owner, object_id_t parent = 0,
|
|
||||||
|
FailureIsolationBase(object_id_t owner,
|
||||||
|
object_id_t parent = objects::NO_OBJECT,
|
||||||
uint8_t messageDepth = 10, uint8_t parameterDomainBase = 0xF0);
|
uint8_t messageDepth = 10, uint8_t parameterDomainBase = 0xF0);
|
||||||
|
|
||||||
virtual ~FailureIsolationBase();
|
virtual ~FailureIsolationBase();
|
||||||
virtual ReturnValue_t initialize();
|
virtual ReturnValue_t initialize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is called by the DHB in performOperation()
|
||||||
|
*/
|
||||||
void checkForFailures();
|
void checkForFailures();
|
||||||
MessageQueueId_t getEventReceptionQueue();
|
MessageQueueId_t getEventReceptionQueue() override;
|
||||||
virtual void triggerEvent(Event event, uint32_t parameter1 = 0,
|
virtual void triggerEvent(Event event, uint32_t parameter1 = 0,
|
||||||
uint32_t parameter2 = 0);
|
uint32_t parameter2 = 0);
|
||||||
protected:
|
protected:
|
||||||
MessageQueueIF* eventQueue;
|
MessageQueueIF* eventQueue = nullptr;
|
||||||
object_id_t ownerId;
|
object_id_t ownerId;
|
||||||
HasHealthIF* owner;
|
HasHealthIF* owner = nullptr;
|
||||||
object_id_t faultTreeParent;
|
object_id_t faultTreeParent;
|
||||||
uint8_t parameterDomainBase;
|
uint8_t parameterDomainBase;
|
||||||
void setOwnerHealth(HasHealthIF::HealthState health);
|
void setOwnerHealth(HasHealthIF::HealthState health);
|
||||||
@ -38,7 +45,7 @@ protected:
|
|||||||
virtual ReturnValue_t confirmFault(EventMessage* event);
|
virtual ReturnValue_t confirmFault(EventMessage* event);
|
||||||
virtual void decrementFaultCounters() = 0;
|
virtual void decrementFaultCounters() = 0;
|
||||||
ReturnValue_t sendConfirmationRequest(EventMessage* event,
|
ReturnValue_t sendConfirmationRequest(EventMessage* event,
|
||||||
MessageQueueId_t destination = 0);
|
MessageQueueId_t destination = MessageQueueIF::NO_QUEUE);
|
||||||
void throwFdirEvent(Event event, uint32_t parameter1 = 0,
|
void throwFdirEvent(Event event, uint32_t parameter1 = 0,
|
||||||
uint32_t parameter2 = 0);
|
uint32_t parameter2 = 0);
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user