Compare commits

...

5 Commits

Author SHA1 Message Date
Sean Rhea
30c877a5f2 fix FTDI required for SRM download bug
GC supports two download port types: serial ports and D2XX.  Before, if
either of these failed to load, the download dialog wouldn't show either
port type.  With this patch, if both fail, GC displays a warning, but if
either one succeeds, GC will proceed with only that port type.  This
change should fix the problem that users were having to download and
install both the FTDI drivers and the PL2303 ones in order to download
from the SRM PCV.
2010-02-06 11:23:26 -08:00
Robert Carlsen
92d2601a5a Added sanity checking to ignore missing metrics
There is a possibility that ride metrics may become unavailable yet
remain requested by QSettings (stored in
~/Library/Preferences/org.goldencheetah.GoldenCheetah.plist on OS X).

This patch ignores any metrics listed in the preferences yet are not
supported by the running version of Golden Cheetah.
2010-02-05 08:09:34 -08:00
Sean Rhea
113375669f don't check dependencies until newMetric is called
Before, we checked them during addMetric, and that left us vulnerable
link-order errors.  With this patch, we wait until someone actually asks
for an instance of a metric, and then we check all metrics' dependencies.
That way, since the Ride Summary always creates at least one metric, we'll
still check the dependencies of them all.  We just do it a little later in
the program's execution than before.
2010-02-05 08:08:21 -08:00
Sean Rhea
cd0e9c184b add Erase Ride(s) button to download dialog
This is a workaround for the SRM erase bug.  It gives the user a way to
try erasing the device's memory without re-downloading a ride.
2010-02-04 20:26:16 -08:00
Sean Rhea
28cbe359d4 regenerate stress cache after config change
fixes #32
2010-02-04 05:15:02 -08:00
10 changed files with 69 additions and 13 deletions

View File

@@ -33,15 +33,18 @@ CommPort::addListFunction(ListFunction f)
QVector<CommPortPtr>
CommPort::listCommPorts(QString &err)
{
err = "";
QStringList errors;
QVector<CommPortPtr> result;
for (int i = 0; listFunctions && i < listFunctions->size(); ++i) {
QVector<CommPortPtr> tmp = (*listFunctions)[i](err);
if (err == "")
QString thisError = "";
QVector<CommPortPtr> tmp = (*listFunctions)[i](thisError);
if (thisError == "")
result << tmp;
else
err += "\n";
errors << thisError;
}
if (result.isEmpty() && !errors.isEmpty())
err = errors.join("\n");
return result;
}

View File

