Merge branch 'development' into meier/ColeredDebugOutput
This commit is contained in:
commit
3895806a2b
@ -12,119 +12,119 @@ MessageQueueId_t EventManagerIF::eventmanagerQueue = MessageQueueIF::NO_QUEUE;
|
|||||||
// 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.
|
||||||
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)},
|
||||||
{fsfwconfig::FSFW_EVENTMGMT_EVENTIDMATCHERS,
|
{fsfwconfig::FSFW_EVENTMGMT_EVENTIDMATCHERS,
|
||||||
sizeof(EventIdRangeMatcher)},
|
sizeof(EventIdRangeMatcher)},
|
||||||
{fsfwconfig::FSFW_EVENTMGMR_RANGEMATCHERS,
|
{fsfwconfig::FSFW_EVENTMGMR_RANGEMATCHERS,
|
||||||
sizeof(ReporterRangeMatcher)}
|
sizeof(ReporterRangeMatcher)}
|
||||||
};
|
};
|
||||||
|
|
||||||
EventManager::EventManager(object_id_t setObjectId) :
|
EventManager::EventManager(object_id_t setObjectId) :
|
||||||
SystemObject(setObjectId),
|
SystemObject(setObjectId),
|
||||||
factoryBackend(0, poolConfig, false, true) {
|
factoryBackend(0, poolConfig, false, true) {
|
||||||
mutex = MutexFactory::instance()->createMutex();
|
mutex = MutexFactory::instance()->createMutex();
|
||||||
eventReportQueue = QueueFactory::instance()->createMessageQueue(
|
eventReportQueue = QueueFactory::instance()->createMessageQueue(
|
||||||
MAX_EVENTS_PER_CYCLE, EventMessage::EVENT_MESSAGE_SIZE);
|
MAX_EVENTS_PER_CYCLE, EventMessage::EVENT_MESSAGE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventManager::~EventManager() {
|
EventManager::~EventManager() {
|
||||||
QueueFactory::instance()->deleteMessageQueue(eventReportQueue);
|
QueueFactory::instance()->deleteMessageQueue(eventReportQueue);
|
||||||
MutexFactory::instance()->deleteMutex(mutex);
|
MutexFactory::instance()->deleteMutex(mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueId_t EventManager::getEventReportQueue() {
|
MessageQueueId_t EventManager::getEventReportQueue() {
|
||||||
return eventReportQueue->getId();
|
return eventReportQueue->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t EventManager::performOperation(uint8_t opCode) {
|
ReturnValue_t EventManager::performOperation(uint8_t opCode) {
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
while (result == HasReturnvaluesIF::RETURN_OK) {
|
while (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
EventMessage message;
|
EventMessage message;
|
||||||
result = eventReportQueue->receiveMessage(&message);
|
result = eventReportQueue->receiveMessage(&message);
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||||
printEvent(&message);
|
printEvent(&message);
|
||||||
#endif
|
#endif
|
||||||
notifyListeners(&message);
|
notifyListeners(&message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::notifyListeners(EventMessage* message) {
|
void EventManager::notifyListeners(EventMessage* message) {
|
||||||
lockMutex();
|
lockMutex();
|
||||||
for (auto iter = listenerList.begin(); iter != listenerList.end(); ++iter) {
|
for (auto iter = listenerList.begin(); iter != listenerList.end(); ++iter) {
|
||||||
if (iter->second.match(message)) {
|
if (iter->second.match(message)) {
|
||||||
MessageQueueSenderIF::sendMessage(iter->first, message,
|
MessageQueueSenderIF::sendMessage(iter->first, message,
|
||||||
message->getSender());
|
message->getSender());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unlockMutex();
|
unlockMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t EventManager::registerListener(MessageQueueId_t listener,
|
ReturnValue_t EventManager::registerListener(MessageQueueId_t listener,
|
||||||
bool forwardAllButSelected) {
|
bool forwardAllButSelected) {
|
||||||
auto result = listenerList.insert(
|
auto result = listenerList.insert(
|
||||||
std::pair<MessageQueueId_t, EventMatchTree>(listener,
|
std::pair<MessageQueueId_t, EventMatchTree>(listener,
|
||||||
EventMatchTree(&factoryBackend, forwardAllButSelected)));
|
EventMatchTree(&factoryBackend, forwardAllButSelected)));
|
||||||
if (!result.second) {
|
if (!result.second) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t EventManager::subscribeToEvent(MessageQueueId_t listener,
|
ReturnValue_t EventManager::subscribeToEvent(MessageQueueId_t listener,
|
||||||
EventId_t event) {
|
EventId_t event) {
|
||||||
return subscribeToEventRange(listener, event);
|
return subscribeToEventRange(listener, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t EventManager::subscribeToAllEventsFrom(MessageQueueId_t listener,
|
ReturnValue_t EventManager::subscribeToAllEventsFrom(MessageQueueId_t listener,
|
||||||
object_id_t object) {
|
object_id_t object) {
|
||||||
return subscribeToEventRange(listener, 0, 0, true, object);
|
return subscribeToEventRange(listener, 0, 0, true, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t EventManager::subscribeToEventRange(MessageQueueId_t listener,
|
ReturnValue_t EventManager::subscribeToEventRange(MessageQueueId_t listener,
|
||||||
EventId_t idFrom, EventId_t idTo, bool idInverted,
|
EventId_t idFrom, EventId_t idTo, bool idInverted,
|
||||||
object_id_t reporterFrom, object_id_t reporterTo,
|
object_id_t reporterFrom, object_id_t reporterTo,
|
||||||
bool reporterInverted) {
|
bool reporterInverted) {
|
||||||
auto iter = listenerList.find(listener);
|
auto iter = listenerList.find(listener);
|
||||||
if (iter == listenerList.end()) {
|
if (iter == listenerList.end()) {
|
||||||
return LISTENER_NOT_FOUND;
|
return LISTENER_NOT_FOUND;
|
||||||
}
|
}
|
||||||
lockMutex();
|
lockMutex();
|
||||||
ReturnValue_t result = iter->second.addMatch(idFrom, idTo, idInverted,
|
ReturnValue_t result = iter->second.addMatch(idFrom, idTo, idInverted,
|
||||||
reporterFrom, reporterTo, reporterInverted);
|
reporterFrom, reporterTo, reporterInverted);
|
||||||
unlockMutex();
|
unlockMutex();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener,
|
ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener,
|
||||||
EventId_t idFrom, EventId_t idTo, bool idInverted,
|
EventId_t idFrom, EventId_t idTo, bool idInverted,
|
||||||
object_id_t reporterFrom, object_id_t reporterTo,
|
object_id_t reporterFrom, object_id_t reporterTo,
|
||||||
bool reporterInverted) {
|
bool reporterInverted) {
|
||||||
auto iter = listenerList.find(listener);
|
auto iter = listenerList.find(listener);
|
||||||
if (iter == listenerList.end()) {
|
if (iter == listenerList.end()) {
|
||||||
return LISTENER_NOT_FOUND;
|
return LISTENER_NOT_FOUND;
|
||||||
}
|
}
|
||||||
lockMutex();
|
lockMutex();
|
||||||
ReturnValue_t result = iter->second.removeMatch(idFrom, idTo, idInverted,
|
ReturnValue_t result = iter->second.removeMatch(idFrom, idTo, idInverted,
|
||||||
reporterFrom, reporterTo, reporterInverted);
|
reporterFrom, reporterTo, reporterInverted);
|
||||||
unlockMutex();
|
unlockMutex();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::lockMutex() {
|
void EventManager::lockMutex() {
|
||||||
mutex->lockMutex(timeoutType, timeoutMs);
|
mutex->lockMutex(timeoutType, timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::unlockMutex() {
|
void EventManager::unlockMutex() {
|
||||||
mutex->unlockMutex();
|
mutex->unlockMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::setMutexTimeout(MutexIF::TimeoutType timeoutType,
|
void EventManager::setMutexTimeout(MutexIF::TimeoutType timeoutType,
|
||||||
uint32_t timeoutMs) {
|
uint32_t timeoutMs) {
|
||||||
this->timeoutType = timeoutType;
|
this->timeoutType = timeoutType;
|
||||||
this->timeoutMs = timeoutMs;
|
this->timeoutMs = timeoutMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||||
@ -157,7 +157,7 @@ void EventManager::printUtility(sif::OutputTypes printType, EventMessage *messag
|
|||||||
message->getReporter() << std::setfill(' ') << std::dec;
|
message->getReporter() << std::setfill(' ') << std::dec;
|
||||||
}
|
}
|
||||||
sif::info << " reported event with ID " << message->getEventId() << std::endl;
|
sif::info << " reported event with ID " << message->getEventId() << std::endl;
|
||||||
sif::debug << translateEvents(message->getEvent()) << " | " <<std::hex << "P1 Hex: 0x" <<
|
sif::info << translateEvents(message->getEvent()) << " | " <<std::hex << "P1 Hex: 0x" <<
|
||||||
message->getParameter1() << " | P1 Dec: " << std::dec << message->getParameter1() <<
|
message->getParameter1() << " | P1 Dec: " << std::dec << message->getParameter1() <<
|
||||||
std::hex << " | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " <<
|
std::hex << " | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " <<
|
||||||
std::dec << message->getParameter2() << std::endl;
|
std::dec << message->getParameter2() << std::endl;
|
||||||
@ -170,9 +170,10 @@ void EventManager::printUtility(sif::OutputTypes printType, EventMessage *messag
|
|||||||
sif::printInfo("Event Manager: Reporter ID 0x%08x reported event with ID %d\n",
|
sif::printInfo("Event Manager: Reporter ID 0x%08x reported event with ID %d\n",
|
||||||
message->getReporter(), message->getEventId());
|
message->getReporter(), message->getEventId());
|
||||||
}
|
}
|
||||||
sif::printInfo("P1 Hex: 0x%x | P1 Dec: %d | P2 Hex: 0x%x | P2 Dec: %d\n",
|
|
||||||
message->getParameter1(), message->getParameter1(),
|
sif::printInfo("%s | P1 Hex: 0x%x | P1 Dec: %d | P2 Hex: 0x%x | P2 Dec: %d\n",
|
||||||
message->getParameter2(), message->getParameter2());
|
translateEvents(message->getEvent()), message->getParameter1(),
|
||||||
|
message->getParameter1(), message->getParameter2(), message->getParameter2());
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user