2020-12-14 21:30:39 +01:00
|
|
|
#ifndef FSFW_TMTCSERVICES_PUSSERVICEBASE_H_
|
|
|
|
#define FSFW_TMTCSERVICES_PUSSERVICEBASE_H_
|
|
|
|
|
|
|
|
#include "AcceptsTelecommandsIF.h"
|
|
|
|
#include "VerificationCodes.h"
|
|
|
|
#include "VerificationReporter.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../objectmanager/ObjectManagerIF.h"
|
|
|
|
#include "../objectmanager/SystemObject.h"
|
|
|
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
|
|
|
#include "../tasks/ExecutableObjectIF.h"
|
2021-06-14 10:19:01 +02:00
|
|
|
#include "../tmtcpacket/pus/tc.h"
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../ipc/MessageQueueIF.h"
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
namespace Factory{
|
|
|
|
void setStaticFrameworkObjectIds();
|
|
|
|
}
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
/**
|
2020-06-10 21:36:21 +02:00
|
|
|
* @defgroup pus_services PUS Service Framework
|
2016-06-15 23:48:41 +02:00
|
|
|
* These group contains all implementations of PUS Services in the OBSW.
|
|
|
|
* Most of the Services are directly taken from the ECSS PUS Standard.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2020-06-10 21:36:21 +02:00
|
|
|
* @brief This class is the basis for all PUS Services,
|
|
|
|
* which can immediately process Telecommand Packets.
|
|
|
|
* @details
|
|
|
|
* It manages Telecommand reception and the generation of Verification Reports.
|
|
|
|
* Every class that inherits from this abstract class has to implement
|
|
|
|
* handleRequest and performService. Services that are created with this
|
2016-06-15 23:48:41 +02:00
|
|
|
* Base class have to handle any kind of request immediately on reception.
|
2020-06-10 21:36:21 +02:00
|
|
|
* All PUS Services are System Objects, so an Object ID needs to be specified
|
|
|
|
* on construction.
|
|
|
|
* @ingroup pus_services
|
2016-06-15 23:48:41 +02:00
|
|
|
*/
|
2020-06-10 20:28:44 +02:00
|
|
|
class PusServiceBase : public ExecutableObjectIF,
|
|
|
|
public AcceptsTelecommandsIF,
|
|
|
|
public SystemObject,
|
|
|
|
public HasReturnvaluesIF {
|
2018-07-12 16:29:32 +02:00
|
|
|
friend void (Factory::setStaticFrameworkObjectIds)();
|
2016-06-15 23:48:41 +02:00
|
|
|
public:
|
|
|
|
/**
|
2020-06-10 21:36:21 +02:00
|
|
|
* @brief The passed values are set, but inter-object initialization is
|
|
|
|
* done in the initialize method.
|
|
|
|
* @param setObjectId
|
|
|
|
* The system object identifier of this Service instance.
|
|
|
|
* @param setApid
|
|
|
|
* The APID the Service is instantiated for.
|
|
|
|
* @param setServiceId
|
|
|
|
* The Service Identifier as specified in ECSS PUS.
|
2016-06-15 23:48:41 +02:00
|
|
|
*/
|
2020-06-10 21:36:21 +02:00
|
|
|
PusServiceBase( object_id_t setObjectId, uint16_t setApid,
|
|
|
|
uint8_t setServiceId);
|
2016-06-15 23:48:41 +02:00
|
|
|
/**
|
|
|
|
* The destructor is empty.
|
|
|
|
*/
|
|
|
|
virtual ~PusServiceBase();
|
|
|
|
/**
|
2020-06-10 21:36:21 +02:00
|
|
|
* @brief The handleRequest method shall handle any kind of Telecommand
|
|
|
|
* Request immediately.
|
2020-01-18 22:53:38 +01:00
|
|
|
* @details
|
2020-06-10 21:36:21 +02:00
|
|
|
* Implemetations can take the Telecommand in currentPacket and perform
|
|
|
|
* any kind of operation.
|
|
|
|
* They may send additional "Start Success (1,3)" messages with the
|
|
|
|
* verifyReporter, but Completion Success or Failure Reports are generated
|
|
|
|
* automatically after execution of this method.
|
2020-01-18 22:53:38 +01:00
|
|
|
*
|
|
|
|
* If a Telecommand can not be executed within one call cycle,
|
|
|
|
* this Base class is not the right parent.
|
|
|
|
*
|
2020-06-10 21:36:21 +02:00
|
|
|
* The child class may add additional error information by setting
|
|
|
|
* #errorParameters which aren attached to the generated verification
|
|
|
|
* message.
|
2020-01-18 22:53:38 +01:00
|
|
|
*
|
|
|
|
* Subservice checking should be implemented in this method.
|
|
|
|
*
|
2020-06-10 21:36:21 +02:00
|
|
|
* @return The returned status_code is directly taken as main error code
|
|
|
|
* in the Verification Report.
|
2016-06-15 23:48:41 +02:00
|
|
|
* On success, RETURN_OK shall be returned.
|
|
|
|
*/
|
2020-06-10 20:28:44 +02:00
|
|
|
virtual ReturnValue_t handleRequest(uint8_t subservice) = 0;
|
2016-06-15 23:48:41 +02:00
|
|
|
/**
|
2020-06-10 21:36:21 +02:00
|
|
|
* In performService, implementations can handle periodic,
|
|
|
|
* non-TC-triggered activities.
|
2016-06-15 23:48:41 +02:00
|
|
|
* The performService method is always called.
|
2020-06-10 21:36:21 +02:00
|
|
|
* @return Currently, everything other that RETURN_OK only triggers
|
|
|
|
* diagnostic output.
|
2016-06-15 23:48:41 +02:00
|
|
|
*/
|
|
|
|
virtual ReturnValue_t performService() = 0;
|
|
|
|
/**
|
|
|
|
* This method implements the typical activity of a simple PUS Service.
|
2020-06-10 21:36:21 +02:00
|
|
|
* It checks for new requests, and, if found, calls handleRequest, sends
|
|
|
|
* completion verification messages and deletes
|
2016-06-15 23:48:41 +02:00
|
|
|
* the TC requests afterwards.
|
|
|
|
* performService is always executed afterwards.
|
2020-06-10 21:36:21 +02:00
|
|
|
* @return @c RETURN_OK if the periodic performService was successful.
|
|
|
|
* @c RETURN_FAILED else.
|
2016-06-15 23:48:41 +02:00
|
|
|
*/
|
2020-06-29 16:57:00 +02:00
|
|
|
ReturnValue_t performOperation(uint8_t opCode) override;
|
|
|
|
virtual uint16_t getIdentifier() override;
|
|
|
|
MessageQueueId_t getRequestQueue() override;
|
|
|
|
virtual ReturnValue_t initialize() override;
|
|
|
|
|
|
|
|
virtual void setTaskIF(PeriodicTaskIF* taskHandle) override;
|
|
|
|
virtual ReturnValue_t initializeAfterTaskCreation() override;
|
2018-07-12 16:29:32 +02:00
|
|
|
protected:
|
2020-06-29 16:57:00 +02:00
|
|
|
/**
|
|
|
|
* @brief Handle to the underlying task
|
|
|
|
* @details
|
|
|
|
* Will be set by setTaskIF(), which is called on task creation.
|
|
|
|
*/
|
|
|
|
PeriodicTaskIF* taskHandle = nullptr;
|
2018-07-12 16:29:32 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2020-06-10 20:49:30 +02:00
|
|
|
uint32_t errorParameter1 = 0;
|
2018-07-12 16:29:32 +02:00
|
|
|
/**
|
|
|
|
* One of two error parameters for additional error information.
|
|
|
|
*/
|
2020-06-10 20:49:30 +02:00
|
|
|
uint32_t errorParameter2 = 0;
|
2018-07-12 16:29:32 +02:00
|
|
|
/**
|
2020-06-10 21:36:21 +02:00
|
|
|
* This is a complete instance of the telecommand reception queue
|
|
|
|
* of the class. It is initialized on construction of the class.
|
2018-07-12 16:29:32 +02:00
|
|
|
*/
|
2020-06-10 20:49:30 +02:00
|
|
|
MessageQueueIF* requestQueue = nullptr;
|
2018-07-12 16:29:32 +02:00
|
|
|
/**
|
2020-06-10 21:36:21 +02:00
|
|
|
* An instance of the VerificationReporter class, that simplifies
|
|
|
|
* sending any kind of verification message to the TC Verification Service.
|
2018-07-12 16:29:32 +02:00
|
|
|
*/
|
|
|
|
VerificationReporter verifyReporter;
|
|
|
|
/**
|
|
|
|
* The current Telecommand to be processed.
|
|
|
|
* It is deleted after handleRequest was executed.
|
|
|
|
*/
|
2021-06-14 10:19:01 +02:00
|
|
|
TcPacketStoredPus currentPacket;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
|
|
|
static object_id_t packetSource;
|
|
|
|
|
|
|
|
static object_id_t packetDestination;
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* This constant sets the maximum number of packets accepted per call.
|
2020-06-10 21:36:21 +02:00
|
|
|
* Remember that one packet must be completely handled in one
|
|
|
|
* #handleRequest call.
|
2018-07-12 16:29:32 +02:00
|
|
|
*/
|
|
|
|
static const uint8_t PUS_SERVICE_MAX_RECEPTION = 10;
|
2020-06-10 20:49:30 +02:00
|
|
|
|
|
|
|
void handleRequestQueue();
|
2016-06-15 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
2020-12-14 21:30:39 +01:00
|
|
|
#endif /* FSFW_TMTCSERVICES_PUSSERVICEBASE_H_ */
|