TwiceAsNice  2019-02-18
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Basda::Microgate::UdpConnectionImpl Class Reference

This class communicates with a BCU. More...

#include <UdpConnectionImpl.h>

Inheritance diagram for Basda::Microgate::UdpConnectionImpl:
Inheritance graph
Collaboration diagram for Basda::Microgate::UdpConnectionImpl:
Collaboration graph

Public Member Functions

 UdpConnectionImpl (const std::string &bcuIpAddress, uint16_t bcuPort, uint16_t localPort)
 
void setTimeoutInMilliseconds (unsigned timeout)
 
void setReceiveBufferSize (unsigned bufferSizeInByte)
 
void initialize ()
 
virtual void send (BcuCommandPtr command)
 
virtual BcuReplyPtr receive ()
 
virtual BcuReplyPtr sendAndWaitForReply (BcuCommandPtr command)
 
virtual ByteBufferPtr receivePacket ()
 
BcuReplyPtr receiveBcuReplyWithMessageId (uint8_t expectedMessageId)
 
virtual ~UdpConnectionImpl ()
 
 UdpConnectionImpl (const std::string &bcuIpAddress, uint16_t bcuPort, uint16_t localPort)
 
void setTimeoutInMilliseconds (unsigned timeout)
 
void setReceiveBufferSize (unsigned bufferSizeInByte)
 
void initialize ()
 
virtual void send (BcuCommandPtr command)
 
virtual BcuReplyPtr receive ()
 
virtual BcuReplyPtr sendAndWaitForReply (BcuCommandPtr command)
 
virtual ByteBufferPtr receivePacket ()
 
BcuReplyPtr receiveBcuReplyWithMessageId (uint8_t expectedMessageId)
 
virtual ~UdpConnectionImpl ()
 
 UdpConnectionImpl (const std::string &bcuIpAddress, uint16_t bcuPort, uint16_t localPort)
 
void setTimeoutInMilliseconds (unsigned timeout)
 
void setReceiveBufferSize (unsigned bufferSizeInByte)
 
void initialize ()
 
virtual void send (BcuCommandPtr command)
 
virtual BcuReplyPtr receive ()
 
virtual BcuReplyPtr sendAndWaitForReply (BcuCommandPtr command)
 
virtual ByteBufferPtr receivePacket ()
 
BcuReplyPtr receiveBcuReplyWithMessageId (uint8_t expectedMessageId)
 
virtual ~UdpConnectionImpl ()
 
- Public Member Functions inherited from Basda::Microgate::UdpConnection
virtual ~UdpConnection ()=0
 
virtual ~UdpConnection ()=0
 
virtual ~UdpConnection ()=0
 

Private Member Functions

int receiveUdpPacketPayload (int8_t *receiveBuffer, unsigned payloadLengthInByte)
 
bool convertUdpPacketPayloadToBcuReplyIfPossible (int8_t *udpPayload, unsigned payloadLengthInByte)
 
bool isValidReplyCode (uint8_t opCode)
 
void openSocket ()
 
void setReceiveBufferTo (int bufferSizeInByte)
 
void examineIfReceiveBufferHasMinimumSize (int bufferSizeInByte)
 
int getReceiveBufferSizeInByte ()
 
void setSocketTimeout ()
 
int receiveUdpPacketPayload (int8_t *receiveBuffer, unsigned payloadLengthInByte)
 
bool convertUdpPacketPayloadToBcuReplyIfPossible (int8_t *udpPayload, unsigned payloadLengthInByte)
 
bool isValidReplyCode (uint8_t opCode)
 
void openSocket ()
 
void setReceiveBufferTo (int bufferSizeInByte)
 
void examineIfReceiveBufferHasMinimumSize (int bufferSizeInByte)
 
int getReceiveBufferSizeInByte ()
 
void setSocketTimeout ()
 
int receiveUdpPacketPayload (int8_t *receiveBuffer, unsigned payloadLengthInByte)
 
bool convertUdpPacketPayloadToBcuReplyIfPossible (int8_t *udpPayload, unsigned payloadLengthInByte)
 
bool isValidReplyCode (uint8_t opCode)
 
void openSocket ()
 
void setReceiveBufferTo (int bufferSizeInByte)
 
void examineIfReceiveBufferHasMinimumSize (int bufferSizeInByte)
 
int getReceiveBufferSizeInByte ()
 
void setSocketTimeout ()
 

Static Private Member Functions

static std::string buildErrnoMessage (int errnoCopy)
 
static std::string buildErrnoMessage (int errnoCopy)
 
static std::string buildErrnoMessage (int errnoCopy)
 

Private Attributes

bool initialized_
 
struct sockaddr_in remoteAddr_
 
int socketFd_
 
std::string ipv4Address_
 
uint16_t bcuPort_
 
uint16_t localPort_
 
unsigned timeoutInMilliseconds_
 
bool hasReceiveBufferSize_
 
unsigned receiveBufferSizeInByte_
 
BcuReplyPtr latestReceivedBcuReply_
 

Static Private Attributes

static const int MAX_MGP_PACKET_SIZE = 4046
 

Detailed Description

This class communicates with a BCU.

Constructor & Destructor Documentation

◆ UdpConnectionImpl() [1/3]

Basda::Microgate::UdpConnectionImpl::UdpConnectionImpl ( const std::string &  bcuIpAddress,
uint16_t  bcuPort,
uint16_t  localPort 
)
Parameters
bcuIpAddressthe IPv4 address of the BCU
bcuPortthe UDP port of the BCU
localPortthe local UDP port

◆ ~UdpConnectionImpl() [1/3]

Basda::Microgate::UdpConnectionImpl::~UdpConnectionImpl ( )
virtual
Note
overridden

◆ UdpConnectionImpl() [2/3]

Basda::Microgate::UdpConnectionImpl::UdpConnectionImpl ( const std::string &  bcuIpAddress,
uint16_t  bcuPort,
uint16_t  localPort 
)
Parameters
bcuIpAddressthe IPv4 address of the BCU
bcuPortthe UDP port of the BCU
localPortthe local UDP port

◆ ~UdpConnectionImpl() [2/3]

virtual Basda::Microgate::UdpConnectionImpl::~UdpConnectionImpl ( )
virtual
Note
overridden

◆ UdpConnectionImpl() [3/3]

Basda::Microgate::UdpConnectionImpl::UdpConnectionImpl ( const std::string &  bcuIpAddress,
uint16_t  bcuPort,
uint16_t  localPort 
)
Parameters
bcuIpAddressthe IPv4 address of the BCU
bcuPortthe UDP port of the BCU
localPortthe local UDP port

◆ ~UdpConnectionImpl() [3/3]

virtual Basda::Microgate::UdpConnectionImpl::~UdpConnectionImpl ( )
virtual
Note
overridden

Member Function Documentation

◆ buildErrnoMessage() [1/3]

std::string Basda::Microgate::UdpConnectionImpl::buildErrnoMessage ( int  errnoCopy)
staticprivate

◆ buildErrnoMessage() [2/3]

static std::string Basda::Microgate::UdpConnectionImpl::buildErrnoMessage ( int  errnoCopy)
staticprivate

◆ buildErrnoMessage() [3/3]

static std::string Basda::Microgate::UdpConnectionImpl::buildErrnoMessage ( int  errnoCopy)
staticprivate

◆ convertUdpPacketPayloadToBcuReplyIfPossible() [1/3]

bool Basda::Microgate::UdpConnectionImpl::convertUdpPacketPayloadToBcuReplyIfPossible ( int8_t udpPayload,
unsigned  payloadLengthInByte 
)
private

◆ convertUdpPacketPayloadToBcuReplyIfPossible() [2/3]

bool Basda::Microgate::UdpConnectionImpl::convertUdpPacketPayloadToBcuReplyIfPossible ( int8_t udpPayload,
unsigned  payloadLengthInByte 
)
private

◆ convertUdpPacketPayloadToBcuReplyIfPossible() [3/3]

bool Basda::Microgate::UdpConnectionImpl::convertUdpPacketPayloadToBcuReplyIfPossible ( int8_t udpPayload,
unsigned  payloadLengthInByte 
)
private

◆ examineIfReceiveBufferHasMinimumSize() [1/3]

void Basda::Microgate::UdpConnectionImpl::examineIfReceiveBufferHasMinimumSize ( int  bufferSizeInByte)
private

◆ examineIfReceiveBufferHasMinimumSize() [2/3]

void Basda::Microgate::UdpConnectionImpl::examineIfReceiveBufferHasMinimumSize ( int  bufferSizeInByte)
private

◆ examineIfReceiveBufferHasMinimumSize() [3/3]

void Basda::Microgate::UdpConnectionImpl::examineIfReceiveBufferHasMinimumSize ( int  bufferSizeInByte)
private

◆ getReceiveBufferSizeInByte() [1/3]

int Basda::Microgate::UdpConnectionImpl::getReceiveBufferSizeInByte ( )
private

◆ getReceiveBufferSizeInByte() [2/3]

int Basda::Microgate::UdpConnectionImpl::getReceiveBufferSizeInByte ( )
private

◆ getReceiveBufferSizeInByte() [3/3]

int Basda::Microgate::UdpConnectionImpl::getReceiveBufferSizeInByte ( )
private

◆ initialize() [1/3]

void Basda::Microgate::UdpConnectionImpl::initialize ( )

◆ initialize() [2/3]

void Basda::Microgate::UdpConnectionImpl::initialize ( )

◆ initialize() [3/3]

void Basda::Microgate::UdpConnectionImpl::initialize ( )

◆ isValidReplyCode() [1/3]

bool Basda::Microgate::UdpConnectionImpl::isValidReplyCode ( uint8_t  opCode)
private

◆ isValidReplyCode() [2/3]

bool Basda::Microgate::UdpConnectionImpl::isValidReplyCode ( uint8_t  opCode)
private

◆ isValidReplyCode() [3/3]

bool Basda::Microgate::UdpConnectionImpl::isValidReplyCode ( uint8_t  opCode)
private

◆ openSocket() [1/3]

void Basda::Microgate::UdpConnectionImpl::openSocket ( )
private

◆ openSocket() [2/3]

void Basda::Microgate::UdpConnectionImpl::openSocket ( )
private

◆ openSocket() [3/3]

void Basda::Microgate::UdpConnectionImpl::openSocket ( )
private

◆ receive() [1/3]

virtual BcuReplyPtr Basda::Microgate::UdpConnectionImpl::receive ( )
virtual
Note
overridden

Implements Basda::Microgate::UdpConnection.

◆ receive() [2/3]

virtual BcuReplyPtr Basda::Microgate::UdpConnectionImpl::receive ( )
virtual
Note
overridden

Implements Basda::Microgate::UdpConnection.

◆ receive() [3/3]

BcuReplyPtr Basda::Microgate::UdpConnectionImpl::receive ( )
virtual
Note
overridden

Implements Basda::Microgate::UdpConnection.

◆ receiveBcuReplyWithMessageId() [1/3]

BcuReplyPtr Basda::Microgate::UdpConnectionImpl::receiveBcuReplyWithMessageId ( uint8_t  expectedMessageId)

◆ receiveBcuReplyWithMessageId() [2/3]

BcuReplyPtr Basda::Microgate::UdpConnectionImpl::receiveBcuReplyWithMessageId ( uint8_t  expectedMessageId)

◆ receiveBcuReplyWithMessageId() [3/3]

BcuReplyPtr Basda::Microgate::UdpConnectionImpl::receiveBcuReplyWithMessageId ( uint8_t  expectedMessageId)

◆ receivePacket() [1/3]

virtual ByteBufferPtr Basda::Microgate::UdpConnectionImpl::receivePacket ( )
virtual
Note
overridden

Implements Basda::Microgate::UdpConnection.

◆ receivePacket() [2/3]

virtual ByteBufferPtr Basda::Microgate::UdpConnectionImpl::receivePacket ( )
virtual
Note
overridden

Implements Basda::Microgate::UdpConnection.

◆ receivePacket() [3/3]

ByteBufferPtr Basda::Microgate::UdpConnectionImpl::receivePacket ( )
virtual
Note
overridden

Implements Basda::Microgate::UdpConnection.

◆ receiveUdpPacketPayload() [1/3]

int Basda::Microgate::UdpConnectionImpl::receiveUdpPacketPayload ( int8_t receiveBuffer,
unsigned  payloadLengthInByte 
)
private

◆ receiveUdpPacketPayload() [2/3]

int Basda::Microgate::UdpConnectionImpl::receiveUdpPacketPayload ( int8_t receiveBuffer,
unsigned  payloadLengthInByte 
)
private

◆ receiveUdpPacketPayload() [3/3]

int Basda::Microgate::UdpConnectionImpl::receiveUdpPacketPayload ( int8_t receiveBuffer,
unsigned  payloadLengthInByte 
)
private

◆ send() [1/3]

virtual void Basda::Microgate::UdpConnectionImpl::send ( BcuCommandPtr  command)
virtual
Note
overridden
overridden

Implements Basda::Microgate::UdpConnection.

◆ send() [2/3]

void Basda::Microgate::UdpConnectionImpl::send ( BcuCommandPtr  command)
virtual
Note
overridden
overridden

Implements Basda::Microgate::UdpConnection.

◆ send() [3/3]

virtual void Basda::Microgate::UdpConnectionImpl::send ( BcuCommandPtr  command)
virtual
Note
overridden
overridden

Implements Basda::Microgate::UdpConnection.

◆ sendAndWaitForReply() [1/3]

virtual BcuReplyPtr Basda::Microgate::UdpConnectionImpl::sendAndWaitForReply ( BcuCommandPtr  command)
virtual
Note
overridden

Implements Basda::Microgate::UdpConnection.

◆ sendAndWaitForReply() [2/3]

BcuReplyPtr Basda::Microgate::UdpConnectionImpl::sendAndWaitForReply ( BcuCommandPtr  command)
virtual
Note
overridden

Implements Basda::Microgate::UdpConnection.

◆ sendAndWaitForReply() [3/3]

virtual BcuReplyPtr Basda::Microgate::UdpConnectionImpl::sendAndWaitForReply ( BcuCommandPtr  command)
virtual
Note
overridden

Implements Basda::Microgate::UdpConnection.

◆ setReceiveBufferSize() [1/3]

void Basda::Microgate::UdpConnectionImpl::setReceiveBufferSize ( unsigned  bufferSizeInByte)

◆ setReceiveBufferSize() [2/3]

void Basda::Microgate::UdpConnectionImpl::setReceiveBufferSize ( unsigned  bufferSizeInByte)

◆ setReceiveBufferSize() [3/3]

void Basda::Microgate::UdpConnectionImpl::setReceiveBufferSize ( unsigned  bufferSizeInByte)

◆ setReceiveBufferTo() [1/3]

void Basda::Microgate::UdpConnectionImpl::setReceiveBufferTo ( int  bufferSizeInByte)
private

◆ setReceiveBufferTo() [2/3]

void Basda::Microgate::UdpConnectionImpl::setReceiveBufferTo ( int  bufferSizeInByte)
private

◆ setReceiveBufferTo() [3/3]

void Basda::Microgate::UdpConnectionImpl::setReceiveBufferTo ( int  bufferSizeInByte)
private

◆ setSocketTimeout() [1/3]

void Basda::Microgate::UdpConnectionImpl::setSocketTimeout ( )
private

◆ setSocketTimeout() [2/3]

void Basda::Microgate::UdpConnectionImpl::setSocketTimeout ( )
private

◆ setSocketTimeout() [3/3]

void Basda::Microgate::UdpConnectionImpl::setSocketTimeout ( )
private

◆ setTimeoutInMilliseconds() [1/3]

void Basda::Microgate::UdpConnectionImpl::setTimeoutInMilliseconds ( unsigned  timeout)
Parameters
timeout0 disables timeout

◆ setTimeoutInMilliseconds() [2/3]

void Basda::Microgate::UdpConnectionImpl::setTimeoutInMilliseconds ( unsigned  timeout)
Parameters
timeout0 disables timeout

◆ setTimeoutInMilliseconds() [3/3]

void Basda::Microgate::UdpConnectionImpl::setTimeoutInMilliseconds ( unsigned  timeout)
Parameters
timeout0 disables timeout

Member Data Documentation

◆ bcuPort_

uint16_t Basda::Microgate::UdpConnectionImpl::bcuPort_
private

◆ hasReceiveBufferSize_

bool Basda::Microgate::UdpConnectionImpl::hasReceiveBufferSize_
private

◆ initialized_

bool Basda::Microgate::UdpConnectionImpl::initialized_
private

◆ ipv4Address_

std::string Basda::Microgate::UdpConnectionImpl::ipv4Address_
private

◆ latestReceivedBcuReply_

BcuReplyPtr Basda::Microgate::UdpConnectionImpl::latestReceivedBcuReply_
private

◆ localPort_

uint16_t Basda::Microgate::UdpConnectionImpl::localPort_
private

◆ MAX_MGP_PACKET_SIZE

static const int Basda::Microgate::UdpConnectionImpl::MAX_MGP_PACKET_SIZE = 4046
staticprivate

◆ receiveBufferSizeInByte_

unsigned Basda::Microgate::UdpConnectionImpl::receiveBufferSizeInByte_
private

◆ remoteAddr_

struct sockaddr_in Basda::Microgate::UdpConnectionImpl::remoteAddr_
private

◆ socketFd_

int Basda::Microgate::UdpConnectionImpl::socketFd_
private

◆ timeoutInMilliseconds_

unsigned Basda::Microgate::UdpConnectionImpl::timeoutInMilliseconds_
private

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