BAOS SDK  18.2.0
Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | List of all members
kdrive::baos::StreamConnector Class Referenceabstract

The StreamConnector is responsible for creating a TCP/IP stream connection with the baos server. More...

#include <StreamConnector.h>

Inheritance diagram for kdrive::baos::StreamConnector:
kdrive::baos::BaosConnector kdrive::baos::StreamConnector12 kdrive::baos::StreamConnector2x

Public Types

typedef std::shared_ptr< StreamConnectorPtr
 
- Public Types inherited from kdrive::baos::BaosConnector
typedef std::shared_ptr< BaosConnectorPtr
 

Public Member Functions

 StreamConnector ()=delete
 
 StreamConnector (unsigned char version)
 
 StreamConnector (unsigned char version, const std::string &remoteHost, unsigned short port=StreamProtocolConstants::Port)
 
 StreamConnector (const StreamConnector &)=delete
 
virtual ~StreamConnector ()
 
StreamConnectoroperator= (const StreamConnector &)=delete
 
void open (const std::string &remoteHost, unsigned short port=StreamProtocolConstants::Port)
 Opens a connection. More...
 
std::string getDescription () override
 Returns a formatted port description. More...
 
void setIpAddress (const std::string &ipAddress)
 Sets the IPv4 address from a BAOS device. More...
 
std::string getIpAddress () const
 Gets the IPv4 address from the BAOS device. More...
 
void setIpPort (unsigned short port)
 Sets the port number from the server (BAOS device). More...
 
unsigned short getIpPort () const
 Gets the port number from the server (BAOS device). More...
 
- Public Member Functions inherited from kdrive::baos::BaosConnector
 BaosConnector ()=delete
 
virtual ~BaosConnector ()
 Destroys the BaosConnector. More...
 
unsigned int getConnectorId () const
 Returns the connector id. More...
 
void setVersion (unsigned char version)
 Sets the protocol version. More...
 
unsigned char getVersion () const
 Returns the protocol version. More...
 
virtual bool isConnected () const
 Indicates whether the rx thread is still running, which means that the connector is connected. More...
 

Static Public Attributes

static const std::string ConnectorTypeLabel = "baos.tcp"
 
static const std::string IpAddress = "baos.tcp.ip_address"
 Property Key for device IPv4 address. More...
 
static const std::string IpPort = "baos.tcp.ip_port"
 Property Key for device IPv4 port. More...
 
static const std::string DeviceName = "baos.tcp.device_name"
 Property Key for device name (optional; set in enumeration) More...
 
- Static Public Attributes inherited from kdrive::baos::BaosConnector
static const std::string ConnectorId = "baos.connector_id"
 Property Key for the connector id, set in the constructor. More...
 
static const std::string Version = "baos.version"
 Property Key for version, set by the connector type or enumeration. More...
 
static const std::string RouteTransportPacket = "baos.route_transport_packet"
 

Protected Types

enum  Defaults { BufferSize = 2048 }
 

Protected Member Functions

int readFromSocket (unsigned char *buffer, int maxBytesToRead)
 
int readFromSocket (unsigned char *buffer, std::size_t bufferSize, int bytesToRead, bool validate)
 
void openImpl () override
 
void closeImpl () override
 
void resetPropertiesImpl () override
 Calls resetPropertiesImpl from BaosConnector and readded following properties with default values: More...
 
void txImpl (std::shared_ptr< connector::Packet > packet) override
 Encapsulate the packet and send it to the socket. More...
 
virtual std::size_t encapsulate (const std::shared_ptr< connector::Packet > packet, unsigned char *buffer, std::size_t bufferSize)=0
 Encapsulate the packet to the specific BAOS version. More...
 
- Protected Member Functions inherited from kdrive::baos::BaosConnector
 BaosConnector (unsigned char version)
 Property Key for enable/disable routing of Transport Packets. More...
 
void resetPropertiesImpl () override
 Calls resetPropertiesImpl from base class and readded own properties. More...
 

