2022-02-16 18:15:06 +01:00
|
|
|
#include "EventManagerMock.h"
|
|
|
|
|
|
|
|
#include <fsfw/ipc/QueueFactory.h>
|
|
|
|
|
|
|
|
EventManagerMock::EventManagerMock() : EventManager(objects::EVENT_MANAGER) {}
|
|
|
|
|
|
|
|
ReturnValue_t EventManagerMock::performOperation(uint8_t opCode) {
|
2022-08-24 17:27:47 +02:00
|
|
|
ReturnValue_t result = returnvalue::OK;
|
|
|
|
while (result == returnvalue::OK) {
|
2022-02-16 18:15:06 +01:00
|
|
|
EventMessage message;
|
|
|
|
result = eventReportQueue->receiveMessage(&message);
|
2022-08-24 17:27:47 +02:00
|
|
|
if (result == returnvalue::OK) {
|
2022-02-16 18:15:06 +01:00
|
|
|
notifyListeners(&message);
|
2022-02-17 15:49:39 +01:00
|
|
|
eventList.emplace_back(message);
|
2022-02-16 18:15:06 +01:00
|
|
|
}
|
|
|
|
}
|
2022-08-24 17:27:47 +02:00
|
|
|
return returnvalue::OK;
|
2022-02-17 15:49:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const std::list<EventMessage>* EventManagerMock::getEventList() {
|
|
|
|
// call performOperation() to get all events still in the message Queue into the list
|
|
|
|
this->performOperation(0);
|
|
|
|
return &eventList;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventManagerMock::clearEventList() { // call performOperation() to get all events still in the
|
|
|
|
// message Queue into the list
|
|
|
|
this->performOperation(0);
|
|
|
|
eventList.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EventManagerMock::isEventInEventList(object_id_t object, Event event) {
|
|
|
|
return isEventInEventList(object, event::getEventId(event));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EventManagerMock::isEventInEventList(object_id_t object, EventId_t eventId) {
|
|
|
|
// call performOperation() to get all events still in the message Queue into the list
|
|
|
|
this->performOperation(0);
|
|
|
|
for (auto iter = eventList.begin(); iter != eventList.end(); iter++) {
|
|
|
|
if ((iter->getReporter() == object) && (iter->getEventId() == eventId)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EventManagerMock::isEventInEventList(object_id_t object, Event event, uint32_t parameter1,
|
|
|
|
uint32_t parameter2) {
|
|
|
|
return isEventInEventList(object, event::getEventId(event), parameter1, parameter2);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EventManagerMock::isEventInEventList(object_id_t object, EventId_t eventId,
|
|
|
|
uint32_t parameter1, uint32_t parameter2) {
|
|
|
|
// call performOperation() to get all events still in the message Queue into the list
|
|
|
|
this->performOperation(0);
|
|
|
|
for (auto iter = eventList.begin(); iter != eventList.end(); iter++) {
|
|
|
|
if ((iter->getReporter() == object) && (iter->getEventId() == eventId) &&
|
|
|
|
(iter->getParameter1() == parameter1) && (iter->getParameter2() == parameter2)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2022-02-16 18:15:06 +01:00
|
|
|
}
|