eive-obsw/linux/ipcore/Ptme.cpp

57 lines
1.4 KiB
C++
Raw Normal View History

2021-09-19 12:27:48 +02:00
#include <fcntl.h>
#include <linux/ipcore/Ptme.h>
2022-01-17 15:58:27 +01:00
#include <sys/mman.h>
2022-01-24 16:33:22 +01:00
#include <unistd.h>
2022-01-26 17:59:31 +01:00
2021-09-26 08:29:30 +02:00
#include "PtmeConfig.h"
2023-01-23 11:52:46 +01:00
#include "eive/definitions.h"
2022-01-17 15:58:27 +01:00
#include "fsfw/serviceinterface/ServiceInterface.h"
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
Ptme::Ptme(object_id_t objectId) : SystemObject(objectId) {}
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
Ptme::~Ptme() {}
2021-09-19 12:27:48 +02:00
ReturnValue_t Ptme::initialize() {
2022-01-17 15:58:27 +01:00
VcInterfaceMapIter iter;
for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) {
2022-01-24 16:33:22 +01:00
iter->second->initialize();
2022-01-17 15:58:27 +01:00
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-09-19 12:27:48 +02:00
}
2023-10-13 09:20:51 +02:00
bool Ptme::containsVc(uint8_t vcId) const {
auto channelIter = vcInterfaceMap.find(vcId);
if (channelIter == vcInterfaceMap.end()) {
return false;
2022-01-17 15:58:27 +01:00
}
2023-10-13 09:20:51 +02:00
return true;
2021-09-19 12:27:48 +02:00
}
2023-03-09 17:44:05 +01:00
void Ptme::addVcInterface(VcId_t vcId, VirtualChannelIF* vc) {
2023-01-23 11:52:46 +01:00
if (vcId > config::NUMBER_OF_VIRTUAL_CHANNELS) {
2022-01-17 15:58:27 +01:00
sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl;
return;
}
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
if (vc == nullptr) {
sif::warning << "Ptme::addVcInterface: Invalid virtual channel interface" << std::endl;
return;
}
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
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;
}
2021-09-19 12:27:48 +02:00
}
2023-03-10 18:04:04 +01:00
2023-10-13 09:20:51 +02:00
VirtualChannelIF* Ptme::getVirtChannel(uint8_t vcId) {
auto channelIter = vcInterfaceMap.find(vcId);
if (channelIter == vcInterfaceMap.end()) {
return nullptr;
2023-03-10 18:04:04 +01:00
}
2023-10-13 09:20:51 +02:00
return channelIter->second;
2023-03-23 18:31:47 +01:00
}