5#ifndef PICOSCENES_PLATFORM_ABSTRACTNIC_HXX
6#define PICOSCENES_PLATFORM_ABSTRACTNIC_HXX
15using namespace std::chrono_literals;
28class AbstractNIC :
public std::enable_shared_from_this<AbstractNIC> {
77 virtual int transmitFramesInBatch(
const std::vector<ModularPicoScenesTxFrame> &frames, uint16_t numRepeats) = 0;
86 template<
int repeat = 1,
typename ... Frames,
typename = std::enable_if_t<(std::is_same_v<std::remove_cvref_t<Frames>, ModularPicoScenesTxFrame *> &&...) ||
87 (std::is_same_v<std::remove_cvref_t<Frames>, ModularPicoScenesTxFrame> &&...) ||
88 ((std::is_same_v<std::remove_cvref_t<Frames>, std::shared_ptr<ModularPicoScenesTxFrame>> ||
89 std::is_same_v<std::remove_cvref_t<Frames>, std::unique_ptr<ModularPicoScenesTxFrame>>) &&...)>>
91 std::vector<ModularPicoScenesTxFrame> batchFrames;
93 if constexpr (((std::is_same_v<std::remove_cvref_t<Frames>, ModularPicoScenesTxFrame *> ||
94 std::is_same_v<std::remove_cvref_t<Frames>, std::shared_ptr<ModularPicoScenesTxFrame>> ||
95 std::is_same_v<std::remove_cvref_t<Frames>, std::unique_ptr<ModularPicoScenesTxFrame>>) && ...)) {
96 (batchFrames.emplace_back(*frames), ...);
97 }
else if constexpr ((std::is_same_v<std::remove_cvref_t<Frames>, ModularPicoScenesTxFrame> && ...)) {
98 (batchFrames.emplace_back(frames), ...);
109 return frontEnd->initializeTxFrame();
157 virtual std::optional<ModularPicoScenesRxFrame>
syncRxConditionally(
const std::function<
bool(
const ModularPicoScenesRxFrame &)> &condition,
const std::chrono::milliseconds &maxWait_ms, std::optional<std::string> conditionaName = std::nullopt) = 0;
165 virtual std::optional<ModularPicoScenesRxFrame>
syncRxWaitTaskId(uint16_t taskid, uint32_t maxWait_ms) = 0;
172 virtual void registerTaskIdHandler(uint16_t taskId,
const std::function<
bool(
const ModularPicoScenesRxFrame &)> &handle) = 0;
226 virtual void registerGeneralHandler(
const std::string &handlerKeyName,
const std::function<
bool(
const ModularPicoScenesRxFrame &)> &handle) = 0;
233 virtual std::function<bool(
const ModularPicoScenesRxFrame &)>
getGeneralHandler(
const std::string &handlerKeyName) = 0;
303 template<
typename FrontEndT,
class = std::enable_if_t<std::is_base_of_v<AbstractFrontEnd, FrontEndT>>>
339 PicoScenesDeviceType
deviceType = PicoScenesDeviceType::Unknown;
Abstract base class for Hardware Abstraction Layer (HAL) configuration.
Abstract base class for Network Interface Card (NIC) operations.
virtual bool checkGeneralHandlerExist(const std::string &handlerKeyName)=0
Check if general handler exists.
virtual void pauseRx()=0
Temporarily pause reception.
virtual void stopTxService()=0
Stop the transmission service.
virtual bool isTxServiceStarted() const =0
Check if transmission service is running.
virtual std::function< bool(const ModularPicoScenesRxFrame &)> getGeneralHandler(const std::string &handlerKeyName)=0
Get general handler by name.
virtual ModularPicoScenesTxFrame initializeTxFrame()
Initialize a new transmission frame.
std::string referredInterfaceName
Interface name reference.
virtual void registerGeneralHandler(const std::string &handlerKeyName, const std::function< bool(const ModularPicoScenesRxFrame &)> &handle)=0
Register a general handler.
const std::string & getReferredInterfaceName() const
Get the interface name.
virtual std::optional< ModularPicoScenesRxFrame > syncRxWaitTaskId(uint16_t taskid, uint32_t maxWait_ms)=0
Wait for a frame with specific task ID.
std::string phyId
Physical interface identifier.
virtual void startRxService()=0
Start the reception service.
virtual void stopRxService()=0
Stop the reception service.
std::shared_ptr< AbstractHALConfiguration > configuration
Hardware abstraction layer configuration.
virtual bool checkFrameTypeHandlerExist(uint8_t frameType)=0
Check if handler exists for specific frame type.
std::shared_ptr< PicoScenesPluginManager > pluginManager
Plugin manager for extending functionality.
std::shared_ptr< AbstractHALConfiguration > getConfiguration() const
Get the HAL configuration.
PicoScenesDeviceType getDeviceType() const
Get the device type.
virtual void resumeRx()=0
Resume paused reception.
const std::shared_ptr< AbstractFrontEnd > & getFrontEnd() const
Get the front end interface.
virtual void pauseTx()=0
Temporarily pause transmission.
virtual void resumeTx()=0
Resume paused transmission.
virtual int transmitPicoScenesFrame(const ModularPicoScenesTxFrame &frame)=0
Transmit a single PicoScenes frame.
virtual void startTxService()=0
Start the transmission service.
virtual bool checkTaskIdHandlerExist(uint16_t taskId)=0
Check if handler exists for specific task ID.
std::shared_ptr< FrontEndT > getTypedFrontEnd() const
Get typed front end instance.
PicoScenesDeviceType deviceType
Type of the device (NIC/SDR)
virtual std::optional< ModularPicoScenesRxFrame > syncRxConditionally(const std::function< bool(const ModularPicoScenesRxFrame &)> &condition, const std::chrono::milliseconds &maxWait_ms, std::optional< std::string > conditionaName=std::nullopt)=0
Wait for a frame that matches specific conditions.
virtual void unregisterFrameTypeHandler(uint8_t frameType)=0
Unregister handler for specific frame type.
virtual void installPlugins() const =0
Install plugins for this NIC.
virtual int transmitFramesInBatch(const std::vector< ModularPicoScenesTxFrame > &frames, uint16_t numRepeats)=0
Transmit multiple frames in batch mode.
virtual PicoScenesFrameTxParameters & getUserSpecifiedTxParameters()=0
This methods returns the PicoScenesFrameTxParameters object created by the user specified Tx paramete...
AbstractNIC(const std::string &referredInterfaceName)
Protected constructor.
std::vector< std::shared_ptr< po::options_description > > getAllNICOptions()
Get all NIC options.
virtual int transmitPicoScenesFrameSync(const ModularPicoScenesTxFrame &frame)=0
Transmit a frame synchronously.
virtual std::function< bool(const ModularPicoScenesRxFrame &)> getHandlerForTaskId(uint16_t taskId)=0
Get handler for specific task ID.
virtual void unregisterTaskIdHandler(uint16_t taskId)=0
Unregister handler for specific task ID.
virtual std::function< bool(const ModularPicoScenesRxFrame &)> getHandlerForFrameType(uint8_t frameType)=0
Get handler for specific frame type.
virtual bool isRxServiceStarted() const =0
Check if reception service is running.
std::shared_ptr< AbstractFrontEnd > frontEnd
Frontend interface for hardware interaction.
virtual void unregisterGeneralHandler(const std::string &handlerKeyName)=0
Unregister general handler.
virtual const PicoScenesFrameTxParameters & getUserSpecifiedTxParameters() const =0
This methods returns the PicoScenesFrameTxParameters object created by the user specified Tx paramete...
const std::shared_ptr< PicoScenesPluginManager > & getPluginManager() const
Get the plugin manager.
virtual void registerFrameTypeHandler(uint8_t frameType, const std::function< bool(const ModularPicoScenesRxFrame &)> &handle)=0
Register handler for specific frame type.
virtual void registerTaskIdHandler(uint16_t taskId, const std::function< bool(const ModularPicoScenesRxFrame &)> &handle)=0
Register a handler for specific task ID.
int transmitFramesInBatch(Frames &&... frames)
Template method for batch transmission of frames.
const std::string & getPhyId() const
Get the physical interface ID.
static std::shared_ptr< FrontEndT > getTypedFrontEndInstance(const std::string &referredInterfaceName)
Get a typed front-end instance for the specified interface.
Manager class for PicoScenes plugins.