From 0b31d0ea3f5631a6ab7e481a43a3f531a9f5df46 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Fri, 22 Aug 2014 21:54:17 +1000 Subject: [PATCH] Fix duplicate ResMed Ti/Te signals from importing --- sleepyhead/Graphs/MinutesAtPressure.cpp | 2 +- sleepyhead/Graphs/gLineChart.cpp | 8 -------- sleepyhead/SleepLib/event.cpp | 2 +- sleepyhead/SleepLib/event.h | 14 +++++++------- .../SleepLib/loader_plugins/resmed_loader.cpp | 14 ++++++++++++++ sleepyhead/daily.cpp | 1 - 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/sleepyhead/Graphs/MinutesAtPressure.cpp b/sleepyhead/Graphs/MinutesAtPressure.cpp index 475b3337..9e3c00e5 100644 --- a/sleepyhead/Graphs/MinutesAtPressure.cpp +++ b/sleepyhead/Graphs/MinutesAtPressure.cpp @@ -434,7 +434,7 @@ void RecalcMAP::run() const QVector & evec = ei.value(); int esize = evec.size(); for (int ei = 0; ei < esize; ++ei) { - EventList *EL = evec[ei]; + const EventList *EL = evec.at(ei); EventDataType gain = EL->gain(); quint32 ELsize = EL->count(); if (ELsize < 1) return; diff --git a/sleepyhead/Graphs/gLineChart.cpp b/sleepyhead/Graphs/gLineChart.cpp index 422053ff..37714a08 100644 --- a/sleepyhead/Graphs/gLineChart.cpp +++ b/sleepyhead/Graphs/gLineChart.cpp @@ -570,11 +570,6 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) num_points += (*ni)->count(); } - if (code == CPAP_FlowRate) { - int i=5; Q_UNUSED(i); - } - - total_points += num_points; codepoints += num_points; @@ -796,12 +791,9 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) data = (*ptr + el.offset()) * gain; lastpx = xst + ((time - minx) * xmult); lastpy = yst - ((data - miny) * ymult); - EventStoreType *eptr = el.rawData() + el.count()-1; - lines.clear(); siz--; for (int i = idx; i < siz; i += sam) { ptr += sam; - if (ptr >= eptr) break; time += rate; data = (*ptr + el.offset()) * gain; diff --git a/sleepyhead/SleepLib/event.cpp b/sleepyhead/SleepLib/event.cpp index c8ee20f0..0451f513 100644 --- a/sleepyhead/SleepLib/event.cpp +++ b/sleepyhead/SleepLib/event.cpp @@ -44,7 +44,7 @@ void EventList::clear() } -qint64 EventList::time(quint32 i) +qint64 EventList::time(quint32 i) const { if (m_type == EVL_Event) { return m_first + qint64(m_time[i]); diff --git a/sleepyhead/SleepLib/event.h b/sleepyhead/SleepLib/event.h index fbc9e188..71ff1cf1 100644 --- a/sleepyhead/SleepLib/event.h +++ b/sleepyhead/SleepLib/event.h @@ -41,16 +41,16 @@ class EventList void AddWaveform(qint64 start, char *data, int recs, qint64 duration); //! \brief Returns a count of records contained in this EventList - inline const quint32 &count() { return m_count; } + inline quint32 count() const { return m_count; } //! \brief Manually sets a count of records contained in this EventList void setCount(quint32 count) { m_count = count; } //! \brief Returns a raw ("ungained") data value from index position i - inline EventStoreType raw(int i) { return m_data[i]; } + inline EventStoreType raw(int i) const { return m_data[i]; } //! \brief Returns a raw ("ungained") data2 value from index position i - inline EventStoreType raw2(int i) { return m_data2[i]; } + inline EventStoreType raw2(int i) const { return m_data2[i]; } //! \brief Returns a data value multiplied by gain from index position i EventDataType data(quint32 i); @@ -59,16 +59,16 @@ class EventList EventDataType data2(quint32 i); //! \brief Returns either the timestamp for the i'th event, or calculates the waveform time position i - qint64 time(quint32 i); + qint64 time(quint32 i) const; //! \brief Returns true if this EventList uses the second data field bool hasSecondField() { return m_second_field; } //! \brief Returns the first events/waveforms starting time in milliseconds since epoch - inline const qint64 &first() { return m_first; } + inline qint64 first() const { return m_first; } //! \brief Returns the last events/waveforms ending time in milliseconds since epoch - inline const qint64 &last() { return m_last; } + inline qint64 last() const { return m_last; } //! \brief Returns the timespan covered by this EventList, in milliseconds since epoch inline qint64 duration() { return m_last - m_first; } @@ -117,7 +117,7 @@ class EventList inline EventDataType max2() { return m_max2; } //! \brief Return the gain value - inline EventDataType gain() { return m_gain; } + inline EventDataType gain() const { return m_gain; } //! \brief Return the gain offset inline EventDataType offset() { return m_offset; } diff --git a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp index cd4afe7f..58845199 100644 --- a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp @@ -645,6 +645,11 @@ void ResmedImport::run() } loader->saveMutex.unlock(); + if (sessionid == 1408571701) { + int i=5; Q_UNUSED(i); + } + + if (!group.EVE.isEmpty()) { loader->LoadEVE(sess, group.EVE); } @@ -2273,11 +2278,20 @@ bool ResmedLoader::LoadPLD(Session *sess, const QString & path) //a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0); } else if (matchSignal(CPAP_Ti, es.label)) { code = CPAP_Ti; + // There are TWO of these with the same label on my VPAP Adapt 36037 + + if (sess->eventlist.contains(code)) { + continue; + } a = sess->AddEventList(code, EVL_Waveform, es.gain, es.offset, 0, 0, rate); a->AddWaveform(edf.startdate, es.data, recs, duration); //a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0); } else if (matchSignal(CPAP_Te, es.label)) { code = CPAP_Te; + // There are TWO of these with the same label on my VPAP Adapt 36037 + if (sess->eventlist.contains(code)) { + continue; + } a = sess->AddEventList(code, EVL_Waveform, es.gain, es.offset, 0, 0, rate); a->AddWaveform(edf.startdate, es.data, recs, duration); //a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0); diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index 522ae577..1d28e3b9 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -656,7 +656,6 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day) QHash mcroot; QHash mccnt; int total_events=0; - bool userflags=p_profile->cpap->userEventFlagging(); qint64 drift=0, clockdrift=p_profile->cpap->clockDrift()*1000L;