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"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
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;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
VerificationReporter::VerificationReporter() :
|
2020-09-29 13:34:27 +02:00
|
|
|
acknowledgeQueue(MessageQueueIF::NO_QUEUE) {
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
2020-09-29 13:34:27 +02:00
|
|
|
VerificationReporter::~VerificationReporter() {}
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
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) {
|
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);
|
2020-09-29 13:34:27 +02:00
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
|
|
|
&message);
|
2018-07-12 16:29:32 +02:00
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
2020-09-29 13:34:27 +02:00
|
|
|
sif::error << "VerificationReporter::sendSuccessReport: Error writing "
|
|
|
|
<< "to queue. Code: " << std::hex << status << std::dec
|
|
|
|
<< std::endl;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2020-09-29 13:34:27 +02:00
|
|
|
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
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);
|
2020-09-29 13:34:27 +02:00
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
|
|
|
&message);
|
2018-07-12 16:29:32 +02:00
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
2020-09-29 13:34:27 +02:00
|
|
|
sif::error << "VerificationReporter::sendSuccessReport: Error writing "
|
|
|
|
<< "to queue. Code: " << std::hex << status << std::dec
|
|
|
|
<< std::endl;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
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);
|
2020-09-29 13:34:27 +02:00
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
|
|
|
&message);
|
2018-07-12 16:29:32 +02:00
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
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;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2020-09-29 13:34:27 +02:00
|
|
|
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
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);
|
2020-09-29 13:34:27 +02:00
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
|
|
|
&message);
|
2018-07-12 16:29:32 +02:00
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
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;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerificationReporter::initialize() {
|
2020-09-29 13:34:27 +02:00
|
|
|
if(messageReceiver == objects::NO_OBJECT) {
|
|
|
|
sif::warning << "VerificationReporter::initialize: Verification message"
|
|
|
|
" receiver object ID not set yet in Factory!" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
2016-06-15 23:48:41 +02:00
|
|
|
AcceptsVerifyMessageIF* temp = objectManager->get<AcceptsVerifyMessageIF>(
|
2018-07-12 16:29:32 +02:00
|
|
|
messageReceiver);
|
2020-09-29 13:34:27 +02:00
|
|
|
if (temp == nullptr) {
|
|
|
|
sif::error << "VerificationReporter::initialize: Message "
|
|
|
|
<< "receiver invalid. Make sure it is set up properly and "
|
|
|
|
<< "implementsAcceptsVerifyMessageIF" << std::endl;
|
|
|
|
return;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
2020-09-29 13:34:27 +02:00
|
|
|
this->acknowledgeQueue = temp->getVerificationQueue();
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|