65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
#include "TmManager.h"
|
|
|
|
#include <fsfw/objectmanager/ObjectManager.h>
|
|
|
|
ReturnValue_t TmManager::initialize() {
|
|
ReturnValue_t result = SystemObject::initialize();
|
|
if (result != returnvalue::OK) {
|
|
return result;
|
|
}
|
|
|
|
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
|
if (IPCStore == nullptr) {
|
|
return returnvalue::FAILED;
|
|
}
|
|
|
|
return returnvalue::OK;
|
|
}
|
|
|
|
ReturnValue_t TmManager::getProtocolInformation(store_address_t tc,
|
|
protocolInformation* information) const {
|
|
const uint8_t* tcData;
|
|
size_t tcDataSize;
|
|
ReturnValue_t result = IPCStore->getData(tc, &tcData, &tcDataSize);
|
|
if (result != returnvalue::OK) {
|
|
return getDefaultProtocolInformation(information);
|
|
}
|
|
|
|
neither_type tcProtocol = neither_type(*tcData);
|
|
|
|
if (not protocolMap.contains(tcProtocol)) {
|
|
return returnvalue::FAILED;
|
|
}
|
|
auto protocolIter = protocolMap.find(tcProtocol);
|
|
|
|
information->reportingQueue = protocolIter->second.queue;
|
|
information->offset = protocolIter->second.offset;
|
|
information->protocol = tcProtocol;
|
|
|
|
return returnvalue::OK;
|
|
}
|
|
|
|
ReturnValue_t TmManager::registerNetworkProtocolInterface(AcceptsTelemetryIF* object,
|
|
neither_type protocol, size_t offset) {
|
|
if (protocolMap.contains(protocol)) {
|
|
return returnvalue::FAILED;
|
|
}
|
|
|
|
protocolMap.emplace(protocol, ProtocolInformation({object->getReportReceptionQueue(), offset}));
|
|
|
|
return returnvalue::OK;
|
|
}
|
|
|
|
ReturnValue_t TmManager::getDefaultProtocolInformation(protocolInformation* information) const {
|
|
if (protocolMap.empty()) {
|
|
return returnvalue::FAILED;
|
|
}
|
|
|
|
auto protocolIter = protocolMap.begin();
|
|
|
|
information->reportingQueue = protocolIter->second.queue;
|
|
information->offset = protocolIter->second.offset;
|
|
information->protocol = protocolIter->first;
|
|
return returnvalue::OK;
|
|
}
|