BAOS SDK
18.2.0
|
The StreamConnector is responsible for creating a TCP/IP stream connection with the baos server. More...
#include <StreamConnector.h>
Public Types | |
typedef std::shared_ptr< StreamConnector > | Ptr |
Public Types inherited from kdrive::baos::BaosConnector | |
typedef std::shared_ptr< BaosConnector > | Ptr |
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 () |
StreamConnector & | operator= (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... | |
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.
typedef std::shared_ptr<StreamConnector> kdrive::baos::StreamConnector::Ptr |
|
protected |
|
delete |
StreamConnector::StreamConnector | ( | unsigned char | version | ) |
StreamConnector::StreamConnector | ( | unsigned char | version, |
const std::string & | remoteHost, | ||
unsigned short | port = StreamProtocolConstants::Port |
||
) |
|
delete |
|
virtual |
|
overrideprotected |
|
protectedpure virtual |
Encapsulate the packet to the specific BAOS version.
|
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.
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.
void StreamConnector::open | ( | const std::string & | remoteHost, |
unsigned short | port = StreamProtocolConstants::Port |
||
) |
Opens a connection.
|
overrideprotected |
|
delete |
|
protected |
|
protected |
|
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().
[in] | ipAddress | The 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
[in] | port | The port number. e.g. 12004 |
|
overrideprotected |
Encapsulate the packet and send it to the socket.
|
static |
|
static |
Property Key for device name (optional; set in enumeration)
|
static |
Property Key for device IPv4 address.
|
static |
Property Key for device IPv4 port.