BAOS SDK v2  1.2.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
TransportTcpIO Class Reference

Base class for a Transport input output connection. More...

#include <baos/transport/TransportTcpIO.h>

+ Inheritance diagram for TransportTcpIO:

Public Types

using UPtr = std::unique_ptr< TransportTcpIO >
 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 Types inherited from TransportIO
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

 TransportTcpIO (BaosMsgQueue &msgQueue, wzcpp::ExecutorBase &executor, wzcpp::TimerManager< Clock > &timerManager)
 Construct a new TransportTcpIO object with a given message queue and executor. More...
 
void stop () override
 
void send (const Buffer &buf) override
 Send a byte list out. More...
 
void open (const std::string &ip4Address, std::uint16_t port)
 Open the TCP connection to the remote device. More...
 
void open (IOEvent::EventDataType arg)
 
void close () override
 Close the Transport connection.
 
void waitForFinished () override
 Wait till the worker of this class has finished.
 
bool isOpen () override
 Get the open state of the Transport connection. More...
 
- Public Member Functions inherited from TransportIO
 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 ()
 
bool isIdle () const
 Get the idle state of the Transport connection. More...
 
void onTimersElapsed (wzcpp::TimerManager< Clock >::TimerIdList &timerIds)
 

Protected Attributes

ip::TcpIO tcpIO_
 
- Protected Attributes inherited from TransportIO
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.
 

Additional Inherited Members

- Static Protected Attributes inherited from TransportIO
static std::atomic< std::uint64_t > msgId
 Used to generate a continuous unique message id.
 

Detailed Description

Base class for a Transport input output connection.

This establishes a Transport connection to the BAOS devices. It sends and receives raw bytes.

Constructor & Destructor Documentation

◆ TransportTcpIO()

TransportTcpIO ( BaosMsgQueue &  msgQueue,
wzcpp::ExecutorBase &  executor,
wzcpp::TimerManager< Clock > &  timerManager 
)

Construct a new TransportTcpIO object with a given message queue and executor.

Parameters
msgQueueAn external message queue to post events into
executorAn external executor to run this class worker in
timerManagerAn external timer manager to manage timers for this transport io

Member Function Documentation

◆ stop()

void stop ( )
overridevirtual

Stops the protocol stack

Implements TransportIO.

◆ send()

void send ( const Buffer &  buf)
overridevirtual

Send a byte list out.

Parameters
bufThe bytes to send

Implements TransportIO.

◆ open()

void open ( const std::string &  ip4Address,
std::uint16_t  port 
)

Open the TCP connection to the remote device.

Parameters
ip4AddressThe IPv4 Address as string in the form "xxx.xxx.xxx.xxx"
portThe tcp port of the remote device

◆ isOpen()

bool isOpen ( )
overridevirtual

Get the open state of the Transport connection.

Returns
true if the Transport connection is established false otherwise

Reimplemented from TransportIO.

Member Data Documentation

◆ tcpIO_

ip::TcpIO tcpIO_
protected

The underlying TcpIO used for the actual TCP connection


The documentation for this class was generated from the following file: