![]() |
YANE-Framework 1.1.0
|
Parenting class for TCP server and client objects. More...
Public Types | |
typedef void(* | T_MESSAGECALLBACK )(char *packetdata, int packetlength, void *ptr) |
Typedef of the callback method to be used for communication. | |
Public Member Functions | |
void | closeConnection () |
Function to close an existing TCP connection. | |
CommBaseTCP (T_MESSAGECALLBACK mess_cb, void *ptr, int readbuffersize, const std::string &name, yane::Utils::DebugMaster *dm, yane::Utils::StatisticsMaster *sm) | |
Constructor. | |
bool | isConnected () |
Function to return whether a TCP connection is established. | |
void | sendData (const char *data, int datasize) |
Function to send data through TCP connection. | |
virtual | ~CommBaseTCP () |
Protected Member Functions | |
virtual void | debugMessage (const std::string &message, int debuglevel) |
Submit a debugmessage. | |
virtual void | debugMessageDouble (const std::string &message, const std::string &varname, int length, double *data, int debuglevel) |
Submit a debugmessage with doublevalued data. | |
virtual void | debugMessageInt (const std::string &message, const std::string &varname, int length, int *data, int debuglevel) |
Submit a debugmessage with integervalued data. | |
virtual void | debugMessageString (const std::string &message, const std::string &varname, const char *data, int debuglevel) |
Submit a debugmessage with textstring data. | |
virtual void | detach () |
Blocks until thread is finished, no return information. | |
virtual bool | isLocked () |
Returns if thread is locked. | |
virtual bool | isRunning () |
Returns if thread is running. | |
virtual void | lock () |
Locks the thread, if already locked blocks. | |
virtual void | run () |
Function which is called after the thread is created. | |
virtual void | start () |
Creates the thread. | |
virtual void | stop () |
Stops the thread. | |
virtual void | trigger () |
Signal / Trigger the thread. | |
virtual bool | trylock () |
Locks the thread but returns immediately. | |
virtual void | unlock () |
Unlock the thread. | |
virtual void | wait () |
Blocks until thread is finished, possible return information. | |
virtual bool | waitForTrigger (unsigned int wait_msec=0, int debuglevel=0) |
Block until triggered. | |
Protected Attributes | |
bool | _abort |
yane::Utils::FIFOBuffer * | _buffer |
Pointer of the first-in-first-out buffer. | |
bool | _connectionestablished |
Bool variable indicating whether a TCP connection is established. | |
DebugClient * | _debugclient |
int | _listensocket |
Socket for incoming messages. | |
T_MESSAGECALLBACK | _mess_cb |
Callback method to be used for communication. | |
char * | _packetdata |
Pointer of the data to be transmitted. | |
void * | _ptr |
Custom pointer passed to the callback function for user defined data. | |
int | _readbuffersize |
Maximal length of incoming data package. | |
bool | _stat_collect |
If true, the actuator will collect statistical data. | |
yane::Utils::StatisticsClientIntCounter * | _stat_crc32 |
Statistics collector for CRC32 errors. | |
yane::Utils::StatisticsClientAverage * | _stat_readbuffersize |
Statistics collector for receiving buffersize. | |
yane::Utils::StatisticsClientIntCounter * | _stat_recvlost |
Statistics collector for lost bytes (receiving) | |
yane::Utils::StatisticsClientIntCounter * | _stat_recvpackages |
Statistics collector for received packages. | |
yane::Utils::StatisticsClientAverage * | _stat_recvpackagesize |
Statistics collector for size of received packages [bytes]. | |
yane::Utils::StatisticsClientPerSecond * | _stat_recvpersec |
Statistics collector for received datarate [bytes/sec]. | |
yane::Utils::StatisticsClientIntCounter * | _stat_recvtotal |
Statistics collector for received bytes. | |
yane::Utils::StatisticsClientIntCounter * | _stat_sentlost |
Statistics collector for lost bytes (sending) | |
yane::Utils::StatisticsClientIntCounter * | _stat_sentpackages |
Statistics collector for sent packages. | |
yane::Utils::StatisticsClientAverage * | _stat_sentpackagesize |
Statistics collector for size of sent packages [bytes]. | |
yane::Utils::StatisticsClientPerSecond * | _stat_sentpersec |
Statistics collector for sent datarate [bytes/sec]. | |
yane::Utils::StatisticsClientIntCounter * | _stat_senttotal |
Statistics collector for sent bytes. | |
yane::Utils::StatisticsClientIntCounter * | _stat_sockerrors |
Statistics collector for socket errors. | |
int | _talksocket |
Socket for outgoing messages. |
Parenting class for TCP server and client objects
typedef void(* yane::NetworkedControl::CommBaseTCP::T_MESSAGECALLBACK)(char *packetdata, int packetlength, void *ptr) |
Typedef of the callback method to be used for communication
packetdata | Pointer of the data to be transmitted |
packetlength | Length of the transmitted package |
ptr | Optional custom pointer passed to the callback function for user defined data |
yane::NetworkedControl::CommBaseTCP::CommBaseTCP | ( | T_MESSAGECALLBACK | mess_cb, |
void * | ptr, | ||
int | readbuffersize, | ||
const std::string & | name, | ||
yane::Utils::DebugMaster * | dm, | ||
yane::Utils::StatisticsMaster * | sm | ||
) |
Constructor
mess_cb | Pointer of the callback function used for communication |
ptr | Optional custom pointer passed to the callback function for user defined data |
readbuffersize | Maximal length of data accepted for input |
name | Name of the thread constructed by this object |
dm | Optional pointer to a class yane::Utils::Debugmaster object |
sm | Optional pointer to a class yane::Utils::StatisticsMaster object |
yane::NetworkedControl::CommBaseTCP::~CommBaseTCP | ( | ) | [virtual] |
Destructor
LIB_EXPORT void yane::Utils::Thread::debugMessage | ( | const std::string & | message, |
int | debuglevel | ||
) | [protected, virtual, inherited] |
Added for convenient handling
message | Message which is debugged |
debuglevel | Level with which the message is debugged. |
LIB_EXPORT void yane::Utils::Thread::debugMessageDouble | ( | const std::string & | message, |
const std::string & | varname, | ||
int | length, | ||
double * | data, | ||
int | debuglevel | ||
) | [protected, virtual, inherited] |
Added for convenient handling
message | Message which is debugged |
varname | Data name |
length | Length of data array |
data | Data which is added. |
debuglevel | Level with which the message is debugged. |
LIB_EXPORT void yane::Utils::Thread::debugMessageInt | ( | const std::string & | message, |
const std::string & | varname, | ||
int | length, | ||
int * | data, | ||
int | debuglevel | ||
) | [protected, virtual, inherited] |
Added for convenient handling
message | Message which is debugged |
varname | Data name |
length | Length of data array |
data | Data which is added. |
debuglevel | Level with which the message is debugged. |
LIB_EXPORT void yane::Utils::Thread::debugMessageString | ( | const std::string & | message, |
const std::string & | varname, | ||
const char * | data, | ||
int | debuglevel | ||
) | [protected, virtual, inherited] |
Added for convenient handling
message | Message which is debugged |
varname | Data name |
data | Pointer to an additional nullterminated character array, that has to be stored as data |
debuglevel | Level with which the message is debugged. |
LIB_EXPORT void yane::Utils::Thread::detach | ( | ) | [virtual, inherited] |
The calling thread is blocked until the thread is finished, no return information
LIB_EXPORT bool yane::Utils::Thread::isLocked | ( | ) | [virtual, inherited] |
Returns wether the thread is locked or not.
LIB_EXPORT bool yane::Utils::Thread::isRunning | ( | ) | [virtual, inherited] |
Returns wether the thread is running (_abort = false) or not.
LIB_EXPORT void yane::Utils::Thread::lock | ( | ) | [virtual, inherited] |
Locks the thread. If already locked the calling thread is blocked until the thread is unlocked.
void yane::NetworkedControl::CommBaseTCP::run | ( | ) | [protected, virtual] |
Overwrite this function to provide your own functionality.
Implements yane::Utils::Thread.
void yane::NetworkedControl::CommBaseTCP::sendData | ( | const char * | data, |
int | datasize | ||
) |
Function to send data through TCP connection
data | Data to be sent |
datasize | Length of data to be sent |
LIB_EXPORT void yane::Utils::Thread::start | ( | ) | [virtual, inherited] |
This function creates the thread and should be called after creating the object.
LIB_EXPORT void yane::Utils::Thread::stop | ( | ) | [virtual, inherited] |
This function sets _abort to false, your thread should stop now.
LIB_EXPORT void yane::Utils::Thread::trigger | ( | ) | [virtual, inherited] |
Signal a thread to resume, if it's blocked due to a call to waitForTrigger()
LIB_EXPORT bool yane::Utils::Thread::trylock | ( | ) | [virtual, inherited] |
Locks the thread. If already locked returns immediately.
LIB_EXPORT void yane::Utils::Thread::unlock | ( | ) | [virtual, inherited] |
Unlocks the thread.
LIB_EXPORT void yane::Utils::Thread::wait | ( | ) | [virtual, inherited] |
The calling thread is blocked until the thread is finished, possible return information
LIB_EXPORT bool yane::Utils::Thread::waitForTrigger | ( | unsigned int | wait_msec = 0 , |
int | debuglevel = 0 |
||
) | [protected, virtual, inherited] |
The calling function (usually the thread) is blocked until the function is triggered.
wait_msec | Time until waiting is aborted. |
debuglevel | Debuglevel with which the abort message is stored. |
bool yane::Utils::Thread::_abort [protected, inherited] |
If true thread should be stopped. Value is changed by stop().
DebugClient* yane::Utils::Thread::_debugclient [protected, inherited] |
Debugclient the debug messages are stored into.