46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
#include "HousekeepingHelper.h"
|
|
|
|
#include <fsfw/objectmanager/ObjectManager.h>
|
|
|
|
#include "GeneratesHousekeepingIF.h"
|
|
|
|
HousekeepingHelper::HousekeepingHelper(GeneratesHousekeepingIF* owner) : owner(owner) {}
|
|
|
|
ReturnValue_t HousekeepingHelper::initialize() {
|
|
tmManager = ObjectManager::instance()->get<TmManager>(objects::TM_MANAGER);
|
|
if (tmManager == nullptr) {
|
|
return returnvalue::FAILED;
|
|
}
|
|
return returnvalue::OK;
|
|
}
|
|
|
|
const HousekeepingSet* HousekeepingHelper::getHousekeepingSet(HousekeepingSetId_t id) {
|
|
auto iter = housekeepingSets.find(id);
|
|
if (iter == housekeepingSets.end()) {
|
|
return nullptr;
|
|
}
|
|
return iter->second;
|
|
}
|
|
|
|
void HousekeepingHelper::registerSet(HousekeepingSet* set) {
|
|
auto id = set->getId();
|
|
housekeepingSets.emplace(id, set);
|
|
}
|
|
|
|
ReturnValue_t HousekeepingHelper::reportHousekeeping(HousekeepingSet* set, const Action* action) {
|
|
SystemObjectIF* ownerAsObject = dynamic_cast<SystemObjectIF*>(owner);
|
|
if (ownerAsObject == nullptr) {
|
|
sif::error << "Duuuuuuuude, what the hell?" << std::endl;
|
|
return returnvalue::FAILED;
|
|
}
|
|
store_address_t tc;
|
|
size_t tcOffset = 0;
|
|
if (action != nullptr) {
|
|
tc = action->tc;
|
|
tcOffset = action->tcOffset;
|
|
}
|
|
|
|
return tmManager->sendTmPacket(ownerAsObject->getObjectId(),
|
|
GeneratesHousekeepingIF::INTERFACE_ID,
|
|
GeneratesHousekeepingIF::Functions::REPORT, set, tc, tcOffset);
|
|
} |