From 5ac6745eefd147c05b0af0a88c0d4d2945228181 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Tue, 4 Jun 2019 14:14:22 -0400 Subject: [PATCH] Fix PRS1 F0V23 PB parsing bug that triggered unordered data warnings. A PB event obviously can't start so late that its duration ends in the future! The fix hasn't been applied to F0V4 or F0V6 yet, since those haven't been tested yet. Also fix a sign bug in EventList::AddEvent when there *is* unordered data. --- oscar/SleepLib/event.cpp | 6 +++--- oscar/SleepLib/loader_plugins/prs1_loader.cpp | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/oscar/SleepLib/event.cpp b/oscar/SleepLib/event.cpp index a90bdbb1..6eda1143 100644 --- a/oscar/SleepLib/event.cpp +++ b/oscar/SleepLib/event.cpp @@ -1,4 +1,4 @@ -/* SleepLib Event Class Implementation +/* SleepLib Event Class Implementation * * Copyright (c) 2011-2018 Mark Watkins * @@ -85,12 +85,12 @@ void EventList::AddEvent(qint64 time, EventStoreType data) if (m_first > time) { // Crud.. Update all the previous records // This really shouldn't happen. - qDebug() << "Unordered time detected in AddEvent()."; + qDebug() << "Unordered time detected in AddEvent()" << m_count << m_first << time << data; qint32 delta = (m_first - time); for (quint32 i = 0; i < m_count; ++i) { - m_time[i] -= delta; + m_time[i] += delta; } m_first = time; diff --git a/oscar/SleepLib/loader_plugins/prs1_loader.cpp b/oscar/SleepLib/loader_plugins/prs1_loader.cpp index 8efec2f8..63a432ed 100644 --- a/oscar/SleepLib/loader_plugins/prs1_loader.cpp +++ b/oscar/SleepLib/loader_plugins/prs1_loader.cpp @@ -3072,7 +3072,7 @@ bool PRS1DataChunk::ParseEventsF0(CPAPMode mode) pos += 2; data1 = buffer[pos++]; - this->AddEvent(new PRS1UnknownValueEvent(code, t - data1, data0)); + this->AddEvent(new PRS1UnknownValueEvent(code, t - data1, data0)); // TODO: start time should probably match PB below break; case 0x0f: // Cheyne Stokes Respiration @@ -3083,7 +3083,11 @@ bool PRS1DataChunk::ParseEventsF0(CPAPMode mode) } pos += 2; data1 = buffer[pos++]; - this->AddEvent(new PRS1PeriodicBreathingEvent(t - data1, data0)); + if (this->familyVersion == 2 || this->familyVersion == 3) { + this->AddEvent(new PRS1PeriodicBreathingEvent(t - data1 - data0, data0)); // PB event appears data1 seconds after conclusion + } else { + this->AddEvent(new PRS1PeriodicBreathingEvent(t - data1, data0)); // TODO: this should probably be the same as F0V23, but it hasn't been tested + } break; case 0x10: // Large Leak @@ -3094,7 +3098,7 @@ bool PRS1DataChunk::ParseEventsF0(CPAPMode mode) } pos += 2; data1 = buffer[pos++]; - this->AddEvent(new PRS1LargeLeakEvent(t - data1, data0)); + this->AddEvent(new PRS1LargeLeakEvent(t - data1, data0)); // TODO: start time should probably match PB above break; case 0x11: // Leak Rate & Snore Graphs