fsfw/tmtcservices/VerificationReporter.cpp

119 lines
4.1 KiB
C++
Raw Normal View History

2020-09-29 13:34:27 +02:00
#include "VerificationReporter.h"
2020-08-13 20:53:35 +02:00
#include "AcceptsVerifyMessageIF.h"
#include "PusVerificationReport.h"
2020-09-29 13:34:27 +02:00
#include "../ipc/MessageQueueIF.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../objectmanager/frameworkObjects.h"
object_id_t VerificationReporter::messageReceiver =
objects::PUS_SERVICE_1_VERIFICATION;
VerificationReporter::VerificationReporter() :
2020-09-29 13:34:27 +02:00
acknowledgeQueue(MessageQueueIF::NO_QUEUE) {
}
2020-09-29 13:34:27 +02:00
VerificationReporter::~VerificationReporter() {}
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
TcPacketBase* current_packet, uint8_t set_step) {
2020-09-29 13:34:27 +02:00
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
this->initialize();
}
PusVerificationMessage message(set_report_id,
current_packet->getAcknowledgeFlags(),
current_packet->getPacketId(),
current_packet->getPacketSequenceControl(), 0, set_step);
2020-09-29 13:34:27 +02:00
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&message);
if (status != HasReturnvaluesIF::RETURN_OK) {
2021-01-03 14:16:52 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2020-09-29 13:34:27 +02:00
sif::error << "VerificationReporter::sendSuccessReport: Error writing "
<< "to queue. Code: " << std::hex << status << std::dec
<< std::endl;
#endif
}
}
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl,
uint8_t set_step) {
2020-09-29 13:34:27 +02:00
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
this->initialize();
}
PusVerificationMessage message(set_report_id, ackFlags, tcPacketId,
tcSequenceControl, 0, set_step);
2020-09-29 13:34:27 +02:00
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&message);
if (status != HasReturnvaluesIF::RETURN_OK) {
2021-01-03 14:16:52 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2020-09-29 13:34:27 +02:00
sif::error << "VerificationReporter::sendSuccessReport: Error writing "
<< "to queue. Code: " << std::hex << status << std::dec
<< std::endl;
#endif
}
}
void VerificationReporter::sendFailureReport(uint8_t report_id,
TcPacketBase* current_packet, ReturnValue_t error_code, uint8_t step,
uint32_t parameter1, uint32_t parameter2) {
2020-09-29 13:34:27 +02:00
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
this->initialize();
}
PusVerificationMessage message(report_id,
current_packet->getAcknowledgeFlags(),
current_packet->getPacketId(),
current_packet->getPacketSequenceControl(), error_code, step,
parameter1, parameter2);
2020-09-29 13:34:27 +02:00
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&message);
if (status != HasReturnvaluesIF::RETURN_OK) {
2021-01-03 14:16:52 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2020-09-29 13:34:27 +02:00
sif::error << "VerificationReporter::sendFailureReport: Error writing "
<< "to queue. Code: " << std::hex << "0x" << status << std::dec
<< std::endl;
#endif
}
}
void VerificationReporter::sendFailureReport(uint8_t report_id,
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl,
ReturnValue_t error_code, uint8_t step, uint32_t parameter1,
uint32_t parameter2) {
2020-09-29 13:34:27 +02:00
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
this->initialize();
}
PusVerificationMessage message(report_id, ackFlags, tcPacketId,
tcSequenceControl, error_code, step, parameter1, parameter2);
2020-09-29 13:34:27 +02:00
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&message);
if (status != HasReturnvaluesIF::RETURN_OK) {
2021-01-03 14:16:52 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2020-09-29 13:34:27 +02:00
sif::error << "VerificationReporter::sendFailureReport: Error writing "
<< "to queue. Code: " << std::hex << "0x" << status << std::dec
<< std::endl;
#endif
}
}
void VerificationReporter::initialize() {
2020-09-29 13:34:27 +02:00
if(messageReceiver == objects::NO_OBJECT) {
2021-01-03 14:16:52 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2020-09-29 13:34:27 +02:00
sif::warning << "VerificationReporter::initialize: Verification message"
" receiver object ID not set yet in Factory!" << std::endl;
#endif
2020-09-29 13:34:27 +02:00
return;
}
AcceptsVerifyMessageIF* temp = objectManager->get<AcceptsVerifyMessageIF>(
messageReceiver);
2020-09-29 13:34:27 +02:00
if (temp == nullptr) {
2021-01-03 14:16:52 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2020-09-29 13:34:27 +02:00
sif::error << "VerificationReporter::initialize: Message "
<< "receiver invalid. Make sure it is set up properly and "
<< "implementsAcceptsVerifyMessageIF" << std::endl;
#endif
2020-09-29 13:34:27 +02:00
return;
}
2020-09-29 13:34:27 +02:00
this->acknowledgeQueue = temp->getVerificationQueue();
}