eive-obsw/mission/com/VirtualChannel.h

50 lines
1.7 KiB
C
Raw Normal View History

2023-03-09 17:44:05 +01:00
#pragma once
2021-09-22 16:54:55 +02:00
#include <fsfw/objectmanager/SystemObject.h>
#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>
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
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 09:39:50 +02:00
ReturnValue_t finishWrite(const uint8_t* data, size_t start, size_t remainingSize) override;
2023-10-13 09:20:51 +02:00
ReturnValue_t handleLastWriteSynchronously(const uint8_t* data, size_t start, size_t remLen,
unsigned maxDelayMs);
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
};