applied formatting
Some checks failed
EIVE/eive-obsw/pipeline/head Build queued...
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
2022-01-17 15:58:27 +01:00
parent 975b3cd294
commit 77c45c0de9
206 changed files with 28883 additions and 30263 deletions

View File

@ -8,15 +8,15 @@ namespace initmission {
void printAddObjectError(const char* name, object_id_t objectId) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x"
<< std::hex << std::setfill('0') << std::setw(8) << objectId
<< " failed!" << std::dec << std::endl;
sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x"
<< std::hex << std::setfill('0') << std::setw(8) << objectId << " failed!" << std::dec
<< std::endl;
#else
sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n" ,
name, objectId);
sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n",
name, objectId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
}
}
} // namespace initmission
#endif /* MISSION_UTILITY_INITMISSION_H_ */

View File

@ -1,28 +1,22 @@
#include "Timestamp.h"
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
Timestamp::Timestamp() {
ReturnValue_t result = Clock::getDateAndTime(&time);
if (result != RETURN_OK) {
sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl;
}
ReturnValue_t result = Clock::getDateAndTime(&time);
if (result != RETURN_OK) {
sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl;
}
}
Timestamp::~Timestamp() {
}
Timestamp::~Timestamp() {}
std::string Timestamp::str() {
timestamp << std::to_string(time.year) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.month) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.day) << "--"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.hour) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.minute) << "-"
<< std::setw(2) << std::setfill('0')
<< std::to_string(time.second) << "--";
return timestamp.str();
timestamp << std::to_string(time.year) << "-" << std::setw(2) << std::setfill('0')
<< std::to_string(time.month) << "-" << std::setw(2) << std::setfill('0')
<< std::to_string(time.day) << "--" << std::setw(2) << std::setfill('0')
<< std::to_string(time.hour) << "-" << std::setw(2) << std::setfill('0')
<< std::to_string(time.minute) << "-" << std::setw(2) << std::setfill('0')
<< std::to_string(time.second) << "--";
return timestamp.str();
}

View File

@ -1,11 +1,12 @@
#ifndef MISSION_UTILITY_TIMESTAMP_H_
#define MISSION_UTILITY_TIMESTAMP_H_
#include <string>
#include <sstream>
#include <iomanip>
#include "fsfw/timemanager/Clock.h"
#include <sstream>
#include <string>
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/timemanager/Clock.h"
/**
* @brief This class generates timestamps for files.
@ -13,18 +14,18 @@
* @author J. Meier
*/
class Timestamp : public HasReturnvaluesIF {
public:
Timestamp();
virtual ~Timestamp();
public:
Timestamp();
virtual ~Timestamp();
/**
* @brief Returns the timestamp string
*/
std::string str();
/**
* @brief Returns the timestamp string
*/
std::string str();
private:
std::stringstream timestamp;
Clock::TimeOfDay_t time;
private:
std::stringstream timestamp;
Clock::TimeOfDay_t time;
};
#endif /* MISSION_UTILITY_TIMESTAMP_H_ */

View File

