From 06ce5d686cf7e351237396686d6d140f481f363c Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Thu, 21 Aug 2014 15:46:14 +1000 Subject: [PATCH] CMS50F/i stuff, summary only colors in overview, sesslist cleanup, empty day cleanup --- sleepyhead/Graphs/gSummaryChart.cpp | 15 ++++- sleepyhead/SleepLib/day.cpp | 4 +- sleepyhead/SleepLib/day.h | 2 +- .../loader_plugins/cms50f37_loader.cpp | 13 ++-- sleepyhead/SleepLib/serialoximeter.h | 2 +- sleepyhead/daily.cpp | 66 ++++++++++++------- 6 files changed, 67 insertions(+), 35 deletions(-) diff --git a/sleepyhead/Graphs/gSummaryChart.cpp b/sleepyhead/Graphs/gSummaryChart.cpp index 25638681..63b371b1 100644 --- a/sleepyhead/Graphs/gSummaryChart.cpp +++ b/sleepyhead/Graphs/gSummaryChart.cpp @@ -588,6 +588,8 @@ void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) painter.setClipRect(left, top, width, height); painter.setClipping(true); + QColor summaryColor = QColor("dark gray"); + for (qint64 Q = minx; Q <= maxx + ms_per_day; Q += ms_per_day) { zd = Q / ms_per_day; d = m_values.find(zd); @@ -598,6 +600,8 @@ void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) if (d != m_values.end()) { day = m_days[zd]; + bool summary_only = day->summaryOnly(); + if (!m_hours.contains(zd)) { goto jumpnext; @@ -637,6 +641,9 @@ void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) QColor col = m_colors[0]; //if (hourssummaryOnly(); QString z = dt.toString(Qt::SystemLocaleShortDate); @@ -1256,11 +1266,14 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event, gGraph *graph) } } + if (summary_only) { + z += "\r\n"+QObject::tr("(Summary Only)"); + } graph->ToolTip(z, x, y - 15); return false; } else { - QString z = dt.toString(Qt::SystemLocaleShortDate) + "\r\nNo Data"; + QString z = dt.toString(Qt::SystemLocaleShortDate) + "\r\n"+QObject::tr("No Data"); graph->ToolTip(z, x, y - 15); return false; } diff --git a/sleepyhead/SleepLib/day.cpp b/sleepyhead/SleepLib/day.cpp index 0a0686e4..b9ddfcf5 100644 --- a/sleepyhead/SleepLib/day.cpp +++ b/sleepyhead/SleepLib/day.cpp @@ -54,7 +54,7 @@ Machine *Day::machine(MachineType type) return nullptr; } -QList Day::getSessions(MachineType type) +QList Day::getSessions(MachineType type, bool ignore_enabled) { QList::iterator it; QList::iterator sess_end = sessions.end(); @@ -62,7 +62,7 @@ QList Day::getSessions(MachineType type) QList newlist; for (it = sessions.begin(); it != sess_end; ++it) { - if (!(*it)->enabled()) + if (!ignore_enabled && !(*it)->enabled()) continue; if ((*it)->machine()->type() == type) diff --git a/sleepyhead/SleepLib/day.h b/sleepyhead/SleepLib/day.h index d723d98d..70de1900 100644 --- a/sleepyhead/SleepLib/day.h +++ b/sleepyhead/SleepLib/day.h @@ -41,7 +41,7 @@ class Day Machine *machine(MachineType type); //! \brief Returns a list of sessions for the specified machine type - QList getSessions(MachineType type); + QList getSessions(MachineType type, bool ignore_enabled = false); //! \brief Add Session to this Day object (called during Load) void addSession(Session *s); diff --git a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp index f4c660e2..44b8f946 100644 --- a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp @@ -460,12 +460,12 @@ void CMS50F37Loader::processBytes(QByteArray bytes) buf[i] = (buf[i] & 0x7f) | (msb & 0x01 ? 0x80 : 0); } - quint16 pi = buffer.data()[idx+4] | buffer.data()[idx+5] << 8; + qint16 pi = buffer.data()[idx+4] | buffer.data()[idx+5] << 8; pulse = buf[3]; quint8 spo2 = buf[2]; - oxirec->append(((spo2 == 0) || (pulse == 0) || (pi == 0xfff6)) ? OxiRecord(0,0,0) : OxiRecord(pulse, spo2, pi)); + oxirec->append(((spo2 == 0) || (pulse == 0) || (pi>=0)) ? OxiRecord(0,0,0) : OxiRecord(pulse, spo2, pi)); } else if (res == 0x0f) { // f,80,de,c2,de,c2,de,c2 cms50F data... @@ -473,11 +473,14 @@ void CMS50F37Loader::processBytes(QByteArray bytes) buffer[idx+i] = (buffer[idx+i] & 0x7f) | (msb & 0x01 ? 0x80 : 0); } - oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(buffer.at(idx+3), buffer.at(idx+2))); + pulse = buffer.at(idx+3); + oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(pulse, buffer.at(idx+2))); - oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(buffer.at(idx+5), buffer.at(idx+4))); + pulse = buffer.at(idx+5); + oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(pulse, buffer.at(idx+4))); - oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(buffer.at(idx+7), buffer.at(idx+6))); + pulse = buffer.at(idx+7); + oxirec->append((pulse == 0xff) ? OxiRecord(0,0) : OxiRecord(pulse, buffer.at(idx+6))); } QStringList str; diff --git a/sleepyhead/SleepLib/serialoximeter.h b/sleepyhead/SleepLib/serialoximeter.h index 3b533e8e..d7172ffe 100644 --- a/sleepyhead/SleepLib/serialoximeter.h +++ b/sleepyhead/SleepLib/serialoximeter.h @@ -21,7 +21,7 @@ struct OxiRecord { quint8 pulse; quint8 spo2; - quint16 perf; + qint16 perf; OxiRecord():pulse(0), spo2(0),perf(0) {} OxiRecord(quint8 p, quint8 s): pulse(p), spo2(s) {} diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index 8d67f653..6033f3d7 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -957,13 +957,13 @@ QString Daily::getSessionInformation(Day * day) } html+="\n"; html+=QString("" - ""+STR_TR_On+"" - ""+STR_TR_Date+"" - ""+STR_TR_Start+"" - ""+STR_TR_End+"" - ""+tr("Duration")+""); + ""+STR_TR_On+"" + ""+STR_TR_Date+"" + ""+STR_TR_Start+"" + ""+STR_TR_End+"" + ""+tr("Duration")+""); - QList sesslist = day->getSessions(mi.key()); + QList sesslist = day->getSessions(mi.key(), true); for (QList::iterator s=sesslist.begin(); s != sesslist.end(); ++s) { if (((*s)->machine()->type() == MT_CPAP) && @@ -982,16 +982,14 @@ QString Daily::getSessionInformation(Day * day) sess->settings[SESSION_ENABLED]=true; } bool b=sess->settings[SESSION_ENABLED].toBool(); - html+=QString("" - "" - "" + html+=QString("" + "" "" - "" - "" - "" + "" + "" + "" "" - "
%2
%2
" "%5%6%7%5%6%7%3
" ) .arg((*s)->session()) .arg(QObject::tr("%1 Session #%2").arg((*s)->machine()->loaderName()).arg((*s)->session(),8,10,QChar('0'))) @@ -1420,6 +1418,20 @@ void Daily::Load(QDate date) "tr.datarow:nth-child(even) {" "background-color: #f8f8f8;" "}" + "tr.datarow2:nth-child(4n-1) {" + "background-color: #f8f8f8;" + "}" + "tr.datarow2:nth-child(4n+0) {" + "background-color: #f8f8f8;" + "}" + "table.curved {" + "border: 1px solid gray;" + "border-radius:10px;" + "-moz-border-radius:10px;" + "-webkit-border-radius:10px;" + "page-break-after:auto;" + "-fs-table-paginate: paginate;" + "}" "" "" @@ -1596,27 +1608,28 @@ void Daily::Load(QDate date) } html+="\n"; + html+="
\n"; } else { html+="\n"; if (!isBrick) { html+="\n"; if (day->size()>0) { - html+=""; - html+="\n"; + html+=""; + html+=""; + html+="\n"; } else { - html+=""; - html+="\n"; + html+=""; + html+="\n"; } } else { // machine is a brick - html+=""; - html+="\n"; - html+="\n"; + html+=""; + html+="\n"; + html+="\n"; } html+="\n"; html+="
 

"+tr("Sessions all off!")+"

"+tr("Sessions exist for this day but are switched off.")+"
"+tr("Sessions all off!")+"
"+tr("Sessions exist for this day but are switched off.")+"

"+tr("Impossibly short session")+"

"+tr("Zero hours??")+"

"+tr("Impossibly short session")+"

"+tr("Zero hours??")+"

"+tr("BRICK :(")+"

"+tr("Sorry, your machine only provides compliance data.")+"
"+tr("Complain to your Equipment Provider!")+"

"+tr("BRICK :(")+"

"+tr("Sorry, your machine only provides compliance data.")+"
"+tr("Complain to your Equipment Provider!")+"
 
\n"; } - html+="
\n"; } // if (!CPAP) else html+=getSleepTime(day); @@ -1628,11 +1641,14 @@ void Daily::Load(QDate date) } else { if (cpap && day->hours(MT_CPAP)<0.0000001) { } else { - html+="\n"; - html+="\n"; - html+="\n"; + html+="
"+tr("No data available")+"
 
"; + html+=""; + html+=""; + html+=""; + html+=""; + html+=""; + html+=""; html+="
"+tr("\"Nothing's here!\"")+"
"+tr("Bob is bored with this days lack of data.")+"
\n"; - html+="
\n"; } }