5 #include "workerthread.h"
7 WorkerThread::WorkerThread(QObject
*parent
)
10 qDebug("WorkerThread::WorkerThread()");
12 // Initialize random generator here
15 // Make thread work forever by default
18 // At this point the class hasn't been fully initialized.
19 // The user must call setFileName(), before run()'ing.
22 WorkerThread::~WorkerThread()
24 qDebug("WorkerThread::~WorkerThread()");
36 void WorkerThread::run(void)
40 qDebug("WorkerThread::run()");
45 if (m_data
.size() >= 2007) {
47 condition
.wait(&m_mutex
);
51 qDebug("Reading from file");
53 if (in
.status() == QDataStream::ReadPastEnd
) {
54 qDebug("Datastream has read past end");
65 void WorkerThread::setFileName(QString fileName
)
67 qDebug("WorkerThread::setFileName()");
72 // Caution: discard all old data in QQueue
73 // Worst case scenario if you don't: frame read corruption
77 m_file
.setFileName(fileName
);
78 if (!m_file
.open(QIODevice::ReadOnly
)) {
79 qDebug("Cannot open file name: %s", fileName
);
82 in
.setDevice(&m_file
);
86 quint32
WorkerThread::getMagicVersion(void) const
88 qDebug("WorkerThread::getMagicVersion()");
90 return m_magicVersion
;
93 quint32
WorkerThread::getProtocolVersion(void) const
95 qDebug("WorkerThread::getProtocolVersion()");
97 return m_protocolVersion
;
100 float WorkerThread::getDuration(void) const
102 qDebug("WorkerThread::getDuration()");
107 quint32
WorkerThread::getNumOfRecords(void) const
109 qDebug("WorkerThread::getNumOfRecords()");
111 return m_numOfRecords
;
114 void WorkerThread::extractFileHeader(void)
116 qDebug("WorkerThread::extractFileHeader()");
118 in
>> m_magicVersion
;
119 //Q_ASSERT(m_magicVersion == 0xA0B0C0D0);
121 in
>> m_protocolVersion
;
122 //Q_ASSERT(m_protocolVersion == 0x1);
125 in
>> m_numOfRecords
;
127 // qDebug() adds an extra space between items,
128 // plus a new line in the last one.
129 qDebug() << "Magic version =" << hex
<< m_magicVersion
;
130 qDebug() << "Protocol version =" << m_protocolVersion
;
131 qDebug() << "Duration in msec = " << m_duration
;
132 qDebug() << "Number of records =" << m_numOfRecords
;