added new pus services
This commit is contained in:
100
pus/Service1TelecommandVerification.cpp
Normal file
100
pus/Service1TelecommandVerification.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
#include <framework/pus/Service1TelecommandVerification.h>
|
||||
#include <framework/pus/servicepackets/Service1Packets.h>
|
||||
|
||||
#include <framework/ipc/QueueFactory.h>
|
||||
#include <framework/tmtcservices/PusVerificationReport.h>
|
||||
#include <framework/tmtcpacket/pus/TmPacketStored.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/tmtcservices/AcceptsTelemetryIF.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
|
||||
|
||||
Service1TelecommandVerification::Service1TelecommandVerification(
|
||||
object_id_t objectId, uint16_t apid, uint8_t serviceId,
|
||||
object_id_t targetDestination):
|
||||
SystemObject(objectId), apid(apid), serviceId(serviceId),
|
||||
targetDestination(targetDestination) {
|
||||
tmQueue = QueueFactory::instance()->createMessageQueue();
|
||||
}
|
||||
|
||||
Service1TelecommandVerification::~Service1TelecommandVerification() {}
|
||||
|
||||
MessageQueueId_t Service1TelecommandVerification::getVerificationQueue(){
|
||||
return tmQueue->getId();
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t Service1TelecommandVerification::performOperation(
|
||||
uint8_t operationCode){
|
||||
PusVerificationMessage message;
|
||||
ReturnValue_t status = tmQueue->receiveMessage(&message);
|
||||
while(status == HasReturnvaluesIF::RETURN_OK) {
|
||||
status = sendVerificationReport(&message);
|
||||
if(status != HasReturnvaluesIF::RETURN_OK) {
|
||||
return status;
|
||||
}
|
||||
status = tmQueue->receiveMessage(&message);
|
||||
}
|
||||
if (status == MessageQueueIF::EMPTY) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t Service1TelecommandVerification::sendVerificationReport(
|
||||
PusVerificationMessage* message) {
|
||||
ReturnValue_t result;
|
||||
if(message->getReportId() % 2 == 0) {
|
||||
result = generateFailureReport(message);
|
||||
} else {
|
||||
result = generateSuccessReport(message);
|
||||
}
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "Service1TelecommandVerification::initialize: "
|
||||
"Sending verification packet failed !" << std::endl;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t Service1TelecommandVerification::generateFailureReport(
|
||||
PusVerificationMessage *message) {
|
||||
FailureReport report(
|
||||
message->getReportId(), message->getTcPacketId(),
|
||||
message->getTcSequenceControl(), message->getStep(),
|
||||
message->getErrorCode(), message->getParameter1(),
|
||||
message->getParameter2());
|
||||
TmPacketStored tmPacket(apid, serviceId, message->getReportId(),
|
||||
packetSubCounter++, &report);
|
||||
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(),
|
||||
tmQueue->getId());
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t Service1TelecommandVerification::generateSuccessReport(
|
||||
PusVerificationMessage *message) {
|
||||
SuccessReport report(message->getReportId(),message->getTcPacketId(),
|
||||
message->getTcSequenceControl(),message->getStep());
|
||||
TmPacketStored tmPacket(apid, serviceId, message->getReportId(),
|
||||
packetSubCounter++, &report);
|
||||
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(),
|
||||
tmQueue->getId());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t Service1TelecommandVerification::initialize() {
|
||||
// Get target object for TC verification messages
|
||||
AcceptsTelemetryIF* funnel = objectManager->
|
||||
get<AcceptsTelemetryIF>(targetDestination);
|
||||
if(funnel == nullptr){
|
||||
sif::error << "Service1TelecommandVerification::initialize: Specified"
|
||||
" TM funnel invalid. Make sure it is set up and implements"
|
||||
" AcceptsTelemetryIF." << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
tmQueue->setDefaultDestination(funnel->getReportReceptionQueue());
|
||||
return SystemObject::initialize();
|
||||
}
|
Reference in New Issue
Block a user