nexxT.interface.DataSamples module

This module defines the nexxT interface class DataSample.

class nexxT.interface.DataSamples.DataSample(content, datatype, timestamp)[source]

Bases: object

Note

Import this class with from nexxT.interface import DataSample.

This class is used for storing a data sample of the nexxT framework. For most generic usage, a QByteArray is used for the storage. This means that deserialization has to be performed on every usage and data generators need to serialize the data. Assumes that serializing / deserializing are efficient operations.

DataSample instances additionally have a type, which is a string and it should uniquely define the serialization method. Last but not least, an integer timestamp is stored for all DataSample instances.

Note

Usually, nexxT is using the wrapped C++ class instead of the python version. In python there are no differences between the wrapped C++ class and this python class. The C++ interface is defined in nexxT::DataSample

TIMESTAMP_RES = 1e-06

the resolution of the timestamps

__init__(content, datatype, timestamp)[source]

Create a new data sample instance.

Parameters:
  • content – A QByteArray instance containing the (serialized) content

  • datatype – A string instance which uniquely defines the serialized content

  • timestamp – An integer representing the sample’s time stamp [µs]

static copy(src)[source]

Create a copy of this DataSample instance

Parameters:

src – the instance to be copied

Returns:

the cloned data sample

static currentTime()[source]

Returns the current system time suitable for data sample timestamps. Note: The python implementation uses time.time_ns, which unfortunately has limited accuracy under windows (16 ms).

Returns:

an integer instance

getContent()[source]

Get the contents of this sample as a QByteArray. Note that this is an efficient operation due to the copy on write semantics of QByteArray. It also asserts that the original contents cannot be modified.

In C++, make sure to keep an instance of the QByteArray until done with processing. Moreover, consider to use QByteArray::constData() for a pointer-to-memory access rather than QByteArray::data(), since the latter will eventually make an unnecessary deep copy of the encapsulated data.

Returns:

QByteArray instance copy

getDatatype()[source]

Return the data type.

Returns:

data type string

getTimestamp()[source]

Return the timestamp associated to the data.

Returns:

integer timestamp