OpenCurves  0.9
RTStringMessage Class Reference

Represents a string based message for real-time data plots. More...

#include <rtstringmessage.h>

Inheritance diagram for RTStringMessage:
RTMessage

Public Member Functions

 RTStringMessage (const QString &message=QString())
 Constructor, sending message() when setMesssage() is called.
 
void setMessage (QByteArray &buffer) override
 Set the message to send in buffer. More...
 
int readMessage (const QByteArray &buffer) override
 Read incoming message data. More...
 
void setHeadings (const QStringList &headings)
 Set the headings. More...
 
QStringList headings () const override
 Returns the cache headings. More...
 
unsigned populateValues (std::vector< double > &values) const override
 Data access request for the latest data. More...
 
- Public Member Functions inherited from RTMessage
virtual ~RTMessage ()
 Virtual destructor.
 

Protected Attributes

QString _message
 Message to send, or last read.
 
QStringList _headings
 Cached headings.
 

Detailed Description

Represents a string based message for real-time data plots.

A string message is simply parsed as a delimited value string. Parsing matches that used for file loading; PlotFile::dataLine().

A real time source does not expect heading names, and by default simply labels values "Column 1", "Column 2", etc. This can be overridden by calling setHeadings(), but the number of items must match the incoming data.

As with a data file, each line is expected to have the same number of items.

Member Function Documentation

QStringList RTStringMessage::headings ( ) const
overridevirtual

Returns the cache headings.

Headings are either set explicitly or determined by the first value populateValues() call.

Returns
The headings if available. Empty otherwise.

Implements RTMessage.

Referenced by setHeadings().

unsigned RTStringMessage::populateValues ( std::vector< double > &  values) const
overridevirtual

Data access request for the latest data.

This parses the current message, as read by the last readMessage() call. The headings are populate, if not set, to a numerical sequence 'Column #' to match the number of incoming values.

Parameters
valuesPopulated with the latest data set.
Returns
The number of items in values.

Implements RTMessage.

int RTStringMessage::readMessage ( const QByteArray &  buffer)
overridevirtual

Read incoming message data.

Simply converted to string.

Parameters
bufferThe buffer to convert.
Returns
The number of bytes read on success, negative on error. Zero if nothing to read.

Implements RTMessage.

void RTStringMessage::setHeadings ( const QStringList &  headings)
inline

Set the headings.

Parameters
headingsThe new headings.

References _headings, and headings().

void RTStringMessage::setMessage ( QByteArray &  buffer)
overridevirtual

Set the message to send in buffer.

Write the message given on construction.

Parameters
bufferto populate.

Implements RTMessage.


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