Rev 239 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 239 | Rev 240 | ||
---|---|---|---|
1 | /*************************************************************************** |
1 | /*************************************************************************** |
2 | * Copyright (C) 2008 by Manuel Schrape * |
2 | * Copyright (C) 2008 by Manuel Schrape * |
3 | * manuel.schrape@gmx.de * |
3 | * manuel.schrape@gmx.de * |
4 | * and Andreas Bresser bresser@informatik.uni-bremen.de * |
4 | * and Andreas Bresser bresser@informatik.uni-bremen.de * |
5 | * * |
5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * |
6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * |
7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License. * |
8 | * the Free Software Foundation; either version 2 of the License. * |
9 | * * |
9 | * * |
10 | * This program is distributed in the hope that it will be useful, * |
10 | * This program is distributed in the hope that it will be useful, * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * GNU General Public License for more details. * |
13 | * GNU General Public License for more details. * |
14 | * * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
17 | * Free Software Foundation, Inc., * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | ***************************************************************************/ |
19 | ***************************************************************************/ |
20 | 20 | ||
21 | #include "CSVLogger.h" |
21 | #include "CSVLogger.h" |
22 | 22 | ||
23 | CSVLogger::CSVLogger(cSettings * settings) { |
23 | CSVLogger::CSVLogger(cSettings * settings, sMode * mode) { |
24 | // QFile-Instanz (Log-Datei) |
24 | // QFile-Instanz (Log-Datei) |
25 | csvfile = new QFile(""); |
25 | csvfile = new QFile(""); |
26 | this->settings = settings; |
26 | this->settings = settings; |
- | 27 | this->mode = mode; |
|
27 | } |
28 | } |
28 | 29 | ||
29 | CSVLogger::~CSVLogger() { |
30 | CSVLogger::~CSVLogger() { |
30 | close(); |
31 | close(); |
31 | } |
32 | } |
32 | 33 | ||
33 | //datei ist geöffnet bedeutet wir sind soweit und können schreiben |
34 | //datei ist geöffnet bedeutet wir sind soweit und können schreiben |
34 | bool CSVLogger::ready() { |
35 | bool CSVLogger::ready() { |
35 | return csvfile->isOpen(); |
36 | return csvfile->isOpen(); |
36 | } |
37 | } |
37 | 38 | ||
38 | //Datei schließen |
39 | //Datei schließen |
39 | void CSVLogger::close() |
40 | void CSVLogger::close() |
40 | { |
41 | { |
41 | if (csvfile->isOpen()) |
42 | if (csvfile->isOpen()) |
42 | csvfile->close(); |
43 | csvfile->close(); |
43 | } |
44 | } |
44 | 45 | ||
45 | //neuen Log erstellen |
46 | //neuen Log erstellen |
46 | void CSVLogger::newLog(QString filename) { |
47 | void CSVLogger::newLog() { |
47 | if (!csvfile->isOpen()) |
48 | if (!csvfile->isOpen()) |
48 | { |
49 | { |
- | 50 | QString mode_name = mode->Hardware; |
|
- | 51 | if (mode_name.size() == 0) { |
|
- | 52 | mode_name = QString("groundstation_log"); |
|
- | 53 | } |
|
- | 54 | QString filename = settings->DIR.Logging + |
|
- | 55 | mode_name + "_" + |
|
- | 56 | QDate::currentDate().toString(("yyyy-MM-dd")) + "_" + |
|
- | 57 | QTime::currentTime().toString("hh-mm") + ".csv"; |
|
49 | csvfile = new QFile(filename); |
58 | csvfile = new QFile(filename); |
50 | if (!csvfile->exists()) |
59 | if (!csvfile->exists()) |
51 | { |
60 | { |
52 | csvfile->open(QIODevice::Append | QIODevice::Text); |
61 | csvfile->open(QIODevice::Append | QIODevice::Text); |
53 | } |
62 | } |
54 | } |
63 | } |
55 | } |
64 | } |
56 | 65 | ||
57 | //daten schreiben |
66 | //daten schreiben |
58 | void CSVLogger::write(int * analogData) { |
67 | void CSVLogger::write(int * analogData) { |
59 | if (csvfile->isOpen()) |
68 | if (csvfile->isOpen()) |
60 | { |
69 | { |
61 | QTextStream out(csvfile); |
70 | QTextStream out(csvfile); |
62 | for (int a=0; a<MaxAnalog; a++) |
71 | for (int a=0; a<MaxAnalog; a++) |
63 | { |
72 | { |
64 | if (settings->Analog1.LogView[a]) |
73 | if (settings->Analog1.LogView[a]) |
65 | { |
74 | { |
66 | out << analogData[a]; |
75 | out << analogData[a]; |
67 | if (a < MaxAnalog - 1) |
76 | if (a < MaxAnalog - 1) |
68 | out << ';'; |
77 | out << ';'; |
69 | } |
78 | } |
70 | } |
79 | } |
71 | out << "\n"; |
80 | out << "\n"; |
72 | } |
81 | } |
73 | } |
82 | } |