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)
: PusServiceBase(objectId, apid, serviceId),
storeHelper(apid, nullptr),
storeHelper(apid),
sendHelper(nullptr),
packetSubCounter(0) {}

View File

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

View File

@ -12,7 +12,7 @@ Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t ap
uint32_t messageQueueDepth)
: PusServiceBase(objectId, apid, serviceId),
sendHelper(nullptr),
storeHelper(apid, nullptr),
storeHelper(apid),
maxNumberReportsPerCycle(maxNumberReportsPerCycle) {
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; }
void PusTmCreator::setTimeStamper(TimeStamperIF* timeStamper_) {
pusParams.secHeader.timeStamper = timeStamper_;
void PusTmCreator::setTimeStamper(TimeStamperIF& timeStamper_) {
pusParams.secHeader.timeStamper = &timeStamper_;
updateSpLengthField();
}

View File

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

View File

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

View File

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

View File

@ -9,12 +9,13 @@
class TmStoreHelper {
public:
explicit TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore);
TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore, TimeStamperIF* timeStamper);
explicit TmStoreHelper(uint16_t defaultApid);
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);
void setTimeStamper(TimeStamperIF* timeStamper);
void setTimeStamper(TimeStamperIF& timeStamper);
[[nodiscard]] const store_address_t& getCurrentAddr() const;
void setSourceDataRaw(const uint8_t* data, size_t len);
void setSourceDataSerializable(SerializeIF* serializable);

View File

@ -4,6 +4,7 @@
#include <array>
#include "fsfw/timemanager/TimeStamperIF.h"
#include "fsfw/timemanager/TimeReaderIF.h"
class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF {
public:

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
// the primary header minus 1
REQUIRE(creatorFromEmptyCtor.getPacketDataLen() == 8);
creatorFromEmptyCtor.setTimeStamper(&timeStamper);
creatorFromEmptyCtor.setTimeStamper(timeStamper);
REQUIRE(creatorFromEmptyCtor.getFullPacketLen() == 22);
REQUIRE(creatorFromEmptyCtor.getPacketDataLen() == 15);
}

View File

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

View File

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