2020-08-28 18:33:29 +02:00
|
|
|
#include "InternalErrorReporter.h"
|
|
|
|
|
2020-09-26 17:21:32 +02:00
|
|
|
#include "../ipc/QueueFactory.h"
|
|
|
|
#include "../datapoolglob/GlobalDataSet.h"
|
2020-08-28 18:33:29 +02:00
|
|
|
#include "../datapoolglob/GlobalPoolVariable.h"
|
|
|
|
#include "../ipc/MutexFactory.h"
|
|
|
|
#include "../serviceinterface/ServiceInterfaceStream.h"
|
|
|
|
|
|
|
|
InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId,
|
2020-09-26 17:21:32 +02:00
|
|
|
uint32_t messageQueueDepth) :
|
|
|
|
SystemObject(setObjectId),
|
|
|
|
commandQueue(QueueFactory::instance()->
|
|
|
|
createMessageQueue(messageQueueDepth)),
|
|
|
|
poolManager(this, commandQueue),
|
2020-09-26 17:28:03 +02:00
|
|
|
internalErrorSid(setObjectId, InternalErrorDataset::ERROR_SET_ID),
|
2020-09-26 17:21:32 +02:00
|
|
|
internalErrorDataset(this) {
|
2020-08-28 18:33:29 +02:00
|
|
|
mutex = MutexFactory::instance()->createMutex();
|
|
|
|
}
|
|
|
|
|
|
|
|
InternalErrorReporter::~InternalErrorReporter() {
|
|
|
|
MutexFactory::instance()->deleteMutex(mutex);
|
|
|
|
}
|
|
|
|
|
2020-09-26 17:21:32 +02:00
|
|
|
void InternalErrorReporter::setDiagnosticPrintout(bool enable) {
|
|
|
|
this->diagnosticPrintout = enable;
|
|
|
|
}
|
2020-08-28 18:33:29 +02:00
|
|
|
|
2020-09-26 17:21:32 +02:00
|
|
|
ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
|
|
|
|
internalErrorDataset.read(INTERNAL_ERROR_MUTEX_TIMEOUT);
|
2020-08-28 18:33:29 +02:00
|
|
|
|
|
|
|
uint32_t newQueueHits = getAndResetQueueHits();
|
|
|
|
uint32_t newTmHits = getAndResetTmHits();
|
|
|
|
uint32_t newStoreHits = getAndResetStoreHits();
|
|
|
|
|
2020-09-26 17:21:32 +02:00
|
|
|
#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;
|
2020-09-26 17:24:06 +02:00
|
|
|
sif::debug << "TM errors: " << newTmHits << std::endl;
|
|
|
|
sif::debug << "Store errors: " << newStoreHits << std::endl;
|
2020-09-26 17:21:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
internalErrorDataset.queueHits.value += newQueueHits;
|
2020-09-26 17:24:06 +02:00
|
|
|
internalErrorDataset.storeHits.value += newStoreHits;
|
|
|
|
internalErrorDataset.tmHits.value += newTmHits;
|
2020-09-26 17:21:32 +02:00
|
|
|
|
|
|
|
internalErrorDataset.commit(INTERNAL_ERROR_MUTEX_TIMEOUT);
|
|
|
|
|
|
|
|
CommandMessage message;
|
|
|
|
ReturnValue_t result = commandQueue->receiveMessage(&message);
|
|
|
|
if(result != MessageQueueIF::EMPTY) {
|
|
|
|
poolManager.handleHousekeepingMessage(&message);
|
|
|
|
}
|
2020-08-28 18:33:29 +02:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::queueMessageNotSent() {
|
|
|
|
incrementQueueHits();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::lostTm() {
|
|
|
|
incrementTmHits();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getAndResetQueueHits() {
|
|
|
|
uint32_t value;
|
2020-09-26 17:21:32 +02:00
|
|
|
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
2020-08-28 18:33:29 +02:00
|
|
|
value = queueHits;
|
|
|
|
queueHits = 0;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getQueueHits() {
|
|
|
|
uint32_t value;
|
2020-09-26 17:21:32 +02:00
|
|
|
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
2020-08-28 18:33:29 +02:00
|
|
|
value = queueHits;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::incrementQueueHits() {
|
2020-09-26 17:21:32 +02:00
|
|
|
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
2020-08-28 18:33:29 +02:00
|
|
|
queueHits++;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getAndResetTmHits() {
|
|
|
|
uint32_t value;
|
2020-09-26 17:21:32 +02:00
|
|
|
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
2020-08-28 18:33:29 +02:00
|
|
|
value = tmHits;
|
|
|
|
tmHits = 0;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getTmHits() {
|
|
|
|
uint32_t value;
|
2020-09-26 17:21:32 +02:00
|
|
|
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
2020-08-28 18:33:29 +02:00
|
|
|
value = tmHits;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::incrementTmHits() {
|
2020-09-26 17:21:32 +02:00
|
|
|
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
2020-08-28 18:33:29 +02:00
|
|
|
tmHits++;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::storeFull() {
|
|
|
|
incrementStoreHits();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getAndResetStoreHits() {
|
|
|
|
uint32_t value;
|
2020-09-26 17:21:32 +02:00
|
|
|
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
2020-08-28 18:33:29 +02:00
|
|
|
value = storeHits;
|
|
|
|
storeHits = 0;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getStoreHits() {
|
|
|
|
uint32_t value;
|
2020-09-26 17:21:32 +02:00
|
|
|
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
2020-08-28 18:33:29 +02:00
|
|
|
value = storeHits;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::incrementStoreHits() {
|
2020-09-26 17:21:32 +02:00
|
|
|
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT);
|
2020-08-28 18:33:29 +02:00
|
|
|
storeHits++;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
}
|
2020-09-26 17:21:32 +02:00
|
|
|
|
|
|
|
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>());
|
2020-09-26 17:28:03 +02:00
|
|
|
// todo: Only send HK if values have changed, will be supported by
|
|
|
|
// pool manager soon.
|
|
|
|
poolManager.subscribeForPeriodicPacket(internalErrorSid, false,
|
|
|
|
getPeriodicOperationFrequency(), false);
|
2020-09-26 17:21:32 +02:00
|
|
|
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;
|
|
|
|
}
|