diff --git a/oscar/SleepLib/loader_plugins/prs1_loader.cpp b/oscar/SleepLib/loader_plugins/prs1_loader.cpp index 878e6d5d..a8ddff75 100644 --- a/oscar/SleepLib/loader_plugins/prs1_loader.cpp +++ b/oscar/SleepLib/loader_plugins/prs1_loader.cpp @@ -6647,10 +6647,12 @@ bool PRS1DataChunk::ParseSettingsF0V6(const unsigned char* data, int size) CHECK_VALUE(data[pos], 0x80); // EZ-Start enabled this->AddEvent(new PRS1ParsedSettingEvent(PRS1_SETTING_EZ_START, data[pos] != 0)); break; - case 0x42: // EZ-Start for Auto-CPAP? + case 0x42: // EZ-Start enabled for Auto-CPAP? // Seen on 500X110 before 0x2b when EZ-Start is enabled on Auto-CPAP CHECK_VALUE(len, 1); - CHECK_VALUE(data[pos], 0x80); // EZ-Start enabled + CHECK_VALUES(data[pos], 0x00, 0x80); // both seem to mean enabled, 0x00 appears when Opti-Start is used instead + // TODO: How to represent which one is active in practice? Should this always be "true" since + // either value means that the setting is enabled? this->AddEvent(new PRS1ParsedSettingEvent(PRS1_SETTING_EZ_START, data[pos] != 0)); break; case 0x2b: // Ramp Type diff --git a/oscar/SleepLib/loader_plugins/resmed_loader.cpp b/oscar/SleepLib/loader_plugins/resmed_loader.cpp index a289f336..4e7cefa7 100644 --- a/oscar/SleepLib/loader_plugins/resmed_loader.cpp +++ b/oscar/SleepLib/loader_plugins/resmed_loader.cpp @@ -360,10 +360,11 @@ int ResmedLoader::Open(const QString & dirpath) // firstImportDay = lastDate.addDays(-1); } else { // Starting from new beginnings - new or purged qDebug() << "New machine or just purged"; + p_profile->forceResmedPrefs(); + mach = p_profile->CreateMachine( info ); } QDateTime ignoreBefore = p_profile->session->ignoreOlderSessionsDate(); bool ignoreOldSessions = p_profile->session->ignoreOlderSessions(); - mach = p_profile->CreateMachine( info ); if (ignoreOldSessions) firstImportDay = ignoreBefore.date(); @@ -469,11 +470,9 @@ int ResmedLoader::Open(const QString & dirpath) // We are done with the Parsed STR EDF objects, so delete them for (auto it=STRmap.begin(), end=STRmap.end(); it != end; ++it) { qDebug() << "Deleting edf of" << it.value().filename; -// sleep(1); delete it.value().edf; } qDebug() << "Finished STRmap cleanup"; -// sleep(1); /////////////////////////////////////////////////////////////////////////////////// // Create the backup folder for storing a copy of everything in.. diff --git a/oscar/SleepLib/loader_plugins/viatom_loader.cpp b/oscar/SleepLib/loader_plugins/viatom_loader.cpp index abe9db14..d6570c10 100644 --- a/oscar/SleepLib/loader_plugins/viatom_loader.cpp +++ b/oscar/SleepLib/loader_plugins/viatom_loader.cpp @@ -297,10 +297,12 @@ bool ViatomFile::ParseHeader() //int spo2_avg = header[17]; //int spo2_min = header[18]; //int spo2_3pct = header[19]; // number of events - //int spo2_4pct = header[20]; // number of events - CHECK_VALUE(header[21], 0); - //int time_under_90pct = header[22]; // in seconds - CHECK_VALUE(header[23], 0); + int spo2_4pct = header[20]; // number of events + if (header[21] > spo2_4pct) { + //CHECK_VALUE(header[21], 0); // sometimes nonzero; maybe spo2_5pct or something like that? + UNEXPECTED_VALUE(header[21], "< drops over 4%"); + } + //int time_under_90pct = header[22] | (header[23] << 8); // in seconds //int events_under_90pct = header[24]; // number of distinct events //float o2_score = header[25] * 0.1; CHECK_VALUE(header[26], 0); @@ -352,9 +354,9 @@ QList ViatomFile::ReadData() // Read all Pulse, SPO2 and Motion data do { ViatomFile::Record rec; - in >> rec.spo2 >> rec.hr >> rec.oximetry_invalid >> rec.motion >> rec._unk; + in >> rec.spo2 >> rec.hr >> rec.oximetry_invalid >> rec.motion >> rec.vibration; CHECK_VALUES(rec.oximetry_invalid, 0, 0xFF); - CHECK_VALUE(rec._unk, 0); // maybe vibration, given column label in CSV + CHECK_VALUES(rec.vibration, 0, 0x80); // 0x80 when vibration is triggered if (rec.oximetry_invalid == 0xFF) { CHECK_VALUE(rec.spo2, 0xFF); CHECK_VALUE(rec.hr, 0xFF); @@ -375,7 +377,7 @@ QList ViatomFile::ReadData() || a.hr != b.hr || a.oximetry_invalid != b.oximetry_invalid || a.motion != b.motion - || a._unk != b._unk) { + || a.vibration != b.vibration) { all_are_duplicated = false; break; } diff --git a/oscar/SleepLib/loader_plugins/viatom_loader.h b/oscar/SleepLib/loader_plugins/viatom_loader.h index a919cb64..55fe88f3 100644 --- a/oscar/SleepLib/loader_plugins/viatom_loader.h +++ b/oscar/SleepLib/loader_plugins/viatom_loader.h @@ -66,7 +66,7 @@ public: unsigned char hr; unsigned char oximetry_invalid; unsigned char motion; - unsigned char _unk; + unsigned char vibration; }; ViatomFile(QFile & file); ~ViatomFile() = default; diff --git a/oscar/SleepLib/profiles.cpp b/oscar/SleepLib/profiles.cpp index c58bd182..edf94273 100644 --- a/oscar/SleepLib/profiles.cpp +++ b/oscar/SleepLib/profiles.cpp @@ -94,14 +94,6 @@ Profile::~Profile() removeLock(); } - delete user; - delete doctor; - delete cpap; - delete oxi; - delete appearance; - delete session; - delete general; - // delete machine objects... for (auto & mach : m_machlist) { delete mach; @@ -111,6 +103,13 @@ Profile::~Profile() delete day; } + delete user; + delete doctor; + delete cpap; + delete oxi; + delete appearance; + delete session; + delete general; } bool Profile::Save(QString filename) @@ -354,7 +353,17 @@ qint64 Profile::diskSpace() return (diskSpaceSummaries()+diskSpaceEvents()+diskSpaceBackups()); } - +void Profile::forceResmedPrefs() +{ + session->setBackupCardData(true); + session->setDaySplitTime(QTime(12,0,0)); + session->setIgnoreShortSessions(0); + session->setCombineCloseSessions(0); + session->setLockSummarySessions(true); + general->setPrefCalcPercentile(95.0); // 95% + general->setPrefCalcMiddle(0); // Median (50%) + general->setPrefCalcMax(1); // 99.9th percentile max +} #if defined(Q_OS_WIN) class Environment diff --git a/oscar/SleepLib/profiles.h b/oscar/SleepLib/profiles.h index 8ba9ed74..4c218082 100644 --- a/oscar/SleepLib/profiles.h +++ b/oscar/SleepLib/profiles.h @@ -57,6 +57,9 @@ class Profile : public Preferences qint64 diskSpaceBackups(); qint64 diskSpace(); + //! \brief Force some preferences for ResMed machines + virtual void forceResmedPrefs(); + //! \brief Returns hostname that locked profile, or empty string if unlocked QString checkLock(); diff --git a/oscar/oscar.pro b/oscar/oscar.pro index 480b46fb..24a68f10 100644 --- a/oscar/oscar.pro +++ b/oscar/oscar.pro @@ -488,7 +488,10 @@ QMAKE_CXXFLAGS += -Werror # Make deprecation warnings just warnings QMAKE_CFLAGS += -Wno-error=deprecated-declarations QMAKE_CXXFLAGS += -Wno-error=deprecated-declarations - +lessThan(QT_MAJOR_VERSION,5)|lessThan(QT_MINOR_VERSION,9) { + QMAKE_CFLAGS += -Wno-error=strict-aliasing + QMAKE_CXXFLAGS += -Wno-error=strict-aliasing +} # Create a debug GUI build by adding "CONFIG+=memdebug" to your qmake command memdebug { diff --git a/oscar/preferencesdialog.cpp b/oscar/preferencesdialog.cpp index ff284be6..b8cc61c9 100644 --- a/oscar/preferencesdialog.cpp +++ b/oscar/preferencesdialog.cpp @@ -52,12 +52,20 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Profile *_profile) : channeltype[schema::UNKNOWN] = tr("Always Minor"); bool haveResMed = false; QList machines = profile->GetMachines(MT_CPAP); - for (QList::iterator it = machines.begin(); it != machines.end(); ++it) { - const QString & mclass=(*it)->loaderName(); - if (mclass == STR_MACH_ResMed) { - haveResMed = true; - break; +// qDebug() << "Machile list size is" << machines.size(); + if ( machines.size() > 0 ) { + for (QList::iterator it = machines.begin(); it != machines.end(); ++it) { + const QString & mclass=(*it)->loaderName(); + if (mclass == STR_MACH_ResMed) { + haveResMed = true; + break; + } } + } else { + if (QMessageBox::question(this, tr("No CPAP machines detected"), + tr("Will you be using a ResMed brand machine?"), + QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes ) + haveResMed = true; } #ifdef LOCK_RESMED_SESSIONS @@ -66,21 +74,13 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Profile *_profile) : ui->ResMedWarning->setVisible(haveResMed); if (haveResMed) { + profile->forceResmedPrefs(); ui->sessionSplitWidget->setVisible(!haveResMed); - profile->session->setDaySplitTime(QTime(12,0,0)); - profile->session->setIgnoreShortSessions(0); - profile->session->setCombineCloseSessions(0); - profile->session->setLockSummarySessions(true); - p_profile->general->setPrefCalcPercentile(95.0); // 95% - p_profile->general->setPrefCalcMiddle(0); // Median (50%) - p_profile->general->setPrefCalcMax(1); // 99.9th percentile max ui->prefCalcMax->setEnabled(false); ui->prefCalcMiddle->setEnabled(false); ui->prefCalcPercentile->setEnabled(false); ui->showUnknownFlags->setEnabled(false); ui->calculateUnintentionalLeaks->setEnabled(false); - - p_profile->session->setBackupCardData(true); ui->createSDBackups->setChecked(true); ui->createSDBackups->setEnabled(false); diff --git a/oscar/tests/resmedtests.cpp b/oscar/tests/resmedtests.cpp index 865bb0f5..6c6eb0c1 100644 --- a/oscar/tests/resmedtests.cpp +++ b/oscar/tests/resmedtests.cpp @@ -30,9 +30,9 @@ void ResmedTests::initTestCase(void) void ResmedTests::cleanupTestCase(void) { delete AppSetting; - delete p_pref; delete p_profile; p_profile = nullptr; + delete p_pref; } diff --git a/oscar/update_gitinfo.bat b/oscar/update_gitinfo.bat index e19b0baf..6b9314f4 100755 --- a/oscar/update_gitinfo.bat +++ b/oscar/update_gitinfo.bat @@ -1,26 +1,34 @@ @echo off setlocal EnableDelayedExpansion set DIR=%~dp0 +:::set DIR=\oscar\oscar-code\oscar\ cd %DIR% -for /f %%i in ('git rev-parse --git-dir') do set GIT_DIR=%%i -if "%GIT_DIR%"=="" goto GitDone +:: Check git in path and git directory can be found +where /Q git.exe +if errorlevel 1 goto GitFail -for /f %%i in ('git rev-parse --abbrev-ref HEAD') do set GIT_BRANCH=%%i -if "%GIT_BRANCH%"=="HEAD" set GIT_BRANCH="" -for /f %%i in ('git rev-parse --short HEAD') do set GIT_REVISION=%%i -for /f %%i in ('git diff-index --quiet HEAD --') do set GIT_INDEX=%%i -if "%GIT_INDEX%"!=="" ( - set GIT_REVISION=%GIT_REVISION%-plus - set GIT_TAG= - goto GitDone -) +git rev-parse --git-dir >nul 2>&1 +if errorlevel 1 goto GitFail -for /f %%i in ('git describe --exact-match --tags') do set GIT_TAG=%%i + for /f %%i in ('git rev-parse --abbrev-ref HEAD') do set GIT_BRANCH=%%i + if "%GIT_BRANCH%"=="HEAD" set GIT_BRANCH="" + for /f %%i in ('git rev-parse --short HEAD') do set GIT_REVISION=%%i + git diff-index --quiet HEAD -- + if %errorlevel%==0 goto GitTag + set GIT_REVISION=%GIT_REVISION%-plus + set GIT_TAG= + goto GitDone + :GitTag + for /f %%i in ('git describe --exact-match --tags') do set GIT_TAG=%%i + goto GitDone + +:GitFail + set GIT_REVISION="private" :GitDone -@echo Update_gtinfo.bat: GIT_DIR=%GIT_DIR%, GIT_BRANCH=%GIT_BRANCH%, GIT_REVISION=%GIT_REVISION%, GIT_TAG=%GIT_TAG% +@echo Update_gtinfo.bat: GIT_BRANCH=%GIT_BRANCH%, GIT_REVISION=%GIT_REVISION%, GIT_TAG=%GIT_TAG% echo // This is an auto generated file > %DIR%git_info.new @@ -34,9 +42,6 @@ if "%GIT_TAG%"=="" goto DefinesDone echo #define GIT_TAG "%GIT_TAG%" >> %DIR%git_info.new :DefinesDone -:::type %DIR%git_info.new -:::set - fc %DIR%git_info.h %DIR%git_info.new 1>nul 2>nul && del /q %DIR%git_info.new || goto NewFile goto AllDone @@ -45,3 +50,4 @@ echo Updating %DIR%git_info.h move /y %DIR%git_info.new %DIR%git_info.h :AllDone +endlocal \ No newline at end of file