Bug fix to previous commit

This commit is contained in:
Mark Watkins 2014-05-16 08:48:51 +10:00
parent ad43791fc7
commit dd1cdd83fb
4 changed files with 29 additions and 15 deletions

View File

@ -67,10 +67,10 @@ class Channel
const QString &label() { return m_label; } const QString &label() { return m_label; }
const QString &units() { return m_unit; } const QString &units() { return m_unit; }
inline const EventDataType &upperThreshold() { return m_upperThreshold; } const EventDataType &upperThreshold() { return m_upperThreshold; }
inline const EventDataType &lowerThreshold() { return m_lowerThreshold; } const EventDataType &lowerThreshold() { return m_lowerThreshold; }
inline QColor &upperThresholdColor() { return m_upperThresholdColor; } const QColor &upperThresholdColor() { return m_upperThresholdColor; }
inline QColor &lowerThresholdColor() { return m_lowerThresholdColor; } const QColor &lowerThresholdColor() { return m_lowerThresholdColor; }
const int &linkid() { return m_link; } const int &linkid() { return m_link; }

View File

@ -1660,6 +1660,9 @@ EventDataType Session::timeAboveThreshold(ChannelID id, EventDataType threshold)
} }
} }
} }
if (started) {
total += ti-started;
}
EventDataType time = double(total) / 60000.0; EventDataType time = double(total) / 60000.0;
return time; return time;
} }
@ -1697,6 +1700,11 @@ EventDataType Session::timeBelowThreshold(ChannelID id, EventDataType threshold)
} }
} }
} }
if (started) {
total += ti-started;
}
EventDataType time = double(total) / 60000.0; EventDataType time = double(total) / 60000.0;
return time; return time;
} }

View File

@ -371,6 +371,12 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
it.value()->AddLayer(new gXAxis(),LayerBottom,0,20); it.value()->AddLayer(new gXAxis(),LayerBottom,0,20);
} }
if (PROFILE.cpap->showLeakRedline()) {
schema::channel[CPAP_Leak].setUpperThreshold(PROFILE.cpap->leakRedline());
} else {
schema::channel[CPAP_Leak].setUpperThreshold(0); // switch it off
}
layout->layout(); layout->layout();
QTextCharFormat format = ui->calendar->weekdayTextFormat(Qt::Saturday); QTextCharFormat format = ui->calendar->weekdayTextFormat(Qt::Saturday);

View File

@ -612,12 +612,6 @@ QString Statistics::GenerateHTML()
name = ahitxt; name = ahitxt;
} else if ((row.calc == SC_HOURS) || (row.calc == SC_COMPLIANCE)) { } else if ((row.calc == SC_HOURS) || (row.calc == SC_COMPLIANCE)) {
name = row.src; name = row.src;
} else if ((row.calc == SC_ABOVE) || (row.calc == SC_BELOW)) {
ChannelID id = schema::channel[row.src].id();
if ((id == NoChannel) || (!PROFILE.hasChannel(id))) {
continue;
}
name = calcnames[row.calc].arg(schema::channel[id].fullname()); //.arg(tr("threshold"));
} else if (row.calc == SC_COLUMNHEADERS) { } else if (row.calc == SC_COLUMNHEADERS) {
html += QString("<tr><td><b>%1</b></td>\n").arg(tr("Details")); html += QString("<tr><td><b>%1</b></td>\n").arg(tr("Details"));
for (int j=0; j < periods.size(); j++) { for (int j=0; j < periods.size(); j++) {
@ -656,17 +650,23 @@ QString Statistics::GenerateHTML()
} else if (row.calc == SC_UNDEFINED) { } else if (row.calc == SC_UNDEFINED) {
continue; continue;
} else { } else {
if (row.calc == SC_ABOVE) {
int i=5;
}
ChannelID id = schema::channel[row.src].id(); ChannelID id = schema::channel[row.src].id();
if ((id == NoChannel) || (!PROFILE.hasChannel(id))) { if ((id == NoChannel) || (!PROFILE.hasChannel(id))) {
continue; continue;
} }
name = calcnames[row.calc].arg(schema::channel[id].fullname()); name = calcnames[row.calc].arg(schema::channel[id].fullname());
} }
html += QString("<tr><td>%1</td>").arg(name); QString line;
line += QString("<tr><td>%1</td>").arg(name);
for (int j=0; j < periods.size(); j++) { for (int j=0; j < periods.size(); j++) {
html += QString("<td>%2</td>") QString val=row.value(periods.at(j).start,periods.at(j).end);
.arg(row.value(periods.at(j).start,periods.at(j).end)); line += QString("<td>%2</td>")
.arg(val);
} }
html += line;
html += "</tr>\n"; html += "</tr>\n";
} }
@ -1230,7 +1230,7 @@ QString Statistics::GenerateHTML()
QString StatisticsRow::value(QDate start, QDate end) QString StatisticsRow::value(QDate start, QDate end)
{ {
const int decimals=2; const int decimals=2;
QString value = ""; QString value;
float days = PROFILE.countDays(type, start, end); float days = PROFILE.countDays(type, start, end);
// Handle special data sources first // Handle special data sources first
@ -1255,7 +1255,7 @@ QString StatisticsRow::value(QDate start, QDate end)
break; break;
case SC_WAVG: case SC_WAVG:
value = QString("%1").arg(p_profile->calcWavg(code, type, start, end), 0, 'f', decimals); value = QString("%1").arg(p_profile->calcWavg(code, type, start, end), 0, 'f', decimals);
break; break;
case SC_MEDIAN: case SC_MEDIAN:
value = QString("%1").arg(p_profile->calcPercentile(code, 0.5F, type, start, end), 0, 'f', decimals); value = QString("%1").arg(p_profile->calcPercentile(code, 0.5F, type, start, end), 0, 'f', decimals);
break; break;