5 #include "workerthread.h"
7 WorkerThread::WorkerThread(QObject
*parent
)
10 qDebug("WorkerThread::WorkerThread()");
12 // Initialize random generator here
15 m_file
.setFileName("foo.dat");
16 m_file
.open(QIODevice::ReadOnly
);
17 in
.setDevice(&m_file
);
23 WorkerThread::~WorkerThread()
25 qDebug("WorkerThread::~WorkerThread()");
37 void WorkerThread::run(void)
41 qDebug("WorkerThread::run()");
46 if (m_data
.size() >= 667) {
48 condition
.wait(&mutex
);
59 void WorkerThread::setFileName(QString fileName
)
61 qDebug("WorkerThread::setFileName()");
66 // Caution: discard all old data in QQueue
67 // Worst case scenario if you don't: frame read corruption
71 m_file
.setFileName(fileName
);
72 m_file
.open(QIODevice::ReadOnly
);
73 in
.setDevice(&m_file
);
77 quint32
WorkerThread::getMagicVersion(void) const
79 qDebug("WorkerThread::getMagicVersion()");
81 return m_magicVersion
;
84 quint32
WorkerThread::getProtocolVersion(void) const
86 qDebug("WorkerThread::getProtocolVersion()");
88 return m_protocolVersion
;
91 quint32
WorkerThread::getNumOfRecords(void) const
93 qDebug("WorkerThread::getNumOfRecords()");
95 return m_numOfRecords
;
98 void WorkerThread::extractFileHeader(void)
100 qDebug("WorkerThread::extractFileHeader()");
102 in
>> m_magicVersion
;
103 //Q_ASSERT(m_magicVersion == 0xA0B0C0D0);
105 in
>> m_protocolVersion
;
106 //Q_ASSERT(m_protocolVersion == 0x1);
108 in
>> m_numOfRecords
;
110 // qDebug() adds an extra space between items,
111 // plus a new line in the last one.
112 qDebug() << "Magic version =" << hex
<< m_magicVersion
;
113 qDebug() << "Protocol version =" << m_protocolVersion
;
114 qDebug() << "Number of records =" << m_numOfRecords
;