eive-obsw/mission/com/VirtualChannel.cpp

35 lines
1.0 KiB
C++
Raw Normal View History

2021-09-26 08:29:30 +02:00
#include "VirtualChannel.h"
2021-09-22 16:54:55 +02:00
2023-03-09 17:44:05 +01:00
VirtualChannel::VirtualChannel(object_id_t objectId, uint8_t vcId, const char* vcName, PtmeIF& ptme,
2023-03-27 21:23:09 +02:00
const std::atomic_bool& txOn)
2023-03-27 21:39:37 +02:00
: SystemObject(objectId), ptme(ptme), vcId(vcId), vcName(vcName), txOn(txOn) {}
2023-03-09 17:44:05 +01:00
ReturnValue_t VirtualChannel::initialize() { return returnvalue::OK; }
ReturnValue_t VirtualChannel::sendNextTm(const uint8_t* data, size_t size) {
return write(data, size);
2021-09-22 16:54:55 +02:00
}
2023-03-09 17:44:05 +01:00
ReturnValue_t VirtualChannel::write(const uint8_t* data, size_t size) {
2023-06-20 19:39:22 +02:00
if (txOn) {
return ptme.writeToVc(vcId, data, size);
}
return returnvalue::OK;
2021-09-22 16:54:55 +02:00
}
2023-03-09 17:44:05 +01:00
uint8_t VirtualChannel::getVcid() const { return vcId; }
2022-09-16 11:43:11 +02:00
const char* VirtualChannel::getName() const { return vcName.c_str(); }
2023-03-10 18:04:04 +01:00
2023-06-20 19:39:22 +02:00
bool VirtualChannel::isBusy() const {
// Data is discarded, so channel is not busy.
if (not txOn) {
return false;
}
return ptme.isBusy(vcId);
}
2023-03-23 18:31:47 +01:00
2023-03-28 14:59:31 +02:00
void VirtualChannel::cancelTransfer() { ptme.cancelTransfer(vcId); }
2023-03-28 10:13:39 +02:00
2023-03-28 14:59:31 +02:00
bool VirtualChannel::isTxOn() const { return txOn; }