From 4ae9f5c74622ded292dd9f5e8ad130fb2e8c7a2f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Sep 2022 17:40:06 +0200 Subject: [PATCH] retval refactoring --- config/commonPollingSequenceFactory.cpp | 12 ++++----- example/controller/FsfwTestController.cpp | 16 +++++------- example/test/FsfwExampleTask.cpp | 32 +++++++++++------------ example/test/FsfwReaderTask.cpp | 6 ++--- example/test/FsfwTestTask.cpp | 2 +- example/test/MutexExample.cpp | 8 +++--- example/utility/TmFunnel.cpp | 17 ++++++------ 7 files changed, 45 insertions(+), 48 deletions(-) diff --git a/config/commonPollingSequenceFactory.cpp b/config/commonPollingSequenceFactory.cpp index aea1633..632df0d 100644 --- a/config/commonPollingSequenceFactory.cpp +++ b/config/commonPollingSequenceFactory.cpp @@ -24,15 +24,15 @@ ReturnValue_t pst::pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TEST_DUMMY_2, length * 0.5, FsfwExampleTask::OpCodes::DELAY_SHORT); thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0.5, FsfwExampleTask::OpCodes::DELAY_SHORT); - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() == returnvalue::OK) { + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "pst::pollingSequenceInitFunction: Initialization errors!" << std::endl; #else sif::printError("pst::pollingSequenceInitFunction: Initialization errors!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::OK; } } @@ -54,14 +54,14 @@ ReturnValue_t pst::pollingSequenceDevices(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.8 * length, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.8 * length, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() == returnvalue::OK) { + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "pst::pollingSequenceTestFunction: Initialization errors!" << std::endl; #else sif::printError("pst::pollingSequenceTestFunction: Initialization errors!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::OK; } } diff --git a/example/controller/FsfwTestController.cpp b/example/controller/FsfwTestController.cpp index 6c915dc..c2c89c9 100644 --- a/example/controller/FsfwTestController.cpp +++ b/example/controller/FsfwTestController.cpp @@ -10,15 +10,15 @@ FsfwTestController::FsfwTestController(object_id_t objectId, object_id_t device0 deviceDataset0(device0), deviceDataset1(device1) {} -FsfwTestController::~FsfwTestController() {} +FsfwTestController::~FsfwTestController() = default; ReturnValue_t FsfwTestController::handleCommandMessage(CommandMessage *message) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FsfwTestController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FsfwTestController::performControlOperation() { @@ -64,11 +64,10 @@ void FsfwTestController::performControlOperation() { ReturnValue_t FsfwTestController::initializeAfterTaskCreation() { namespace td = testdevice; ReturnValue_t result = TestController::initializeAfterTaskCreation(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - HasLocalDataPoolIF *device0 = - ObjectManager::instance()->get(deviceDataset0.getCreatorObjectId()); + auto *device0 = ObjectManager::instance()->get(deviceDataset0.getCreatorObjectId()); if (device0 == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 0 " @@ -90,8 +89,7 @@ ReturnValue_t FsfwTestController::initializeAfterTaskCreation() { getCommandQueue(), false); } - HasLocalDataPoolIF *device1 = - ObjectManager::instance()->get(deviceDataset0.getCreatorObjectId()); + auto *device1 = ObjectManager::instance()->get(deviceDataset0.getCreatorObjectId()); if (device1 == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 1 " @@ -119,7 +117,7 @@ LocalPoolDataSetBase *FsfwTestController::getDataSetHandle(sid_t sid) { return n ReturnValue_t FsfwTestController::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FsfwTestController::handleChangedDataset(sid_t sid, store_address_t storeId, diff --git a/example/test/FsfwExampleTask.cpp b/example/test/FsfwExampleTask.cpp index edfaf07..42fe566 100644 --- a/example/test/FsfwExampleTask.cpp +++ b/example/test/FsfwExampleTask.cpp @@ -27,13 +27,13 @@ ReturnValue_t FsfwExampleTask::performOperation(uint8_t operationCode) { // TODO: Move this to new test controller? ReturnValue_t result = performMonitoringDemo(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (operationCode == OpCodes::SEND_RAND_NUM) { result = performSendOperation(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -80,14 +80,14 @@ object_id_t FsfwExampleTask::getSender() { ReturnValue_t FsfwExampleTask::initialize() { // Get the dataset of the sender. Will be cached for later checks. object_id_t sender = getSender(); - HasLocalDataPoolIF *senderIF = ObjectManager::instance()->get(sender); + auto *senderIF = ObjectManager::instance()->get(sender); if (senderIF == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FsfwDemoTask::initialize: Sender object invalid!" << std::endl; #else sif::printError("FsfwDemoTask::initialize: Sender object invalid!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // we need a private copy of the previous dataset.. or we use the shared @@ -99,7 +99,7 @@ ReturnValue_t FsfwExampleTask::initialize() { #else sif::printError("FsfwDemoTask::initialize: Sender dataset invalid!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return poolManager.initialize(commandQueue); } @@ -122,12 +122,12 @@ ReturnValue_t FsfwExampleTask::initializeLocalDataPool(localpool::DataPool &loca LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE, new PoolEntry({0})); localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE_LIMIT, new PoolEntry({0})); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FsfwExampleTask::performMonitoringDemo() { ReturnValue_t result = demoSet.variableLimit.read(MutexIF::TimeoutType::WAITING, 20); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { /* Configuration error */ #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DummyObject::performOperation: Could not read variableLimit!" << std::endl; @@ -144,12 +144,12 @@ ReturnValue_t FsfwExampleTask::performMonitoringDemo() { demoSet.variableLimit.commit(20); monitor.check(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FsfwExampleTask::performSendOperation() { object_id_t nextRecipient = getNextRecipient(); - FsfwExampleTask *target = ObjectManager::instance()->get(nextRecipient); + auto *target = ObjectManager::instance()->get(nextRecipient); if (target == nullptr) { /* Configuration error */ #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -157,7 +157,7 @@ ReturnValue_t FsfwExampleTask::performSendOperation() { #else sif::printError("DummyObject::performOperation: Next recipient does not exist!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint32_t randomNumber = rand() % 100; @@ -167,7 +167,7 @@ ReturnValue_t FsfwExampleTask::performSendOperation() { /* Send message using own message queue */ ReturnValue_t result = commandQueue->sendMessage(target->getMessageQueueId(), &message); - if (result != HasReturnvaluesIF::RETURN_OK && result != MessageQueueIF::FULL) { + if (result != returnvalue::OK && result != MessageQueueIF::FULL) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FsfwDemoTask::performSendOperation: Send failed with " << result << std::endl; #else @@ -178,7 +178,7 @@ ReturnValue_t FsfwExampleTask::performSendOperation() { /* Send message without via MessageQueueSenderIF */ result = MessageQueueSenderIF::sendMessage(target->getMessageQueueId(), &message, commandQueue->getId()); - if (result != HasReturnvaluesIF::RETURN_OK && result != MessageQueueIF::FULL) { + if (result != returnvalue::OK && result != MessageQueueIF::FULL) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FsfwDemoTask::performSendOperation: Send failed with " << result << std::endl; #else @@ -193,11 +193,11 @@ ReturnValue_t FsfwExampleTask::performSendOperation() { } ReturnValue_t FsfwExampleTask::performReceiveOperation() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; while (result != MessageQueueIF::EMPTY) { CommandMessage receivedMessage; result = commandQueue->receiveMessage(&receivedMessage); - if (result != HasReturnvaluesIF::RETURN_OK && result != MessageQueueIF::EMPTY) { + if (result != returnvalue::OK && result != MessageQueueIF::EMPTY) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Receive failed with " << result << std::endl; #endif @@ -213,11 +213,11 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() { #endif if (senderSet == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } result = senderSet->variableRead.read(MutexIF::TimeoutType::WAITING, 20); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (senderSet->variableRead.value != receivedMessage.getParameter()) { diff --git a/example/test/FsfwReaderTask.cpp b/example/test/FsfwReaderTask.cpp index f80b4f1..19bcc78 100644 --- a/example/test/FsfwReaderTask.cpp +++ b/example/test/FsfwReaderTask.cpp @@ -18,12 +18,12 @@ FsfwReaderTask::FsfwReaderTask(object_id_t objectId, bool enablePrintout) readSet.setReadCommitProtectionBehaviour(true); } -FsfwReaderTask::~FsfwReaderTask() {} +FsfwReaderTask::~FsfwReaderTask() = default; ReturnValue_t FsfwReaderTask::initializeAfterTaskCreation() { /* Give other task some time to set up local data pools. */ TaskFactory::delayTask(20); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FsfwReaderTask::performOperation(uint8_t operationCode) { @@ -51,5 +51,5 @@ ReturnValue_t FsfwReaderTask::performOperation(uint8_t operationCode) { if (variable1 and variable2 and variable3) { }; #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/example/test/FsfwTestTask.cpp b/example/test/FsfwTestTask.cpp index 71a2dcf..4167c0c 100644 --- a/example/test/FsfwTestTask.cpp +++ b/example/test/FsfwTestTask.cpp @@ -17,5 +17,5 @@ ReturnValue_t FsfwTestTask::performPeriodicAction() { if (periodicEvent) { triggerEvent(TEST_EVENT, 0x1234, 0x4321); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/example/test/MutexExample.cpp b/example/test/MutexExample.cpp index 8de182c..7501471 100644 --- a/example/test/MutexExample.cpp +++ b/example/test/MutexExample.cpp @@ -8,7 +8,7 @@ void MutexExample::example() { MutexIF *mutex2 = MutexFactory::instance()->createMutex(); ReturnValue_t result = mutex->lockMutex(MutexIF::TimeoutType::WAITING, 2 * 60 * 1000); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MutexExample::example: Lock Failed with " << result << std::endl; #else @@ -17,7 +17,7 @@ void MutexExample::example() { } result = mutex2->lockMutex(MutexIF::TimeoutType::BLOCKING); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MutexExample::example: Lock Failed with " << result << std::endl; #else @@ -26,7 +26,7 @@ void MutexExample::example() { } result = mutex->unlockMutex(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MutexExample::example: Unlock Failed with " << result << std::endl; #else @@ -35,7 +35,7 @@ void MutexExample::example() { } result = mutex2->unlockMutex(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MutexExample::example: Unlock Failed with " << result << std::endl; #else diff --git a/example/utility/TmFunnel.cpp b/example/utility/TmFunnel.cpp index 0dd0eb3..82dbec3 100644 --- a/example/utility/TmFunnel.cpp +++ b/example/utility/TmFunnel.cpp @@ -27,9 +27,9 @@ MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) { ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) { TmTcMessage currentMessage; ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); - while (status == HasReturnvaluesIF::RETURN_OK) { + while (status == returnvalue::OK) { status = handlePacket(¤tMessage); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { sif::warning << "TmFunnel packet handling failed" << std::endl; break; } @@ -37,7 +37,7 @@ ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) { } if (status == MessageQueueIF::EMPTY) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return status; } @@ -47,12 +47,12 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) { uint8_t *packetData = nullptr; size_t size = 0; ReturnValue_t result = tmPool->modifyData(message->getStorageId(), &packetData, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } PusTmZeroCopyWriter packet(timeReader, packetData, size); result = packet.parseDataWithoutCrcCheck(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } packet.setSequenceCount(sourceSequenceCount++); @@ -60,7 +60,7 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) { packet.updateErrorControl(); result = tmQueue->sendToDefault(message); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { tmPool->deleteData(message->getStorageId()); #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl; @@ -70,7 +70,7 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) { if (storageDestination != objects::NO_OBJECT) { result = storageQueue->sendToDefault(message); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { tmPool->deleteData(message->getStorageId()); #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmFunnel::handlePacket: Error sending to storage handler" << std::endl; @@ -93,8 +93,7 @@ ReturnValue_t TmFunnel::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - AcceptsTelemetryIF *tmTarget = - ObjectManager::instance()->get(downlinkDestination); + auto *tmTarget = ObjectManager::instance()->get(downlinkDestination); if (tmTarget == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl;