From c3fc4bb267bfd133f6f069d02d1f1a9d3639aa00 Mon Sep 17 00:00:00 2001 From: Phil Olynyk Date: Sun, 12 Nov 2017 11:40:02 -0500 Subject: [PATCH] Use LAST . to find file extension --- .../SleepLib/loader_plugins/cms50_loader.cpp | 8 ++++++-- .../SleepLib/loader_plugins/cms50f37_loader.cpp | 14 +++++++++----- .../SleepLib/loader_plugins/md300w1_loader.cpp | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sleepyhead/SleepLib/loader_plugins/cms50_loader.cpp b/sleepyhead/SleepLib/loader_plugins/cms50_loader.cpp index 64bb71ad..0eacd747 100644 --- a/sleepyhead/SleepLib/loader_plugins/cms50_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/cms50_loader.cpp @@ -121,7 +121,7 @@ int CMS50Loader::Open(QString path) setStatus(LIVE); return 1; } - QString ext = path.section(".",1); + QString ext = path.section(".", -1); // find the last '.' if ((ext.compare("spo2", Qt::CaseInsensitive)==0) || (ext.compare("spo", Qt::CaseInsensitive)==0) || (ext.compare("spor", Qt::CaseInsensitive)==0)) { // try to read and process SpoR file.. return readSpoRFile(path) ? 1 : 0; @@ -536,17 +536,21 @@ bool CMS50Loader::readSpoRFile(QString path) { QFile file(path); if (!file.exists()) { + qWarning() << "Can't find the oximeter file: " << path; return false; } if (!file.open(QFile::ReadOnly)) { + qWarning() << "Can't open the oximeter file: " << path; return false; } bool spo2header = false; QString ext = path.section('.', -1); + qDebug() << "Oximeter file extention is " << ext; if (ext.compare("spo2",Qt::CaseInsensitive) == 0) { spo2header = true; + qDebug() << "Oximeter file looks like an SpO2 type" ; } QByteArray data; @@ -591,7 +595,7 @@ bool CMS50Loader::readSpoRFile(QString path) quint32 hour, minute, second; if (data.at(pos) != 1) { - qWarning() << ".spo2 file" << path << "might be a different"; + qWarning() << "oximeter file" << path << "might be odd format"; } // Unknown cruft header... diff --git a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp index 6bb1f5c2..84b4be32 100644 --- a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp @@ -72,7 +72,7 @@ bool CMS50F37Loader::openDevice() b = scanDevice("rfcomm", 0, 0); // Linux } if (!b) { - qDebug() << "No oximeter found"; + qWarning() << "No oximeter found"; return false; } } @@ -154,7 +154,7 @@ int CMS50F37Loader::Open(QString path) } else if (path.compare("live") == 0) { return 0; } - QString ext = path.section(".",1); + QString ext = path.section(".", -1); // find the LAST '.' if ((ext.compare("spo2", Qt::CaseInsensitive)==0) || (ext.compare("spo", Qt::CaseInsensitive)==0) || (ext.compare("spor", Qt::CaseInsensitive)==0)) { // try to read and process SpoR file.. return readSpoRFile(path) ? 1 : 0; @@ -815,7 +815,7 @@ void CMS50F37Loader::resetImportTimeout() qDebug() << "Oximeter device stopped transmitting.. Transfer complete"; // We were importing, but now are done if (!finished_import && (started_import && started_reading)) { - qDebug() << "Switching CMS50 back to live mode and finalizing import"; + qDebug() << "Switching CMS50F37 back to live mode and finalizing import"; // Turn back on live streaming so the end of capture can be dealt with @@ -835,7 +835,7 @@ void CMS50F37Loader::resetImportTimeout() return; } - qDebug() << "Should CMS50 resetImportTimeout reach here?"; + qDebug() << "Should CMS50F37 resetImportTimeout reach here?"; // else what??? } cb_reset = imp_callbacks; @@ -853,17 +853,21 @@ bool CMS50F37Loader::readSpoRFile(QString path) { QFile file(path); if (!file.exists()) { + qWarning() << "Can't find the oximeter file: " << path; return false; } if (!file.open(QFile::ReadOnly)) { + qWarning() << "Can't open the oximeter file: " << path; return false; } bool spo2header = false; QString ext = path.section('.', -1); + qDebug() << "Oximeter file extention is " << ext; if (ext.compare("spo2",Qt::CaseInsensitive) == 0) { spo2header = true; + qDebug() << "Oximeter file looks like an SpO2 type" ; } QByteArray data; @@ -897,7 +901,7 @@ bool CMS50F37Loader::readSpoRFile(QString path) QString dstr(dchr); m_startTime = QDateTime::fromString(dstr, "MM/dd/yy HH:mm:ss"); if (m_startTime.date().year() < 2000) { m_startTime = m_startTime.addYears(100); } - } else { + } else { // this should probaly find the most recent SH data day m_startTime = QDateTime(QDate::currentDate(), QTime(0,0,0)); } } else { // !spo2header diff --git a/sleepyhead/SleepLib/loader_plugins/md300w1_loader.cpp b/sleepyhead/SleepLib/loader_plugins/md300w1_loader.cpp index 41703e11..3caede48 100644 --- a/sleepyhead/SleepLib/loader_plugins/md300w1_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/md300w1_loader.cpp @@ -95,7 +95,7 @@ int MD300W1Loader::Open(QString path) setStatus(LIVE); return 1; } - QString ext = path.section(".",1); + QString ext = path.section(".", -1); // find the last '.' if (ext.compare("dat", Qt::CaseInsensitive)==0) { // try to read and process SpoR file.. return readDATFile(path) ? 1 : 0;