replace some API components with references

This commit is contained in:
Robin Müller 2022-07-25 10:50:52 +02:00
parent 63ee88af17
commit 832367fb30
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
12 changed files with 30 additions and 20 deletions

View File

@ -7,7 +7,7 @@
Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId) Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId)
: PusServiceBase(objectId, apid, serviceId), : PusServiceBase(objectId, apid, serviceId),
storeHelper(apid, nullptr), storeHelper(apid),
sendHelper(nullptr), sendHelper(nullptr),
packetSubCounter(0) {} packetSubCounter(0) {}

View File

@ -16,7 +16,7 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t obj
serviceId(serviceId), serviceId(serviceId),
targetDestination(targetDestination), targetDestination(targetDestination),
sendHelper(nullptr), sendHelper(nullptr),
storeHelper(apid, nullptr) { storeHelper(apid) {
tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
} }

View File

@ -12,7 +12,7 @@ Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t ap
uint32_t messageQueueDepth) uint32_t messageQueueDepth)
: PusServiceBase(objectId, apid, serviceId), : PusServiceBase(objectId, apid, serviceId),
sendHelper(nullptr), sendHelper(nullptr),
storeHelper(apid, nullptr), storeHelper(apid),
maxNumberReportsPerCycle(maxNumberReportsPerCycle) { maxNumberReportsPerCycle(maxNumberReportsPerCycle) {
eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
} }

View File

@ -26,8 +26,8 @@ uint8_t PusTmCreator::getSubService() const { return pusParams.secHeader.subserv
PusTmParams& PusTmCreator::getParams() { return pusParams; } PusTmParams& PusTmCreator::getParams() { return pusParams; }
void PusTmCreator::setTimeStamper(TimeStamperIF* timeStamper_) { void PusTmCreator::setTimeStamper(TimeStamperIF& timeStamper_) {
pusParams.secHeader.timeStamper = timeStamper_; pusParams.secHeader.timeStamper = &timeStamper_;
updateSpLengthField(); updateSpLengthField();
} }

View File

@ -45,7 +45,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF
PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams); PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams);
~PusTmCreator() override = default; ~PusTmCreator() override = default;
void setTimeStamper(TimeStamperIF* timeStamper); void setTimeStamper(TimeStamperIF& timeStamper);
SpacePacketParams& getSpParams(); SpacePacketParams& getSpParams();
void setApid(uint16_t apid); void setApid(uint16_t apid);
void setDestId(uint16_t destId); void setDestId(uint16_t destId);

View File

@ -20,7 +20,7 @@ CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t a
apid(apid), apid(apid),
service(service), service(service),
timeoutSeconds(commandTimeoutSeconds), timeoutSeconds(commandTimeoutSeconds),
tmStoreHelper(apid, nullptr), tmStoreHelper(apid),
tmSendHelper(nullptr), tmSendHelper(nullptr),
commandMap(numberOfParallelCommands) { commandMap(numberOfParallelCommands) {
commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth);

View File

@ -2,16 +2,21 @@
#include "TmTcMessage.h" #include "TmTcMessage.h"
TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore, TmStoreHelper::TmStoreHelper(uint16_t defaultApid): tmStore(nullptr) {
TimeStamperIF* timeStamper) creator.setApid(defaultApid);
: tmStore(tmStore) { }
TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore) : tmStore(&tmStore) {
creator.setApid(defaultApid);
}
TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore,
TimeStamperIF& timeStamper)
: tmStore(&tmStore) {
creator.setApid(defaultApid); creator.setApid(defaultApid);
creator.setTimeStamper(timeStamper); creator.setTimeStamper(timeStamper);
} }
TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore) : tmStore(tmStore) {
creator.setApid(defaultApid);
}
ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, uint16_t counter) { ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, uint16_t counter) {
PusTmParams& params = creator.getParams(); PusTmParams& params = creator.getParams();
@ -48,7 +53,7 @@ ReturnValue_t TmStoreHelper::addPacketToStore() {
SerializeIF::Endianness::NETWORK); SerializeIF::Endianness::NETWORK);
} }
void TmStoreHelper::setTimeStamper(TimeStamperIF* timeStamper_) { void TmStoreHelper::setTimeStamper(TimeStamperIF& timeStamper_) {
creator.setTimeStamper(timeStamper_); creator.setTimeStamper(timeStamper_);
} }

