OpenCurves
0.9
|
Represents a binary based message for real-time data plots. More...
#include <rtbinarymessage.h>
Public Types | |
enum | FieldType { Padding, PadTo, PadByField, PadToField, Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32, Uint64, Float32, Float64 } |
Fixed field types. More... | |
Public Member Functions | |
RTBinaryMessage (bool littleEndian=false) | |
Create a binary message. More... | |
bool | littleEndian () const |
Does the message write little Endian? More... | |
void | setMessage (QByteArray &buffer) override |
Writes the binary message to buffer . More... | |
int | readMessage (const QByteArray &buffer) override |
Read and update values from the buffer . More... | |
QStringList | headings () const override |
Return the list of headings. More... | |
unsigned | populateValues (std::vector< double > &values) const override |
Request the most up to date field values. More... | |
void | addField (const QString &name, FieldType type, bool heading=false, const QVariant &value=QVariant()) |
Registers a field. More... | |
int | fieldIndex (const QString &key) const |
Query the index of a field named key . More... | |
double | fieldValueD (const QString &key) const |
Requests a field value by name, converting to a double. More... | |
QVariant | fieldValueV (const QString &key) const |
Requests a field value by name, returning a QVariant . More... | |
![]() | |
virtual | ~RTMessage () |
Virtual destructor. | |
Static Public Attributes | |
static const unsigned | TypeSizes [] |
Sizes for various FieldType items (bytes). | |
Represents a binary based message for real-time data plots.
This stores a number of fields and may read or write these appropriately. Each field has a known type and a default value. When writing, each field has its default value written to the buffer. When reading, each field is read from the stream, changing its value.
A field may also be a padding field. Padding may be specified
Padding
- pad by adding a fixed byte countPadTo
- pad the buffer out to the specified byte countPadToField
- pad the buffer out to a specified byte count. The byte count is attained by reading another field. The padding field name is stored as a string in the original field's value.The same padding process is used on reading or writing, with zero bytes used for writing padding, and padding bytes skipped while reading.
Supports writing little or big Endian.
Registered fields may be marked as headings. Only those marked as such are reported by headings()
and populateValues()
.
RTBinaryMessage::RTBinaryMessage | ( | bool | littleEndian = false | ) |
Create a binary message.
littleEndian | True to write little Endian, false to write big. |
void RTBinaryMessage::addField | ( | const QString & | name, |
FieldType | type, | ||
bool | heading = false , |
||
const QVariant & | value = QVariant() |
||
) |
Registers a field.
name | The field name. May be used as a heading. |
type | The field type. |
heading | True if this field is exposed as a heading. |
value | The default or initial value. |
int RTBinaryMessage::fieldIndex | ( | const QString & | key | ) | const |
Query the index of a field named key
.
key | The field name to query. |
key
or -1 if there is no such field. double RTBinaryMessage::fieldValueD | ( | const QString & | key | ) | const |
Requests a field value by name, converting to a double.
key | The field name requested. |
QVariant RTBinaryMessage::fieldValueV | ( | const QString & | key | ) | const |
Requests a field value by name, returning a QVariant
.
key | The field name requested. |
QVariant
. Returns a null value on any failure, but a valid field value may also be null.
|
overridevirtual |
Return the list of headings.
This is the list of fields marked as headings.
Implements RTMessage.
|
inline |
Does the message write little Endian?
|
overridevirtual |
Request the most up to date field values.
Only exposes those marked as headings.
values | The values array to populate. |
Implements RTMessage.
|
overridevirtual |
Read and update values from the buffer
.
buffer | The buffer to read from. |
Implements RTMessage.
|
overridevirtual |