2023-03-09 17:44:05 +01:00
|
|
|
#pragma once
|
2021-09-22 16:54:55 +02:00
|
|
|
|
2023-03-09 01:32:27 +01:00
|
|
|
#include <fsfw/objectmanager/SystemObject.h>
|
2022-11-02 10:26:45 +01:00
|
|
|
#include <linux/ipcore/PtmeIF.h>
|
2023-03-09 17:44:05 +01:00
|
|
|
#include <linux/ipcore/VirtualChannelIF.h>
|
2021-09-22 16:54:55 +02:00
|
|
|
|
2023-03-09 17:44:05 +01:00
|
|
|
#include <atomic>
|
|
|
|
#include <string>
|
2022-01-17 15:57:52 +01:00
|
|
|
|
2021-09-22 16:54:55 +02:00
|
|
|
/**
|
2021-09-26 08:29:30 +02:00
|
|
|
* @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.
|
2021-09-22 16:54:55 +02:00
|
|
|
*
|
|
|
|
* @author J. Meier
|
|
|
|
*/
|
2023-03-09 17:44:05 +01:00
|
|
|
class VirtualChannel : public SystemObject, public VirtualChannelIF {
|
2022-01-17 15:58:27 +01:00
|
|
|
public:
|
2023-10-13 09:20:51 +02:00
|
|
|
static constexpr uint8_t CLASS_ID = CLASS_ID::VIRTUAL_CHANNEL;
|
|
|
|
|
|
|
|
static constexpr ReturnValue_t CHANNEL_DOES_NOT_EXIST = returnvalue::makeCode(CLASS_ID, 0);
|
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
/**
|
|
|
|
* @brief Constructor
|
|
|
|
*
|
|
|
|
* @param vcId The virtual channel id assigned to this object
|
|
|
|
* @param tmQueueDepth Queue depth of queue receiving telemetry from other objects
|
|
|
|
*/
|
2023-03-09 17:44:05 +01:00
|
|
|
VirtualChannel(object_id_t objectId, uint8_t vcId, const char* vcName, PtmeIF& ptme,
|
|
|
|
const std::atomic_bool& linkStateProvider);
|
2022-01-17 15:58:27 +01:00
|
|
|
|
2023-03-09 01:32:27 +01:00
|
|
|
ReturnValue_t initialize() override;
|
2023-10-13 09:20:51 +02:00
|
|
|
ReturnValue_t sendNextTm(const uint8_t* data, size_t size, size_t& writtenSize);
|
2023-03-10 18:04:04 +01:00
|
|
|
bool isBusy() const override;
|
2023-10-13 09:20:51 +02:00
|
|
|
ReturnValue_t write(const uint8_t* data, size_t size, size_t& writtenSize) override;
|
2023-10-13 15:10:52 +02:00
|
|
|
ReturnValue_t advanceWrite(size_t& writtenSize) override;
|
|
|
|
ReturnValue_t handleWriteCompletionSynchronously(size_t& writtenSize,
|
|
|
|
unsigned maxCompletionTimeMs);
|
2023-10-13 15:24:06 +02:00
|
|
|
bool writeActive() const override;
|
2023-03-23 18:31:47 +01:00
|
|
|
void cancelTransfer() override;
|
2023-03-09 17:44:05 +01:00
|
|
|
uint8_t getVcid() const;
|
2023-03-28 10:13:39 +02:00
|
|
|
bool isTxOn() const;
|
2022-01-17 15:58:27 +01:00
|
|
|
|
2023-03-09 17:44:05 +01:00
|
|
|
const char* getName() const;
|
2022-01-17 15:58:27 +01:00
|
|
|
|
|
|
|
private:
|
2023-03-09 17:44:05 +01:00
|
|
|
PtmeIF& ptme;
|
2022-04-27 16:44:03 +02:00
|
|
|
uint8_t vcId = 0;
|
2022-09-16 11:43:11 +02:00
|
|
|
std::string vcName;
|
2023-03-27 21:23:09 +02:00
|
|
|
const std::atomic_bool& txOn;
|
2021-09-22 16:54:55 +02:00
|
|
|
};
|