View File

@ -9,12 +9,13 @@
class TmStoreHelper { class TmStoreHelper {
public: public:
explicit TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore); explicit TmStoreHelper(uint16_t defaultApid);
TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore, TimeStamperIF* timeStamper); TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore);
TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, TimeStamperIF& timeStamper);
ReturnValue_t preparePacket(uint8_t service, uint8_t subservice, uint16_t counter); ReturnValue_t preparePacket(uint8_t service, uint8_t subservice, uint16_t counter);
void setTimeStamper(TimeStamperIF* timeStamper); void setTimeStamper(TimeStamperIF& timeStamper);
[[nodiscard]] const store_address_t& getCurrentAddr() const; [[nodiscard]] const store_address_t& getCurrentAddr() const;
void setSourceDataRaw(const uint8_t* data, size_t len); void setSourceDataRaw(const uint8_t* data, size_t len);
void setSourceDataSerializable(SerializeIF* serializable); void setSourceDataSerializable(SerializeIF* serializable);

View File

@ -4,6 +4,7 @@
#include <array> #include <array>
#include "fsfw/timemanager/TimeStamperIF.h" #include "fsfw/timemanager/TimeStamperIF.h"
#include "fsfw/timemanager/TimeReaderIF.h"
class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF {
public: public:
@ -74,7 +75,7 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF {
serFailRetval = HasReturnvaluesIF::RETURN_FAILED; serFailRetval = HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override { ReturnValue_t readTimeStamp(const uint8_t* buffer, size_t maxSize) override {
return deSerialize(&buffer, &maxSize, SerializeIF::Endianness::NETWORK); return deSerialize(&buffer, &maxSize, SerializeIF::Endianness::NETWORK);
} }
size_t getTimestampLen() override { return getSerializedSize(); } size_t getTimestampLen() override { return getSerializedSize(); }

View File

@ -129,7 +129,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") {
// As specified in standard, the data length fields is the total size of the packet without // As specified in standard, the data length fields is the total size of the packet without
// the primary header minus 1 // the primary header minus 1
REQUIRE(creatorFromEmptyCtor.getPacketDataLen() == 8); REQUIRE(creatorFromEmptyCtor.getPacketDataLen() == 8);
creatorFromEmptyCtor.setTimeStamper(&timeStamper); creatorFromEmptyCtor.setTimeStamper(timeStamper);
REQUIRE(creatorFromEmptyCtor.getFullPacketLen() == 22); REQUIRE(creatorFromEmptyCtor.getFullPacketLen() == 22);
REQUIRE(creatorFromEmptyCtor.getPacketDataLen() == 15); REQUIRE(creatorFromEmptyCtor.getPacketDataLen() == 15);
} }

View File

@ -1,2 +1,3 @@
target_sources(${FSFW_TEST_TGT} PRIVATE target_sources(${FSFW_TEST_TGT} PRIVATE
testStoreHelper.cpp
) )

View File

@ -2,9 +2,11 @@
#include "fsfw/storagemanager/LocalPool.h" #include "fsfw/storagemanager/LocalPool.h"
#include "fsfw/tmtcservices/TmStoreHelper.h" #include "fsfw/tmtcservices/TmStoreHelper.h"
#include "mocks/CdsShortTimestamperMock.h"
TEST_CASE("TM Store Helper", "[tm-store-helper]") { TEST_CASE("TM Store Helper", "[tm-store-helper]") {
auto timeStamper = CdsShortTimestamperMock();
LocalPool::LocalPoolConfig cfg = {{10, 32}, {5, 64}}; LocalPool::LocalPoolConfig cfg = {{10, 32}, {5, 64}};
LocalPool pool(objects::NO_OBJECT, cfg); LocalPool pool(objects::NO_OBJECT, cfg);
auto storeHelper = TmStoreHelper(2, &pool); auto storeHelper = TmStoreHelper(2, pool, timeStamper);
} }