| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title ApidManager.hpp | ||
| 3 | // \author thomas-bc | ||
| 4 | // \brief hpp file for ApidManager component implementation class | ||
| 5 | // ====================================================================== | ||
| 6 | |||
| 7 | #ifndef Svc_Ccsds_ApidManager_HPP | ||
| 8 | #define Svc_Ccsds_ApidManager_HPP | ||
| 9 | |||
| 10 | #include "Fw/Com/ComPacket.hpp" | ||
| 11 | #include "Fw/DataStructures/ArrayMap.hpp" | ||
| 12 | #include "Svc/Ccsds/ApidManager/ApidManagerComponentAc.hpp" | ||
| 13 | |||
| 14 | namespace Svc { | ||
| 15 | |||
| 16 | namespace Ccsds { | ||
| 17 | |||
| 18 | static_assert(ComCfg::Apid::SPP_IDLE_PACKET == 0x07FF, | ||
| 19 | "SPP_IDLE_PACKET must exist and equal 0x07FF (as specified by standard)"); | ||
| 20 | static_assert(ComCfg::Apid::INVALID_UNINITIALIZED == 0x0800, | ||
| 21 | "Invalid APID must be 0x0800 (11 bits values allow 0-2047)"); | ||
| 22 | static_assert(ComCfg::Apid::FW_PACKET_COMMAND == Fw::ComPacketType::FW_PACKET_COMMAND, | ||
| 23 | "APID FW_PACKET_COMMAND must exist, used by the Framework"); | ||
| 24 | static_assert(ComCfg::Apid::FW_PACKET_TELEM == Fw::ComPacketType::FW_PACKET_TELEM, | ||
| 25 | "APID FW_PACKET_TELEM must exist, used by the Framework"); | ||
| 26 | static_assert(ComCfg::Apid::FW_PACKET_LOG == Fw::ComPacketType::FW_PACKET_LOG, | ||
| 27 | "APID FW_PACKET_LOG must exist, used by the Framework"); | ||
| 28 | static_assert(ComCfg::Apid::FW_PACKET_FILE == Fw::ComPacketType::FW_PACKET_FILE, | ||
| 29 | "APID FW_PACKET_FILE must exist, used by the Framework"); | ||
| 30 | static_assert(ComCfg::Apid::FW_PACKET_PACKETIZED_TLM == Fw::ComPacketType::FW_PACKET_PACKETIZED_TLM, | ||
| 31 | "APID FW_PACKET_PACKETIZED_TLM must exist, used by the Framework"); | ||
| 32 | static_assert(ComCfg::Apid::FW_PACKET_UNKNOWN == Fw::ComPacketType::FW_PACKET_UNKNOWN, | ||
| 33 | "APID FW_PACKET_UNKNOWN must exist, used by the Framework"); | ||
| 34 | |||
| 35 | class ApidManager final : public ApidManagerComponentBase { | ||
| 36 | friend class ApidManagerTester; //!< Friend class for testing | ||
| 37 | |||
| 38 | public: | ||
| 39 | static constexpr U16 MAX_TRACKED_APIDS = ComCfg::Apid::NUM_CONSTANTS; | ||
| 40 | // ---------------------------------------------------------------------- | ||
| 41 | // Component construction and destruction | ||
| 42 | // ---------------------------------------------------------------------- | ||
| 43 | |||
| 44 | //! Construct ApidManager object | ||
| 45 | ApidManager(const char* const compName //!< The component name | ||
| 46 | ); | ||
| 47 | |||
| 48 | //! Destroy ApidManager object | ||
| 49 | ✗ | ~ApidManager() = default; | |
| 50 | |||
| 51 | private: | ||
| 52 | // ---------------------------------------------------------------------- | ||
| 53 | // Handler implementations for typed input ports | ||
| 54 | // ---------------------------------------------------------------------- | ||
| 55 | |||
| 56 | //! Handler implementation for validateApidSeqCountIn | ||
| 57 | U16 validateApidSeqCountIn_handler(FwIndexType portNum, //!< The port number | ||
| 58 | const ComCfg::Apid& apid, | ||
| 59 | U16 seqCount) override; | ||
| 60 | |||
| 61 | //! Handler implementation for validateApidSeqCountIn | ||
| 62 | U16 getApidSeqCountIn_handler(FwIndexType portNum, //!< The port number | ||
| 63 | const ComCfg::Apid& apid, | ||
| 64 | U16 seqCount) override; | ||
| 65 | |||
| 66 | private: | ||
| 67 | // ---------------------------------------------------------------------- | ||
| 68 | // Helpers | ||
| 69 | // ---------------------------------------------------------------------- | ||
| 70 | //! Get the sequence count for a given APID and increment it for the next. | ||
| 71 | //! Wraps around at 14 bits. Asserts if the APID cannot be inserted in the table. | ||
| 72 | U16 getAndIncrementSeqCount(ComCfg::Apid::T apid); | ||
| 73 | |||
| 74 | //! Helper function for wrapping around at 14 bits when calculating the next sequence count | ||
| 75 | U16 calculateNextSeqCount(const U16 seqCount) const; | ||
| 76 | |||
| 77 | //! ArrayMap with internal storage | ||
| 78 | //! Key: APID | ||
| 79 | //! Value: sequence count | ||
| 80 | //! Capacity: MAX_TRACKED_APIDS | ||
| 81 | using MapType = Fw::ArrayMap<ComCfg::Apid::T, U16, MAX_TRACKED_APIDS>; | ||
| 82 | |||
| 83 | private: | ||
| 84 | // ---------------------------------------------------------------------- | ||
| 85 | // Member variables | ||
| 86 | // ---------------------------------------------------------------------- | ||
| 87 | MapType m_apidSequences; | ||
| 88 | }; | ||
| 89 | |||
| 90 | } // namespace Ccsds | ||
| 91 | } // namespace Svc | ||
| 92 | |||
| 93 | #endif | ||
| 94 |