From d0fc360697e0fae7ccb4b827b8bc3d0398c342bc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 20 May 2022 08:34:14 +0200 Subject: [PATCH] apply afmt --- src/fsfw/objectmanager/frameworkObjects.h | 1 + src/fsfw/pus/Service11TelecommandScheduling.h | 48 +++++++------------ .../pus/Service11TelecommandScheduling.tpp | 48 +++++++++++-------- 3 files changed, 44 insertions(+), 53 deletions(-) diff --git a/src/fsfw/objectmanager/frameworkObjects.h b/src/fsfw/objectmanager/frameworkObjects.h index cc233c0f..cddc6ba2 100644 --- a/src/fsfw/objectmanager/frameworkObjects.h +++ b/src/fsfw/objectmanager/frameworkObjects.h @@ -14,6 +14,7 @@ enum framework_objects : object_id_t { PUS_SERVICE_5_EVENT_REPORTING = 0x53000005, PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008, PUS_SERVICE_9_TIME_MGMT = 0x53000009, + PUS_SERVICE_11_TC_SCHEDULER = 0x53000011, PUS_SERVICE_17_TEST = 0x53000017, PUS_SERVICE_20_PARAMETERS = 0x53000020, PUS_SERVICE_200_MODE_MGMT = 0x53000200, diff --git a/src/fsfw/pus/Service11TelecommandScheduling.h b/src/fsfw/pus/Service11TelecommandScheduling.h index 5e446b07..9a8be603 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.h +++ b/src/fsfw/pus/Service11TelecommandScheduling.h @@ -45,19 +45,17 @@ class Service11TelecommandScheduling final : public PusServiceBase { HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); // The types of PUS-11 subservices - enum Subservice : uint8_t { - ENABLE_SCHEDULING = 1, - DISABLE_SCHEDULING = 2, - RESET_SCHEDULING = 3, - INSERT_ACTIVITY = 4, - DELETE_ACTIVITY = 5, - FILTER_DELETE_ACTIVITY = 6, - TIMESHIFT_ACTIVITY = 7, - FILTER_TIMESHIFT_ACTIVITY = 8, - DETAIL_REPORT = 9, - TIMEBASE_SCHEDULE_DETAIL_REPORT = 10, - TIMESHIFT_ALL_SCHEDULE_ACTIVITIES = 15 - }; + enum [[maybe_unused]] Subservice : uint8_t{ENABLE_SCHEDULING = 1, + DISABLE_SCHEDULING = 2, + RESET_SCHEDULING = 3, + INSERT_ACTIVITY = 4, + DELETE_ACTIVITY = 5, + FILTER_DELETE_ACTIVITY = 6, + TIMESHIFT_ACTIVITY = 7, + FILTER_TIMESHIFT_ACTIVITY = 8, + DETAIL_REPORT = 9, + TIMEBASE_SCHEDULE_DETAIL_REPORT = 10, + TIMESHIFT_ALL_SCHEDULE_ACTIVITIES = 15}; // The types of time windows for TC[11,6] and TC[11,8], as defined in ECSS-E-ST-70-41C, // requirement 8.11.3c (p. 507) @@ -73,7 +71,7 @@ class Service11TelecommandScheduling final : public PusServiceBase { uint16_t releaseTimeMarginSeconds = DEFAULT_RELEASE_TIME_MARGIN, bool debugMode = false); - ~Service11TelecommandScheduling(); + ~Service11TelecommandScheduling() override; /** PusServiceBase overrides */ ReturnValue_t handleRequest(uint8_t subservice) override; @@ -82,8 +80,8 @@ class Service11TelecommandScheduling final : public PusServiceBase { private: struct TelecommandStruct { - uint64_t requestId; - uint32_t seconds; + uint64_t requestId{}; + uint32_t seconds{}; store_address_t storeAddr; // uint16 }; @@ -92,9 +90,6 @@ class Service11TelecommandScheduling final : public PusServiceBase { // minimum release time offset to insert into schedule const uint16_t RELEASE_TIME_MARGIN_SECONDS = 5; - // the maximum amount of stored TCs is defined here - static constexpr uint16_t MAX_STORED_TELECOMMANDS = 500; - bool debugMode = false; StorageManagerIF* tcStore = nullptr; AcceptsTelecommandsIF* tcRecipient = nullptr; @@ -139,17 +134,6 @@ class Service11TelecommandScheduling final : public PusServiceBase { */ ReturnValue_t doFilterTimeshiftActivity(const uint8_t* data, size_t size); - /** - * @brief Deserializes a generic type from a payload buffer by using the FSFW - * SerializeAdapter Interface. - * @param output Output to be deserialized - * @param buf Payload buffer (application data) - * @param bufsize Remaining size of payload buffer (application data size) - * @return RETURN_OK if successful - */ - template - ReturnValue_t deserializeViaFsfwInterface(T& output, const uint8_t* buf, size_t bufsize); - /** * @brief Extracts the Request ID from the Application Data of a TC by utilizing a ctor of the * class TcPacketPus. @@ -177,7 +161,7 @@ class Service11TelecommandScheduling final : public PusServiceBase { * @param ssc Source Sequence Count * @return Request ID */ - uint64_t buildRequestId(uint32_t sourceId, uint16_t apid, uint16_t ssc) const; + [[nodiscard]] uint64_t buildRequestId(uint32_t sourceId, uint16_t apid, uint16_t ssc) const; /** * @brief Gets the filter range for filter TCs from a data packet @@ -194,7 +178,7 @@ class Service11TelecommandScheduling final : public PusServiceBase { /** * @brief Prints content of multimap. Use for simple debugging only. */ - void debugPrintMultimapContent(void) const; + void debugPrintMultimapContent() const; }; #include "Service11TelecommandScheduling.tpp" diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index c72e6631..41c36200 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -1,11 +1,12 @@ #pragma once -#include -#include -#include - #include +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serialize/SerializeAdapter.h" +#include "fsfw/serviceinterface.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" + static constexpr auto DEF_END = SerializeIF::Endianness::BIG; template @@ -18,7 +19,7 @@ inline Service11TelecommandScheduling::Service11TelecommandScheduli tcRecipient(tcRecipient) {} template -inline Service11TelecommandScheduling::~Service11TelecommandScheduling() {} +inline Service11TelecommandScheduling::~Service11TelecommandScheduling() = default; template inline ReturnValue_t Service11TelecommandScheduling::handleRequest( @@ -404,7 +405,6 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterTimesh // and then insert it again as new entry telecommandMap.insert(std::make_pair(tempKey, tempTc)); shiftedItemsCount++; - continue; } if (debugMode) { @@ -463,9 +463,9 @@ template inline uint64_t Service11TelecommandScheduling::buildRequestId(uint32_t sourceId, uint16_t apid, uint16_t ssc) const { - uint64_t sourceId64 = static_cast(sourceId); - uint64_t apid64 = static_cast(apid); - uint64_t ssc64 = static_cast(ssc); + auto sourceId64 = static_cast(sourceId); + auto apid64 = static_cast(apid); + auto ssc64 = static_cast(ssc); return (sourceId64 << 32) | (apid64 << 16) | ssc64; } @@ -483,7 +483,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr if (typeRaw > 3) { return INVALID_TYPE_TIME_WINDOW; } - TypeOfTimeWindow type = static_cast(typeRaw); + auto type = static_cast(typeRaw); // we now have the type of delete activity - so now we set the range to delete, // according to the type of time window. @@ -558,7 +558,10 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr // additional security check, this should never be true if (itBegin->first > itEnd->first) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 +#else sif::printError("11::GetMapFilterFromData: itBegin > itEnd\n"); +#endif return RETURN_FAILED; } @@ -580,19 +583,22 @@ inline ReturnValue_t Service11TelecommandScheduling::handleInvalidD } template -inline void Service11TelecommandScheduling::debugPrintMultimapContent(void) const { +inline void Service11TelecommandScheduling::debugPrintMultimapContent() const { + for (const auto &dit : telecommandMap) { #if FSFW_DISABLE_PRINTOUT == 0 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content" - << std::endl; - sif::debug << "[" << dit->first << "]: Request ID: " << dit->second.requestId << " | " - << "Store Address: " << dit->second.storeAddr << std::endl; + sif::debug << "Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content" + << std::endl; + sif::debug << "[" << dit.first << "]: Request ID: " << dit.second.requestId << " | " + << "Store Address: " << dit.second.storeAddr.raw << std::endl; #else - sif::printDebug("Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content\n"); - for (auto dit = telecommandMap.begin(); dit != telecommandMap.end(); ++dit) { - sif::printDebug("[%d]: Request ID: %d | Store Address: %d\n", dit->first, - dit->second.requestId, dit->second.storeAddr); + sif::printDebug( + "Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content\n"); + for (auto dit = telecommandMap.begin(); dit != telecommandMap.end(); ++dit) { + sif::printDebug("[%d]: Request ID: %d | Store Address: %d\n", dit->first, + dit->second.requestId, dit->second.storeAddr); + } +#endif +#endif } -#endif -#endif }