Detailed Description

The StreamConnector is responsible for creating a TCP/IP stream connection with the baos server.

The StreamConnector is responsible for creating a TCP/IP socket connection to the remote BAOS device. It requires the IP Address of the device.

It implements a connect and a disconnect signal. These signals are invoked when the stream connection is connector and disconnected respectively.

StreamConnector automatically keeps the TCP/IP connection alive. The remote device will close the connection if not activity is noticed within a 2 minute period.

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
BufferSize 

Constructor & Destructor Documentation

kdrive::baos::StreamConnector::StreamConnector ( )
delete
StreamConnector::StreamConnector ( unsigned char  version)
StreamConnector::StreamConnector ( unsigned char  version,
const std::string &  remoteHost,
unsigned short  port = StreamProtocolConstants::Port 
)
kdrive::baos::StreamConnector::StreamConnector ( const StreamConnector )
delete
StreamConnector::~StreamConnector ( )
virtual

Member Function Documentation

void StreamConnector::closeImpl ( )
overrideprotected
virtual std::size_t kdrive::baos::StreamConnector::encapsulate ( const std::shared_ptr< connector::Packet >  packet,
unsigned char *  buffer,
std::size_t  bufferSize 
)
protectedpure virtual

Encapsulate the packet to the specific BAOS version.

std::string StreamConnector::getDescription ( )
override

Returns a formatted port description.

Format: Baos on <IpAddress> e.g. 192.168.1.200

std::string StreamConnector::getIpAddress ( ) const

Gets the IPv4 address from the BAOS device.

This function do not read/write anything from/to the BAOS device.

Returns
The IPv4 address. e.g. "192.168.1.30"
unsigned short StreamConnector::getIpPort ( ) const

Gets the port number from the server (BAOS device).

This function do not read/write anything from/to the BAOS device.

Returns
The port number. e.g. 12004
void StreamConnector::open ( const std::string &  remoteHost,
unsigned short  port = StreamProtocolConstants::Port 
)

Opens a connection.

void StreamConnector::openImpl ( )
overrideprotected
StreamConnector& kdrive::baos::StreamConnector::operator= ( const StreamConnector )
delete
int StreamConnector::readFromSocket ( unsigned char *  buffer,
int  maxBytesToRead 
)
protected
int StreamConnector::readFromSocket ( unsigned char *  buffer,
std::size_t  bufferSize,
int  bytesToRead,
bool  validate 
)
protected
void StreamConnector::resetPropertiesImpl ( )
overrideprotected

Calls resetPropertiesImpl from BaosConnector and readded following properties with default values:

void StreamConnector::setIpAddress ( const std::string &  ipAddress)

Sets the IPv4 address from a BAOS device.

This function do not read/write anything from/to the BAOS device. This property do not changed the IP address of a BAOS device. It were used to specified to which device should connect on open().

Warning
Should only set if the connection is closed.
Parameters
[in]ipAddressThe IPv4 address. e.g. "192.168.1.30"
void StreamConnector::setIpPort ( unsigned short  port)

Sets the port number from the server (BAOS device).

This function do not read/write anything from/to the BAOS device. This property do not changed the port number of a BAOS device. It were used to specified to which device should connect on open(). The default value is 12004 = BAOS Port Number

Warning
Should only set if the connection is closed.
Parameters
[in]portThe port number. e.g. 12004
void StreamConnector::txImpl ( std::shared_ptr< connector::Packet >  packet)
overrideprotected

Encapsulate the packet and send it to the socket.

Member Data Documentation

const std::string StreamConnector::ConnectorTypeLabel = "baos.tcp"
static
const std::string StreamConnector::DeviceName = "baos.tcp.device_name"
static

Property Key for device name (optional; set in enumeration)

const std::string StreamConnector::IpAddress = "baos.tcp.ip_address"
static

Property Key for device IPv4 address.

const std::string StreamConnector::IpPort = "baos.tcp.ip_port"
static

Property Key for device IPv4 port.


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