2016-06-15 23:48:41 +02:00
|
|
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
|
|
|
#include <framework/tmtcservices/AcceptsVerifyMessageIF.h>
|
|
|
|
#include <framework/tmtcservices/PusVerificationReport.h>
|
|
|
|
#include <framework/tmtcservices/VerificationReporter.h>
|
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
object_id_t VerificationReporter::messageReceiver = 0;
|
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
VerificationReporter::VerificationReporter() :
|
2018-07-12 16:29:32 +02:00
|
|
|
acknowledgeQueue() {
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VerificationReporter::~VerificationReporter() {
|
|
|
|
//Default, empty
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
|
|
|
|
TcPacketBase* current_packet, uint8_t set_step) {
|
2018-07-12 16:29:32 +02:00
|
|
|
if (this->acknowledgeQueue == 0) {
|
2016-06-15 23:48:41 +02:00
|
|
|
this->initialize();
|
|
|
|
}
|
2018-07-12 16:29:32 +02:00
|
|
|
PusVerificationMessage message(set_report_id,
|
|
|
|
current_packet->getAcknowledgeFlags(),
|
|
|
|
current_packet->getPacketId(),
|
|
|
|
current_packet->getPacketSequenceControl(), 0, set_step);
|
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message);
|
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
2016-06-15 23:48:41 +02:00
|
|
|
error
|
|
|
|
<< "VerificationReporter::sendSuccessReport: Error writing to queue. Code: "
|
|
|
|
<< (uint16_t) status << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
|
2018-07-12 16:29:32 +02:00
|
|
|
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl,
|
|
|
|
uint8_t set_step) {
|
|
|
|
if (this->acknowledgeQueue == 0) {
|
2016-06-15 23:48:41 +02:00
|
|
|
this->initialize();
|
|
|
|
}
|
2018-07-12 16:29:32 +02:00
|
|
|
PusVerificationMessage message(set_report_id, ackFlags, tcPacketId,
|
|
|
|
tcSequenceControl, 0, set_step);
|
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message);
|
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
2016-06-15 23:48:41 +02:00
|
|
|
error
|
|
|
|
<< "VerificationReporter::sendSuccessReport: Error writing to queue. Code: "
|
|
|
|
<< (uint16_t) status << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerificationReporter::sendFailureReport(uint8_t report_id,
|
|
|
|
TcPacketBase* current_packet, ReturnValue_t error_code, uint8_t step,
|
|
|
|
uint32_t parameter1, uint32_t parameter2) {
|
2018-07-12 16:29:32 +02:00
|
|
|
if (this->acknowledgeQueue == 0) {
|
2016-06-15 23:48:41 +02:00
|
|
|
this->initialize();
|
|
|
|
}
|
2018-07-12 16:29:32 +02:00
|
|
|
PusVerificationMessage message(report_id,
|
|
|
|
current_packet->getAcknowledgeFlags(),
|
|
|
|
current_packet->getPacketId(),
|
|
|
|
current_packet->getPacketSequenceControl(), error_code, step,
|
2016-06-15 23:48:41 +02:00
|
|
|
parameter1, parameter2);
|
2018-07-12 16:29:32 +02:00
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message);
|
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
2016-06-15 23:48:41 +02:00
|
|
|
error
|
|
|
|
<< "VerificationReporter::sendFailureReport Error writing to queue. Code: "
|
|
|
|
<< (uint16_t) status << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerificationReporter::sendFailureReport(uint8_t report_id,
|
2018-07-12 16:29:32 +02:00
|
|
|
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl,
|
|
|
|
ReturnValue_t error_code, uint8_t step, uint32_t parameter1,
|
|
|
|
uint32_t parameter2) {
|
|
|
|
if (this->acknowledgeQueue == 0) {
|
2016-06-15 23:48:41 +02:00
|
|
|
this->initialize();
|
|
|
|
}
|
2018-07-12 16:29:32 +02:00
|
|
|
PusVerificationMessage message(report_id, ackFlags, tcPacketId,
|
|
|
|
tcSequenceControl, error_code, step, parameter1, parameter2);
|
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message);
|
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
2016-06-15 23:48:41 +02:00
|
|
|
error
|
|
|
|
<< "VerificationReporter::sendFailureReport Error writing to queue. Code: "
|
|
|
|
<< (uint16_t) status << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerificationReporter::initialize() {
|
|
|
|
AcceptsVerifyMessageIF* temp = objectManager->get<AcceptsVerifyMessageIF>(
|
2018-07-12 16:29:32 +02:00
|
|
|
messageReceiver);
|
2016-06-15 23:48:41 +02:00
|
|
|
if (temp != NULL) {
|
2018-07-12 16:29:32 +02:00
|
|
|
this->acknowledgeQueue = temp->getVerificationQueue();
|
2016-06-15 23:48:41 +02:00
|
|
|
} else {
|
|
|
|
error
|
|
|
|
<< "VerificationReporter::VerificationReporter: Configuration error."
|
|
|
|
<< std::endl;
|
|
|
|
}
|
|
|
|
}
|