eive-obsw/mission/com/VirtualChannel.h
Robin Mueller b8beddc11b
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
EIVE/eive-obsw/pipeline/pr-cfdp-source-handler This commit looks good
gens
2023-10-13 15:24:06 +02:00

51 lines
1.7 KiB
C++

#pragma once
#include <fsfw/objectmanager/SystemObject.h>
#include <linux/ipcore/PtmeIF.h>
#include <linux/ipcore/VirtualChannelIF.h>
#include <atomic>
#include <string>
/**
* @brief This class represents a virtual channel. Sending a tm message to an object of this class
* will forward the tm packet to the respective virtual channel of the PTME IP Core.
*
* @author J. Meier
*/
class VirtualChannel : public SystemObject, public VirtualChannelIF {
public:
static constexpr uint8_t CLASS_ID = CLASS_ID::VIRTUAL_CHANNEL;
static constexpr ReturnValue_t CHANNEL_DOES_NOT_EXIST = returnvalue::makeCode(CLASS_ID, 0);
/**
* @brief Constructor
*
* @param vcId The virtual channel id assigned to this object
* @param tmQueueDepth Queue depth of queue receiving telemetry from other objects
*/
VirtualChannel(object_id_t objectId, uint8_t vcId, const char* vcName, PtmeIF& ptme,
const std::atomic_bool& linkStateProvider);
ReturnValue_t initialize() override;
ReturnValue_t sendNextTm(const uint8_t* data, size_t size, size_t& writtenSize);
bool isBusy() const override;
ReturnValue_t write(const uint8_t* data, size_t size, size_t& writtenSize) override;
ReturnValue_t advanceWrite(size_t& writtenSize) override;
ReturnValue_t handleWriteCompletionSynchronously(size_t& writtenSize,
unsigned maxCompletionTimeMs);
bool writeActive() const override;
void cancelTransfer() override;
uint8_t getVcid() const;
bool isTxOn() const;
const char* getName() const;
private:
PtmeIF& ptme;
uint8_t vcId = 0;
std::string vcName;
const std::atomic_bool& txOn;
};