From 6f3adfdcbe0f63ef5f14c9e40cc944ee6c9af45a Mon Sep 17 00:00:00 2001 From: Guy Scharf Date: Mon, 2 Aug 2021 16:36:28 -0700 Subject: [PATCH] Fix Pressure Relief column on Statistics page for SleepStyle machines --- oscar/SleepLib/day.cpp | 25 +++++++++++++++++++ .../loader_plugins/sleepstyle_loader.cpp | 14 ++++++++--- .../loader_plugins/sleepstyle_loader.h | 7 +++--- oscar/VERSION | 2 +- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/oscar/SleepLib/day.cpp b/oscar/SleepLib/day.cpp index 30b97cc1..740f7899 100644 --- a/oscar/SleepLib/day.cpp +++ b/oscar/SleepLib/day.cpp @@ -1514,6 +1514,31 @@ QString Day::getPressureRelief() ChannelID pr_level_chan = loader->PresReliefLevel(); ChannelID pr_mode_chan = loader->PresReliefMode(); + // Separate calculation for SleepStyle machines + if (mach->info.loadername == "SleepStyle") { + pr_str = loader->PresReliefLabel(); + + int pr_level = -1; + if (pr_level_chan != NoChannel && settingExists(pr_level_chan)) { + pr_level = qRound(settings_wavg(pr_level_chan)); + } + if (pr_level == -1) + return STR_TR_None; + + if ((pr_mode_chan != NoChannel) && settingExists(pr_mode_chan)) { + schema::Channel & chan = schema::channel[pr_level_chan]; + QString level = chan.option(pr_level); + if (level.isEmpty()) { + level = QString().number(pr_level) + " " + chan.units(); + if (settings_min(pr_level_chan) != settings_max(pr_level_chan)) + level = QObject::tr("varies"); + } + pr_str += QString(" %1").arg(level); + } + + return pr_str; + } + if ((pr_mode_chan != NoChannel) && settingExists(pr_mode_chan)) { // TODO: This is an awful hack that depends on the enum ordering of the pressure relief mode. // See the comment in getCPAPModeStr(). diff --git a/oscar/SleepLib/loader_plugins/sleepstyle_loader.cpp b/oscar/SleepLib/loader_plugins/sleepstyle_loader.cpp index 0217bd6f..43b2c779 100644 --- a/oscar/SleepLib/loader_plugins/sleepstyle_loader.cpp +++ b/oscar/SleepLib/loader_plugins/sleepstyle_loader.cpp @@ -686,9 +686,12 @@ bool SleepStyleLoader::OpenSummary(Machine *mach, const QString & filename) } if (EPRLevel == 0) - sess->settings[SS_EPR] = 0; - else + sess->settings[SS_EPR] = 0; // Show EPR off + else { sess->settings[SS_EPRLevel] = EPRLevel; + sess->settings[SS_EPR] = 1; + } + sess->settings[SS_Humidity] = humidityLevel; sess->settings[SS_Ramp] = ramp; @@ -858,6 +861,7 @@ bool SleepStyleLoader::OpenDetail(Machine *mach, const QString & filename) a5 = data[idx + 6]; // [0..5] UF2, [6..7] Unknown // SenseAwake bits are in the first two bits of the last three data fields + // TODO: Confirm that the bits are in the right order a6 = (a3 >> 6) << 4 | ((a4 >> 6) << 2) | (a5 >> 6); // See if extra bits from the first two fields are used at any time (see debug later) @@ -865,6 +869,7 @@ bool SleepStyleLoader::OpenDetail(Machine *mach, const QString & filename) bitmask = 1; for (int k = 0; k < 6; k++) { // There are 6 flag sets per 2 minutes + // TODO: Modify if all four channels are to be reported separately if (a1 & bitmask) { A->AddEvent(ti+60000, 0); } // Grouped by F&P as A if (a2 & bitmask) { A->AddEvent(ti+60000, 0); } // Grouped by F&P as A if (a3 & bitmask) { H->AddEvent(ti+60000, 0); } // Grouped by F&P as H @@ -900,6 +905,9 @@ bool SleepStyleLoader::OpenDetail(Machine *mach, const QString & filename) return 1; } +ChannelID SleepStyleLoader::PresReliefMode() { return SS_EPR; } +ChannelID SleepStyleLoader::PresReliefLevel() { return SS_EPRLevel; } + void SleepStyleLoader::initChannels() { using namespace schema; @@ -922,7 +930,7 @@ void SleepStyleLoader::initChannels() channel.add(GRP_CPAP, chan = new Channel(SS_EPRLevel = 0xf307, SETTING, MT_CPAP, SESSION, "EPRLevel-ss", QObject::tr("EPR Level"), QObject::tr("Exhale Pressure Relief Level"), QObject::tr("EPR Level"), - "", INTEGER, Qt::black)); + STR_UNIT_CMH2O, INTEGER, Qt::black)); chan->addOption(0, STR_TR_Off); channel.add(GRP_CPAP, chan = new Channel(SS_Ramp = 0xf308, SETTING, MT_CPAP, SESSION, diff --git a/oscar/SleepLib/loader_plugins/sleepstyle_loader.h b/oscar/SleepLib/loader_plugins/sleepstyle_loader.h index 9196d0ce..cc576e73 100644 --- a/oscar/SleepLib/loader_plugins/sleepstyle_loader.h +++ b/oscar/SleepLib/loader_plugins/sleepstyle_loader.h @@ -94,9 +94,10 @@ class SleepStyleLoader : public CPAPLoader //////////////////////////////////////////////////////////////////////////////////////////////////////////// // Now for some CPAPLoader overrides //////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual QString presRelType() { return QObject::tr("EPR"); } - virtual ChannelID presReliefMode() { return SS_EPR; } - virtual ChannelID PresReliefLevel() { return SS_EPRLevel; } +// virtual QString presRelType() { return QObject::tr("EPR"); } + virtual QString PresReliefLabel() { return QObject::tr("EPR: "); } + virtual ChannelID PresReliefMode(); + virtual ChannelID PresReliefLevel(); //////////////////////////////////////////////////////////////////////////////////////////////////////////// protected: diff --git a/oscar/VERSION b/oscar/VERSION index 0873c54f..52cf5906 100644 --- a/oscar/VERSION +++ b/oscar/VERSION @@ -1,4 +1,4 @@ // Update the string below to set OSCAR's version and release status. // See https://semver.org/spec/v2.0.0.html for details on format. -#define VERSION "1.2.1-alpha.2" +#define VERSION "1.2.1-alpha.3"