-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRawDataWriter.cpp
More file actions
39 lines (30 loc) · 920 Bytes
/
RawDataWriter.cpp
File metadata and controls
39 lines (30 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <QFile>
#include <QDir>
#include "Types/RawData.hpp"
#include "RawDataWriter.hpp"
RawDataWriter::RawDataWriter(QObject* parent)
: QObject(parent)
{
}
void RawDataWriter::init()
{
const auto openFile = [this](QFile*& file, int index) {
const QString path(QDir::current().absoluteFilePath("rx%1.bin"));
if (file) file->deleteLater();
file = new QFile(path.arg(index), this);
if (!file->open(QIODevice::WriteOnly))
qFatal("Can't open file %s for write: %s",
qPrintable(file->fileName()),
qPrintable(file->errorString()));
};
openFile(mRx1, 1);
openFile(mRx2, 2);
}
void RawDataWriter::onData(const RawData& data)
{
const auto write = [](QFile* file, const QByteArray& data) {
if (file && !data.isEmpty()) file->write(data);
};
write(mRx1, data.rx1());
write(mRx2, data.rx2());
}