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.
This commit is contained in:
sawinglogz 2019-06-04 14:14:22 -04:00
parent 2021e91426
commit 5ac6745eef
2 changed files with 10 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* SleepLib Event Class Implementation
/* SleepLib Event Class Implementation
*
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
*
@ -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;

View File

@ -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