/QMK-Groundstation/trunk/Forms/mktool.cpp |
---|
198,8 → 198,8 |
// Seriell-Port |
serialPort = new ManageSerialPort; |
// QFile-Instanz (Log-Datei) |
CSVFile = new QFile(""); |
// neuer Logger |
logger = new Logger(Settings); |
// LCD-Dialog |
f_LCD = new dlg_LCD(this); |
275,7 → 275,7 |
connect(pb_HexFile, SIGNAL(clicked()), this, SLOT(slot_pb_HexFile())); |
// CVS-Record starten / stoppen |
connect(ac_RecordCSV, SIGNAL(triggered()), this, SLOT(slot_RecordCSV())); |
connect(ac_RecordCSV, SIGNAL(triggered()), this, SLOT(slot_RecordLog())); |
// Timer-Events |
connect(Ticker, SIGNAL(timeout()), SLOT(slot_Ticker())); |
613,15 → 613,44 |
} |
// CVS-Datei neu anlegen. |
if ((CSVFile->isOpen()) && (Old_Analog1.LogView != Settings->Analog1.LogView)) |
if (Old_Analog1.LogView != Settings->Analog1.LogView) |
{ |
slot_RecordCSV(); |
slot_RecordCSV(); |
QString filename = Settings->DIR.Logging + Mode.Hardware + " - " + QDate::currentDate().toString(("yyyy-MM-dd")) + " -- " + QTime::currentTime().toString("hh-mm"); |
logger->close(); |
logger->newLog(filename); |
update_Log(); |
} |
} |
} |
//aktualisiere Logging-Status |
void MKTool::update_Log() { |
if (logger->is_active()) |
{ |
logger->write(AnalogData); |
pb_Record->setText("Log Stop"); |
ac_RecordCSV->setText("Log Stop"); |
lb_Status->setText(tr("Log-Record gestartet.")); |
} |
else |
{ |
pb_Record->setText("Log Aufzeichnen"); |
ac_RecordCSV->setText("Log Aufzeichnen"); |
lb_Status->setText(tr("Log-Record gestopt.")); |
} |
} |
//starte/stoppe Logging, wenn auf den entsprechenden Button gedrückt wurde |
void MKTool::slot_RecordLog() |
{ |
if (!logger->is_active()) |
logger->start_Log(); |
else |
logger->close(); |
update_Log(); |
} |
void MKTool::slot_ac_Preferences() |
{ |
dlg_Preferences *f_Preferences = new dlg_Preferences(this); |
1060,76 → 1089,9 |
} |
// Debug-Daten anzeigen und Aufzeichnen |
/////////////////////////////////////// |
void MKTool::write_CSV() |
{ |
QTextStream Out(CSVFile); |
for (int a=0; a<MaxAnalog; a++) |
{ |
if (Settings->Analog1.LogView[a]) |
{ |
Out << AnalogData[a]; |
if (a < MaxAnalog - 1) |
Out << ';'; |
} |
} |
Out << "\n"; |
} |
void MKTool::slot_RecordCSV() // DONE 0.71g |
{ |
if (!CSVFile->isOpen()) |
{ |
QString Filename = Settings->DIR.Logging + Mode.Hardware + " - " + QDate::currentDate().toString(("yyyy-MM-dd")) + " -- " + QTime::currentTime().toString("hh-mm") + ".csv"; |
CSVFile = new QFile(Filename); |
if (!CSVFile->exists()) |
{ |
CSVFile->open(QIODevice::Append | QIODevice::Text); |
QTextStream Out(CSVFile); |
for (int a = 0; a < MaxAnalog; a++) |
{ |
if (Settings->Analog1.LogView[a]) |
{ |
Out << Settings->Analog1.Label[a]; |
if (a < MaxAnalog - 1) |
Out << ';'; |
} |
} |
Out << "\n"; |
} |
else |
{ |
CSVFile->open(QIODevice::Append | QIODevice::Text); |
} |
// pb_Record->setIcon(ToolBox::Icon(6)); |
// pb_Record->setText("CSV Stop"); |
// ac_RecordCSV->setIcon(ToolBox::Icon(6)); |
ac_RecordCSV->setText("CSV Stop"); |
lb_Status->setText(tr("CVS-Record gestartet.")); |
} |
else |
{ |
CSVFile->close(); |
// pb_Record->setIcon(ToolBox::Icon(7)); |
// pb_Record->setText("CSV Aufzeichnen"); |
// ac_RecordCSV->setIcon(ToolBox::Icon(7)); |
ac_RecordCSV->setText("CSV Aufzeichnen"); |
lb_Status->setText(tr("CVS-Record gestopt.")); |
} |
} |
void MKTool::show_DebugData() |
{ |
if (CSVFile->isOpen()) |
{ |
write_CSV(); |
} |
logger->write(AnalogData); |
if (ac_StartPlotter->isChecked()) |
{ |
1697,8 → 1659,5 |
set_Preferences(); |
Settings->write_Settings(); |
if (CSVFile->isOpen()) |
{ |
CSVFile->close(); |
logger->close(); |
} |
} |
/QMK-Groundstation/trunk/Forms/mktool.h |
---|
47,8 → 47,8 |
#include "../Classes/cQMK_Server.h" |
#include "../Classes/cAttitude.h" |
#include "../Classes/cSpeedMeter.h" |
#include "../Logger/Logger.h" |
class QextSerialPort; |
class MKTool : public QMainWindow, public Ui::dlg_mktool_UI |
117,8 → 117,8 |
int LCD_Page; |
int LCD_MAX_Page; |
// Object für das Datenfile; |
QFile *CSVFile; |
//Logger für CVS und andere |
Logger * logger; |
sMode Mode; |
sRxData RxData; |
156,7 → 156,7 |
// Debugdaten anzeigen und speichern. |
void show_DebugData(); |
void write_CSV(); |
void update_Log(); |
// Programmeinstellungen speichern |
void set_Preferences(); |
206,7 → 206,7 |
void slot_TabChanged(int Tab); |
void slot_RecordCSV(); |
void slot_RecordLog(); |
void slot_ScrollPlot(int Pos); |
/QMK-Groundstation/trunk/Logger/CSVLogger.cpp |
---|
0,0 → 1,73 |
/*************************************************************************** |
* Copyright (C) 2008 by Manuel Schrape * |
* manuel.schrape@gmx.de * |
* and Andreas Bresser bresser@informatik.uni-bremen.de * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
#include "CSVLogger.h" |
CSVLogger::CSVLogger(cSettings * settings) { |
// QFile-Instanz (Log-Datei) |
csvfile = new QFile(""); |
this->settings = settings; |
} |
CSVLogger::~CSVLogger() { |
close(); |
} |
//datei ist geöffnet bedeutet wir sind soweit und können schreiben |
bool CSVLogger::ready() { |
return csvfile->isOpen(); |
} |
//Datei schließen |
void CSVLogger::close() |
{ |
if (csvfile->isOpen()) |
csvfile->close(); |
} |
//neuen Log erstellen |
void CSVLogger::newLog(QString filename) { |
if (!csvfile->isOpen()) |
{ |
csvfile = new QFile(filename); |
if (!csvfile->exists()) |
{ |
csvfile->open(QIODevice::Append | QIODevice::Text); |
} |
} |
} |
//daten schreiben |
void CSVLogger::write(int * analogData) { |
if (csvfile->isOpen()) |
{ |
QTextStream out(csvfile); |
for (int a=0; a<MaxAnalog; a++) |
{ |
if (settings->Analog1.LogView[a]) |
{ |
out << analogData[a]; |
if (a < MaxAnalog - 1) |
out << ';'; |
} |
} |
out << "\n"; |
} |
} |
/QMK-Groundstation/trunk/Logger/CSVLogger.h |
---|
0,0 → 1,53 |
/*************************************************************************** |
* Copyright (C) 2008 by Manuel Schrape * |
* manuel.schrape@gmx.de * |
* and Andreas Bresser bresser@informatik.uni-bremen.de * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
#ifndef CSVLOGGER_H |
#define CSVLOGGER_H |
#include <QString> |
#include <QTextStream> |
#include <QFile> |
#include "../Classes/cSettings.h" |
#include "DefaultLogger.h" |
class CSVLogger : public DefaultLogger |
{ |
private: |
// Object für das Datenfile; |
QFile * csvfile; |
cSettings * settings; |
public: |
CSVLogger(cSettings * settings); |
~CSVLogger(); |
//schreibe log |
void write(int * analogData); |
//erzeuge neue Log-Datei/neuen Datensatz |
void newLog(QString name); |
//alles bereit zum schreiben? |
bool ready(); |
//alles schließen |
void close(); |
}; |
#endif |
/QMK-Groundstation/trunk/Logger/DefaultLogger.h |
---|
0,0 → 1,44 |
/*************************************************************************** |
* Copyright (C) 2009 by Manuel Schrape * |
* manuel.schrape@gmx.de * |
* and Andreas Bresser bresser@informatik.uni-bremen.de * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
#ifndef DEFAULTLOGGER_H |
#define DEFAULTLOGGER_H |
#include <QString> |
#include "../Classes/cSettings.h" |
//Interface für einen Logger |
class DefaultLogger |
{ |
public: |
//schreibe log |
virtual void write(int *) { }; |
//erzeuge neue Log-Datei/neuen Datensatz |
virtual void newLog(QString) { }; |
//alles bereit zum schreiben? |
virtual bool ready() { return false; }; |
//alles schließen |
virtual void close() {}; |
}; |
#endif |
/QMK-Groundstation/trunk/Logger/Logger.cpp |
---|
0,0 → 1,69 |
/*************************************************************************** |
* Copyright (C) 2009 by Manuel Schrape * |
* manuel.schrape@gmx.de * |
* and Andreas Bresser bresser@informatik.uni-bremen.de * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
#include "Logger.h" |
Logger::Logger(cSettings * settings) |
{ |
csv = new CSVLogger(settings); |
logger << csv; |
active = false; |
} |
Logger::~Logger() |
{ |
close(); |
} |
//schreibe log |
void Logger::write(int * analogData) |
{ |
if (active == true) |
foreach (DefaultLogger * log, logger) |
if (log->ready()) |
log->write(analogData); |
} |
//erzeuge neue Log-Datei/neuen Datensatz |
void Logger::newLog(QString name) |
{ |
foreach (DefaultLogger * log, logger) |
log->newLog(name); |
} |
//starte Logging |
void Logger::start_Log() |
{ |
active = true; |
} |
//soll geloggt werden? |
bool Logger::is_active() |
{ |
return active; |
} |
//alles schließen |
void Logger::close() |
{ |
active = false; |
foreach (DefaultLogger * log, logger) |
log->close(); |
} |
/QMK-Groundstation/trunk/Logger/Logger.h |
---|
0,0 → 1,60 |
/*************************************************************************** |
* Copyright (C) 2009 by Manuel Schrape * |
* manuel.schrape@gmx.de * |
* and Andreas Bresser bresser@informatik.uni-bremen.de * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
#ifndef LOGGER_H |
#define LOGGER_H |
#include <QLinkedList> |
#include <QString> |
#include "DefaultLogger.h" |
#include "../Classes/cSettings.h" |
//Die verschiedenen header der einzelnen Logger |
//TODO: MySQLLogger, SQLiteLogger und/oder PostGreSQLLogger |
#include "CSVLogger.h" |
class Logger |
{ |
private: |
CSVLogger * csv; |
//Liste aller bekannten Logger |
QLinkedList<DefaultLogger *> logger; |
bool active; |
public: |
Logger(cSettings * settings); |
~Logger(); |
void start_Log(); |
//soll geloggt werden? |
bool is_active(); |
//schreibe log |
void write(int * analogData); |
//erzeuge neue Log-Datei/neuen Datensatz |
void newLog(QString name); |
//alles schließen |
void close(); |
}; |
#endif |
/QMK-Groundstation/trunk/debian.pro |
---|
35,6 → 35,8 |
Classes/cAttitude.cpp \ |
Classes/cSpeedMeter.cpp \ |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
57,6 → 59,9 |
Classes/cAttitude.h \ |
Classes/cSpeedMeter.h \ |
Classes/cQMK_Server.h \ |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
win32:HEADERS += SerialPort/win_qextserialport.h |
/QMK-Groundstation/trunk/eeepc.pro |
---|
35,6 → 35,8 |
Classes/cAttitude.cpp \ |
Classes/cSpeedMeter.cpp \ |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
57,6 → 59,9 |
Classes/cAttitude.h \ |
Classes/cSpeedMeter.h \ |
Classes/cQMK_Server.h \ |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
win32:HEADERS += SerialPort/win_qextserialport.h |
/QMK-Groundstation/trunk/gentoo.pro |
---|
35,6 → 35,8 |
Classes/cAttitude.cpp \ |
Classes/cSpeedMeter.cpp \ |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
57,6 → 59,9 |
Classes/cAttitude.h \ |
Classes/cSpeedMeter.h \ |
Classes/cQMK_Server.h \ |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
win32:HEADERS += SerialPort/win_qextserialport.h |
/QMK-Groundstation/trunk/osx.pro |
---|
35,6 → 35,8 |
Classes/cAttitude.cpp \ |
Classes/cSpeedMeter.cpp \ |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
57,6 → 59,9 |
Classes/cAttitude.h \ |
Classes/cSpeedMeter.h \ |
Classes/cQMK_Server.h \ |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
win32:HEADERS += SerialPort/win_qextserialport.h |
/QMK-Groundstation/trunk/suse.pro |
---|
35,6 → 35,8 |
Classes/cAttitude.cpp \ |
Classes/cSpeedMeter.cpp \ |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
57,6 → 59,9 |
Classes/cAttitude.h \ |
Classes/cSpeedMeter.h \ |
Classes/cQMK_Server.h \ |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
win32:HEADERS += SerialPort/win_qextserialport.h |
/QMK-Groundstation/trunk/win.pro |
---|
56,6 → 56,8 |
Classes/cAttitude.cpp \ |
Classes/cSpeedMeter.cpp \ |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
78,6 → 80,9 |
Classes/cAttitude.h \ |
Classes/cSpeedMeter.h \ |
Classes/cQMK_Server.h \ |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
win32:HEADERS += SerialPort/win_qextserialport.h |