mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Track down zero time that led to future sessions
This commit is contained in:
parent
d1dac68454
commit
2da3a9cd86
@ -31,8 +31,8 @@ ResMedEDFInfo::~ResMedEDFInfo() { }
|
||||
bool ResMedEDFInfo::Parse( ) // overrides and calls the super's Parse
|
||||
{
|
||||
if ( ! EDFInfo::Parse( ) ) {
|
||||
qWarning() << "EDFInfo::Parse failed!";
|
||||
sleep(1);
|
||||
// qWarning() << "EDFInfo::Parse failed!";
|
||||
// sleep(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ bool ResMedEDFInfo::Parse( ) // overrides and calls the super's Parse
|
||||
|
||||
if (!edfHdr.startdate_orig.isValid()) {
|
||||
qDebug() << "Invalid date time retreieved parsing EDF File " << filename;
|
||||
sleep(1);
|
||||
// sleep(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ bool ResMedEDFInfo::Parse( ) // overrides and calls the super's Parse
|
||||
//startdate-=timezoneOffset();
|
||||
if (startdate == 0) {
|
||||
qDebug() << "Invalid startdate = 0 in EDF File " << filename;
|
||||
sleep(1);
|
||||
// sleep(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,7 @@ int ResmedLoader::Open(const QString & dirpath)
|
||||
} else { // passed the tests, stuff it into the map
|
||||
QDate date = stredf->edfHdr.startdate_orig.date();
|
||||
long int days = stredf->GetNumDataRecords();
|
||||
qDebug() << strpath << "starts at" << date << "for" << days;
|
||||
qDebug() << strpath.section("/",-2,-1) << "starts at" << date << "for" << days;
|
||||
STRmap[date] = STRFile(strpath, days, stredf);
|
||||
}
|
||||
} else {
|
||||
@ -466,7 +466,7 @@ int ResmedLoader::Open(const QString & dirpath)
|
||||
date = stredf->edfHdr.startdate_orig.date();
|
||||
days = stredf->GetNumDataRecords();
|
||||
if (STRmap.contains(date)) { // Keep the longer of the two STR files
|
||||
qDebug() << filename << "overlaps" << STRmap[date].filename << "for" << days;
|
||||
qDebug() << filename << "overlaps" << STRmap[date].filename.section("/",-2,-1) << "for" << days;
|
||||
if (days <= STRmap[date].days) {
|
||||
qDebug() << "Skipping" << filename;
|
||||
delete stredf;
|
||||
@ -476,7 +476,7 @@ int ResmedLoader::Open(const QString & dirpath)
|
||||
// qDebug() << "Resetting STR date from" << date.toString() << "to first of month ... WHY???";
|
||||
// date = QDate(date.year(), date.month(), 1);
|
||||
|
||||
qDebug() << fi.canonicalFilePath() << "starts at" << date << "for" << days;
|
||||
qDebug() << fi.canonicalFilePath().section("/", -2,-1) << "starts at" << date << "for" << days;
|
||||
STRmap[date] = STRFile(fi.canonicalFilePath(), days, stredf);
|
||||
} // end for walking the STR_Backup directory
|
||||
#ifdef STR_DEBUG
|
||||
@ -1727,7 +1727,7 @@ EDFduration getEDFDuration(const QString & filename)
|
||||
d2.setDate(d2.year() + 100, d2.month(), d2.day());
|
||||
startDate.setDate(d2);
|
||||
}
|
||||
if ( ! startDate.isValid() ) {
|
||||
if ( (! startDate.isValid()) || ( startDate > QDateTime::currentDateTime()) ) {
|
||||
qDebug() << "Invalid date time retreieved parsing EDF duration for" << filename;
|
||||
qDebug() << "Time zone(Utc) is" << startDate.timeZone().abbreviation(QDateTime::currentDateTimeUtc());
|
||||
qDebug() << "Time zone is" << startDate.timeZone().abbreviation(QDateTime::currentDateTime());
|
||||
@ -1954,7 +1954,7 @@ struct OverlappingEDF {
|
||||
void ResDayTask::run()
|
||||
{
|
||||
if (resday->files.size() == 0) { // No EDF files???
|
||||
if ( ! resday->str.date.isValid()) {
|
||||
if (( ! resday->str.date.isValid()) || (resday->str.date > QDate::currentDate()) ) {
|
||||
// This condition should be impossible, but just in case something gets fudged up elsewhere later
|
||||
qDebug() << "No edf files in resday" << resday->date << "and the str date is inValid";
|
||||
return;
|
||||
@ -1967,6 +1967,11 @@ void ResDayTask::run()
|
||||
for (int i=0;i<resday->str.maskon.size();++i) {
|
||||
quint32 maskon = resday->str.maskon[i];
|
||||
quint32 maskoff = resday->str.maskoff[i];
|
||||
if ( (maskon > QDateTime::currentDateTime().toTime_t()) ||
|
||||
(maskoff > QDateTime::currentDateTime().toTime_t()) ) {
|
||||
qWarning() << "mask time in future" << resday->date;
|
||||
continue;
|
||||
}
|
||||
if (((maskon>0) && (maskoff>0)) && (maskon != maskoff)) { //ignore very short sessions
|
||||
Session * sess = new Session(mach, maskon);
|
||||
sess->set_first(quint64(maskon) * 1000L);
|
||||
@ -2003,6 +2008,11 @@ void ResDayTask::run()
|
||||
if (resday->str.date.isValid()) {
|
||||
//First populate Overlaps with Mask ON/OFF events
|
||||
for (int i=0; i < maskOnSize; ++i) {
|
||||
if ( (resday->str.maskon[i] > QDateTime::currentDateTime().toTime_t()) ||
|
||||
(resday->str.maskoff[i] > QDateTime::currentDateTime().toTime_t()) ) {
|
||||
qWarning() << "mask time in future" << resday->date;
|
||||
continue;
|
||||
}
|
||||
if (((resday->str.maskon[i]>0) || (resday->str.maskoff[i]>0))
|
||||
&& (resday->str.maskon[i] != resday->str.maskoff[i]) ) {
|
||||
OverlappingEDF ov;
|
||||
@ -2045,6 +2055,11 @@ void ResDayTask::run()
|
||||
}
|
||||
if (!added) { // Didn't get a hit, look at the EDF files duration and check for an overlap
|
||||
EDFduration dur = getEDFDuration(fullpath);
|
||||
if ((dur.start > (QDateTime::currentDateTime().toMSecsSinceEpoch()/1000L)) ||
|
||||
(dur.end > (QDateTime::currentDateTime().toMSecsSinceEpoch()/1000L)) ) {
|
||||
qWarning() << "Future Date in" << fullpath;
|
||||
continue; // skip this file
|
||||
}
|
||||
for (int i=overlaps.size()-1; i>=0; --i) {
|
||||
OverlappingEDF & ovr = overlaps[i];
|
||||
if ((ovr.start < dur.end) && (dur.start < ovr.end)) {
|
||||
@ -2072,7 +2087,7 @@ void ResDayTask::run()
|
||||
ov.end = dur.end;
|
||||
ov.filemap.insert(filetime_t, filename);
|
||||
#ifdef SESSION_DEBUG
|
||||
qDebug() << "Creating session for" << filename;
|
||||
qDebug() << "Creating overlap for" << filename;
|
||||
qDebug() << "Starts:" << dur.start << "Ends:" << dur.end;
|
||||
#endif
|
||||
overlaps.append(ov);
|
||||
@ -2172,13 +2187,14 @@ void ResDayTask::run()
|
||||
qDebug() << "Session" << sess->session()
|
||||
<< "["+QDateTime::fromTime_t(sess->session()).toString("MMM dd, yyyy hh:mm:ss")+"]"
|
||||
<< "has zero duration";
|
||||
qDebug() << QString("Start: %1").arg(sess->realFirst(),0,16) << QString("End: %1").arg(sess->realLast(),0,16);
|
||||
}
|
||||
if (sess->length() < 0) {
|
||||
// we want empty sessions even though they are crap
|
||||
qDebug() << "Session" << sess->session()
|
||||
<< "["+QDateTime::fromTime_t(sess->session()).toString("MMM dd, yyyy hh:mm:ss")+"]"
|
||||
<< "has negative duration";
|
||||
qDebug() << "Start:" << sess->realFirst() << "End:" << sess->realLast();
|
||||
qDebug() << QString("Start: %1").arg(sess->realFirst(),0,16) << QString("End: %1").arg(sess->realLast(),0,16);
|
||||
}
|
||||
|
||||
if (resday->str.date.isValid()) {
|
||||
@ -2195,9 +2211,8 @@ void ResDayTask::run()
|
||||
#endif
|
||||
StoreSettings(sess, R);
|
||||
|
||||
} else {
|
||||
// No corresponding STR.edf record, but we have EDF files
|
||||
#ifdef SESSION_DEBUG
|
||||
} else { // No corresponding STR.edf record, but we have EDF files
|
||||
#ifdef STR_DEBUG
|
||||
qDebug() << "EDF files without STR record" << resday->date.toString();
|
||||
#endif
|
||||
bool foundprev = false;
|
||||
@ -2221,7 +2236,6 @@ void ResDayTask::run()
|
||||
foundprev = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
loader->sessionMutex.unlock();
|
||||
sess->setNoSettings(true);
|
||||
@ -2233,7 +2247,7 @@ void ResDayTask::run()
|
||||
GuessPAPMode(sess);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end else no STR record for these edf files
|
||||
|
||||
sess->UpdateSummaries();
|
||||
#ifdef SESSION_DEBUG
|
||||
@ -2245,6 +2259,12 @@ void ResDayTask::run()
|
||||
// loader->saveMutex.lock();
|
||||
// loader->saveMutex.unlock();
|
||||
|
||||
if ( (QDateTime::fromTime_t(sess->session()) > QDateTime::currentDateTime()) ||
|
||||
(sess->realFirst() == 0) || (sess->realLast() == 0) )
|
||||
qWarning() << "Skipping Future session:" << sess->session()
|
||||
<< "["+QDateTime::fromTime_t(sess->session()).toString("MMM dd, yyyy hh:mm:ss")+"]"
|
||||
<< "\noriginal date is" << resday->date.toString();
|
||||
else
|
||||
save(loader, sess);
|
||||
|
||||
// Free the memory used by this session
|
||||
@ -2272,9 +2292,10 @@ bool ResmedLoader::LoadCSL(Session *sess, const QString & path)
|
||||
time.start();
|
||||
#endif
|
||||
|
||||
QString filename = path.section(-2, -1);
|
||||
ResMedEDFInfo edf;
|
||||
if ( ! edf.Open(path) ) {
|
||||
qDebug() << "LoadCSL failed to open" << path;
|
||||
qDebug() << "LoadCSL failed to open" << filename;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2284,7 +2305,7 @@ bool ResmedLoader::LoadCSL(Session *sess, const QString & path)
|
||||
#endif
|
||||
|
||||
if (!edf.Parse()) {
|
||||
qDebug() << "LoadCSL failed to parse" << path;
|
||||
qDebug() << "LoadCSL failed to parse" << filename;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2350,9 +2371,10 @@ bool ResmedLoader::LoadEVE(Session *sess, const QString & path)
|
||||
QTime time;
|
||||
time.start();
|
||||
#endif
|
||||
QString filename = path.section(-2, -1);
|
||||
ResMedEDFInfo edf;
|
||||
if ( ! edf.Open(path) ) {
|
||||
qDebug() << "LoadEVE failed to open" << path;
|
||||
qDebug() << "LoadEVE failed to open" << filename;
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_EFFICIENCY
|
||||
@ -2361,7 +2383,7 @@ bool ResmedLoader::LoadEVE(Session *sess, const QString & path)
|
||||
#endif
|
||||
|
||||
if (!edf.Parse()) {
|
||||
qDebug() << "LoadEVE failed to parse" << path;
|
||||
qDebug() << "LoadEVE failed to parse" << filename;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2444,9 +2466,10 @@ bool ResmedLoader::LoadBRP(Session *sess, const QString & path)
|
||||
QTime time;
|
||||
time.start();
|
||||
#endif
|
||||
QString filename = path.section(-2, -1);
|
||||
ResMedEDFInfo edf;
|
||||
if ( ! edf.Open(path) ) {
|
||||
qDebug() << "LoadBRP failed to open" << path;
|
||||
qDebug() << "LoadBRP failed to open" << filename;
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_EFFICIENCY
|
||||
@ -2454,7 +2477,7 @@ bool ResmedLoader::LoadBRP(Session *sess, const QString & path)
|
||||
time.start();
|
||||
#endif
|
||||
if (!edf.Parse()) {
|
||||
qDebug() << "LoadBRP failed to parse" << path;
|
||||
qDebug() << "LoadBRP failed to parse" << filename;
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_EFFICIENCY
|
||||
@ -2545,9 +2568,10 @@ bool ResmedLoader::LoadSAD(Session *sess, const QString & path)
|
||||
time.start();
|
||||
#endif
|
||||
|
||||
QString filename = path.section(-2, -1);
|
||||
ResMedEDFInfo edf;
|
||||
if ( ! edf.Open(path) ) {
|
||||
qDebug() << "LoadSAD failed to open" << path;
|
||||
qDebug() << "LoadSAD failed to open" << filename;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2557,7 +2581,7 @@ bool ResmedLoader::LoadSAD(Session *sess, const QString & path)
|
||||
#endif
|
||||
|
||||
if (!edf.Parse()) {
|
||||
qDebug() << "LoadSAD failed to parse" << path;
|
||||
qDebug() << "LoadSAD failed to parse" << filename;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2619,9 +2643,10 @@ bool ResmedLoader::LoadPLD(Session *sess, const QString & path)
|
||||
QTime time;
|
||||
time.start();
|
||||
#endif
|
||||
QString filename = path.section(-2, -1);
|
||||
ResMedEDFInfo edf;
|
||||
if ( ! edf.Open(path) ) {
|
||||
qDebug() << "LoadPLD failed to open" << path;
|
||||
qDebug() << "LoadPLD failed to open" << filename;
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_EFFICIENCY
|
||||
@ -2630,7 +2655,7 @@ bool ResmedLoader::LoadPLD(Session *sess, const QString & path)
|
||||
#endif
|
||||
|
||||
if (!edf.Parse()) {
|
||||
qDebug() << "LoadPLD failed to parse" << path;
|
||||
qDebug() << "LoadPLD failed to parse" << filename;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1622,6 +1622,7 @@ void packEventList(EventList *el, EventDataType minval = 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lastt = t;
|
||||
}
|
||||
|
||||
@ -1862,12 +1863,15 @@ void MainWindow::RestartApplication(bool force_login, QString cmdline)
|
||||
|
||||
void MainWindow::on_actionPurge_Current_Day_triggered()
|
||||
{
|
||||
if (!daily) return;
|
||||
if (!daily)
|
||||
return;
|
||||
QDate date = daily->getDate();
|
||||
qDebug() << "Purging CPAP data from" << date;
|
||||
daily->Unload(date);
|
||||
Day *day = p_profile->GetDay(date, MT_CPAP);
|
||||
Machine *cpap = nullptr;
|
||||
if (day) cpap = day->machine(MT_CPAP);
|
||||
if (day)
|
||||
cpap = day->machine(MT_CPAP);
|
||||
|
||||
if (cpap) {
|
||||
QList<Session *>::iterator s;
|
||||
@ -1876,6 +1880,9 @@ void MainWindow::on_actionPurge_Current_Day_triggered()
|
||||
QList<SessionID> sidlist;
|
||||
for (s = day->begin(); s != day->end(); ++s) {
|
||||
list.push_back(*s);
|
||||
qDebug() << "Purging session ID:" << (*s)->session() << "["+QDateTime::fromTime_t((*s)->session()).toString()+"]";
|
||||
qDebug() << "First Time:" << QDateTime::fromMSecsSinceEpoch((*s)->realFirst()).toString();
|
||||
qDebug() << "Last Time:" << QDateTime::fromMSecsSinceEpoch((*s)->realLast()).toString();
|
||||
sidlist.push_back((*s)->session());
|
||||
}
|
||||
|
||||
@ -1884,6 +1891,7 @@ void MainWindow::on_actionPurge_Current_Day_triggered()
|
||||
|
||||
QFile impfile(cpap->getDataPath()+"/imported_files.csv");
|
||||
if (impfile.exists()) {
|
||||
qDebug() << "Obsolet file exists" << impfile.fileName();
|
||||
if (impfile.open(QFile::ReadOnly)) {
|
||||
QTextStream impstream(&impfile);
|
||||
QString serial;
|
||||
@ -1920,7 +1928,7 @@ void MainWindow::on_actionPurge_Current_Day_triggered()
|
||||
out.flush();
|
||||
}
|
||||
impfile.close();
|
||||
}
|
||||
} // end of obsolte file code
|
||||
|
||||
QFile rxcache(p_profile->Get("{" + STR_GEN_DataFolder + "}/RXChanges.cache" ));
|
||||
rxcache.remove();
|
||||
@ -1942,6 +1950,11 @@ void MainWindow::on_actionPurge_Current_Day_triggered()
|
||||
|
||||
daily->clearLastDay();
|
||||
daily->LoadDate(date);
|
||||
if (overview)
|
||||
overview->ReloadGraphs();
|
||||
if (welcome)
|
||||
welcome->refreshPage();
|
||||
GenerateStatistics();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionRebuildCPAP(QAction *action)
|
||||
@ -2002,13 +2015,15 @@ void MainWindow::on_actionRebuildCPAP(QAction *action)
|
||||
} else {
|
||||
}
|
||||
}
|
||||
if (overview) overview->ReloadGraphs();
|
||||
if (overview)
|
||||
overview->ReloadGraphs();
|
||||
if (daily) {
|
||||
daily->Unload();
|
||||
daily->clearLastDay(); // otherwise Daily will crash
|
||||
daily->ReloadGraphs();
|
||||
}
|
||||
if (welcome) welcome->refreshPage();
|
||||
if (welcome)
|
||||
welcome->refreshPage();
|
||||
PopulatePurgeMenu();
|
||||
GenerateStatistics();
|
||||
p_profile->StoreMachines();
|
||||
|
Loading…
Reference in New Issue
Block a user