-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloggingthread.cpp
More file actions
70 lines (62 loc) · 1.85 KB
/
Copy pathloggingthread.cpp
File metadata and controls
70 lines (62 loc) · 1.85 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// loggingthread.cpp
#include "loggingthread.h"
#include <QCoreApplication>
#include <QFile>
// Declaration of external variables
extern QList<QVector<double>> existingVectors;
extern QList<QVector<double>> existingVectors2;
extern QList<QVector<double>> loglist;
extern QList<QVector<double>> loglist2;
extern int log_start;
extern int global_log;
extern double log_data1[7][60];
extern double log_data2[7][60];
extern int startlog_gui;
LoggingThread::LoggingThread(QObject *parent) : QThread(parent) {}
LoggingThread::~LoggingThread() {}
void LoggingThread::run()
{
// Logging
QFile file("logdata.txt");
if (file.open(QIODevice::Append | QIODevice::Text))
{
QTextStream stream(&file);
while (true)
{
if (startlog_gui == 1)
{
if (log_start == 1)
{
if (global_log == 0)
{
for (int j = 0; j < 60; ++j)
{
for (int i = 0; i < 7; ++i)
{
stream << log_data2[i][j] << ",";
}
stream << "\n";
}
}
else if (global_log == 1)
{
for (int j = 0; j < 60; ++j)
{
for (int i = 0; i < 7; ++i)
{
stream << log_data1[i][j] << ",";
}
stream << "\n";
}
}
log_start = 0;
}
}
}
}
else
{
qWarning() << "Failed to open file for writing:" << file.errorString();
file.close();
}
}