|
BAOS SDK v2
1.2.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
|
Base class for a Transport input output connection. More...
#include <baos/transport/TransportIO.h>
Inheritance diagram for TransportIO:Classes | |
| struct | BaosPromise |
Public Types | |
| enum class | PromiseState { UNUSED , SET , RESOLVED } |
| using | Clock = std::chrono::system_clock |
| An alias for the clock internaly used. | |
| using | UPtr = std::unique_ptr< TransportIO > |
| Alias for a std::unique_ptr to this class. | |
| using | UniqueLock = std::unique_lock< std::mutex > |
| Alias for unique lock used by this class. | |
Public Member Functions | |
| TransportIO (BaosMsgQueue &msgQueue, wzcpp::ExecutorBase &executor, wzcpp::TimerManager< Clock > &timerManager) | |
| Construct a new TransportIO object with a given message queue and executor. More... | |
| TransportIO (const TransportIO &)=delete | |
| TransportIO & | operator= (const TransportIO &)=delete |
| TransportIO (TransportIO &&)=delete | |
| TransportIO & | operator= (TransportIO &&)=delete |
| template<typename LayerType > | |
| void | addLayer (std::uint32_t layerId) |
| ProtocolLayer & | getLayer (unsigned int layerId) |
| void | start () |
| virtual void | stop ()=0 |
| virtual void | send (const Buffer &frame)=0 |
| Send a baos frame. More... | |
| virtual void | close ()=0 |
| Close the Transport connection. | |
| virtual void | waitForFinished ()=0 |
| Wait till the worker of this class has finished. | |
| virtual bool | isOpen () |
| Get the open state of the Transport connection. More... | |
| bool | isIdle () const |
| Get the idle state of the Transport connection. More... | |
| void | onTimersElapsed (wzcpp::TimerManager< Clock >::TimerIdList &timerIds) |
Protected Member Functions | |
| virtual void | eventHandler ()=0 |
| Handles the incoming IOEvents. | |
| virtual void | sendToIo (const Buffer &frame)=0 |
Protected Attributes | |
| std::unique_ptr< ProtocolStack > | transportStack_ |
| The transport stack to use for actual sending and receiving. | |
| std::atomic< bool > | shouldStop_ {false} |
| Flag to indicate that the receiver worker should stop. | |
| std::condition_variable | cvFinished_ |
| Condition variable which is set when the receiver worker has stopped. | |
| std::mutex | cvFinished_mut_ |
| The correponding mutex for the cvFinished_ condition variable. | |
| bool | stopped_ {false} |
| std::atomic< bool > | isOpen_ {false} |
| Flag to show if the Transport connection is open or not. | |
| TransportMsgQueue | msgQueue_ |
| Reference to the message queue in which events will be posted by this class. | |
| BaosMsgQueue & | bMsgQ_ |
| Reference to the message queue in which baos events will be posted by this class. | |
| wzcpp::ExecutorBase & | executor_ |
| Reference to the executor to use for running the receive(RX) worker. | |
| wzcpp::TimerManager< Clock > & | timerManager_ |
| Reference to the timer manager used by this transport IO. | |
| wzcpp::TimerManager< Clock >::AllTimersCallbackId | timerCallbackId_ {0} |
| The id of the callback registered in the timer manager to handle timer events for this transport io. | |
| BaosPromise | connectionPromise_ |
| A promise to be resolved when the connection is established, or disconnected. | |
Static Protected Attributes | |
| static std::atomic< std::uint64_t > | msgId |
| Used to generate a continuous unique message id. | |
Base class for a Transport input output connection.
This establishes a Transport connection to the BAOS devices. It sends and receives raw bytes.
| TransportIO | ( | BaosMsgQueue & | msgQueue, |
| wzcpp::ExecutorBase & | executor, | ||
| wzcpp::TimerManager< Clock > & | timerManager | ||
| ) |
Construct a new TransportIO object with a given message queue and executor.
| msgQueue | An external message queue to post events into |
| executor | An external executor to run this class worker in |
| timerManager | An external timer manager to manage timers for this transport io |
|
delete |
Copy constructor is not supported
|
delete |
Move constructor is not supported
|
delete |
Copy assignment operator is not supported
|
delete |
Move assignment operator is not supported
| void start | ( | ) |
Starts the protocol stack
|
pure virtual |
Stops the protocol stack
Implemented in TransportTcpIO.
|
pure virtual |
|
virtual |
Get the open state of the Transport connection.
Reimplemented in TransportTcpIO.
| bool isIdle | ( | ) | const |
Get the idle state of the Transport connection.
|
protected |
Flag to show the actual state of the receive worker. Because condition variables may suffer from spurious wakeups.