changed health table parameter to objectId

This commit is contained in:
Ulrich Mohr 2023-02-23 12:44:42 +01:00
parent 5b92247fbd
commit d76d97a36b
2 changed files with 22 additions and 5 deletions

View File

@ -10,9 +10,23 @@
CServiceHealthCommanding::CServiceHealthCommanding(HealthServiceCfg args) CServiceHealthCommanding::CServiceHealthCommanding(HealthServiceCfg args)
: CommandingServiceBase(args.objectId, args.apid, "PUS 201 Health MGMT", args.service, : CommandingServiceBase(args.objectId, args.apid, "PUS 201 Health MGMT", args.service,
args.numParallelCommands, args.commandTimeoutSeconds), args.numParallelCommands, args.commandTimeoutSeconds),
healthTable(args.table), healthTableId(args.table),
maxNumHealthInfoPerCycle(args.maxNumHealthInfoPerCycle) {} maxNumHealthInfoPerCycle(args.maxNumHealthInfoPerCycle) {}
ReturnValue_t CServiceHealthCommanding::initialize() {
ReturnValue_t result = CommandingServiceBase::initialize();
if (result != returnvalue::OK) {
return result;
}
healthTable = ObjectManager::instance()->get<HealthTable>(healthTableId);
if(healthTable == nullptr) {
return returnvalue::FAILED;
}
return returnvalue::OK;
}
ReturnValue_t CServiceHealthCommanding::isValidSubservice(uint8_t subservice) { ReturnValue_t CServiceHealthCommanding::isValidSubservice(uint8_t subservice) {
switch (subservice) { switch (subservice) {
case (Subservice::COMMAND_SET_HEALTH): case (Subservice::COMMAND_SET_HEALTH):
@ -134,7 +148,7 @@ void CServiceHealthCommanding::doPeriodicOperation() {
ReturnValue_t CServiceHealthCommanding::iterateHealthTable(bool reset) { ReturnValue_t CServiceHealthCommanding::iterateHealthTable(bool reset) {
std::pair<object_id_t, HasHealthIF::HealthState> pair; std::pair<object_id_t, HasHealthIF::HealthState> pair;
ReturnValue_t result = healthTable.iterate(&pair, reset); ReturnValue_t result = healthTable->iterate(&pair, reset);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} else { } else {

View File

@ -6,7 +6,7 @@
#include "fsfw/tmtcservices/CommandingServiceBase.h" #include "fsfw/tmtcservices/CommandingServiceBase.h"
struct HealthServiceCfg { struct HealthServiceCfg {
HealthServiceCfg(object_id_t objectId, uint16_t apid, HealthTable &healthTable, HealthServiceCfg(object_id_t objectId, uint16_t apid, object_id_t healthTable,
uint16_t maxNumHealthInfoPerCycle) uint16_t maxNumHealthInfoPerCycle)
: objectId(objectId), : objectId(objectId),
apid(apid), apid(apid),
@ -14,7 +14,7 @@ struct HealthServiceCfg {
maxNumHealthInfoPerCycle(maxNumHealthInfoPerCycle) {} maxNumHealthInfoPerCycle(maxNumHealthInfoPerCycle) {}
object_id_t objectId; object_id_t objectId;
uint16_t apid; uint16_t apid;
HealthTable &table; object_id_t table;
uint16_t maxNumHealthInfoPerCycle; uint16_t maxNumHealthInfoPerCycle;
uint8_t service = 201; uint8_t service = 201;
uint8_t numParallelCommands = 4; uint8_t numParallelCommands = 4;
@ -40,6 +40,8 @@ class CServiceHealthCommanding : public CommandingServiceBase {
CServiceHealthCommanding(HealthServiceCfg args); CServiceHealthCommanding(HealthServiceCfg args);
~CServiceHealthCommanding() override = default; ~CServiceHealthCommanding() override = default;
ReturnValue_t initialize() override;
protected: protected:
/* CSB abstract function implementations */ /* CSB abstract function implementations */
ReturnValue_t isValidSubservice(uint8_t subservice) override; ReturnValue_t isValidSubservice(uint8_t subservice) override;
@ -57,7 +59,8 @@ class CServiceHealthCommanding : public CommandingServiceBase {
void doPeriodicOperation() override; void doPeriodicOperation() override;
private: private:
HealthTable &healthTable; const object_id_t healthTableId;
HealthTable *healthTable;
uint16_t maxNumHealthInfoPerCycle = 0; uint16_t maxNumHealthInfoPerCycle = 0;
bool reportAllHealth = false; bool reportAllHealth = false;
ReturnValue_t iterateHealthTable(bool reset); ReturnValue_t iterateHealthTable(bool reset);