integrated all changes
This commit is contained in:
parent
e800aad979
commit
b71cab3993
@ -8,13 +8,16 @@
|
||||
const uint16_t EventManager::POOL_SIZES[N_POOLS] = {
|
||||
sizeof(EventMatchTree::Node), sizeof(EventIdRangeMatcher),
|
||||
sizeof(ReporterRangeMatcher) };
|
||||
//If one checks registerListener calls, there are around 40 (to max 50) objects registering for certain events.
|
||||
//Each listener requires 1 or 2 EventIdMatcher and 1 or 2 ReportRangeMatcher. So a good guess is 75 to a max of 100 pools required for each, which fits well.
|
||||
// If one checks registerListener calls, there are around 40 (to max 50)
|
||||
// objects registering for certain events.
|
||||
// Each listener requires 1 or 2 EventIdMatcher and 1 or 2 ReportRangeMatcher.
|
||||
// So a good guess is 75 to a max of 100 pools required for each, which fits well.
|
||||
// SHOULDDO: Shouldn't this be in the config folder and passed via ctor?
|
||||
const uint16_t EventManager::N_ELEMENTS[N_POOLS] = { 240, 120, 120 };
|
||||
|
||||
EventManager::EventManager(object_id_t setObjectId) :
|
||||
SystemObject(setObjectId), eventReportQueue(NULL), mutex(NULL), factoryBackend(
|
||||
0, POOL_SIZES, N_ELEMENTS, false, true) {
|
||||
SystemObject(setObjectId),
|
||||
factoryBackend(0, POOL_SIZES, N_ELEMENTS, false, true) {
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
eventReportQueue = QueueFactory::instance()->createMessageQueue(
|
||||
MAX_EVENTS_PER_CYCLE, EventMessage::EVENT_MESSAGE_SIZE);
|
||||
@ -108,41 +111,45 @@ ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener,
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
//forward declaration, should be implemented by mission
|
||||
const char* translateObject(object_id_t object);
|
||||
const char * translateEvents(Event event);
|
||||
|
||||
void EventManager::printEvent(EventMessage* message) {
|
||||
const char *string = 0;
|
||||
switch (message->getSeverity()) {
|
||||
case SEVERITY::INFO:
|
||||
// string = translateObject(message->getReporter());
|
||||
// sif::info << "EVENT: ";
|
||||
// if (string != 0) {
|
||||
// sif::info << string;
|
||||
// } else {
|
||||
// sif::info << "0x" << std::hex << message->getReporter() << std::dec;
|
||||
// }
|
||||
// sif::info << " reported " << translateEvents(message->getEvent()) << " ("
|
||||
// << std::dec << message->getEventId() << std::hex << ") P1: 0x"
|
||||
// << message->getParameter1() << " P2: 0x"
|
||||
// << message->getParameter2() << std::dec << std::endl;
|
||||
break;
|
||||
default:
|
||||
#ifdef DEBUG_INFO_EVENT
|
||||
string = translateObject(message->getReporter());
|
||||
sif::error << "EVENT: ";
|
||||
sif::info << "EVENT: ";
|
||||
if (string != 0) {
|
||||
sif::error << string;
|
||||
sif::info << string;
|
||||
} else {
|
||||
sif::error << "0x" << std::hex << message->getReporter() << std::dec;
|
||||
sif::info << "0x" << std::hex << message->getReporter() << std::dec;
|
||||
}
|
||||
sif::error << " reported " << translateEvents(message->getEvent()) << " ("
|
||||
sif::info << " reported " << translateEvents(message->getEvent()) << " ("
|
||||
<< std::dec << message->getEventId() << std::hex << ") P1: 0x"
|
||||
<< message->getParameter1() << " P2: 0x"
|
||||
<< message->getParameter2() << std::dec << std::endl;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
string = translateObject(message->getReporter());
|
||||
sif::debug << "EventManager: ";
|
||||
if (string != 0) {
|
||||
sif::debug << string;
|
||||
}
|
||||
else {
|
||||
sif::debug << "0x" << std::hex << message->getReporter() << std::dec;
|
||||
}
|
||||
sif::debug << " reported " << translateEvents(message->getEvent())
|
||||
<< " (" << std::dec << message->getEventId() << ") "
|
||||
<< std::endl;
|
||||
|
||||
sif::debug << std::hex << "P1 Hex: 0x" << message->getParameter1()
|
||||
<< ", P1 Dec: " << std::dec << message->getParameter1()
|
||||
<< std::endl;
|
||||
sif::debug << std::hex << "P2 Hex: 0x" << message->getParameter2()
|
||||
<< ", P2 Dec: " << std::dec << message->getParameter2()
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -10,6 +10,12 @@
|
||||
#include "../ipc/MutexIF.h"
|
||||
#include <map>
|
||||
|
||||
#ifdef DEBUG
|
||||
// forward declaration, should be implemented by mission
|
||||
extern const char* translateObject(object_id_t object);
|
||||
extern const char* translateEvents(Event event);
|
||||
#endif
|
||||
|
||||
class EventManager: public EventManagerIF,
|
||||
public ExecutableObjectIF,
|
||||
public SystemObject {
|
||||
@ -36,11 +42,11 @@ public:
|
||||
ReturnValue_t performOperation(uint8_t opCode);
|
||||
protected:
|
||||
|
||||
MessageQueueIF* eventReportQueue;
|
||||
MessageQueueIF* eventReportQueue = nullptr;
|
||||
|
||||
std::map<MessageQueueId_t, EventMatchTree> listenerList;
|
||||
|
||||
MutexIF* mutex;
|
||||
MutexIF* mutex = nullptr;
|
||||
|
||||
static const uint8_t N_POOLS = 3;
|
||||
LocalPool<N_POOLS> factoryBackend;
|
||||
|
Loading…
Reference in New Issue
Block a user