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