updating code from Flying Laptop
This is the framework of Flying Laptop OBSW version A.13.0.
This commit is contained in:
@ -1,19 +1,12 @@
|
||||
/*
|
||||
* ConfirmsFailuresIF.h
|
||||
*
|
||||
* Created on: 10.09.2015
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORK_FDIR_CONFIRMSFAILURESIF_H_
|
||||
#define FRAMEWORK_FDIR_CONFIRMSFAILURESIF_H_
|
||||
|
||||
#include <framework/ipc/MessageQueue.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
|
||||
class ConfirmsFailuresIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = HANDLES_FAILURES_IF;
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::HANDLES_FAILURES_IF;
|
||||
static const ReturnValue_t YOUR_FAULT = MAKE_RETURN_CODE(0);
|
||||
static const ReturnValue_t MY_FAULT = MAKE_RETURN_CODE(1);
|
||||
static const ReturnValue_t CONFIRM_LATER = MAKE_RETURN_CODE(2);
|
||||
|
@ -1,10 +1,3 @@
|
||||
/*
|
||||
* EventCorrelation.cpp
|
||||
*
|
||||
* Created on: 15.10.2015
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#include <framework/fdir/EventCorrelation.h>
|
||||
|
||||
EventCorrelation::EventCorrelation(uint32_t timeout) :
|
||||
|
@ -1,10 +1,3 @@
|
||||
/*
|
||||
* EventCorrelation.h
|
||||
*
|
||||
* Created on: 15.10.2015
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORK_FDIR_EVENTCORRELATION_H_
|
||||
#define FRAMEWORK_FDIR_EVENTCORRELATION_H_
|
||||
|
||||
|
@ -1,35 +1,32 @@
|
||||
/*
|
||||
* FDIRBase.cpp
|
||||
*
|
||||
* Created on: 09.09.2015
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#include <framework/events/EventManagerIF.h>
|
||||
#include <framework/fdir/FDIRBase.h>
|
||||
#include <framework/fdir/FailureIsolationBase.h>
|
||||
#include <framework/health/HasHealthIF.h>
|
||||
#include <framework/health/HealthMessage.h>
|
||||
#include <framework/ipc/QueueFactory.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
FDIRBase::FDIRBase(object_id_t owner, object_id_t parent, uint8_t messageDepth, uint8_t parameterDomainBase) :
|
||||
eventQueue(messageDepth, EventMessage::EVENT_MESSAGE_SIZE), ownerId(
|
||||
|
||||
FailureIsolationBase::FailureIsolationBase(object_id_t owner, object_id_t parent, uint8_t messageDepth, uint8_t parameterDomainBase) :
|
||||
eventQueue(NULL), ownerId(
|
||||
owner), owner(NULL), faultTreeParent(parent), parameterDomainBase(parameterDomainBase) {
|
||||
eventQueue = QueueFactory::instance()->createMessageQueue(messageDepth, EventMessage::EVENT_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
FDIRBase::~FDIRBase() {
|
||||
FailureIsolationBase::~FailureIsolationBase() {
|
||||
QueueFactory::instance()->deleteMessageQueue(eventQueue);
|
||||
}
|
||||
|
||||
ReturnValue_t FDIRBase::initialize() {
|
||||
ReturnValue_t FailureIsolationBase::initialize() {
|
||||
EventManagerIF* manager = objectManager->get<EventManagerIF>(
|
||||
objects::EVENT_MANAGER);
|
||||
if (manager == NULL) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
ReturnValue_t result = manager->registerListener(eventQueue.getId());
|
||||
ReturnValue_t result = manager->registerListener(eventQueue->getId());
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
if (ownerId != 0) {
|
||||
result = manager->subscribeToAllEventsFrom(eventQueue.getId(), ownerId);
|
||||
result = manager->subscribeToAllEventsFrom(eventQueue->getId(), ownerId);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -44,16 +41,16 @@ ReturnValue_t FDIRBase::initialize() {
|
||||
if (parentIF == NULL) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
eventQueue.setDefaultDestination(parentIF->getEventReceptionQueue());
|
||||
eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue());
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void FDIRBase::checkForFailures() {
|
||||
void FailureIsolationBase::checkForFailures() {
|
||||
EventMessage event;
|
||||
for (ReturnValue_t result = eventQueue.receiveMessage(&event);
|
||||
result == RETURN_OK; result = eventQueue.receiveMessage(&event)) {
|
||||
if (event.getSender() == eventQueue.getId()) {
|
||||
for (ReturnValue_t result = eventQueue->receiveMessage(&event);
|
||||
result == RETURN_OK; result = eventQueue->receiveMessage(&event)) {
|
||||
if (event.getSender() == eventQueue->getId()) {
|
||||
//We already got this event, because we sent it.
|
||||
continue;
|
||||
}
|
||||
@ -81,7 +78,7 @@ void FDIRBase::checkForFailures() {
|
||||
decrementFaultCounters();
|
||||
}
|
||||
|
||||
void FDIRBase::setOwnerHealth(HasHealthIF::HealthState health) {
|
||||
void FailureIsolationBase::setOwnerHealth(HasHealthIF::HealthState health) {
|
||||
if (owner != NULL) {
|
||||
owner->setHealth(health);
|
||||
}
|
||||
@ -89,45 +86,45 @@ void FDIRBase::setOwnerHealth(HasHealthIF::HealthState health) {
|
||||
|
||||
}
|
||||
|
||||
MessageQueueId_t FDIRBase::getEventReceptionQueue() {
|
||||
return eventQueue.getId();
|
||||
MessageQueueId_t FailureIsolationBase::getEventReceptionQueue() {
|
||||
return eventQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t FDIRBase::sendConfirmationRequest(EventMessage* event,
|
||||
ReturnValue_t FailureIsolationBase::sendConfirmationRequest(EventMessage* event,
|
||||
MessageQueueId_t destination) {
|
||||
event->setMessageId(EventMessage::CONFIRMATION_REQUEST);
|
||||
if (destination != 0) {
|
||||
return eventQueue.sendMessage(destination, event);
|
||||
return eventQueue->sendMessage(destination, event);
|
||||
} else if (faultTreeParent != 0) {
|
||||
return eventQueue.sendToDefault(event);
|
||||
return eventQueue->sendToDefault(event);
|
||||
}
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
void FDIRBase::eventConfirmed(EventMessage* event) {
|
||||
void FailureIsolationBase::eventConfirmed(EventMessage* event) {
|
||||
}
|
||||
|
||||
void FDIRBase::wasParentsFault(EventMessage* event) {
|
||||
void FailureIsolationBase::wasParentsFault(EventMessage* event) {
|
||||
}
|
||||
|
||||
void FDIRBase::doConfirmFault(EventMessage* event) {
|
||||
void FailureIsolationBase::doConfirmFault(EventMessage* event) {
|
||||
ReturnValue_t result = confirmFault(event);
|
||||
if (result == YOUR_FAULT) {
|
||||
event->setMessageId(EventMessage::YOUR_FAULT);
|
||||
eventQueue.reply(event);
|
||||
eventQueue->reply(event);
|
||||
} else if (result == MY_FAULT) {
|
||||
event->setMessageId(EventMessage::MY_FAULT);
|
||||
eventQueue.reply(event);
|
||||
eventQueue->reply(event);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t FDIRBase::confirmFault(EventMessage* event) {
|
||||
ReturnValue_t FailureIsolationBase::confirmFault(EventMessage* event) {
|
||||
return YOUR_FAULT;
|
||||
}
|
||||
|
||||
void FDIRBase::triggerEvent(Event event, uint32_t parameter1,
|
||||
void FailureIsolationBase::triggerEvent(Event event, uint32_t parameter1,
|
||||
uint32_t parameter2) {
|
||||
//With this mechanism, all events are disabled for a certain device.
|
||||
//That's not so good for visibility.
|
||||
@ -135,11 +132,11 @@ void FDIRBase::triggerEvent(Event event, uint32_t parameter1,
|
||||
return;
|
||||
}
|
||||
EventMessage message(event, ownerId, parameter1, parameter2);
|
||||
EventManagerIF::triggerEvent(&message, eventQueue.getId());
|
||||
EventManagerIF::triggerEvent(&message, eventQueue->getId());
|
||||
eventReceived(&message);
|
||||
}
|
||||
|
||||
bool FDIRBase::isFdirDisabledForSeverity(EventSeverity_t severity) {
|
||||
bool FailureIsolationBase::isFdirDisabledForSeverity(EventSeverity_t severity) {
|
||||
if ((owner != NULL) && (severity != SEVERITY::INFO)) {
|
||||
if (owner->getHealth() == HasHealthIF::EXTERNAL_CONTROL) {
|
||||
//External control disables handling of fault messages.
|
||||
@ -149,8 +146,8 @@ bool FDIRBase::isFdirDisabledForSeverity(EventSeverity_t severity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void FDIRBase::throwFdirEvent(Event event, uint32_t parameter1,
|
||||
void FailureIsolationBase::throwFdirEvent(Event event, uint32_t parameter1,
|
||||
uint32_t parameter2) {
|
||||
EventMessage message(event, ownerId, parameter1, parameter2);
|
||||
EventManagerIF::triggerEvent(&message, eventQueue.getId());
|
||||
EventManagerIF::triggerEvent(&message, eventQueue->getId());
|
||||
}
|
@ -1,34 +1,32 @@
|
||||
/*
|
||||
* FDIRBase.h
|
||||
*
|
||||
* Created on: 09.09.2015
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORK_FDIR_FDIRBASE_H_
|
||||
#define FRAMEWORK_FDIR_FDIRBASE_H_
|
||||
#ifndef FRAMEWORK_FDIR_FAILUREISOLATIONBASE_H_
|
||||
#define FRAMEWORK_FDIR_FAILUREISOLATIONBASE_H_
|
||||
|
||||
#include <framework/events/EventMessage.h>
|
||||
#include <framework/fdir/ConfirmsFailuresIF.h>
|
||||
#include <framework/fdir/FaultCounter.h>
|
||||
#include <framework/health/HealthMessage.h>
|
||||
#include <framework/ipc/MessageQueue.h>
|
||||
#include <framework/parameters/HasParametersIF.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
class FDIRBase: public HasReturnvaluesIF, public ConfirmsFailuresIF, public HasParametersIF {
|
||||
#include <framework/ipc/MessageQueueIF.h>
|
||||
|
||||
class FailureIsolationBase: public HasReturnvaluesIF,
|
||||
public ConfirmsFailuresIF,
|
||||
public HasParametersIF {
|
||||
public:
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FDIR_1;
|
||||
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_TURNS_OFF_DEVICE = MAKE_EVENT(3, SEVERITY::MEDIUM); //!< FDIR turns off device. Par1: event that caused recovery.
|
||||
FDIRBase(object_id_t owner, object_id_t parent = 0, uint8_t messageDepth = 10, uint8_t parameterDomainBase = 0xF0);
|
||||
virtual ~FDIRBase();
|
||||
FailureIsolationBase(object_id_t owner, object_id_t parent = 0,
|
||||
uint8_t messageDepth = 10, uint8_t parameterDomainBase = 0xF0);
|
||||
virtual ~FailureIsolationBase();
|
||||
virtual ReturnValue_t initialize();
|
||||
void checkForFailures();
|
||||
MessageQueueId_t getEventReceptionQueue();
|
||||
virtual void triggerEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0);
|
||||
virtual void triggerEvent(Event event, uint32_t parameter1 = 0,
|
||||
uint32_t parameter2 = 0);
|
||||
protected:
|
||||
MessageQueue eventQueue;
|
||||
MessageQueueIF* eventQueue;
|
||||
object_id_t ownerId;
|
||||
HasHealthIF* owner;
|
||||
object_id_t faultTreeParent;
|
||||
@ -39,11 +37,13 @@ protected:
|
||||
virtual void wasParentsFault(EventMessage* event);
|
||||
virtual ReturnValue_t confirmFault(EventMessage* event);
|
||||
virtual void decrementFaultCounters() = 0;
|
||||
ReturnValue_t sendConfirmationRequest(EventMessage* event, MessageQueueId_t destination = 0);
|
||||
void throwFdirEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0);
|
||||
ReturnValue_t sendConfirmationRequest(EventMessage* event,
|
||||
MessageQueueId_t destination = 0);
|
||||
void throwFdirEvent(Event event, uint32_t parameter1 = 0,
|
||||
uint32_t parameter2 = 0);
|
||||
private:
|
||||
void doConfirmFault(EventMessage* event);
|
||||
bool isFdirDisabledForSeverity(EventSeverity_t severity);
|
||||
void doConfirmFault(EventMessage* event);bool isFdirDisabledForSeverity(
|
||||
EventSeverity_t severity);
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_FDIR_FDIRBASE_H_ */
|
||||
#endif /* FRAMEWORK_FDIR_FAILUREISOLATIONBASE_H_ */
|
@ -1,10 +1,3 @@
|
||||
/*
|
||||
* FaultCounter.cpp
|
||||
*
|
||||
* Created on: 15.09.2015
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#include <framework/fdir/FaultCounter.h>
|
||||
|
||||
FaultCounter::FaultCounter(uint32_t failureThreshold, uint32_t decrementAfterMs,
|
||||
|
@ -1,10 +1,3 @@
|
||||
/*
|
||||
* FaultCounter.h
|
||||
*
|
||||
* Created on: 15.09.2015
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORK_FDIR_FAULTCOUNTER_H_
|
||||
#define FRAMEWORK_FDIR_FAULTCOUNTER_H_
|
||||
|
||||
|
Reference in New Issue
Block a user