diff --git a/src/DBAccess.h b/src/DBAccess.h new file mode 100644 index 000000000..17d416a6f --- /dev/null +++ b/src/DBAccess.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2009 Justin F. Knotzke (jknotzke@shampoo.ca) + * + * 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, or (at your option) + * any later version. + * + * 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., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _GC_DBAccess_h +#define _GC_DBAccess_h 1 + + + +#import +#import +#import +#import "SummaryMetrics.h" +#import "Season.h" + +class RideFile; +class Zones; +class RideMetric; +class DBAccess +{ + + public: + DBAccess(QDir home); + typedef QHash MetricMap; + void importAllRides(QDir path, Zones *zones); + bool importRide(SummaryMetrics *summaryMetrics); + QSqlDatabase initDatabase(QDir home); + bool createDatabase(); + QStringList getAllFileNames(); + void closeConnection(); + QList getAllDates(); + QList getAllMetricsFor(QDateTime start, QDateTime end); + bool createSeasonsTable(); + bool createMetricsTable(); + bool createSeason(Season season); + QList getAllSeasons(); + //bool deleteSeason(Season season); + + + + private: + QSqlDatabase db; + bool createIndex(); + +}; +#endif \ No newline at end of file diff --git a/src/DbAccess.cpp b/src/DbAccess.cpp new file mode 100644 index 000000000..700673feb --- /dev/null +++ b/src/DbAccess.cpp @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2006 Justin Knotzke (jknotzke@shampoo.ca) + * + * 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, or (at your option) + * any later version. + * + * 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., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "DBAccess.h" +#include +#include +#include "RideFile.h" +#include "Zones.h" +#include "Settings.h" +#include "RideItem.h" +#include "RideMetric.h" +#include "TimeUtils.h" +#include +#include +#include +#include "SummaryMetrics.h" + + +DBAccess::DBAccess(QDir home) +{ + initDatabase(home); + if(!createDatabase()) + createIndex(); +} + +void DBAccess::closeConnection() +{ + db.close(); +} + +QSqlDatabase DBAccess::initDatabase(QDir home) +{ + + + if(db.isOpen()) + return db; + + db = QSqlDatabase::addDatabase("QSQLITE"); + db.setDatabaseName(home.absolutePath() + "/metricDB"); + if (!db.open()) { + QMessageBox::critical(0, qApp->tr("Cannot open database"), + qApp->tr("Unable to establish a database connection.\n" + "This example needs SQLite support. Please read " + "the Qt SQL driver documentation for information how " + "to build it.\n\n" + "Click Cancel to exit."), QMessageBox::Cancel); + return db; + } + + return db; +} + +bool DBAccess::createMetricsTable() +{ + QSqlQuery query; + bool rc = query.exec("create table metrics (id integer primary key autoincrement, " + "filename varchar," + "ride_date date," + "ride_time double, " + "average_cad double," + "workout_time double, " + "total_distance double," + "x_power double," + "average_speed double," + "total_work double," + "average_power double," + "average_hr double," + "relative_intensity double," + "bike_score double)"); + + if(!rc) + qDebug() << query.lastError(); + + return rc; + +} + +bool DBAccess::createSeasonsTable() +{ + QSqlQuery query; + bool rc = query.exec("CREAATE TABLE seasons(id integer primary key autoincrement," + "start_date date," + "end_date date," + "name varchar)"); + + if(!rc) + qDebug() << query.lastError(); + + return rc; +} + + +bool DBAccess::createDatabase() +{ + + bool rc = false; + + //Check to see if the table already exists.. + QStringList tableList = db.tables(QSql::Tables); + if(!tableList.empty()) + return true; + + rc = createMetricsTable(); + + if(!rc) + return rc; + + rc = createIndex(); + if(!rc) + return rc; + return createSeasonsTable(); + + +} + +bool DBAccess::createIndex() +{ + QSqlQuery query; + query.prepare("create INDEX IDX_FILENAME on metrics(filename)"); + bool rc = query.exec(); + if(!rc) + qDebug() << query.lastError(); + + return rc; +} + +bool DBAccess::importRide(SummaryMetrics *summaryMetrics ) +{ + + QSqlQuery query; + + query.prepare("insert into metrics (filename, ride_date, ride_time, average_cad, workout_time, total_distance," + "x_power, average_speed, total_work, average_power, average_hr," + "relative_intensity, bike_score) values (?,?,?,?,?,?,?,?,?,?,?,?,?)"); + + + query.addBindValue(summaryMetrics->getFileName()); + query.addBindValue(summaryMetrics->getRideDate()); + query.addBindValue(summaryMetrics->getRideTime()); + query.addBindValue(summaryMetrics->getCadence()); + query.addBindValue(summaryMetrics->getWorkoutTime()); + query.addBindValue(summaryMetrics->getDistance()); + query.addBindValue(summaryMetrics->getXPower()); + query.addBindValue(summaryMetrics->getSpeed()); + query.addBindValue(summaryMetrics->getTotalWork()); + query.addBindValue(summaryMetrics->getWatts()); + query.addBindValue(summaryMetrics->getHeartRate()); + query.addBindValue(summaryMetrics->getRelativeIntensity()); + query.addBindValue(summaryMetrics->getBikeScore()); + + bool rc = query.exec(); + + if(!rc) + { + qDebug() << query.lastError(); + } + return rc; +} + +QStringList DBAccess::getAllFileNames() +{ + QSqlQuery query("SELECT filename from metrics"); + QStringList fileList; + + while(query.next()) + { + QString filename = query.value(0).toString(); + fileList << filename; + } + + return fileList; +} + +QList DBAccess::getAllDates() +{ + QSqlQuery query("SELECT ride_date from metrics"); + QList dates; + + while(query.next()) + { + QDateTime date = query.value(0).toDateTime(); + dates << date; + } + return dates; +} + +QList DBAccess::getAllMetricsFor(QDateTime start, QDateTime end) +{ + QList metrics; + + + QSqlQuery query("SELECT filename, ride_date, ride_time, average_cad, workout_time, total_distance," + "x_power, average_speed, total_work, average_power, average_hr," + "relative_intensity, bike_scoreFROM metrics WHERE ride_date >=:start AND ride_date <=:end"); + query.bindValue(":start", start); + query.bindValue(":end", end); + + while(query.next()) + { + + SummaryMetrics summaryMetrics; + summaryMetrics.setFileName(query.value(0).toString()); + summaryMetrics.setRideDate(query.value(1).toDateTime()); + summaryMetrics.setRideTime(query.value(2).toDouble()); + summaryMetrics.setCadence(query.value(3).toDouble()); + summaryMetrics.setWorkoutTime(query.value(4).toDouble()); + summaryMetrics.setDistance(query.value(5).toDouble()); + summaryMetrics.setXPower(query.value(6).toDouble()); + summaryMetrics.setSpeed(query.value(7).toDouble()); + summaryMetrics.setTotalWork(query.value(8).toDouble()); + summaryMetrics.setWatts(query.value(9).toDouble()); + summaryMetrics.setHeartRate(query.value(10).toDouble()); + summaryMetrics.setRelativeIntensity(query.value(11).toDouble()); + summaryMetrics.setBikeScore(query.value(12).toDouble()); + + metrics << summaryMetrics; + } + + return metrics; +} + +bool DBAccess::createSeason(Season season) +{ + QSqlQuery query; + + query.prepare("INSERT INTO season (start_date, end_date, name) values (?,?,?)"); + + + query.addBindValue(season.getStart()); + query.addBindValue(season.getEnd()); + query.addBindValue(season.getName()); + + bool rc = query.exec(); + + if(!rc) + qDebug() << query.lastError(); + + return rc; + +} + +QList DBAccess::getAllSeasons() +{ + QSqlQuery query("SELECT start_date, end_date, name from season"); + QList seasons; + + while(query.next()) + { + Season season; + season.setStart(query.value(0).toDateTime()); + season.setEnd(query.value(1).toDateTime()); + season.setName(query.value(2).toString()); + seasons << season; + + } + return seasons; + +} \ No newline at end of file diff --git a/src/DbAccess.h b/src/DbAccess.h new file mode 100644 index 000000000..17d416a6f --- /dev/null +++ b/src/DbAccess.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2009 Justin F. Knotzke (jknotzke@shampoo.ca) + * + * 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, or (at your option) + * any later version. + * + * 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., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _GC_DBAccess_h +#define _GC_DBAccess_h 1 + + + +#import +#import +#import +#import "SummaryMetrics.h" +#import "Season.h" + +class RideFile; +class Zones; +class RideMetric; +class DBAccess +{ + + public: + DBAccess(QDir home); + typedef QHash MetricMap; + void importAllRides(QDir path, Zones *zones); + bool importRide(SummaryMetrics *summaryMetrics); + QSqlDatabase initDatabase(QDir home); + bool createDatabase(); + QStringList getAllFileNames(); + void closeConnection(); + QList getAllDates(); + QList getAllMetricsFor(QDateTime start, QDateTime end); + bool createSeasonsTable(); + bool createMetricsTable(); + bool createSeason(Season season); + QList getAllSeasons(); + //bool deleteSeason(Season season); + + + + private: + QSqlDatabase db; + bool createIndex(); + +}; +#endif \ No newline at end of file diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index be97157a2..7e95334e2 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -44,6 +44,7 @@ #include "DatePickerDialog.h" #include "ToolsDialog.h" +#include "MetricAggregator.h" #include "SplitRideDialog.h" /* temp for the qmake/QMAKE_CXXFLAGS bug with xcode */ @@ -410,8 +411,10 @@ MainWindow::MainWindow(const QDir &home) : SLOT(showOptions()), tr("Ctrl+O")); optionsMenu->addAction(tr("&Tools..."), this, SLOT(showTools()), tr("Ctrl+T")); - // optionsMenu->addAction(tr("&Import Ride to DB..."), this, - // SLOT(importRideToDB()), tr("Ctrl+R")); + //optionsMenu->addAction(tr("&Reset Metrics..."), this, + // SLOT(importRideToDB()), tr("Ctrl+R")); + //optionsMenu->addAction(tr("&Update Metrics..."), this, + // SLOT(importRideToDB()), tr("Ctrl+U")); QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); @@ -1164,12 +1167,22 @@ MainWindow::aboutDialog() )); } -/* + void MainWindow::importRideToDB() -{ +{ + MetricAggregator *aggregator = new MetricAggregator(); + aggregator->aggregateRides(home, zones); + delete aggregator; } -*/ +void MainWindow::scanForMissing() +{ + MetricAggregator *aggregator = new MetricAggregator(); + aggregator->scanForMissing(home, zones); + delete aggregator; +} + + void MainWindow::notesChanged() diff --git a/src/MainWindow.h b/src/MainWindow.h index 49c591fca..b873b7258 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -74,6 +74,8 @@ class MainWindow : public QMainWindow void saveNotes(); void showOptions(); void showTools(); + void importRideToDB(); + void scanForMissing(); protected: @@ -104,7 +106,7 @@ class MainWindow : public QMainWindow QTreeWidgetItem *allRides; PowerHist *powerHist; Zones *zones; - + // pedal force/pedal velocity scatter plot widgets PfPvPlot *pfPvPlot; QLineEdit *qaCPValue; diff --git a/src/MetricAggregator.cpp b/src/MetricAggregator.cpp new file mode 100644 index 000000000..3c03c793d --- /dev/null +++ b/src/MetricAggregator.cpp @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2009 Justin F. Knotzke (jknotzke@shampoo.ca) + * + * 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, or (at your option) + * any later version. + * + * 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., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + + +#include "MetricAggregator.h" +#include "DBAccess.h" +#include "RideFile.h" +#include "Zones.h" +#include "Settings.h" +#include "RideItem.h" +#include "RideMetric.h" +#include "TimeUtils.h" +#include +#include +#include + +static char *rideFileRegExp = ("^(\\d\\d\\d\\d)_(\\d\\d)_(\\d\\d)" + "_(\\d\\d)_(\\d\\d)_(\\d\\d)\\.(raw|srm|csv|tcx)$"); + + +MetricAggregator::MetricAggregator() +{ + +} + +void MetricAggregator::aggregateRides(QDir home, Zones *zones) +{ + qDebug() << QDateTime::currentDateTime(); + DBAccess *dbaccess = new DBAccess(home); + QRegExp rx(rideFileRegExp); + QStringList errors; + QStringListIterator i(RideFileFactory::instance().listRideFiles(home)); + while (i.hasNext()) { + QString name = i.next(); + QFile file(home.absolutePath() + "/" + name); + RideFile *ride = RideFileFactory::instance().openRideFile(file, errors); + importRide(home, zones, ride, name, dbaccess); + } + dbaccess->closeConnection(); + delete dbaccess; + qDebug() << QDateTime::currentDateTime(); + +} + +bool MetricAggregator::importRide(QDir path, Zones *zones, RideFile *ride, QString fileName, DBAccess *dbaccess) +{ + + SummaryMetrics *summaryMetric = new SummaryMetrics(); + + + QFile file(path.absolutePath() + "/" + fileName); + int zone_range = -1; + + QRegExp rx(rideFileRegExp); + if (!rx.exactMatch(fileName)) { + fprintf(stderr, "bad name: %s\n", fileName.toAscii().constData()); + assert(false); + return false; + } + summaryMetric->setFileName(fileName); + assert(rx.numCaptures() == 7); + QDate date(rx.cap(1).toInt(), rx.cap(2).toInt(),rx.cap(3).toInt()); + QTime time(rx.cap(4).toInt(), rx.cap(5).toInt(),rx.cap(6).toInt()); + QDateTime dateTime(date, time); + + summaryMetric->setRideDate(dateTime); + + if (zones) + zone_range = zones->whichRange(dateTime.date()); + + QSettings settings(GC_SETTINGS_CO, GC_SETTINGS_APP); + QVariant unit = settings.value(GC_UNIT); + + const RideMetricFactory &factory = RideMetricFactory::instance(); + QSet todo; + + for (int i = 0; i < factory.metricCount(); ++i) + todo.insert(factory.metricName(i)); + + + while (!todo.empty()) { + QMutableSetIterator i(todo); + later: + while (i.hasNext()) { + const QString &name = i.next(); + const QVector &deps = factory.dependencies(name); + for (int j = 0; j < deps.size(); ++j) + if (!metrics.contains(deps[j])) + goto later; + RideMetric *metric = factory.newMetric(name); + metric->compute(ride, zones, zone_range, metrics); + metrics.insert(name, metric); + i.remove(); + double value = metric->value(true); + if(name == "workout_time") + summaryMetric->setWorkoutTime(value); + else if(name == "average_cad") + summaryMetric->setCadence(value); + else if(name == "total_distance") + summaryMetric->setDistance(value); + else if(name == "skibax_power") + summaryMetric->setXPower(value); + else if(name == "average_speed") + summaryMetric->setSpeed(value); + else if(name == "total_work") + summaryMetric->setTotalWork(value); + else if(name == "average_power") + summaryMetric->setWatts(value); + else if(name == "time_riding") + summaryMetric->setRideTime(value); + else if(name == "average_hr") + summaryMetric->setHeartRate(value); + else if(name == "skiba_relative_intensity") + summaryMetric->setRelativeIntensity(value); + else if(name == "skiba_bike_score") + summaryMetric->setBikeScore(value); + + } + } + + dbaccess->importRide(summaryMetric); + delete summaryMetric; + + return true; + +} + +void MetricAggregator::scanForMissing(QDir home, Zones *zones) +{ + QStringList errors; + DBAccess *dbaccess = new DBAccess(home); + QStringList filenames = dbaccess->getAllFileNames(); + QRegExp rx(rideFileRegExp); + QStringListIterator i(RideFileFactory::instance().listRideFiles(home)); + while (i.hasNext()) { + QString name = i.next(); + if(!filenames.contains(name)) + { + qDebug() << "Found missing file: " << name; + QFile file(home.absolutePath() + "/" + name); + RideFile *ride = RideFileFactory::instance().openRideFile(file, errors); + importRide(home, zones, ride, name, dbaccess); + + } + + } + dbaccess->closeConnection(); + delete dbaccess; + +} + + diff --git a/src/MetricAggregator.h b/src/MetricAggregator.h new file mode 100644 index 000000000..2adc6859c --- /dev/null +++ b/src/MetricAggregator.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2009 Justin F. Knotzke (jknotzke@shampoo.ca) + * + * 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, or (at your option) + * any later version. + * + * 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., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef METRICAGGREGATOR_H_ +#define METRICAGGREGATOR_H_ + + +#include +#include "RideFile.h" +#include +#include "Zones.h" +#include "RideMetric.h" +#include "DbAccess.h" + + +class MetricAggregator +{ + public: + MetricAggregator(); + void aggregateRides(QDir home, Zones *zones); + typedef QHash MetricMap; + bool importRide(QDir path, Zones *zones, RideFile *ride, QString fileName, DBAccess *dbaccess); + MetricMap metrics; + void MetricAggregator::scanForMissing(QDir home, Zones *zones); + + + + +}; + + + +#endif /* METRICAGGREGATOR_H_ */ diff --git a/src/Season.cpp b/src/Season.cpp new file mode 100644 index 000000000..580d46073 --- /dev/null +++ b/src/Season.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2009 Justin F. Knotzke (jknotzke@shampoo.ca) + * + * 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, or (at your option) + * any later version. + * + * 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., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "Season.h" +#include + +Season::Season() +{ + +} + +QString Season::getName() { + + return name; +} + +QDateTime Season::getStart() +{ + return start; +} + +QDateTime Season::getEnd() +{ + return end; +} + +void Season::setEnd(QDateTime _end) +{ + end = _end; +} + +void Season::setStart(QDateTime _start) +{ + start = _start; +} + +void Season::setName(QString _name) +{ + name = _name; +} \ No newline at end of file diff --git a/src/Season.h b/src/Season.h new file mode 100644 index 000000000..d98257070 --- /dev/null +++ b/src/Season.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2009 Justin F. Knotzke (jknotzke@shampoo.ca) + * + * 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, or (at your option) + * any later version. + * + * 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., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SEASON_H_ +#define SEASON_H_ + +#include +#include + +class Season + { + public: + Season(); + QDateTime getStart(); + QDateTime getEnd(); + QString getName(); + + void setStart(QDateTime _start); + void setEnd(QDateTime _end); + void setName(QString _name); + + private: + QDateTime start; + QDateTime end; + QString name; + + }; + + +#endif /* SEASON_H_ */ diff --git a/src/SummaryMetrics.cpp b/src/SummaryMetrics.cpp new file mode 100644 index 000000000..ea6a98ca4 --- /dev/null +++ b/src/SummaryMetrics.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2009 Justin F. Knotzke (jknotzke@shampoo.ca) + * + * 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, or (at your option) + * any later version. + * + * 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., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#include "SummaryMetrics.h" + +SummaryMetrics::SummaryMetrics() { } + + + +double SummaryMetrics::getDistance() { return distance; } +double SummaryMetrics::getSpeed() { return speed; } +double SummaryMetrics::getWatts() { return watts; } +double SummaryMetrics::getBikeScore() { return bikeScore; } +double SummaryMetrics::getXPower() { return xPower; } +double SummaryMetrics::getCadence() { return cadence; } +double SummaryMetrics::getHeartRate() { return heartRate; } +double SummaryMetrics::getRideTime() { return rideTime; } +QString SummaryMetrics::getFileName() { return fileName; } +double SummaryMetrics::getTotalWork() { return totalWork; } +double SummaryMetrics::getWorkoutTime() { return workoutTime; } +double SummaryMetrics::getRelativeIntensity() { return relativeIntensity; } +QDateTime SummaryMetrics::getRideDate() { return rideDate; } + +void SummaryMetrics::setSpeed(double _speed) { speed = _speed; } +void SummaryMetrics::setWatts(double _watts) { watts = _watts; } +void SummaryMetrics::setBikeScore(double _bikescore) { bikeScore = _bikescore; } +void SummaryMetrics::setXPower(double _xPower) { xPower = _xPower; } +void SummaryMetrics::setCadence(double _cadence) { cadence = _cadence; } +void SummaryMetrics::setDistance(double _distance) { distance = _distance; } +void SummaryMetrics::setRideTime(double _rideTime) { rideTime = _rideTime; } +void SummaryMetrics::setTotalWork(double _totalWork) { totalWork = _totalWork; } +void SummaryMetrics::setFileName(QString _fileName) { fileName = _fileName; } +void SummaryMetrics::setWorkoutTime(double _workoutTime) { workoutTime = _workoutTime; } +void SummaryMetrics::setRelativeIntensity(double _relativeIntensity) { relativeIntensity = _relativeIntensity; } +void SummaryMetrics::setHeartRate(double _heartRate) { heartRate = _heartRate; } +void SummaryMetrics::setRideDate(QDateTime _rideDate) { rideDate = _rideDate; } \ No newline at end of file diff --git a/src/SummaryMetrics.h b/src/SummaryMetrics.h new file mode 100644 index 000000000..cd8e6cfca --- /dev/null +++ b/src/SummaryMetrics.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2009 Justin F. Knotzke (jknotzke@shampoo.ca) + * + * 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, or (at your option) + * any later version. + * + * 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., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SUMMARYMETRICS_H_ +#define SUMMARYMETRICS_H_ + +#include +#include + +class SummaryMetrics +{ + public: + SummaryMetrics(); + QString getFileName(); + double getDistance(); + double getSpeed(); + double getWatts(); + double getBikeScore(); + double getXPower(); + double getCadence(); + double getHeartRate(); + double getRideTime(); + double getWorkoutTime(); + double getTotalWork(); + double getRelativeIntensity(); + QDateTime getRideDate(); + + void setDistance(double _distance); + void setSpeed(double _speed); + void setWatts(double _watts); + void setBikeScore(double _bikescore); + void setXPower(double _xPower); + void setCadence(double _cadence); + void setHeartRate(double _heartRate); + void setWorkoutTime(double _workoutTime); + void setRideTime(double _rideTime); + void setFileName(QString _filename); + void setTotalWork(double _totalWork); + void setRelativeIntensity(double _relativeIntensity); + void setRideDate(QDateTime _rideDate); + + + private: + double distance; + double speed; + double watts; + double bikeScore; + double xPower; + double cadence; + double heartRate; + double rideTime; + QString fileName; + double totalWork; + double workoutTime; + double relativeIntensity; + QDateTime rideDate; + +}; + + +#endif /* SUMMARYMETRICS_H_ */ diff --git a/src/src.pro b/src/src.pro index 0a2a9d30d..c944849c0 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,16 +1,16 @@ - TEMPLATE = app TARGET = GoldenCheetah DEPENDPATH += . INCLUDEPATH += /usr/local/qwt/include /sw/include /usr/local/include CONFIG += static debug -QT += xml -LIBS += /usr/local/qwt/lib/libqwt.a +QT += xml sql +LIBS += /usr/local/qwt/lib/libqwt.5.dylib /usr/local/lib/libftd2xx.0.1.4.dylib LIBS += -lm -lz -QMAKE_CXXFLAGS += -DGC_BUILD_DATE=\\\"`date +'\"%a_%b_%d,_%Y\"'`\\\" +QMAKE_CXXFLAGS = -DGC_BUILD_DATE="`date +'\"%a_%b_%d,_%Y\"'`" QMAKE_CXXFLAGS += -DGC_SVN_VERSION=\\\"`svnversion . | cut -f '2' -d ':'`\\\" QMAKE_CXXFLAGS += -DGC_MAJOR_VER=1 QMAKE_CXXFLAGS += -DGC_MINOR_VER=0 + RC_FILE = images/gc.icns macx { @@ -41,6 +41,7 @@ HEADERS += \ ChooseCyclistDialog.h \ CpintPlot.h \ CsvRideFile.h \ + DBAccess.h \ DownloadRideDialog.h \ MainWindow.h \ PfPvPlot.h \ @@ -65,15 +66,18 @@ HEADERS += \ ToolsDialog.h \ Zones.h \ srm.h \ - SplitRideDialog.h + MetricAggregator.h \ + Season.h \ + SummaryMetrics.h \ + SplitRideDialog.h \ - SOURCES += \ AllPlot.cpp \ BestIntervalDialog.cpp \ ChooseCyclistDialog.cpp \ CpintPlot.cpp \ CsvRideFile.cpp \ + DBAccess.cpp \ DownloadRideDialog.cpp \ MainWindow.cpp \ PfPvPlot.cpp \ @@ -101,7 +105,11 @@ SOURCES += \ Zones.cpp \ main.cpp \ srm.cpp \ - SplitRideDialog.cpp + Season.cpp \ + MetricAggregator.cpp \ + SummaryMetrics.cpp \ + SplitRideDialog.cpp + RESOURCES = application.qrc