Public Member Functions | Protected Member Functions | Private Attributes | List of all members
DataParser Class Referenceabstract

A class for the data parsing on a separete thread. More...

#include <dataparser.h>

Inheritance diagram for DataParser:
Inheritance graph
[legend]

Public Member Functions

void addRawData (const XsByteArray &arr)
 Adds the raw data to an array. More...
 
void clear ()
 Clears the data queue. More...
 
 DataParser ()
 Default constructor. More...
 
virtual void handleMessage (const XsMessage &message)=0
 Handles a message. More...
 
virtual const char * parserType () const
 
virtual XsResultValue processBufferedData (const XsByteArray &rawIn, std::deque< XsMessage > &messages)=0
 Read all messages from the buffered read data after adding new data supplied in rawIn. More...
 
virtual XsResultValue readDataToBuffer (XsByteArray &raw)=0
 Read available data from the open IO device. More...
 
void terminate ()
 Terminates the thread. More...
 
 ~DataParser () override
 

Protected Member Functions

void initFunction () override
 Initializes the thread. More...
 
int32_t innerFunction () override
 The inner thread function. More...
 
void signalStopThread (void) override
 Tells the thread to stop but does not wait for it to end. More...
 
- Protected Member Functions inherited from xsens::StandardThread
virtual void exitFunction (void)
 Virtual exit function. More...
 
XsThread threadHandle () const
 Return the thread handle. More...
 
XsThreadId getThreadId (void) const
 
bool isAlive (void) volatile const noexcept
 
bool isRunning (void) volatile const noexcept
 Returns whether the thread is currently running. More...
 
bool isTerminating () volatile const noexcept
 Returns whether the thread should (have) terminate(d) More...
 
bool setPriority (XsThreadPriority pri)
 Sets the priority of the thread. More...
 
 StandardThread ()
 
bool startThread (const char *name=NULL)
 Starts the thread. More...
 
void stopThread (void) noexcept
 Tells the thread to stop and waits for it to end. More...
 
virtual ~StandardThread ()
 

Private Attributes

std::queue< XsByteArraym_incoming
 
xsens::Mutex m_incomingMutex
 
xsens::WaitEvent m_newDataEvent
 
char m_parserType [128]
 

Additional Inherited Members

- Protected Attributes inherited from xsens::StandardThread
pthread_attr_t m_attr
 Duplicates m_stop functionality for external dependent classes such as Semaphore. More...
 
bool m_running
 Indicates that the thread is running. More...
 
volatile std::atomic_bool m_stop
 Indicates that the thread should stop. Derived classes should check isTerminating() instead of directly polling this value when checking if the thread should stop. However, there are some cases (tests, SignallingThread) where direct access from within the class is desired, which is why the vlaue is protected instead of private. More...
 
volatile std::atomic_bool m_yieldOnZeroSleep
 When true, a sleep value of 0 returned by innerFunction will trigger a thread yield operation. When false, the next cycle is started immediately. More...
 

Detailed Description

A class for the data parsing on a separete thread.

Definition at line 76 of file dataparser.h.

Constructor & Destructor Documentation

◆ DataParser()

DataParser::DataParser ( )

Default constructor.

Definition at line 76 of file dataparser.cpp.

◆ ~DataParser()

DataParser::~DataParser ( )
override

Definition at line 81 of file dataparser.cpp.

Member Function Documentation

◆ addRawData()

void DataParser::addRawData ( const XsByteArray arr)

Adds the raw data to an array.

Parameters
arrThe reference to a byte array to which the data will be added

Definition at line 95 of file dataparser.cpp.

◆ clear()

void DataParser::clear ( )

Clears the data queue.

Definition at line 160 of file dataparser.cpp.

◆ handleMessage()

virtual void DataParser::handleMessage ( const XsMessage message)
pure virtual

Handles a message.

Implemented in SerialCommunicator, and ProxyCommunicator.

◆ initFunction()

void DataParser::initFunction ( )
overrideprotectedvirtual

Initializes the thread.

Reimplemented from xsens::StandardThread.

Definition at line 150 of file dataparser.cpp.

◆ innerFunction()

int32_t DataParser::innerFunction ( )
overrideprotectedvirtual

The inner thread function.

Reimplemented from xsens::StandardThread.

Definition at line 105 of file dataparser.cpp.

◆ parserType()

virtual const char* DataParser::parserType ( ) const
inlinevirtual
Returns
The parser type

Definition at line 103 of file dataparser.h.

◆ processBufferedData()

virtual XsResultValue DataParser::processBufferedData ( const XsByteArray rawIn,
std::deque< XsMessage > &  messages 
)
pure virtual

Read all messages from the buffered read data after adding new data supplied in rawIn.

Parameters
rawInThe byte array with all data
messagesThe message to process
Returns
The messages that were read.

Implemented in SerialCommunicator, and ProxyCommunicator.

◆ readDataToBuffer()

virtual XsResultValue DataParser::readDataToBuffer ( XsByteArray raw)
pure virtual

Read available data from the open IO device.

Parameters
rawA buffer that will receive the read data.
Returns
XRV_OK if successful

Implemented in SerialCommunicator, and ProxyCommunicator.

◆ signalStopThread()

void DataParser::signalStopThread ( void  )
overrideprotectedvirtual

Tells the thread to stop but does not wait for it to end.

Reimplemented from xsens::StandardThread.

Definition at line 168 of file dataparser.cpp.

◆ terminate()

void DataParser::terminate ( )

Terminates the thread.

Definition at line 176 of file dataparser.cpp.

Member Data Documentation

◆ m_incoming

std::queue<XsByteArray> DataParser::m_incoming
private

Definition at line 115 of file dataparser.h.

◆ m_incomingMutex

xsens::Mutex DataParser::m_incomingMutex
private

Definition at line 114 of file dataparser.h.

◆ m_newDataEvent

xsens::WaitEvent DataParser::m_newDataEvent
private

Definition at line 116 of file dataparser.h.

◆ m_parserType

char DataParser::m_parserType[128]
private

Definition at line 117 of file dataparser.h.


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


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:21