From ea7add7a9e42f5d70a645665dff42d3920cae2ce Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Sun, 3 Jul 2011 13:38:55 +1000 Subject: [PATCH] Ignoring empty ResMed sessions --- SleepLib/loader_plugins/resmed_loader.cpp | 5 +++-- SleepLib/machine.cpp | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/SleepLib/loader_plugins/resmed_loader.cpp b/SleepLib/loader_plugins/resmed_loader.cpp index 601d579f..28111e73 100644 --- a/SleepLib/loader_plugins/resmed_loader.cpp +++ b/SleepLib/loader_plugins/resmed_loader.cpp @@ -78,7 +78,7 @@ bool EDFParser::Parse() // break; //serialnumber+=recordingident[i]; //} - QDateTime startDate=QDateTime::fromString(QString::fromAscii(header.datetime,16),"dd.MM.yyHH.mm.ss"); + QDateTime startDate=QDateTime::fromString(QString::fromAscii(header.datetime,16),"dd.MM.yyHH.mm.ss").toUTC(); QDate d2=startDate.date(); if (d2.year()<2000) { d2.setYMD(d2.year()+100,d2.month(),d2.day()); @@ -107,7 +107,8 @@ bool EDFParser::Parse() return false; enddate=startdate+dur_data_record*qint64(num_data_records); - + if (dur_data_record==0) + return false; // this could be loaded quicker by transducer_type[signal] etc.. diff --git a/SleepLib/machine.cpp b/SleepLib/machine.cpp index 44f66539..fad5bff6 100644 --- a/SleepLib/machine.cpp +++ b/SleepLib/machine.cpp @@ -226,7 +226,7 @@ Session *Machine::SessionExists(SessionID session) } Day *Machine::AddSession(Session *s,Profile *p) { - double span; + double span=0; assert(s!=NULL); assert(p!=NULL); @@ -251,6 +251,7 @@ Day *Machine::AddSession(Session *s,Profile *p) // less than n hours since last session yesterday? if (span < hours_since_last_session) { previous=true; + } else { } } @@ -263,6 +264,7 @@ Day *Machine::AddSession(Session *s,Profile *p) // Bedtime was late last night. if (span < hours_since_midnight) { + previous=true; } } @@ -286,7 +288,8 @@ Day *Machine::AddSession(Session *s,Profile *p) //qDebug("Adding Profile Day %s",dstr.toAscii().data()); day[date]=new Day(this); // Add this Day record to profile - QDateTime d=QDateTime::fromMSecsSinceEpoch(date); + QDateTime d=QDateTime::fromMSecsSinceEpoch(date).toUTC(); + qDebug() << "New day: " << d.toString("yyyy-MM-dd HH:mm:ss"); p->AddDay(d.date(),day[date],m_type); }