fsfw/src/fsfw/pus/CServiceHealthCommanding.h

82 lines
3.2 KiB
C
Raw Normal View History

2020-12-01 14:59:35 +01:00
#ifndef FSFW_PUS_CSERVICE201HEALTHCOMMANDING_H_
#define FSFW_PUS_CSERVICE201HEALTHCOMMANDING_H_
2023-02-01 17:07:38 +01:00
#include <fsfw/health/HealthTable.h>
#include "fsfw/tmtcservices/CommandingServiceBase.h"
2020-12-01 14:59:35 +01:00
2023-02-01 17:33:24 +01:00
struct HealthServiceCfg {
HealthServiceCfg(object_id_t objectId, uint16_t apid, HealthTable &healthTable,
uint16_t maxNumHealthInfoPerCycle)
: objectId(objectId),
apid(apid),
table(healthTable),
maxNumHealthInfoPerCycle(maxNumHealthInfoPerCycle) {}
object_id_t objectId;
uint16_t apid;
HealthTable &table;
uint16_t maxNumHealthInfoPerCycle;
uint8_t service = 201;
uint8_t numParallelCommands = 4;
uint16_t commandTimeoutSeconds = 60;
};
2020-12-01 14:59:35 +01:00
/**
* @brief Custom PUS service to set health of all objects
* implementing hasHealthIF.
*
* Examples: Device Handlers, Assemblies or Subsystems.
* Full Documentation: ECSS-E-ST-70-41C or ECSS-E-70-41A
* Dissertation Baetz p. 115, 116, 165-167.
*
* This is a gateway service. It relays device commands using the software bus.
* This service is very closely tied to the Commanding Service Base template
* class. There is constant interaction between this Service Base und a
* child class like this service
*
*/
2023-02-01 17:33:24 +01:00
class CServiceHealthCommanding : public CommandingServiceBase {
2022-02-02 10:29:30 +01:00
public:
2023-02-01 17:33:24 +01:00
CServiceHealthCommanding(HealthServiceCfg args);
~CServiceHealthCommanding() override = default;
2020-12-01 14:59:35 +01:00
2022-02-02 10:29:30 +01:00
protected:
/* CSB abstract function implementations */
ReturnValue_t isValidSubservice(uint8_t subservice) override;
ReturnValue_t getMessageQueueAndObject(uint8_t subservice, const uint8_t *tcData,
size_t tcDataLen, MessageQueueId_t *id,
object_id_t *objectId) override;
/** Prepare health command */
ReturnValue_t prepareCommand(CommandMessage *message, uint8_t subservice, const uint8_t *tcData,
size_t tcDataLen, uint32_t *state, object_id_t objectId) override;
/** Handle health reply */
ReturnValue_t handleReply(const CommandMessage *reply, Command_t previousCommand, uint32_t *state,
CommandMessage *optionalNextCommand, object_id_t objectId,
bool *isStep) override;
2020-12-01 14:59:35 +01:00
2023-02-01 17:33:24 +01:00
void doPeriodicOperation() override;
2022-02-02 10:29:30 +01:00
private:
2023-02-01 17:07:38 +01:00
HealthTable &healthTable;
2023-02-01 17:33:24 +01:00
uint16_t maxNumHealthInfoPerCycle = 0;
bool reportAllHealth = false;
2023-02-01 17:07:38 +01:00
ReturnValue_t iterateHealthTable(bool reset);
static ReturnValue_t checkInterfaceAndAcquireMessageQueue(MessageQueueId_t *MessageQueueToSet,
const object_id_t *objectId);
2020-12-01 14:59:35 +01:00
2022-05-09 10:47:56 +02:00
[[maybe_unused]] ReturnValue_t prepareHealthSetReply(const CommandMessage *reply);
2020-12-01 14:59:35 +01:00
2022-02-02 10:29:30 +01:00
enum Subservice {
//! [EXPORT] : [TC] Set health of target object
COMMAND_SET_HEALTH = 1,
//! [EXPORT] : [TM] Reply to health set command which also provides old health
REPLY_HEALTH_SET = 2,
//! [EXPORT] : [TC] Commands object to announce their health as an event
COMMAND_ANNOUNCE_HEALTH = 3,
//! [EXPORT] : [TC] Commands all objects in the health map to announce their health
COMMAND_ANNOUNCE_HEALTH_ALL = 4
};
2020-12-01 14:59:35 +01:00
};
#endif /* FSFW_PUS_CSERVICE201HEALTHCOMMANDING_H_ */