1
0
forked from fsfw/fsfw

updating code from Flying Laptop

This is the framework of Flying Laptop OBSW version A.13.0.
This commit is contained in:
2018-07-12 16:29:32 +02:00
parent 1d22a6c97e
commit 575f70ba03
395 changed files with 12807 additions and 8404 deletions

View File

@ -1,7 +1,7 @@
#ifndef ACCEPTSTELECOMMANDSIF_H_
#define ACCEPTSTELECOMMANDSIF_H_
#include <framework/ipc/MessageQueue.h>
#include <framework/ipc/MessageQueueSenderIF.h>
/**
* @brief This interface is implemented by classes that are sinks for
@ -11,7 +11,7 @@
*/
class AcceptsTelecommandsIF {
public:
static const uint8_t INTERFACE_ID = ACCEPTS_TELECOMMANDS_IF;
static const uint8_t INTERFACE_ID = CLASS_ID::ACCEPTS_TELECOMMANDS_IF;
static const ReturnValue_t ACTIVITY_STARTED = MAKE_RETURN_CODE(1);
static const ReturnValue_t INVALID_SUBSERVICE = MAKE_RETURN_CODE(2);
static const ReturnValue_t ILLEGAL_APPLICATION_DATA = MAKE_RETURN_CODE(3);

View File

@ -1,7 +1,7 @@
#ifndef ACCEPTSTELEMETRYIF_H_
#define ACCEPTSTELEMETRYIF_H_
#include <framework/ipc/MessageQueueSender.h>
#include <framework/ipc/MessageQueueSenderIF.h>
/**
* @brief This interface is implemented by classes that are sinks for
* Telemetry.

View File

@ -1,14 +1,7 @@
/*
* AcceptsVerifyMessageIF.h
*
* Created on: 23.11.2012
* Author: baetz
*/
#ifndef ACCEPTSVERIFICATIONMESSAGEIF_H_
#define ACCEPTSVERIFICATIONMESSAGEIF_H_
#include <framework/ipc/MessageQueue.h>
#include <framework/ipc/MessageQueueSenderIF.h>
class AcceptsVerifyMessageIF {
public:

View File

@ -4,7 +4,6 @@
#include <framework/container/FixedMap.h>
#include <framework/container/FIFO.h>
#include <framework/ipc/CommandMessage.h>
#include <framework/ipc/MessageQueue.h>
#include <framework/objectmanager/ObjectManagerIF.h>
#include <framework/objectmanager/SystemObject.h>
#include <framework/serialize/SerializeAdapter.h>
@ -17,6 +16,9 @@
#include <framework/tmtcservices/AcceptsTelemetryIF.h>
#include <framework/tmtcservices/TmTcMessage.h>
#include <framework/tmtcservices/VerificationReporter.h>
#include <framework/internalError/InternalErrorReporterIF.h>
#include <framework/ipc/QueueFactory.h>
#include <framework/timemanager/Clock.h>
template<typename STATE_T>
class CommandingServiceBase: public SystemObject,
@ -24,7 +26,7 @@ class CommandingServiceBase: public SystemObject,
public ExecutableObjectIF,
public HasReturnvaluesIF {
public:
static const uint8_t INTERFACE_ID = COMMAND_SERVICE_BASE;
static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE;
static const ReturnValue_t EXECUTION_COMPLETE = MAKE_RETURN_CODE(1);
static const ReturnValue_t NO_STEP_MESSAGE = MAKE_RETURN_CODE(2);
static const ReturnValue_t OBJECT_BUSY = MAKE_RETURN_CODE(3);
@ -35,10 +37,11 @@ public:
CommandingServiceBase(object_id_t setObjectId, uint16_t apid,
uint8_t service, uint8_t numberOfParallelCommands,
uint16_t commandTimeout_seconds, size_t queueDepth = 20);
uint16_t commandTimeout_seconds, object_id_t setPacketSource,
object_id_t setPacketDestination, size_t queueDepth = 20);
virtual ~CommandingServiceBase();
virtual ReturnValue_t performOperation();
virtual ReturnValue_t performOperation(uint8_t opCode);
virtual uint16_t getIdentifier();
@ -74,9 +77,9 @@ protected:
StorageManagerIF *TCStore;
MessageQueue commandQueue;
MessageQueueIF* commandQueue;
MessageQueue requestQueue;
MessageQueueIF* requestQueue;
VerificationReporter verificationReporter;
@ -85,12 +88,17 @@ protected:
uint32_t failureParameter1; //!< May be set be children to return a more precise failure condition.
uint32_t failureParameter2; //!< May be set be children to return a more precise failure condition.
void sendTmPacket(uint8_t subservice, const uint8_t *data,
uint32_t dataLen);
object_id_t packetSource;
object_id_t packetDestination;
void sendTmPacket(uint8_t subservice, const uint8_t *data, uint32_t dataLen,
const uint8_t* headerData = NULL, uint32_t headerSize = 0);
void sendTmPacket(uint8_t subservice, object_id_t objectId,
const uint8_t *data, uint32_t dataLen);
void sendTmPacket(uint8_t subservice, SerializeIF* content);
void sendTmPacket(uint8_t subservice, SerializeIF* content,
SerializeIF* header = NULL);
virtual ReturnValue_t isValidSubservice(uint8_t subservice) = 0;
virtual ReturnValue_t prepareCommand(CommandMessage *message,
@ -110,6 +118,9 @@ protected:
virtual void doPeriodicOperation();
void checkAndExecuteFifo(
typename FixedMap<MessageQueueId_t, CommandInfo>::Iterator *iter);
private:
void handleCommandQueue();
@ -123,29 +134,32 @@ private:
void startExecution(TcPacketStored *storedPacket,
typename FixedMap<MessageQueueId_t, CommandInfo>::Iterator *iter);
void checkAndExecuteFifo(
typename FixedMap<MessageQueueId_t, CommandInfo>::Iterator *iter);
void checkTimeout();
};
template<typename STATE_T>
CommandingServiceBase<STATE_T>::CommandingServiceBase(object_id_t setObjectId,
uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands,
uint16_t commandTimeout_seconds, size_t queueDepth) :
uint16_t commandTimeout_seconds, object_id_t setPacketSource,
object_id_t setPacketDestination, size_t queueDepth) :
SystemObject(setObjectId), apid(apid), service(service), timeout_seconds(
commandTimeout_seconds), tmPacketCounter(0), IPCStore(NULL), TCStore(
NULL), commandQueue(queueDepth), requestQueue(20), commandMap(
NULL), commandQueue(NULL), requestQueue(NULL), commandMap(
numberOfParallelCommands), failureParameter1(0), failureParameter2(
0) {
0), packetSource(setPacketSource), packetDestination(
setPacketDestination) {
commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
requestQueue = QueueFactory::instance()->createMessageQueue(20); //TODO: Funny magic number.
}
template<typename STATE_T>
CommandingServiceBase<STATE_T>::~CommandingServiceBase() {
QueueFactory::instance()->deleteMessageQueue(commandQueue);
QueueFactory::instance()->deleteMessageQueue(requestQueue);
}
template<typename STATE_T>
ReturnValue_t CommandingServiceBase<STATE_T>::performOperation() {
ReturnValue_t CommandingServiceBase<STATE_T>::performOperation(uint8_t opCode) {
handleCommandQueue();
handleRequestQueue();
checkTimeout();
@ -160,7 +174,7 @@ uint16_t CommandingServiceBase<STATE_T>::getIdentifier() {
template<typename STATE_T>
MessageQueueId_t CommandingServiceBase<STATE_T>::getRequestQueue() {
return requestQueue.getId();
return requestQueue->getId();
}
template<typename STATE_T>
@ -171,16 +185,15 @@ ReturnValue_t CommandingServiceBase<STATE_T>::initialize() {
}
AcceptsTelemetryIF* packetForwarding =
objectManager->get<AcceptsTelemetryIF>(
objects::PUS_PACKET_FORWARDING);
objectManager->get<AcceptsTelemetryIF>(packetDestination);
PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>(
objects::PUS_PACKET_DISTRIBUTOR);
packetSource);
if ((packetForwarding == NULL) && (distributor == NULL)) {
return RETURN_FAILED;
}
distributor->registerService(this);
requestQueue.setDefaultDestination(
requestQueue->setDefaultDestination(
packetForwarding->getReportReceptionQueue());
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
@ -200,11 +213,15 @@ void CommandingServiceBase<STATE_T>::handleCommandQueue() {
CommandMessage reply, nextCommand;
ReturnValue_t result, sendResult = RETURN_OK;
bool isStep = false;
for (result = commandQueue.receiveMessage(&reply); result == RETURN_OK;
result = commandQueue.receiveMessage(&reply)) {
for (result = commandQueue->receiveMessage(&reply); result == RETURN_OK;
result = commandQueue->receiveMessage(&reply)) {
isStep = false;
typename FixedMap<MessageQueueId_t,
CommandingServiceBase<STATE_T>::CommandInfo>::Iterator iter;
if (reply.getSender() == MessageQueueIF::NO_QUEUE) {
handleUnrequestedReply(&reply);
continue;
}
if ((iter = commandMap.find(reply.getSender())) == commandMap.end()) {
handleUnrequestedReply(&reply);
continue;
@ -218,7 +235,7 @@ void CommandingServiceBase<STATE_T>::handleCommandQueue() {
case NO_STEP_MESSAGE:
iter->command = nextCommand.getCommand();
if (nextCommand.getCommand() != CommandMessage::CMD_NONE) {
sendResult = commandQueue.sendMessage(reply.getSender(),
sendResult = commandQueue->sendMessage(reply.getSender(),
&nextCommand);
}
if (sendResult == RETURN_OK) {
@ -249,8 +266,8 @@ void CommandingServiceBase<STATE_T>::handleCommandQueue() {
verificationReporter.sendFailureReport(
TC_VERIFY::COMPLETION_FAILURE,
iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId,
iter->tcInfo.tcSequenceControl, sendResult,
0, failureParameter1, failureParameter2);
iter->tcInfo.tcSequenceControl, sendResult, 0,
failureParameter1, failureParameter2);
}
failureParameter1 = 0;
failureParameter2 = 0;
@ -266,7 +283,8 @@ void CommandingServiceBase<STATE_T>::handleCommandQueue() {
verificationReporter.sendFailureReport(
TC_VERIFY::PROGRESS_FAILURE, iter->tcInfo.ackFlags,
iter->tcInfo.tcPacketId, iter->tcInfo.tcSequenceControl,
result, ++iter->step, failureParameter1, failureParameter2);
result, ++iter->step, failureParameter1,
failureParameter2);
} else {
verificationReporter.sendFailureReport(
TC_VERIFY::COMPLETION_FAILURE, iter->tcInfo.ackFlags,
@ -290,8 +308,8 @@ void CommandingServiceBase<STATE_T>::handleRequestQueue() {
TcPacketStored packet;
MessageQueueId_t queue;
object_id_t objectId;
for (result = requestQueue.receiveMessage(&message); result == RETURN_OK;
result = requestQueue.receiveMessage(&message)) {
for (result = requestQueue->receiveMessage(&message); result == RETURN_OK;
result = requestQueue->receiveMessage(&message)) {
address = message.getStorageId();
packet.setStoreAddress(address);
@ -334,12 +352,14 @@ void CommandingServiceBase<STATE_T>::handleRequestQueue() {
template<typename STATE_T>
void CommandingServiceBase<STATE_T>::sendTmPacket(uint8_t subservice,
const uint8_t* data, uint32_t dataLen) {
const uint8_t* data, uint32_t dataLen, const uint8_t* headerData,
uint32_t headerSize) {
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
this->tmPacketCounter++, data, dataLen);
TmTcMessage tmMessage(tmPacketStored.getStoreAddress());
if (requestQueue.sendToDefault(&tmMessage) != RETURN_OK) {
tmPacketStored.deletePacket();
this->tmPacketCounter, data, dataLen, headerData, headerSize);
ReturnValue_t result = tmPacketStored.sendPacket(
requestQueue->getDefaultDestination(), requestQueue->getId());
if (result == HasReturnvaluesIF::RETURN_OK) {
this->tmPacketCounter++;
}
}
@ -352,21 +372,24 @@ void CommandingServiceBase<STATE_T>::sendTmPacket(uint8_t subservice,
SerializeAdapter<object_id_t>::serialize(&objectId, &pBuffer, &size,
sizeof(object_id_t), true);
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
this->tmPacketCounter++, data, dataLen, buffer, size);
TmTcMessage tmMessage(tmPacketStored.getStoreAddress());
if (requestQueue.sendToDefault(&tmMessage) != RETURN_OK) {
tmPacketStored.deletePacket();
this->tmPacketCounter, data, dataLen, buffer, size);
ReturnValue_t result = tmPacketStored.sendPacket(
requestQueue->getDefaultDestination(), requestQueue->getId());
if (result == HasReturnvaluesIF::RETURN_OK) {
this->tmPacketCounter++;
}
}
template<typename STATE_T>
void CommandingServiceBase<STATE_T>::sendTmPacket(uint8_t subservice,
SerializeIF* content) {
SerializeIF* content, SerializeIF* header) {
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
this->tmPacketCounter++, content);
TmTcMessage tmMessage(tmPacketStored.getStoreAddress());
if (requestQueue.sendToDefault(&tmMessage) != RETURN_OK) {
tmPacketStored.deletePacket();
this->tmPacketCounter, content, header);
ReturnValue_t result = tmPacketStored.sendPacket(
requestQueue->getDefaultDestination(), requestQueue->getId());
if (result == HasReturnvaluesIF::RETURN_OK) {
this->tmPacketCounter++;
}
}
@ -386,11 +409,11 @@ void CommandingServiceBase<STATE_T>::startExecution(
switch (result) {
case RETURN_OK:
if (message.getCommand() != CommandMessage::CMD_NONE) {
sendResult = commandQueue.sendMessage((*iter).value->first,
sendResult = commandQueue->sendMessage((*iter).value->first,
&message);
}
if (sendResult == RETURN_OK) {
OSAL::getUptime(&(*iter)->uptimeOfStart);
Clock::getUptime(&(*iter)->uptimeOfStart);
(*iter)->step = 0;
// (*iter)->state = 0;
(*iter)->subservice = storedPacket->getSubService();
@ -409,7 +432,7 @@ void CommandingServiceBase<STATE_T>::startExecution(
case EXECUTION_COMPLETE:
if (message.getCommand() != CommandMessage::CMD_NONE) {
//Fire-and-forget command.
sendResult = commandQueue.sendMessage((*iter).value->first,
sendResult = commandQueue->sendMessage((*iter).value->first,
&message);
}
if (sendResult == RETURN_OK) {
@ -470,7 +493,7 @@ inline void CommandingServiceBase<STATE_T>::doPeriodicOperation() {
template<typename STATE_T>
void CommandingServiceBase<STATE_T>::checkTimeout() {
uint32_t uptime;
OSAL::getUptime(&uptime);
Clock::getUptime(&uptime);
typename FixedMap<MessageQueueId_t,
CommandingServiceBase<STATE_T>::CommandInfo>::Iterator iter;
for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) {

View File

@ -1,30 +1,28 @@
/*
* PusServiceBase.cpp
*
* Created on: May 9, 2012
* Author: baetz
*/
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/tcdistribution/PUSDistributorIF.h>
#include <framework/tmtcservices/AcceptsTelemetryIF.h>
#include <framework/tmtcservices/PusServiceBase.h>
#include <framework/tmtcservices/PusVerificationReport.h>
#include <framework/tmtcservices/TmTcMessage.h>
#include <framework/ipc/QueueFactory.h>
PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t set_apid,
uint8_t set_service_id) :
SystemObject(setObjectId), apid(set_apid), serviceId(set_service_id), errorParameter1(
0), errorParameter2(0), requestQueue(PUS_SERVICE_MAX_RECEPTION) {
object_id_t PusServiceBase::packetSource = 0;
object_id_t PusServiceBase::packetDestination = 0;
PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId) :
SystemObject(setObjectId), apid(setApid), serviceId(setServiceId), errorParameter1(
0), errorParameter2(0), requestQueue(NULL) {
requestQueue = QueueFactory::instance()->createMessageQueue(PUS_SERVICE_MAX_RECEPTION);
}
PusServiceBase::~PusServiceBase() {
QueueFactory::instance()->deleteMessageQueue(requestQueue);
}
ReturnValue_t PusServiceBase::performOperation() {
ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) {
TmTcMessage message;
for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) {
ReturnValue_t status = this->requestQueue.receiveMessage(&message);
ReturnValue_t status = this->requestQueue->receiveMessage(&message);
// debug << "PusServiceBase::performOperation: Receiving from MQ ID: " << std::hex << this->requestQueue.getId() << std::dec << " returned: " << status << std::endl;
if (status == RETURN_OK) {
this->currentPacket.setStoreAddress(message.getStorageId());
@ -44,7 +42,7 @@ ReturnValue_t PusServiceBase::performOperation() {
this->currentPacket.deletePacket();
errorParameter1 = 0;
errorParameter2 = 0;
} else if (status == OSAL::QUEUE_EMPTY) {
} else if (status == OperatingSystemIF::QUEUE_EMPTY) {
status = RETURN_OK;
// debug << "PusService " << (uint16_t)this->serviceId << ": no new packet." << std::endl;
break;
@ -73,7 +71,7 @@ uint16_t PusServiceBase::getIdentifier() {
}
MessageQueueId_t PusServiceBase::getRequestQueue() {
return this->requestQueue.getId();
return this->requestQueue->getId();
}
ReturnValue_t PusServiceBase::initialize() {
@ -82,18 +80,18 @@ ReturnValue_t PusServiceBase::initialize() {
return result;
}
AcceptsTelemetryIF* dest_service = objectManager->get<AcceptsTelemetryIF>(
objects::PUS_PACKET_FORWARDING);
packetDestination);
PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>(
objects::PUS_PACKET_DISTRIBUTOR);
packetSource);
if ((dest_service != NULL) && (distributor != NULL)) {
this->requestQueue.setDefaultDestination(
this->requestQueue->setDefaultDestination(
dest_service->getReportReceptionQueue());
distributor->registerService(this);
return RETURN_OK;
} else {
error << "PusServiceBase::PusServiceBase: Service "
<< (uint32_t) this->serviceId << ": Configuration error."
<< std::endl;
<< " Make sure packetSource and packetDestination are defined correctly" << std::endl;
return RETURN_FAILED;
}
}

View File

@ -1,7 +1,6 @@
#ifndef PUSSERVICEBASE_H_
#define PUSSERVICEBASE_H_
#include <framework/ipc/MessageQueue.h>
#include <framework/objectmanager/ObjectManagerIF.h>
#include <framework/objectmanager/SystemObject.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
@ -10,6 +9,12 @@
#include <framework/tmtcservices/AcceptsTelecommandsIF.h>
#include <framework/tmtcservices/VerificationCodes.h>
#include <framework/tmtcservices/VerificationReporter.h>
#include <framework/internalError/InternalErrorReporterIF.h>
#include <framework/ipc/MessageQueueIF.h>
namespace Factory{
void setStaticFrameworkObjectIds();
}
/**
* \defgroup pus_services PUS Service Framework
@ -26,44 +31,7 @@
* \ingroup pus_services
*/
class PusServiceBase : public ExecutableObjectIF, public AcceptsTelecommandsIF, public SystemObject, public HasReturnvaluesIF {
private:
/**
* This constant sets the maximum number of packets accepted per call.
* Remember that one packet must be completely handled in one #handleRequest call.
*/
static const uint8_t PUS_SERVICE_MAX_RECEPTION = 10;
protected:
/**
* The APID of this instance of the Service.
*/
uint16_t apid;
/**
* The Service Identifier.
*/
uint8_t serviceId;
/**
* One of two error parameters for additional error information.
*/
uint32_t errorParameter1;
/**
* One of two error parameters for additional error information.
*/
uint8_t errorParameter2;
/**
* This is a complete instance of the Telecommand reception queue of the class.
* It is initialized on construction of the class.
*/
MessageQueue requestQueue;
/**
* An instance of the VerificationReporter class, that simplifies sending any kind of
* Verification Message to the TC Verification Service.
*/
VerificationReporter verifyReporter;
/**
* The current Telecommand to be processed.
* It is deleted after handleRequest was executed.
*/
TcPacketStored currentPacket;
friend void (Factory::setStaticFrameworkObjectIds)();
public:
/**
* The constructor for the class.
@ -72,7 +40,7 @@ public:
* @param set_apid The APID the Service is instantiated for.
* @param set_service_id The Service Identifier as specified in ECSS PUS.
*/
PusServiceBase( object_id_t setObjectId, uint16_t set_apid, uint8_t set_service_id );
PusServiceBase( object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId);
/**
* The destructor is empty.
*/
@ -103,10 +71,52 @@ public:
* @return - \c RETURN_OK if the periodic performService was successfull.
* - \c RETURN_FAILED else.
*/
ReturnValue_t performOperation();
ReturnValue_t performOperation(uint8_t opCode);
virtual uint16_t getIdentifier();
MessageQueueId_t getRequestQueue();
virtual ReturnValue_t initialize();
protected:
/**
* The APID of this instance of the Service.
*/
uint16_t apid;
/**
* The Service Identifier.
*/
uint8_t serviceId;
/**
* One of two error parameters for additional error information.
*/
uint32_t errorParameter1;
/**
* One of two error parameters for additional error information.
*/
uint8_t errorParameter2;
/**
* This is a complete instance of the Telecommand reception queue of the class.
* It is initialized on construction of the class.
*/
MessageQueueIF* requestQueue;
/**
* An instance of the VerificationReporter class, that simplifies sending any kind of
* Verification Message to the TC Verification Service.
*/
VerificationReporter verifyReporter;
/**
* The current Telecommand to be processed.
* It is deleted after handleRequest was executed.
*/
TcPacketStored currentPacket;
static object_id_t packetSource;
static object_id_t packetDestination;
private:
/**
* This constant sets the maximum number of packets accepted per call.
* Remember that one packet must be completely handled in one #handleRequest call.
*/
static const uint8_t PUS_SERVICE_MAX_RECEPTION = 10;
};
#endif /* PUSSERVICEBASE_H_ */

View File

@ -1,10 +1,3 @@
/*
* PusVerificationReport.cpp
*
* Created on: 22.05.2012
* Author: baetz
*/
#include <framework/serialize/SerializeAdapter.h>
#include <framework/tmtcservices/PusVerificationReport.h>

View File

@ -1,10 +1,3 @@
/*
* PusVerificationReport.h
*
* Created on: 22.05.2012
* Author: baetz
*/
#ifndef PUSVERIFICATIONREPORT_H_
#define PUSVERIFICATIONREPORT_H_

View File

@ -1,4 +1,5 @@
#include <framework/tmtcservices/TmTcMessage.h>
#include <string.h>
TmTcMessage::TmTcMessage() {

View File

@ -1,10 +1,3 @@
/*
* VerificationCodes.h
*
* Created on: Aug 8, 2012
* Author: baetz
*/
#ifndef VERIFICATIONCODES_H_
#define VERIFICATIONCODES_H_

View File

@ -1,17 +1,12 @@
/*
* VerificationReporter.cpp
*
* Created on: 20.07.2012
* Author: baetz
*/
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/tmtcservices/AcceptsVerifyMessageIF.h>
#include <framework/tmtcservices/PusVerificationReport.h>
#include <framework/tmtcservices/VerificationReporter.h>
object_id_t VerificationReporter::messageReceiver = 0;
VerificationReporter::VerificationReporter() :
acknowledge_queue() {
acknowledgeQueue() {
}
VerificationReporter::~VerificationReporter() {
@ -20,12 +15,15 @@ VerificationReporter::~VerificationReporter() {
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
TcPacketBase* current_packet, uint8_t set_step) {
if (this->acknowledge_queue.getDefaultDestination() == 0) {
if (this->acknowledgeQueue == 0) {
this->initialize();
}
PusVerificationMessage message(set_report_id, current_packet->getAcknowledgeFlags(), current_packet->getPacketId(), current_packet->getPacketSequenceControl(), set_step);
ReturnValue_t status = this->acknowledge_queue.sendToDefault(&message);
if (status != OSAL::RETURN_OK) {
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) {
error
<< "VerificationReporter::sendSuccessReport: Error writing to queue. Code: "
<< (uint16_t) status << std::endl;
@ -33,13 +31,15 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
}
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl, uint8_t set_step) {
if (this->acknowledge_queue.getDefaultDestination() == 0) {
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl,
uint8_t set_step) {
if (this->acknowledgeQueue == 0) {
this->initialize();
}
PusVerificationMessage message(set_report_id, ackFlags, tcPacketId, tcSequenceControl, set_step);
ReturnValue_t status = this->acknowledge_queue.sendToDefault(&message);
if (status != OSAL::RETURN_OK) {
PusVerificationMessage message(set_report_id, ackFlags, tcPacketId,
tcSequenceControl, 0, set_step);
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message);
if (status != HasReturnvaluesIF::RETURN_OK) {
error
<< "VerificationReporter::sendSuccessReport: Error writing to queue. Code: "
<< (uint16_t) status << std::endl;
@ -49,13 +49,16 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
void VerificationReporter::sendFailureReport(uint8_t report_id,
TcPacketBase* current_packet, ReturnValue_t error_code, uint8_t step,
uint32_t parameter1, uint32_t parameter2) {
if (this->acknowledge_queue.getDefaultDestination() == 0) {
if (this->acknowledgeQueue == 0) {
this->initialize();
}
PusVerificationMessage message(report_id, current_packet->getAcknowledgeFlags(), current_packet->getPacketId(), current_packet->getPacketSequenceControl(), error_code, step,
PusVerificationMessage message(report_id,
current_packet->getAcknowledgeFlags(),
current_packet->getPacketId(),
current_packet->getPacketSequenceControl(), error_code, step,
parameter1, parameter2);
ReturnValue_t status = this->acknowledge_queue.sendToDefault(&message);
if (status != OSAL::RETURN_OK) {
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message);
if (status != HasReturnvaluesIF::RETURN_OK) {
error
<< "VerificationReporter::sendFailureReport Error writing to queue. Code: "
<< (uint16_t) status << std::endl;
@ -63,15 +66,16 @@ void VerificationReporter::sendFailureReport(uint8_t report_id,
}
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) {
if (this->acknowledge_queue.getDefaultDestination() == 0) {
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) {
this->initialize();
}
PusVerificationMessage message(report_id, ackFlags, tcPacketId, tcSequenceControl, error_code, step,
parameter1, parameter2);
ReturnValue_t status = this->acknowledge_queue.sendToDefault(&message);
if (status != OSAL::RETURN_OK) {
PusVerificationMessage message(report_id, ackFlags, tcPacketId,
tcSequenceControl, error_code, step, parameter1, parameter2);
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message);
if (status != HasReturnvaluesIF::RETURN_OK) {
error
<< "VerificationReporter::sendFailureReport Error writing to queue. Code: "
<< (uint16_t) status << std::endl;
@ -80,10 +84,9 @@ void VerificationReporter::sendFailureReport(uint8_t report_id,
void VerificationReporter::initialize() {
AcceptsVerifyMessageIF* temp = objectManager->get<AcceptsVerifyMessageIF>(
objects::PUS_VERIFICATION_SERVICE);
messageReceiver);
if (temp != NULL) {
this->acknowledge_queue.setDefaultDestination(
temp->getVerificationQueue());
this->acknowledgeQueue = temp->getVerificationQueue();
} else {
error
<< "VerificationReporter::VerificationReporter: Configuration error."

View File

@ -1,20 +1,15 @@
/*
* VerificationReporter.h
*
* Created on: 20.07.2012
* Author: baetz
*/
#ifndef VERIFICATIONREPORTER_H_
#define VERIFICATIONREPORTER_H_
#include <framework/ipc/MessageQueueSender.h>
#include <framework/objectmanager/ObjectManagerIF.h>
#include <framework/tmtcservices/PusVerificationReport.h>
namespace Factory{
void setStaticFrameworkObjectIds();
}
class VerificationReporter {
protected:
MessageQueueSender acknowledge_queue;
friend void (Factory::setStaticFrameworkObjectIds)();
public:
VerificationReporter();
virtual ~VerificationReporter();
@ -26,6 +21,11 @@ public:
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl, ReturnValue_t error_code = 0, uint8_t step = 0,
uint32_t parameter1 = 0, uint32_t parameter2 = 0);
void initialize();
private:
static object_id_t messageReceiver;
MessageQueueId_t acknowledgeQueue;
};
#endif /* VERIFICATIONREPORTER_H_ */