updating code from Flying Laptop
This is the framework of Flying Laptop OBSW version A.13.0.
This commit is contained in:
126
internalError/InternalErrorReporter.cpp
Normal file
126
internalError/InternalErrorReporter.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
#include "InternalErrorReporter.h"
|
||||
|
||||
#include <framework/datapool/DataSet.h>
|
||||
#include <framework/datapool/PoolVariable.h>
|
||||
#include <framework/ipc/MutexFactory.h>
|
||||
|
||||
#include <framework/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) {
|
||||
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();
|
||||
}
|
51
internalError/InternalErrorReporter.h
Normal file
51
internalError/InternalErrorReporter.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef INTERNALERRORREPORTER_H_
|
||||
#define INTERNALERRORREPORTER_H_
|
||||
|
||||
#include "InternalErrorReporterIF.h"
|
||||
|
||||
#include <framework/tasks/ExecutableObjectIF.h>
|
||||
#include <framework/objectmanager/SystemObject.h>
|
||||
#include <framework/ipc/MutexIF.h>
|
||||
|
||||
class InternalErrorReporter: public SystemObject,
|
||||
public ExecutableObjectIF,
|
||||
public InternalErrorReporterIF {
|
||||
public:
|
||||
InternalErrorReporter(object_id_t setObjectId, uint32_t queuePoolId,
|
||||
uint32_t tmPoolId, uint32_t storePoolId);
|
||||
virtual ~InternalErrorReporter();
|
||||
|
||||
virtual ReturnValue_t performOperation(uint8_t opCode);
|
||||
|
||||
virtual void queueMessageNotSent();
|
||||
|
||||
virtual void lostTm();
|
||||
|
||||
virtual void storeFull();
|
||||
|
||||
protected:
|
||||
MutexIF* mutex;
|
||||
|
||||
uint32_t queuePoolId;
|
||||
uint32_t tmPoolId;
|
||||
uint32_t storePoolId;
|
||||
|
||||
uint32_t queueHits;
|
||||
uint32_t tmHits;
|
||||
uint32_t storeHits;
|
||||
|
||||
uint32_t getAndResetQueueHits();
|
||||
uint32_t getQueueHits();
|
||||
void incrementQueueHits();
|
||||
|
||||
uint32_t getAndResetTmHits();
|
||||
uint32_t getTmHits();
|
||||
void incrementTmHits();
|
||||
|
||||
uint32_t getAndResetStoreHits();
|
||||
uint32_t getStoreHits();
|
||||
void incrementStoreHits();
|
||||
|
||||
};
|
||||
|
||||
#endif /* INTERNALERRORREPORTER_H_ */
|
27
internalError/InternalErrorReporterIF.h
Normal file
27
internalError/InternalErrorReporterIF.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef INTERNALERRORREPORTERIF_H_
|
||||
#define INTERNALERRORREPORTERIF_H_
|
||||
|
||||
class InternalErrorReporterIF {
|
||||
public:
|
||||
virtual ~InternalErrorReporterIF() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread safe
|
||||
*/
|
||||
virtual void queueMessageNotSent() = 0;
|
||||
|
||||
/**
|
||||
* Thread safe
|
||||
*/
|
||||
virtual void lostTm() = 0;
|
||||
|
||||
/**
|
||||
* Thread safe
|
||||
*/
|
||||
virtual void storeFull() = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* INTERNALERRORREPORTERIF_H_ */
|
Reference in New Issue
Block a user