@@ -49,15 +49,18 @@ DownloadRideDialog::DownloadRideDialog(MainWindow *mainWindow,
}
downloadButton = new QPushButton(tr("&Download"), this);
eraseRideButton = new QPushButton(tr("&Erase Ride(s)"), this);
rescanButton = new QPushButton(tr("&Rescan"), this);
cancelButton = new QPushButton(tr("&Cancel"), this);
connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadClicked()));
connect(eraseRideButton, SIGNAL(clicked()), this, SLOT(eraseClicked()));
connect(rescanButton, SIGNAL(clicked()), this, SLOT(scanCommPorts()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked()));
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(downloadButton);
buttonLayout->addWidget(eraseRideButton);
buttonLayout->addWidget(rescanButton);
buttonLayout->addWidget(cancelButton);
@@ -81,6 +84,7 @@ DownloadRideDialog::setReadyInstruct()
"unit is plugged into the computer,\n"
"then click \"Rescan\" to check again."));
downloadButton->setEnabled(false);
eraseRideButton->setEnabled(false);
}
else {
Device &device = Device::device(deviceCombo->currentText());
@@ -90,6 +94,8 @@ DownloadRideDialog::setReadyInstruct()
else
label->setText(inst + ", \nthen click Download.");
downloadButton->setEnabled(true);
if (deviceCombo->currentText() == "SRM") // only SRM supports erase ride for now
eraseRideButton->setEnabled(true);
}
}
@@ -100,8 +106,8 @@ DownloadRideDialog::scanCommPorts()
QString err;
devList = CommPort::listCommPorts(err);
if (err != "") {
QString msg = "Warning:\n\n" + err + "You may need to (re)install "
"the FTDI drivers before downloading.";
QString msg = "Warning(s):\n\n" + err + "\n\nYou may need to (re)install "
"the FTDI or PL2303 drivers before downloading.";
QMessageBox::warning(0, "Error Loading Device Drivers", msg,
QMessageBox::Ok, QMessageBox::NoButton);
}
@@ -133,6 +139,7 @@ void
DownloadRideDialog::downloadClicked()
{
downloadButton->setEnabled(false);
eraseRideButton->setEnabled(false);
rescanButton->setEnabled(false);
downloadInProgress = true;
CommPortPtr dev;
@@ -211,6 +218,27 @@ DownloadRideDialog::downloadClicked()
accept();
}
void
DownloadRideDialog::eraseClicked()
{
downloadButton->setEnabled(false);
eraseRideButton->setEnabled(false);
rescanButton->setEnabled(false);
downloadInProgress = true;
CommPortPtr dev;
for (int i = 0; i < devList.size(); ++i) {
if (devList[i]->name() == portCombo->currentText()) {
dev = devList[i];
break;
}
}
assert(dev);
Device &device = Device::device(deviceCombo->currentText());
device.cleanup(dev);
downloadInProgress = false;
accept();
}
void
DownloadRideDialog::cancelClicked()
{

View File

@@ -36,6 +36,7 @@ class DownloadRideDialog : public QDialog
private slots:
void downloadClicked();
void eraseClicked();
void cancelClicked();
void setReadyInstruct();
void scanCommPorts();
@@ -44,7 +45,7 @@ class DownloadRideDialog : public QDialog
MainWindow *mainWindow;
QDir home;
QPushButton *downloadButton, *rescanButton, *cancelButton;
QPushButton *downloadButton, *eraseRideButton, *rescanButton, *cancelButton;
QComboBox *portCombo, *deviceCombo;
QLabel *label;

View File

@@ -93,6 +93,7 @@ PerformanceManagerWindow::PerformanceManagerWindow(MainWindow *mainWindow) :
SLOT(PMpickerMoved(const QPoint &)));
connect(metricCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(replot()));
connect(mainWindow, SIGNAL(configChanged()), this, SLOT(configChanged()));
}
PerformanceManagerWindow::~PerformanceManagerWindow()
@@ -101,6 +102,13 @@ PerformanceManagerWindow::~PerformanceManagerWindow()
delete sc;
}
void PerformanceManagerWindow::configChanged()
{
mainWindow->home.remove("stress.cache");
days = 0; // force replot
replot();
}
void PerformanceManagerWindow::setActive(bool value)
{
if (value)

View File

@@ -52,6 +52,7 @@ class PerformanceManagerWindow : public QWidget
void PMpickerMoved(const QPoint &pos);
void setPMSizeFromSlider();
void replot();
void configChanged();
protected:

View File

@@ -32,6 +32,7 @@ RideMetric::computeMetrics(const RideFile *ride, const Zones *zones,
QHash<QString,RideMetric*> done;
while (!todo.isEmpty()) {
QString symbol = todo.takeFirst();
if (!factory.haveMetric(symbol)) continue;
const QVector<QString> &deps = factory.dependencies(symbol);
bool ready = true;
foreach (QString dep, deps) {

View File

@@ -114,11 +114,21 @@ class RideMetricFactory {
QVector<QString> metricNames;
QHash<QString,RideMetric*> metrics;
QHash<QString,QVector<QString>*> dependencyMap;
bool dependenciesChecked;
RideMetricFactory() {}
RideMetricFactory() : dependenciesChecked(false) {}
RideMetricFactory(const RideMetricFactory &other);
RideMetricFactory &operator=(const RideMetricFactory &other);
void checkDependencies() const {
if (dependenciesChecked) return;
foreach(const QString &dependee, dependencyMap.keys()) {
foreach(const QString &dependency, *dependencyMap[dependee])
assert(metrics.contains(dependency));
}
const_cast<RideMetricFactory*>(this)->dependenciesChecked = true;
}
public:
static RideMetricFactory &instance() {
@@ -137,6 +147,7 @@ class RideMetricFactory {
RideMetric *newMetric(const QString &symbol) const {
assert(metrics.contains(symbol));
checkDependencies();
return metrics.value(symbol)->clone();
}
@@ -147,11 +158,10 @@ class RideMetricFactory {
metricNames.append(metric.symbol());
if (deps) {
QVector<QString> *copy = new QVector<QString>;
for (int i = 0; i < deps->size(); ++i) {
assert(metrics.contains((*deps)[i]));
for (int i = 0; i < deps->size(); ++i)
copy->append((*deps)[i]);
}
dependencyMap.insert(metric.symbol(), copy);
dependenciesChecked = false;
}
return true;
}

View File

@@ -197,6 +197,7 @@ RideSummaryWindow::htmlSummary() const
summary += "<td align=\"center\" valign=\"bottom\">Interval Name</td>";
foreach (QString symbol, intervalMetrics) {
RideMetricPtr m = metrics.value(symbol);
if (!m) continue;
summary += "<td align=\"center\" valign=\"bottom\">" + m->name();
if (m->units(metricUnits) == "seconds")
; // don't do anything
@@ -218,6 +219,7 @@ RideSummaryWindow::htmlSummary() const
summary += "<td align=\"center\">" + interval.name + "</td>";
foreach (QString symbol, intervalMetrics) {
RideMetricPtr m = metrics.value(symbol);
if (!m) continue;
QString s("<td align=\"center\">%1</td>");
if (m->units(metricUnits) == "seconds")
summary += s.arg(time_to_string(m->value(metricUnits)));

View File

@@ -398,6 +398,8 @@ Serial::myListCommPorts(QString &err)
QVector<CommPortPtr> result;
char *devices[MAX_DEVICES];
int devcnt = find_devices(devices, MAX_DEVICES);
if (devcnt == 0)
err = "No serial devices found.";
for (int i = 0; i < devcnt; ++i) {
result.append(CommPortPtr(new Serial(devices[i])));
free(devices[i]);

View File

@@ -135,8 +135,8 @@ SrmDevice::cleanup(CommPortPtr dev)
if (!dev2path(dev, path, err))
assert(false);
if (QMessageBox::question(0, "Powercontrol",
"Erase downloaded ride from device memory?",
"&Erase", "&Save Only", "", 1, 1) == 0) {
"Erase ride from device memory?",
"&Erase", "&Cancel", "", 1, 1) == 0) {
SrmpcConn srm(path);
if(!srm.d || (srmpc_clear_chunks(srm.d) < 0)) {
QMessageBox::warning(0, "Error",