@ -1,122 +1,118 @@
#include "OBSWConfig.h"
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/tmtcpacket/pus/tm.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <fsfw/tmtcpacket/pus/tm.h>
#include <mission/utility/TmFunnel.h>
#include "OBSWConfig.h"
object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT;
object_id_t TmFunnel::storageDestination = objects::NO_OBJECT;
TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth):
SystemObject(objectId), messageDepth(messageDepth) {
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
storageQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth)
: SystemObject(objectId), messageDepth(messageDepth) {
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
storageQueue = QueueFactory::instance()->createMessageQueue(
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE);
}
TmFunnel::~TmFunnel() {
}
TmFunnel::~TmFunnel() {}
MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) {
return tmQueue->getId();
return tmQueue->getId();
}
ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
TmTcMessage currentMessage;
ReturnValue_t status = tmQueue->receiveMessage(&currentMessage);
while(status == HasReturnvaluesIF::RETURN_OK)
{
status = handlePacket(&currentMessage);
if(status != HasReturnvaluesIF::RETURN_OK){
break;
}
status = tmQueue->receiveMessage(&currentMessage);
}
TmTcMessage currentMessage;
ReturnValue_t status = tmQueue->receiveMessage(&currentMessage);
while (status == HasReturnvaluesIF::RETURN_OK) {
status = handlePacket(&currentMessage);
if (status != HasReturnvaluesIF::RETURN_OK) {
break;
}
status = tmQueue->receiveMessage(&currentMessage);
}
if (status == MessageQueueIF::EMPTY) {
return HasReturnvaluesIF::RETURN_OK;
}
else {
return status;
}
if (status == MessageQueueIF::EMPTY) {
return HasReturnvaluesIF::RETURN_OK;
} else {
return status;
}
}
ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) {
uint8_t* packetData = nullptr;
size_t size = 0;
ReturnValue_t result = tmStore->modifyData(message->getStorageId(),
&packetData, &size);
if(result != HasReturnvaluesIF::RETURN_OK){
return result;
}
TmPacketPusC packet(packetData);
packet.setPacketSequenceCount(this->sourceSequenceCount);
sourceSequenceCount++;
sourceSequenceCount = sourceSequenceCount %
SpacePacketBase::LIMIT_SEQUENCE_COUNT;
packet.setErrorControl();
uint8_t* packetData = nullptr;
size_t size = 0;
ReturnValue_t result = tmStore->modifyData(message->getStorageId(), &packetData, &size);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
TmPacketPusC packet(packetData);
packet.setPacketSequenceCount(this->sourceSequenceCount);
sourceSequenceCount++;
sourceSequenceCount = sourceSequenceCount % SpacePacketBase::LIMIT_SEQUENCE_COUNT;
packet.setErrorControl();
result = tmQueue->sendToDefault(message);
if(result != HasReturnvaluesIF::RETURN_OK){
tmStore->deleteData(message->getStorageId());
sif::error << "TmFunnel::handlePacket: Error sending to downlink "
"handler" << std::endl;
return result;
}
result = tmQueue->sendToDefault(message);
if (result != HasReturnvaluesIF::RETURN_OK) {
tmStore->deleteData(message->getStorageId());
sif::error << "TmFunnel::handlePacket: Error sending to downlink "
"handler"
<< std::endl;
return result;
}
if(storageDestination != objects::NO_OBJECT) {
result = storageQueue->sendToDefault(message);
if(result != HasReturnvaluesIF::RETURN_OK){
tmStore->deleteData(message->getStorageId());
sif::error << "TmFunnel::handlePacket: Error sending to storage "
"handler" << std::endl;
return result;
}
}
return result;
if (storageDestination != objects::NO_OBJECT) {
result = storageQueue->sendToDefault(message);
if (result != HasReturnvaluesIF::RETURN_OK) {
tmStore->deleteData(message->getStorageId());
sif::error << "TmFunnel::handlePacket: Error sending to storage "
"handler"
<< std::endl;
return result;
}
}
return result;
}
ReturnValue_t TmFunnel::initialize() {
tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (tmStore == nullptr) {
sif::error << "TmFunnel::initialize: TM store not set." << std::endl;
sif::error << "Make sure the tm store is set up properly"
" and implements StorageManagerIF"
<< std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if(tmStore == nullptr) {
sif::error << "TmFunnel::initialize: TM store not set."
<< std::endl;
sif::error << "Make sure the tm store is set up properly"
" and implements StorageManagerIF" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
AcceptsTelemetryIF* tmTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(downlinkDestination);
if(tmTarget == nullptr){
sif::error << "TmFunnel::initialize: Downlink Destination not set."
<< std::endl;
sif::error << "Make sure the downlink destination object is set up "
"properly and implements AcceptsTelemetryIF" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
AcceptsTelemetryIF* tmTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(downlinkDestination);
if (tmTarget == nullptr) {
sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl;
sif::error << "Make sure the downlink destination object is set up "
"properly and implements AcceptsTelemetryIF"
<< std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
#if OBSW_TM_TO_PTME == 1
// Live TM will be sent via the virtual channel 0
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM));
// Live TM will be sent via the virtual channel 0
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM));
#else
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue());
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue());
#endif /* OBSW_TM_TO_PTME == 1 */
// Storage destination is optional.
if(storageDestination == objects::NO_OBJECT) {
return SystemObject::initialize();
}
// Storage destination is optional.
if (storageDestination == objects::NO_OBJECT) {
return SystemObject::initialize();
}
AcceptsTelemetryIF* storageTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(storageDestination);
if(storageTarget != nullptr) {
storageQueue->setDefaultDestination(
storageTarget->getReportReceptionQueue());
}
AcceptsTelemetryIF* storageTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(storageDestination);
if (storageTarget != nullptr) {
storageQueue->setDefaultDestination(storageTarget->getReportReceptionQueue());
}
return SystemObject::initialize();
return SystemObject::initialize();
}

View File

@ -1,13 +1,13 @@
#ifndef MISSION_UTILITY_TMFUNNEL_H_
#define MISSION_UTILITY_TMFUNNEL_H_
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/tmtcservices/TmTcMessage.h>
namespace Factory{
namespace Factory {
void setStaticFrameworkObjectIds();
}
@ -19,32 +19,30 @@ void setStaticFrameworkObjectIds();
* @ingroup utility
* @author J. Meier
*/
class TmFunnel: public AcceptsTelemetryIF,
public ExecutableObjectIF,
public SystemObject {
friend void (Factory::setStaticFrameworkObjectIds)();
public:
TmFunnel(object_id_t objectId, uint32_t messageDepth = 20);
virtual ~TmFunnel();
class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public SystemObject {
friend void(Factory::setStaticFrameworkObjectIds)();
virtual MessageQueueId_t getReportReceptionQueue(
uint8_t virtualChannel = 0) override;
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual ReturnValue_t initialize() override;
public:
TmFunnel(object_id_t objectId, uint32_t messageDepth = 20);
virtual ~TmFunnel();
protected:
static object_id_t downlinkDestination;
static object_id_t storageDestination;
virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override;
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual ReturnValue_t initialize() override;
private:
uint16_t sourceSequenceCount = 0;
MessageQueueIF* tmQueue = nullptr;
MessageQueueIF* storageQueue = nullptr;
protected:
static object_id_t downlinkDestination;
static object_id_t storageDestination;
StorageManagerIF* tmStore = nullptr;
uint32_t messageDepth = 0;
private:
uint16_t sourceSequenceCount = 0;
MessageQueueIF* tmQueue = nullptr;
MessageQueueIF* storageQueue = nullptr;
ReturnValue_t handlePacket(TmTcMessage* message);
StorageManagerIF* tmStore = nullptr;
uint32_t messageDepth = 0;
ReturnValue_t handlePacket(TmTcMessage* message);
};
#endif /* MISSION_UTILITY_TMFUNNEL_H_ */