eive-obsw/linux/ipcore/Ptme.cpp
Robin Mueller ffe1281eb9
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
fix PTME
2023-10-13 09:20:51 +02:00

57 lines
1.4 KiB
C++

#include <fcntl.h>
#include <linux/ipcore/Ptme.h>
#include <sys/mman.h>
#include <unistd.h>
#include "PtmeConfig.h"
#include "eive/definitions.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
Ptme::Ptme(object_id_t objectId) : SystemObject(objectId) {}
Ptme::~Ptme() {}
ReturnValue_t Ptme::initialize() {
VcInterfaceMapIter iter;
for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) {
iter->second->initialize();
}
return returnvalue::OK;
}
bool Ptme::containsVc(uint8_t vcId) const {
auto channelIter = vcInterfaceMap.find(vcId);
if (channelIter == vcInterfaceMap.end()) {
return false;
}
return true;
}
void Ptme::addVcInterface(VcId_t vcId, VirtualChannelIF* vc) {
if (vcId > config::NUMBER_OF_VIRTUAL_CHANNELS) {
sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl;
return;
}
if (vc == nullptr) {
sif::warning << "Ptme::addVcInterface: Invalid virtual channel interface" << std::endl;
return;
}
auto status = vcInterfaceMap.emplace(vcId, vc);
if (status.second == false) {
sif::warning << "Ptme::addVcInterface: Failed to add virtual channel interface to "
"virtual channel map"
<< std::endl;
return;
}
}
VirtualChannelIF* Ptme::getVirtChannel(uint8_t vcId) {
auto channelIter = vcInterfaceMap.find(vcId);
if (channelIter == vcInterfaceMap.end()) {
return nullptr;
}
return channelIter->second;
}