event update
This commit is contained in:
parent
e06b15cb9c
commit
57853ba566
@ -1,7 +1,5 @@
|
|||||||
#include "EventManager.h"
|
#include "EventManager.h"
|
||||||
#include "EventMessage.h"
|
|
||||||
#include <FSFWConfig.h>
|
#include <FSFWConfig.h>
|
||||||
|
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||||
#include "../ipc/QueueFactory.h"
|
#include "../ipc/QueueFactory.h"
|
||||||
#include "../ipc/MutexFactory.h"
|
#include "../ipc/MutexFactory.h"
|
||||||
@ -11,6 +9,7 @@
|
|||||||
// objects registering for certain events.
|
// objects registering for certain events.
|
||||||
// Each listener requires 1 or 2 EventIdMatcher and 1 or 2 ReportRangeMatcher.
|
// 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.
|
// So a good guess is 75 to a max of 100 pools required for each, which fits well.
|
||||||
|
// This should be configurable..
|
||||||
const LocalPool::LocalPoolConfig EventManager::poolConfig = {
|
const LocalPool::LocalPoolConfig EventManager::poolConfig = {
|
||||||
{fsfwconfig::FSFW_EVENTMGMR_MATCHTREE_NODES,
|
{fsfwconfig::FSFW_EVENTMGMR_MATCHTREE_NODES,
|
||||||
sizeof(EventMatchTree::Node)},
|
sizeof(EventMatchTree::Node)},
|
||||||
@ -43,7 +42,7 @@ ReturnValue_t EventManager::performOperation(uint8_t opCode) {
|
|||||||
EventMessage message;
|
EventMessage message;
|
||||||
result = eventReportQueue->receiveMessage(&message);
|
result = eventReportQueue->receiveMessage(&message);
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
#ifdef DEBUG
|
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||||
printEvent(&message);
|
printEvent(&message);
|
||||||
#endif
|
#endif
|
||||||
notifyListeners(&message);
|
notifyListeners(&message);
|
||||||
@ -119,8 +118,8 @@ ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener,
|
|||||||
void EventManager::printEvent(EventMessage* message) {
|
void EventManager::printEvent(EventMessage* message) {
|
||||||
const char *string = 0;
|
const char *string = 0;
|
||||||
switch (message->getSeverity()) {
|
switch (message->getSeverity()) {
|
||||||
case severity::INFO:
|
case SEVERITY::INFO:
|
||||||
#ifdef DEBUG_INFO_EVENT
|
#if DEBUG_INFO_EVENT == 1
|
||||||
string = translateObject(message->getReporter());
|
string = translateObject(message->getReporter());
|
||||||
sif::info << "EVENT: ";
|
sif::info << "EVENT: ";
|
||||||
if (string != 0) {
|
if (string != 0) {
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#ifndef EVENTMANAGERIF_H_
|
#ifndef EVENTMANAGERIF_H_
|
||||||
#define EVENTMANAGERIF_H_
|
#define EVENTMANAGERIF_H_
|
||||||
|
|
||||||
#include "eventmatching/eventmatching.h"
|
|
||||||
#include "EventMessage.h"
|
#include "EventMessage.h"
|
||||||
|
#include "eventmatching/eventmatching.h"
|
||||||
#include "../objectmanager/ObjectManagerIF.h"
|
#include "../objectmanager/ObjectManagerIF.h"
|
||||||
#include "../ipc/MessageQueueSenderIF.h"
|
#include "../ipc/MessageQueueSenderIF.h"
|
||||||
|
#include "../ipc/MessageQueueIF.h"
|
||||||
|
|
||||||
class EventManagerIF {
|
class EventManagerIF {
|
||||||
public:
|
public:
|
||||||
@ -16,7 +17,8 @@ public:
|
|||||||
|
|
||||||
virtual MessageQueueId_t getEventReportQueue() = 0;
|
virtual MessageQueueId_t getEventReportQueue() = 0;
|
||||||
|
|
||||||
virtual ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false) = 0;
|
virtual ReturnValue_t registerListener(MessageQueueId_t listener,
|
||||||
|
bool forwardAllButSelected = false) = 0;
|
||||||
virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener,
|
virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener,
|
||||||
EventId_t event) = 0;
|
EventId_t event) = 0;
|
||||||
virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener,
|
virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener,
|
||||||
@ -31,18 +33,22 @@ public:
|
|||||||
bool reporterInverted = false) = 0;
|
bool reporterInverted = false) = 0;
|
||||||
|
|
||||||
static void triggerEvent(object_id_t reportingObject, Event event,
|
static void triggerEvent(object_id_t reportingObject, Event event,
|
||||||
uint32_t parameter1 = 0, uint32_t parameter2 = 0, MessageQueueId_t sentFrom = 0) {
|
uint32_t parameter1 = 0, uint32_t parameter2 = 0,
|
||||||
|
MessageQueueId_t sentFrom = 0) {
|
||||||
EventMessage message(event, reportingObject, parameter1, parameter2);
|
EventMessage message(event, reportingObject, parameter1, parameter2);
|
||||||
triggerEvent(&message, sentFrom);
|
triggerEvent(&message, sentFrom);
|
||||||
}
|
}
|
||||||
static void triggerEvent(EventMessage* message, MessageQueueId_t sentFrom = 0) {
|
|
||||||
static MessageQueueId_t eventmanagerQueue = 0;
|
static void triggerEvent(EventMessage* message,
|
||||||
if (eventmanagerQueue == 0) {
|
MessageQueueId_t sentFrom = 0) {
|
||||||
|
static MessageQueueId_t eventmanagerQueue = MessageQueueIF::NO_QUEUE;
|
||||||
|
if (eventmanagerQueue == MessageQueueIF::NO_QUEUE) {
|
||||||
EventManagerIF *eventmanager = objectManager->get<EventManagerIF>(
|
EventManagerIF *eventmanager = objectManager->get<EventManagerIF>(
|
||||||
objects::EVENT_MANAGER);
|
objects::EVENT_MANAGER);
|
||||||
if (eventmanager != NULL) {
|
if (eventmanager == nullptr) {
|
||||||
eventmanagerQueue = eventmanager->getEventReportQueue();
|
return;
|
||||||
}
|
}
|
||||||
|
eventmanagerQueue = eventmanager->getEventReportQueue();
|
||||||
}
|
}
|
||||||
MessageQueueSenderIF::sendMessage(eventmanagerQueue, message, sentFrom);
|
MessageQueueSenderIF::sendMessage(eventmanagerQueue, message, sentFrom);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user