Public Member Functions | Private Member Functions | Private Attributes | List of all members
ThreadDispatcher Class Reference

The ThreadDispatcher class coordinates other communication threads and handles start up and shut down procedures. More...

#include <threaddispatcher.h>

Inheritance diagram for ThreadDispatcher:
Inheritance graph
[legend]

Public Member Functions

void dequeueResponse (std::string &response)
 Pop a received command response from the response queue. More...
 
void dequeueSensorGroupMessage (std::string &response)
 Pop a received sensor group message from the message queue. More...
 
void enableDebugMessages (debugCallbackPtr debug)
 Enable pass through of every line in the input buffer. More...
 
void enableRawCommunication ()
 Enables the transmission of raw messages to the serial device. More...
 
const bool IsMessageQueueEmpty () const
 Is there a message in the message queue? More...
 
const bool IsResponseQueueEmpty () const
 Is there a response in the response queue? More...
 
void registerErrorCallback (debugCallbackPtr error)
 Register a callback to handle transmission/communication errors. More...
 
void registerTextCallback (debugCallbackPtr text)
 Register a callback to handle plain text messages from the serial device. More...
 
void setCommunicationCondVar (std::condition_variable *condVar)
 Register the condition variable of the Communication object in order to wakeup a waiting command response thread. More...
 
void setCommunicationWakeUp (bool wakeUp)
 Set wether there is a command response thread waiting or not. More...
 
void setReadingThread (ReadingThread *rxThread)
 Register ReadingThread with the thread dispatcher. More...
 
void setSensorGroupThread (SensorGroupThread *grpThread)
 Register SensorGroupThread with the thread dispatcher. More...
 
void startThread ()
 Start dispatching thread, SensorGroupThread and ReadingThread. More...
 
void stopThread ()
 Stop dispatching thread, SensorGroupThread and ReadingThread. More...
 
 ThreadDispatcher (const std::shared_ptr< Syntax > &syntax)
 ThreadDispatcher constructor. More...
 
- Public Member Functions inherited from CommunicationThread
 CommunicationThread ()
 CommunicationThread default constructor. More...
 
 CommunicationThread (CommunicationThread &&other)=delete
 CommunicationThread default Move initialization. More...
 
 CommunicationThread (const CommunicationThread &other)=delete
 CommunicationThread default Copy initialization. More...
 
CommunicationThreadoperator= (CommunicationThread &&other)=delete
 CommunicationThread default Move assignment. More...
 
CommunicationThreadoperator= (const CommunicationThread &other)
 CommunicationThread default Copy assignment. More...
 
void sleep ()
 Locks the current worker thread until wakeUp() is called. More...
 
void wakeUp ()
 Unlocks the current worker thread. More...
 

Private Member Functions

void workerFunction ()
 Worker function, responsible for dispatching the correct thread and observing incoming messages from the serial device. More...
 

Private Attributes

std::condition_variable * comCV
 
std::queue< std::string > commandResponse
 
debugCallbackPtr debug
 
bool debugMsgEnabled
 
debugCallbackPtr error
 
bool errorCBregistered
 
bool rawCommunicationEnabled
 
ReadingThreadreadingThread
 
std::queue< std::string > sensorGroupMessage
 
SensorGroupThreadsensorGroupThread
 
std::shared_ptr< Syntaxsyntax
 
debugCallbackPtr text
 
bool textCBregistered
 
bool wakeUpCommunication
 

Additional Inherited Members

- Public Attributes inherited from CommunicationThread
bool active
 
std::thread worker
 

Detailed Description

The ThreadDispatcher class coordinates other communication threads and handles start up and shut down procedures.

Definition at line 34 of file threaddispatcher.h.

Constructor & Destructor Documentation

ThreadDispatcher::ThreadDispatcher ( const std::shared_ptr< Syntax > &  syntax)

ThreadDispatcher constructor.

Parameters
[in]syntaxSyntax object

Definition at line 9 of file threaddispatcher.cpp.

Member Function Documentation

void ThreadDispatcher::dequeueResponse ( std::string &  response)

Pop a received command response from the response queue.

Parameters
[in]responseresponse message from the serial device

Definition at line 136 of file threaddispatcher.cpp.

void ThreadDispatcher::dequeueSensorGroupMessage ( std::string &  response)

Pop a received sensor group message from the message queue.

Parameters
[in]responsesensor group message from the serial device

Definition at line 142 of file threaddispatcher.cpp.

void ThreadDispatcher::enableDebugMessages ( debugCallbackPtr  debug)

Enable pass through of every line in the input buffer.

This will call the registered callback whenever there is a new line in the input buffer. The callback decides what to do with that information.

Parameters
[in]debugFunction pointer of the debug callback.

Definition at line 39 of file threaddispatcher.cpp.

void ThreadDispatcher::enableRawCommunication ( )

Enables the transmission of raw messages to the serial device.

Definition at line 45 of file threaddispatcher.cpp.

