fsfw/events/EventManager.h

74 lines
2.1 KiB
C
Raw Normal View History

2020-12-14 20:49:17 +01:00
#ifndef FSFW_EVENT_EVENTMANAGER_H_
#define FSFW_EVENT_EVENTMANAGER_H_
2020-08-28 17:44:10 +02:00
#include "EventManagerIF.h"
2020-12-14 20:49:17 +01:00
#include "eventmatching/EventMatchTree.h"
#include <FSFWConfig.h>
2020-08-28 17:44:10 +02:00
#include "../objectmanager/SystemObject.h"
#include "../storagemanager/LocalPool.h"
#include "../tasks/ExecutableObjectIF.h"
#include "../ipc/MessageQueueIF.h"
#include "../ipc/MutexIF.h"
2020-09-15 17:33:21 +02:00
2020-08-28 17:44:10 +02:00
#include <map>
2020-09-15 17:33:21 +02:00
#if FSFW_DEBUG_OUTPUT == 1
2020-08-28 17:55:13 +02:00
// forward declaration, should be implemented by mission
extern const char* translateObject(object_id_t object);
extern const char* translateEvents(Event event);
#endif
2020-08-28 17:44:10 +02:00
class EventManager: public EventManagerIF,
public ExecutableObjectIF,
public SystemObject {
public:
static const uint16_t MAX_EVENTS_PER_CYCLE = 80;
EventManager(object_id_t setObjectId);
virtual ~EventManager();
MessageQueueId_t getEventReportQueue();
ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false);
ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event);
ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener,
object_id_t object);
ReturnValue_t subscribeToEventRange(MessageQueueId_t listener,
EventId_t idFrom = 0, EventId_t idTo = 0, bool idInverted = false,
object_id_t reporterFrom = 0, object_id_t reporterTo = 0,
bool reporterInverted = false);
ReturnValue_t unsubscribeFromEventRange(MessageQueueId_t listener,
EventId_t idFrom = 0, EventId_t idTo = 0, bool idInverted = false,
object_id_t reporterFrom = 0, object_id_t reporterTo = 0,
bool reporterInverted = false);
ReturnValue_t performOperation(uint8_t opCode);
protected:
2020-08-28 17:55:13 +02:00
MessageQueueIF* eventReportQueue = nullptr;
2020-08-28 17:44:10 +02:00
std::map<MessageQueueId_t, EventMatchTree> listenerList;
2020-08-28 17:55:13 +02:00
MutexIF* mutex = nullptr;
2020-08-28 17:44:10 +02:00
static const uint8_t N_POOLS = 3;
2020-10-14 23:20:53 +02:00
LocalPool factoryBackend;
static const LocalPool::LocalPoolConfig poolConfig;
2020-08-28 17:44:10 +02:00
static const uint16_t POOL_SIZES[N_POOLS];
static const uint16_t N_ELEMENTS[N_POOLS];
void notifyListeners(EventMessage *message);
2020-09-15 17:33:21 +02:00
#if FSFW_DEBUG_OUTPUT == 1
2020-08-28 17:44:10 +02:00
void printEvent(EventMessage *message);
#endif
void lockMutex();
void unlockMutex();
};
2020-12-14 20:49:17 +01:00
#endif /* FSFW_EVENT_EVENTMANAGER_H_ */