2018-07-12 16:29:32 +02:00
|
|
|
#include "InternalErrorReporter.h"
|
|
|
|
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../datapool/DataSet.h"
|
|
|
|
#include "../datapool/PoolVariable.h"
|
|
|
|
#include "../ipc/MutexFactory.h"
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../serviceinterface/ServiceInterfaceStream.h"
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
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) {
|
|
|
|
mutex = MutexFactory::instance()->createMutex();
|
|
|
|
}
|
|
|
|
|
|
|
|
InternalErrorReporter::~InternalErrorReporter() {
|
|
|
|
MutexFactory::instance()->deleteMutex(mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
|
|
|
|
|
|
|
|
DataSet mySet;
|
|
|
|
PoolVariable<uint32_t> queueHitsInPool(queuePoolId, &mySet,
|
|
|
|
PoolVariableIF::VAR_READ_WRITE);
|
|
|
|
PoolVariable<uint32_t> tmHitsInPool(tmPoolId, &mySet,
|
|
|
|
PoolVariableIF::VAR_READ_WRITE);
|
|
|
|
|
|
|
|
PoolVariable<uint32_t> storeHitsInPool(storePoolId, &mySet,
|
|
|
|
PoolVariableIF::VAR_READ_WRITE);
|
|
|
|
mySet.read();
|
|
|
|
|
|
|
|
uint32_t newQueueHits = getAndResetQueueHits();
|
|
|
|
uint32_t newTmHits = getAndResetTmHits();
|
|
|
|
uint32_t newStoreHits = getAndResetStoreHits();
|
|
|
|
|
|
|
|
queueHitsInPool.value += newQueueHits;
|
|
|
|
tmHitsInPool.value += newTmHits;
|
|
|
|
storeHitsInPool.value += newStoreHits;
|
|
|
|
|
|
|
|
mySet.commit(PoolVariableIF::VALID);
|
|
|
|
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::queueMessageNotSent() {
|
|
|
|
incrementQueueHits();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::lostTm() {
|
|
|
|
incrementTmHits();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getAndResetQueueHits() {
|
|
|
|
uint32_t value;
|
|
|
|
mutex->lockMutex(MutexIF::NO_TIMEOUT);
|
|
|
|
value = queueHits;
|
|
|
|
queueHits = 0;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getQueueHits() {
|
|
|
|
uint32_t value;
|
|
|
|
mutex->lockMutex(MutexIF::NO_TIMEOUT);
|
|
|
|
value = queueHits;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::incrementQueueHits() {
|
|
|
|
mutex->lockMutex(MutexIF::NO_TIMEOUT);
|
|
|
|
queueHits++;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getAndResetTmHits() {
|
|
|
|
uint32_t value;
|
|
|
|
mutex->lockMutex(MutexIF::NO_TIMEOUT);
|
|
|
|
value = tmHits;
|
|
|
|
tmHits = 0;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getTmHits() {
|
|
|
|
uint32_t value;
|
|
|
|
mutex->lockMutex(MutexIF::NO_TIMEOUT);
|
|
|
|
value = tmHits;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::incrementTmHits() {
|
|
|
|
mutex->lockMutex(MutexIF::NO_TIMEOUT);
|
|
|
|
tmHits++;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::storeFull() {
|
|
|
|
incrementStoreHits();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getAndResetStoreHits() {
|
|
|
|
uint32_t value;
|
|
|
|
mutex->lockMutex(MutexIF::NO_TIMEOUT);
|
|
|
|
value = storeHits;
|
|
|
|
storeHits = 0;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t InternalErrorReporter::getStoreHits() {
|
|
|
|
uint32_t value;
|
|
|
|
mutex->lockMutex(MutexIF::NO_TIMEOUT);
|
|
|
|
value = storeHits;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalErrorReporter::incrementStoreHits() {
|
|
|
|
mutex->lockMutex(MutexIF::NO_TIMEOUT);
|
|
|
|
storeHits++;
|
|
|
|
mutex->unlockMutex();
|
|
|
|
}
|