direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
NetworkThread Class Reference

Handles the network access to the robot (e.g. via WLAN). More...

#include <networkThread.h>

List of all members.

Public Slots

void sendNetworkCommand (QString text)
void setNetworkMaster ()
void setNetworkSlave ()

Signals

void dataReceived (QString text)
void heartbeat (unsigned char state)

Public Member Functions

bool init (unsigned int portListen, unsigned int portSend)
 NetworkThread ()
virtual void run ()
void stop ()
void swapPorts ()
 ~NetworkThread ()

Private Slots

void processPendingDatagrams ()

Private Attributes

bool iAmTheMaster
bool iAmTheSlave
 Indicates if this program is the master and sends data from the robot over the network.
unsigned int networkPortListen
unsigned int networkPortSend
volatile bool stopped
QUdpSocket * udpSocket

Static Private Attributes

static const unsigned char GREEN = 2
static const unsigned char LEDOFF = 0
static const unsigned char RED = 1
static const unsigned long THREADSLEEPTIME = 1000
 Indicates if this program is the slave and receives data from the robot over the network.

Detailed Description

Handles the network access to the robot (e.g. via WLAN).

Author:
Markus Knapp It opens an UDP socket and listens on a port. When data are received, the signal dataReceived is emitted. UDP used, since the sending of the data does not need to be very reliable.

Definition at line 38 of file networkThread.h.


Constructor & Destructor Documentation

NetworkThread::NetworkThread ( )

Definition at line 23 of file networkThread.cpp.

NetworkThread::~NetworkThread ( )

Definition at line 35 of file networkThread.cpp.


Member Function Documentation

void NetworkThread::dataReceived ( QString  text)
signal

This signal emits when data were received over the network.

Here is the caller graph for this function:

void NetworkThread::heartbeat ( unsigned char  state)
signal

This signal is emitted every MSLEEP seconds to show that we are sending a master signal.

See also:
Gui::setLEDMasterSlave()

Here is the caller graph for this function:

bool NetworkThread::init ( unsigned int  portListen,
unsigned int  portSend 
)

Sets the network ports

Parameters:
portListenis the network port where the class receives data.
portSendis the network port where the class sends data.
Returns:
true on success, false on error

Definition at line 136 of file networkThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkThread::processPendingDatagrams ( )
privateslot

This slot is automatically called by the framework, in the case of pending datagrams.

Definition at line 86 of file networkThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkThread::run ( )
virtual

Starts the thread.

Todo:
add *master# string to ini-file

Definition at line 47 of file networkThread.cpp.

Here is the call graph for this function:

void NetworkThread::sendNetworkCommand ( QString  text)
slot

Sends a string over the network

Definition at line 102 of file networkThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkThread::setNetworkMaster ( )
slot

Enables sending the 'master' signal over network every second

Definition at line 155 of file networkThread.cpp.

void NetworkThread::setNetworkSlave ( )
slot

Setting the network 'slave' state.

Definition at line 164 of file networkThread.cpp.

Here is the caller graph for this function:

void NetworkThread::stop ( )

Stops the thread.

Definition at line 41 of file networkThread.cpp.

Here is the caller graph for this function:

void NetworkThread::swapPorts ( )

Swaps the sender and listener port. This is at the beginning, when we have two instances of this program in one network

Definition at line 116 of file networkThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

const unsigned char NetworkThread::GREEN = 2
staticprivate

Definition at line 123 of file networkThread.h.

bool NetworkThread::iAmTheMaster
private

Definition at line 111 of file networkThread.h.

bool NetworkThread::iAmTheSlave
private

Indicates if this program is the master and sends data from the robot over the network.

Definition at line 112 of file networkThread.h.

const unsigned char NetworkThread::LEDOFF = 0
staticprivate

This is for the

See also:
heartbeat signal (the GUI LED colors)

Definition at line 121 of file networkThread.h.

unsigned int NetworkThread::networkPortListen
private

Definition at line 109 of file networkThread.h.

unsigned int NetworkThread::networkPortSend
private

Definition at line 110 of file networkThread.h.

const unsigned char NetworkThread::RED = 1
staticprivate

Definition at line 122 of file networkThread.h.

volatile bool NetworkThread::stopped
private

Definition at line 108 of file networkThread.h.

const unsigned long NetworkThread::THREADSLEEPTIME = 1000
staticprivate

Indicates if this program is the slave and receives data from the robot over the network.

Definition at line 116 of file networkThread.h.

QUdpSocket* NetworkThread::udpSocket
private

Definition at line 107 of file networkThread.h.


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