const bool ThreadDispatcher::IsMessageQueueEmpty ( ) const

Is there a message in the message queue?

Returns
true if message availible, else false

Definition at line 153 of file threaddispatcher.cpp.

const bool ThreadDispatcher::IsResponseQueueEmpty ( ) const

Is there a response in the response queue?

Returns
true if response availible, else false

Definition at line 148 of file threaddispatcher.cpp.

void ThreadDispatcher::registerErrorCallback ( debugCallbackPtr  error)

Register a callback to handle transmission/communication errors.

The registered function will be called whenever an error during transmission of an outgoing, or parsing of an incoming message occurs. The callback decides what to do with that information.

Parameters
[in]errorFunction pointer of the error callback.
Exceptions
std::exception

Definition at line 122 of file threaddispatcher.cpp.

void ThreadDispatcher::registerTextCallback ( debugCallbackPtr  text)

Register a callback to handle plain text messages from the serial device.

The registered function will be called whenever a plain text message has been received from the serial device. The callback decides what to do with that information.

Parameters
[in]textFunction pointer of the text callback.
Exceptions
std::exception

Definition at line 130 of file threaddispatcher.cpp.

void ThreadDispatcher::setCommunicationCondVar ( std::condition_variable *  condVar)

Register the condition variable of the Communication object in order to wakeup a waiting command response thread.

Parameters
condVarpointer to a condition variable

Definition at line 117 of file threaddispatcher.cpp.

void ThreadDispatcher::setCommunicationWakeUp ( bool  wakeUp)

Set wether there is a command response thread waiting or not.

Parameters
wakeUptrue a command is waiting for response

Definition at line 158 of file threaddispatcher.cpp.

void ThreadDispatcher::setReadingThread ( ReadingThread rxThread)

Register ReadingThread with the thread dispatcher.

Parameters
rxThreadpointer to a ReadingThread object

Definition at line 101 of file threaddispatcher.cpp.

void ThreadDispatcher::setSensorGroupThread ( SensorGroupThread grpThread)

Register SensorGroupThread with the thread dispatcher.

Parameters
rxThreadpointer to a SensorGroupThread object

Definition at line 109 of file threaddispatcher.cpp.

void ThreadDispatcher::startThread ( )
virtual

Start dispatching thread, SensorGroupThread and ReadingThread.

Implements CommunicationThread.

Definition at line 21 of file threaddispatcher.cpp.

void ThreadDispatcher::stopThread ( )
virtual

Stop dispatching thread, SensorGroupThread and ReadingThread.

Implements CommunicationThread.

Definition at line 30 of file threaddispatcher.cpp.

void ThreadDispatcher::workerFunction ( )
privatevirtual

Worker function, responsible for dispatching the correct thread and observing incoming messages from the serial device.

Implements CommunicationThread.

Definition at line 50 of file threaddispatcher.cpp.

Member Data Documentation

std::condition_variable* ThreadDispatcher::comCV
private

condition variable of the Communication object

Definition at line 136 of file threaddispatcher.h.

std::queue<std::string> ThreadDispatcher::commandResponse
private

Incoming command response queue

Definition at line 135 of file threaddispatcher.h.

debugCallbackPtr ThreadDispatcher::debug
private

Pointer to the debug handling function

Definition at line 127 of file threaddispatcher.h.

bool ThreadDispatcher::debugMsgEnabled
private

Is a debug callback available?

Definition at line 130 of file threaddispatcher.h.

debugCallbackPtr ThreadDispatcher::error
private

Pointer to the error handling function

Definition at line 128 of file threaddispatcher.h.

bool ThreadDispatcher::errorCBregistered
private

Is an error callback available?

Definition at line 132 of file threaddispatcher.h.

bool ThreadDispatcher::rawCommunicationEnabled
private

Is a raw communication enabled?

Definition at line 131 of file threaddispatcher.h.

ReadingThread* ThreadDispatcher::readingThread
private

Pointer to the ReadingThread object

Definition at line 125 of file threaddispatcher.h.

std::queue<std::string> ThreadDispatcher::sensorGroupMessage
private

Incoming sensor message queue

Definition at line 137 of file threaddispatcher.h.

SensorGroupThread* ThreadDispatcher::sensorGroupThread
private

Pointer to the SensorGroupThread object

Definition at line 126 of file threaddispatcher.h.

std::shared_ptr<Syntax> ThreadDispatcher::syntax
private

Pointer to a Syntax object

Definition at line 134 of file threaddispatcher.h.

debugCallbackPtr ThreadDispatcher::text
private

Pointer to the text handling function

Definition at line 129 of file threaddispatcher.h.

bool ThreadDispatcher::textCBregistered
private

Is an text callback available?

Definition at line 133 of file threaddispatcher.h.

bool ThreadDispatcher::wakeUpCommunication
private

Definition at line 144 of file threaddispatcher.h.


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


pses_ucbridge
Author(s): Sebastian Ehmes
autogenerated on Sat Oct 28 2017 19:16:13