5#ifndef PICOSCENES_PLATFORM_ABSTRACTFRONTEND_HXX
6#define PICOSCENES_PLATFORM_ABSTRACTFRONTEND_HXX
10#include <condition_variable>
12#include "ModularPicoScenesFrame.hxx"
53 virtual int transmit(
const ModularPicoScenesTxFrame &frame) = 0;
58 virtual int transmitFramesInBatch(
const std::vector<const ModularPicoScenesTxFrame *> &frames, uint32_t repeat) = 0;
60 [[deprecated(
"Use the pointer-version or variadic-template versions of transmitFramesInBatch instead. This method will be removed in future release.")]]
62 std::vector<const ModularPicoScenesTxFrame *> framePoints;
63 framePoints.reserve(frames.size());
64 for (
const auto &frame: frames)
65 framePoints.emplace_back(&frame);
69 template<
int repeat = 1,
typename ... Frames,
typename = std::enable_if_t<(std::is_same_v<std::remove_cvref_t<Frames>, ModularPicoScenesTxFrame *> &&...) ||
70 (std::is_same_v<std::remove_cvref_t<Frames>, ModularPicoScenesTxFrame> &&...) ||
71 ((std::is_same_v<std::remove_cvref_t<Frames>, std::shared_ptr<ModularPicoScenesTxFrame>> ||
72 std::is_same_v<std::remove_cvref_t<Frames>, std::unique_ptr<ModularPicoScenesTxFrame>>) &&...)>>
74 std::vector<const ModularPicoScenesTxFrame *> framePoints;
76 if constexpr ((std::is_same_v<std::remove_cvref_t<Frames>, ModularPicoScenesTxFrame *> && ...)) {
77 (framePoints.emplace_back(frames), ...);
78 }
else if constexpr ((std::is_same_v<std::remove_cvref_t<Frames>, ModularPicoScenesTxFrame> && ...)) {
79 (framePoints.emplace_back(&frames), ...);
80 }
else if constexpr (((std::is_same_v<std::remove_cvref_t<Frames>, std::shared_ptr<ModularPicoScenesTxFrame>> ||
81 std::is_same_v<std::remove_cvref_t<Frames>, std::unique_ptr<ModularPicoScenesTxFrame>>) && ...)) {
82 (framePoints.emplace_back(frames.get()), ...);
197 std::function<void(
const ModularPicoScenesRxFrame &)>
rxHandle =
nullptr;
The shared abstract frontend interface for both SDR and NIC.
PicoScenesDeviceSubtype getFrontEndSubtype() const
Return the PicoScenesDeviceType subtype of this frontend.
std::string referredInterfaceName
the user specified frontend name
virtual int startTx()
Activate internal Tx service loop.
std::condition_variable txPauseCV
void registerRxHandle(const std::function< void(const ModularPicoScenesRxFrame &)> &rxHandle)
Register a handler for the received ModularPicoScenesRxFrame frames.
PicoScenesDeviceType frontEndType
frontend type
AbstractFrontEnd(const std::string &referredInterfaceName)
Create AbstractFrontEnd object according to the user-specified frontend name referredInterfaceName.
PicoScenesDeviceSubtype frontEndSubtype
frontend subtype
virtual int transmit(const ModularPicoScenesTxFrame &frame)=0
virtual int resumeRx()
Resuase the paused Rx service loop, set rxPaused to false.
virtual int transmitFramesInBatch(const std::vector< const ModularPicoScenesTxFrame * > &frames, uint32_t repeat)=0
Transmit frames in batch with precise inter-frame timing.
void setReferredInterfaceName(const std::string &name)
Set the user-specified frontend name.
virtual int startRx()=0
Activiate the Rx service loop.
virtual int stopRx()=0
De-activate the Rx service loop, set rxServiceStarted to false.
PicoScenesFrameTxParameters & getUserSpecifiedTxParameters()
ModularPicoScenesTxFrame initializeTxFrame() override
bool txServiceStarted
indicate whether Tx service is running
bool rxServiceStarted
indicate whether Rx service loop is running
bool txPaused
indicate whether Tx serivce is paused
const std::array< uint8_t, 6 > & getMacAddressPhy() const
Return the MAC address of this frontend. For SDR frontend, this method should generate a pseudo-MAC a...
int transmitFramesInBatch(Frames &&... frames)
virtual void printStatus()=0
Print a status string to command line.
virtual int pauseTx()
Pause Tx service loop.
PicoScenesFrameTxParameters userSpecifiedTxParameters
user-specified Tx parameters
std::array< uint8_t, 6 > macAddress_PHY
macAddress of the frontend
virtual int stopTx()
De-activate Tx service loop.
const std::string & getPhyId() const
Return the PhyId for NIC frontend. This is a undefined behavior for SDR frontend.
virtual int transmitFramesInBatch(const std::vector< ModularPicoScenesTxFrame > &frames, const uint32_t repeat)
virtual ~AbstractFrontEnd()=default
virtual int pauseRx()
Pause the Rx service loop, set rxPaused to true.
virtual bool isTxServiceStarted() const
Returns whether Tx service is started.
bool rxPaused
indicate whether Rx service loop is paused
PicoScenesDeviceType getFrontEndType() const
Return the PicoScenesDeviceType of this frontend.
virtual int resumeTx()
Resume Tx service loop.
const std::string & getReferredInterfaceName() const
Get the user-specified frontend name.
std::function< void(const ModularPicoScenesRxFrame &)> rxHandle
The Rx frame handler.
This class holds the common hardware configuration setters/getters for ALL types of frontend (SDR or ...