Rev 240 | Rev 391 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 240 | Rev 241 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | ***************************************************************************/ |
19 | ***************************************************************************/ |
Line 20... | Line 20... | ||
20 | 20 | ||
Line 21... | Line 21... | ||
21 | #include "CSVLogger.h" |
21 | #include "CSVLogger.h" |
- | 22 | ||
22 | 23 | CSVLogger::CSVLogger(cSettings * settings, sMode * mode) |
|
23 | CSVLogger::CSVLogger(cSettings * settings, sMode * mode) { |
24 | { |
24 | // QFile-Instanz (Log-Datei) |
25 | // QFile-Instanz (Log-Datei) |
25 | csvfile = new QFile(""); |
26 | csvfile = new QFile(""); |
26 | this->settings = settings; |
27 | this->settings = settings; |
Line 27... | Line 28... | ||
27 | this->mode = mode; |
28 | this->mode = mode; |
- | 29 | } |
|
28 | } |
30 | |
29 | 31 | CSVLogger::~CSVLogger() |
|
Line 30... | Line 32... | ||
30 | CSVLogger::~CSVLogger() { |
32 | { |
31 | close(); |
33 | close(); |
- | 34 | } |
|
32 | } |
35 | |
33 | 36 | //datei ist geöffnet bedeutet wir sind soweit und können schreiben |
|
Line 34... | Line 37... | ||
34 | //datei ist geöffnet bedeutet wir sind soweit und können schreiben |
37 | bool CSVLogger::ready() |
35 | bool CSVLogger::ready() { |
38 | { |
Line 42... | Line 45... | ||
42 | if (csvfile->isOpen()) |
45 | if (csvfile->isOpen()) |
43 | csvfile->close(); |
46 | csvfile->close(); |
44 | } |
47 | } |
Line 45... | Line 48... | ||
45 | 48 | ||
46 | //neuen Log erstellen |
49 | //neuen Log erstellen |
- | 50 | void CSVLogger::newLog() |
|
47 | void CSVLogger::newLog() { |
51 | { |
48 | if (!csvfile->isOpen()) |
52 | if (!csvfile->isOpen()) |
49 | { |
53 | { |
- | 54 | QString mode_name = mode->Hardware; |
|
50 | QString mode_name = mode->Hardware; |
55 | |
- | 56 | if (mode_name.size() == 0) |
|
51 | if (mode_name.size() == 0) { |
57 | { |
52 | mode_name = QString("groundstation_log"); |
58 | mode_name = QString("groundstation_log"); |
- | 59 | } |
|
53 | } |
60 | |
54 | QString filename = settings->DIR.Logging + |
- | |
55 | mode_name + "_" + |
61 | QString filename = settings->DIR.Logging + mode_name + "_" + |
56 | QDate::currentDate().toString(("yyyy-MM-dd")) + "_" + |
62 | QDate::currentDate().toString(("yyyy-MM-dd")) + "_" + |
- | 63 | QTime::currentTime().toString("hh-mm") + ".csv"; |
|
57 | QTime::currentTime().toString("hh-mm") + ".csv"; |
64 | |
- | 65 | csvfile = new QFile(filename); |
|
58 | csvfile = new QFile(filename); |
66 | |
59 | if (!csvfile->exists()) |
67 | if (!csvfile->exists()) |
60 | { |
68 | { |
- | 69 | csvfile->open(QIODevice::Append | QIODevice::Text); |
|
- | 70 | ||
- | 71 | QTextStream Out(csvfile); |
|
- | 72 | ||
- | 73 | for (int a = 0; a < MaxAnalog; a++) |
|
- | 74 | { |
|
- | 75 | if (settings->Analog1.LogView[a]) |
|
- | 76 | { |
|
- | 77 | Out << settings->Analog1.Label[a]; |
|
- | 78 | ||
- | 79 | if (a < MaxAnalog - 1) |
|
- | 80 | Out << ';'; |
|
- | 81 | } |
|
- | 82 | } |
|
- | 83 | Out << "\n"; |
|
- | 84 | } |
|
- | 85 | else |
|
- | 86 | { |
|
61 | csvfile->open(QIODevice::Append | QIODevice::Text); |
87 | csvfile->open(QIODevice::Append | QIODevice::Text); |
62 | } |
88 | } |
63 | } |
89 | } |
Line 64... | Line 90... | ||
64 | } |
90 | } |
65 | 91 | ||
- | 92 | //daten schreiben |
|
66 | //daten schreiben |
93 | void CSVLogger::write(int * analogData) |
67 | void CSVLogger::write(int * analogData) { |
94 | { |
68 | if (csvfile->isOpen()) |
95 | if (csvfile->isOpen()) |
69 | { |
96 | { |
70 | QTextStream out(csvfile); |
97 | QTextStream out(csvfile); |