internal error reporter uses new local datapool now
This commit is contained in:
parent
e67b1fce9a
commit
4a97596030
31
internalError/InternalErrorDataset.h
Normal file
31
internalError/InternalErrorDataset.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef FSFW_INTERNALERROR_INTERNALERRORDATASET_H_
|
||||
#define FSFW_INTERNALERROR_INTERNALERRORDATASET_H_
|
||||
|
||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
||||
|
||||
enum errorPoolIds {
|
||||
TM_HITS,
|
||||
QUEUE_HITS,
|
||||
STORE_HITS
|
||||
};
|
||||
|
||||
|
||||
class InternalErrorDataset: public StaticLocalDataSet<3 * sizeof(uint32_t)> {
|
||||
public:
|
||||
static constexpr uint8_t ERROR_SET_ID = 0;
|
||||
|
||||
InternalErrorDataset(HasLocalDataPoolIF* owner):
|
||||
StaticLocalDataSet(owner, ERROR_SET_ID) {}
|
||||
|
||||
InternalErrorDataset(sid_t sid):
|
||||
StaticLocalDataSet(sid) {}
|
||||
|
||||
lp_var_t<uint32_t> tmHits = lp_var_t<uint32_t>(TM_HITS, sid.objectId, this);
|
||||
lp_var_t<uint32_t> queueHits = lp_var_t<uint32_t>(QUEUE_HITS, sid.objectId, this);
|
||||
lp_var_t<uint32_t> storeHits = lp_var_t<uint32_t>(STORE_HITS, sid.objectId, this);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_INTERNALERROR_INTERNALERRORDATASET_H_ */
|
@ -1,16 +1,18 @@
|
||||
#include "../datapoolglob/GlobalDataSet.h"
|
||||
#include "InternalErrorReporter.h"
|
||||
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../datapoolglob/GlobalDataSet.h"
|
||||
#include "../datapoolglob/GlobalPoolVariable.h"
|
||||
#include "../ipc/MutexFactory.h"
|
||||
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId,
|
||||
uint32_t queuePoolId, uint32_t tmPoolId, uint32_t storePoolId) :
|
||||
SystemObject(setObjectId), mutex(NULL), queuePoolId(queuePoolId),
|
||||
tmPoolId(tmPoolId),storePoolId(storePoolId), queueHits(0), tmHits(0),
|
||||
storeHits(0) {
|
||||
uint32_t messageQueueDepth) :
|
||||
SystemObject(setObjectId),
|
||||
commandQueue(QueueFactory::instance()->
|
||||
createMessageQueue(messageQueueDepth)),
|
||||
poolManager(this, commandQueue),
|
||||
internalErrorDataset(this) {
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
@ -18,28 +20,40 @@ InternalErrorReporter::~InternalErrorReporter() {
|
||||
MutexFactory::instance()->deleteMutex(mutex);
|
||||
}
|
||||
|
||||
void InternalErrorReporter::setDiagnosticPrintout(bool enable) {
|
||||
this->diagnosticPrintout = enable;
|
||||
}
|
||||
|
||||
ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
|
||||
|
||||
GlobDataSet mySet;
|
||||
gp_uint32_t queueHitsInPool(queuePoolId, &mySet,
|
||||
PoolVariableIF::VAR_READ_WRITE);
|
||||
gp_uint32_t tmHitsInPool(tmPoolId, &mySet,
|
||||
PoolVariableIF::VAR_READ_WRITE);
|
||||
|
||||
gp_uint32_t storeHitsInPool(storePoolId, &mySet,
|
||||
PoolVariableIF::VAR_READ_WRITE);
|
||||
mySet.read();
|
||||
internalErrorDataset.read(INTERNAL_ERROR_MUTEX_TIMEOUT);
|
||||
|
||||
uint32_t newQueueHits = getAndResetQueueHits();
|
||||
uint32_t newTmHits = getAndResetTmHits();
|
||||
uint32_t newStoreHits = getAndResetStoreHits();
|
||||
|
||||
queueHitsInPool.value += newQueueHits;
|
||||
tmHitsInPool.value += newTmHits;
|
||||
storeHitsInPool.value += newStoreHits;
|
||||
#ifdef DEBUG
|
||||
if(diagnosticPrintout) {
|
||||
if((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) {
|
||||
sif::debug << "InternalErrorReporter::performOperation: Errors "
|
||||
<< "occured!" << std::endl;
|
||||
sif::debug << "Queue errors: " << newQueueHits << std::endl;
|
||||
sif::debug << "TM errors: " << newQueueHits << std::endl;
|
||||
sif::debug << "Store errors: " << newQueueHits << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
mySet.commit(PoolVariableIF::VALID);
|
||||
internalErrorDataset.queueHits.value += newQueueHits;
|
||||
internalErrorDataset.storeHits.value += newTmHits;
|
||||
internalErrorDataset.tmHits.value += newStoreHits;
|
||||
|
||||
internalErrorDataset.commit(INTERNAL_ERROR_MUTEX_TIMEOUT);
|
||||
|
||||
CommandMessage message;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&message);
|
||||
if(result != MessageQueueIF::EMPTY) {
|
||||
poolManager.handleHousekeepingMessage(&message);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@ -53,7 +67,7 @@ void InternalErrorReporter::lostTm() {
|
||||
|
||||
uint32_t InternalErrorReporter::getAndResetQueueHits() {
|
||||
uint32_t value;
|
||||
mutex->lockMutex(MutexIF::BLOCKING);
|
||||
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
||||
value = queueHits;
|
||||
queueHits = 0;
|
||||
mutex->unlockMutex();
|
||||
@ -62,21 +76,21 @@ uint32_t InternalErrorReporter::getAndResetQueueHits() {
|
||||
|
||||
uint32_t InternalErrorReporter::getQueueHits() {
|
||||
uint32_t value;
|
||||
mutex->lockMutex(MutexIF::BLOCKING);
|
||||
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
||||
value = queueHits;
|
||||
mutex->unlockMutex();
|
||||
return value;
|
||||
}
|
||||
|
||||
void InternalErrorReporter::incrementQueueHits() {
|
||||
mutex->lockMutex(MutexIF::BLOCKING);
|
||||
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
||||
queueHits++;
|
||||
mutex->unlockMutex();
|
||||
}
|
||||
|
||||
uint32_t InternalErrorReporter::getAndResetTmHits() {
|
||||
uint32_t value;
|
||||
mutex->lockMutex(MutexIF::BLOCKING);
|
||||
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
||||
value = tmHits;
|
||||
tmHits = 0;
|
||||
mutex->unlockMutex();
|
||||
@ -85,14 +99,14 @@ uint32_t InternalErrorReporter::getAndResetTmHits() {
|
||||
|
||||
uint32_t InternalErrorReporter::getTmHits() {
|
||||
uint32_t value;
|
||||
mutex->lockMutex(MutexIF::BLOCKING);
|
||||
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
||||
value = tmHits;
|
||||
mutex->unlockMutex();
|
||||
return value;
|
||||
}
|
||||
|
||||
void InternalErrorReporter::incrementTmHits() {
|
||||
mutex->lockMutex(MutexIF::BLOCKING);
|
||||
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
||||
tmHits++;
|
||||
mutex->unlockMutex();
|
||||
}
|
||||
@ -103,7 +117,7 @@ void InternalErrorReporter::storeFull() {
|
||||
|
||||
uint32_t InternalErrorReporter::getAndResetStoreHits() {
|
||||
uint32_t value;
|
||||
mutex->lockMutex(MutexIF::BLOCKING);
|
||||
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
||||
value = storeHits;
|
||||
storeHits = 0;
|
||||
mutex->unlockMutex();
|
||||
@ -112,14 +126,49 @@ uint32_t InternalErrorReporter::getAndResetStoreHits() {
|
||||
|
||||
uint32_t InternalErrorReporter::getStoreHits() {
|
||||
uint32_t value;
|
||||
mutex->lockMutex(MutexIF::BLOCKING);
|
||||
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
||||
value = storeHits;
|
||||
mutex->unlockMutex();
|
||||
return value;
|
||||
}
|
||||
|
||||
void InternalErrorReporter::incrementStoreHits() {
|
||||
mutex->lockMutex(MutexIF::BLOCKING);
|
||||
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
||||
storeHits++;
|
||||
mutex->unlockMutex();
|
||||
}
|
||||
|
||||
object_id_t InternalErrorReporter::getObjectId() const {
|
||||
return SystemObject::getObjectId();
|
||||
}
|
||||
|
||||
MessageQueueId_t InternalErrorReporter::getCommandQueue() const {
|
||||
return this->commandQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t InternalErrorReporter::initializeLocalDataPool(
|
||||
LocalDataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
|
||||
localDataPoolMap.emplace(errorPoolIds::TM_HITS,
|
||||
new PoolEntry<uint32_t>());
|
||||
localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS,
|
||||
new PoolEntry<uint32_t>());
|
||||
localDataPoolMap.emplace(errorPoolIds::STORE_HITS,
|
||||
new PoolEntry<uint32_t>());
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
LocalDataPoolManager* InternalErrorReporter::getHkManagerHandle() {
|
||||
return &poolManager;
|
||||
}
|
||||
|
||||
dur_millis_t InternalErrorReporter::getPeriodicOperationFrequency() const {
|
||||
return this->executingTask->getPeriodMs();
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase* InternalErrorReporter::getDataSetHandle(sid_t sid) {
|
||||
return &internalErrorDataset;
|
||||
}
|
||||
|
||||
void InternalErrorReporter::setTaskIF(PeriodicTaskIF *task) {
|
||||
this->executingTask = task;
|
||||
}
|
||||
|
@ -1,37 +1,72 @@
|
||||
#ifndef INTERNALERRORREPORTER_H_
|
||||
#define INTERNALERRORREPORTER_H_
|
||||
#ifndef FSFW_INTERNALERROR_INTERNALERRORREPORTER_H_
|
||||
#define FSFW_INTERNALERROR_INTERNALERRORREPORTER_H_
|
||||
|
||||
#include "InternalErrorReporterIF.h"
|
||||
|
||||
#include "../tasks/PeriodicTaskIF.h"
|
||||
#include "../internalError/InternalErrorDataset.h"
|
||||
#include "../datapoollocal/LocalDataPoolManager.h"
|
||||
#include "../tasks/ExecutableObjectIF.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
#include "../ipc/MutexIF.h"
|
||||
|
||||
/**
|
||||
* @brief This class is used to track internal errors like lost telemetry,
|
||||
* failed message sending or a full store.
|
||||
* @details
|
||||
* All functions were kept virtual so this class can be extended easily
|
||||
* to store custom internal errors (e.g. communication interface errors).
|
||||
*/
|
||||
class InternalErrorReporter: public SystemObject,
|
||||
public ExecutableObjectIF,
|
||||
public InternalErrorReporterIF {
|
||||
public InternalErrorReporterIF,
|
||||
public HasLocalDataPoolIF {
|
||||
public:
|
||||
InternalErrorReporter(object_id_t setObjectId, uint32_t queuePoolId,
|
||||
uint32_t tmPoolId, uint32_t storePoolId);
|
||||
static constexpr uint8_t INTERNAL_ERROR_MUTEX_TIMEOUT = 20;
|
||||
|
||||
InternalErrorReporter(object_id_t setObjectId,
|
||||
uint32_t messageQueueDepth = 5);
|
||||
|
||||
/**
|
||||
* Enable diagnostic printout. Please note that this feature will
|
||||
* only work if DEBUG has been supplied to the build defines.
|
||||
* @param enable
|
||||
*/
|
||||
void setDiagnosticPrintout(bool enable);
|
||||
|
||||
virtual ~InternalErrorReporter();
|
||||
|
||||
virtual ReturnValue_t performOperation(uint8_t opCode);
|
||||
virtual object_id_t getObjectId() const override;
|
||||
virtual MessageQueueId_t getCommandQueue() const override;
|
||||
virtual ReturnValue_t initializeLocalDataPool(
|
||||
LocalDataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
virtual LocalDataPoolManager* getHkManagerHandle() override;
|
||||
virtual dur_millis_t getPeriodicOperationFrequency() const override;
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
|
||||
virtual ReturnValue_t performOperation(uint8_t opCode) override;
|
||||
|
||||
virtual void queueMessageNotSent();
|
||||
|
||||
virtual void lostTm();
|
||||
|
||||
virtual void storeFull();
|
||||
|
||||
virtual void setTaskIF(PeriodicTaskIF* task) override;
|
||||
protected:
|
||||
MutexIF* mutex;
|
||||
MessageQueueIF* commandQueue;
|
||||
LocalDataPoolManager poolManager;
|
||||
|
||||
uint32_t queuePoolId;
|
||||
uint32_t tmPoolId;
|
||||
uint32_t storePoolId;
|
||||
PeriodicTaskIF* executingTask = nullptr;
|
||||
MutexIF* mutex = nullptr;
|
||||
InternalErrorDataset internalErrorDataset;
|
||||
|
||||
uint32_t queueHits;
|
||||
uint32_t tmHits;
|
||||
uint32_t storeHits;
|
||||
bool diagnosticPrintout = true;
|
||||
|
||||
uint32_t queueHits = 0;
|
||||
uint32_t tmHits = 0;
|
||||
uint32_t storeHits = 0;
|
||||
|
||||
uint32_t getAndResetQueueHits();
|
||||
uint32_t getQueueHits();
|
||||
@ -47,4 +82,4 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
#endif /* INTERNALERRORREPORTER_H_ */
|
||||
#endif /* FSFW_INTERNALERROR_INTERNALERRORREPORTER_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user