2022-08-01 11:00:36 +02:00
|
|
|
#include "fsfw/tcdistribution/TcDistributorBase.h"
|
2022-08-01 11:05:46 +02:00
|
|
|
|
|
|
|
#include "fsfw/ipc/QueueFactory.h"
|
2021-07-13 20:22:54 +02:00
|
|
|
#include "fsfw/tmtcservices/TmTcMessage.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2022-08-01 11:00:36 +02:00
|
|
|
TcDistributorBase::TcDistributorBase(object_id_t objectId) : SystemObject(objectId) {
|
2022-02-02 10:29:30 +01:00
|
|
|
tcQueue = QueueFactory::instance()->createMessageQueue(DISTRIBUTER_MAX_PACKETS);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
2022-08-01 11:00:36 +02:00
|
|
|
TcDistributorBase::~TcDistributorBase() { QueueFactory::instance()->deleteMessageQueue(tcQueue); }
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2022-08-01 11:00:36 +02:00
|
|
|
ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) {
|
2022-07-27 17:00:43 +02:00
|
|
|
ReturnValue_t status;
|
2022-02-02 10:29:30 +01:00
|
|
|
for (status = tcQueue->receiveMessage(¤tMessage); status == RETURN_OK;
|
|
|
|
status = tcQueue->receiveMessage(¤tMessage)) {
|
|
|
|
status = handlePacket();
|
|
|
|
}
|
|
|
|
if (status == MessageQueueIF::EMPTY) {
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
2022-07-27 17:00:43 +02:00
|
|
|
return status;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
2022-08-01 11:00:36 +02:00
|
|
|
ReturnValue_t TcDistributorBase::handlePacket() {
|
|
|
|
MessageQueueId_t destId;
|
|
|
|
ReturnValue_t result = selectDestination(destId);
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return result;
|
2022-02-02 10:29:30 +01:00
|
|
|
}
|
2022-08-01 11:00:36 +02:00
|
|
|
result = tcQueue->sendMessage(destId, ¤tMessage);
|
2022-07-27 17:00:43 +02:00
|
|
|
return callbackAfterSending(result);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
2022-08-01 11:00:36 +02:00
|
|
|
ReturnValue_t TcDistributorBase::callbackAfterSending(ReturnValue_t queueStatus) {
|
|
|
|
return RETURN_OK;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|