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/prs1_parser_asv.cpp b/oscar/SleepLib/loader_plugins/prs1_parser_asv.cpp index a5fb6526..f13ce76c 100644 --- a/oscar/SleepLib/loader_plugins/prs1_parser_asv.cpp +++ b/oscar/SleepLib/loader_plugins/prs1_parser_asv.cpp @@ -1260,7 +1260,7 @@ bool PRS1DataChunk::ParseSettingsF5V3(const unsigned char* data, int size) breath_rate = data[pos+1]; timed_inspiration = data[pos+2]; if (breath_rate < 4 || breath_rate > 16) UNEXPECTED_VALUE(breath_rate, "4-16"); - if (timed_inspiration < 12 || timed_inspiration > 24) UNEXPECTED_VALUE(timed_inspiration, "12-24"); + if (timed_inspiration < 12 || timed_inspiration > 25) UNEXPECTED_VALUE(timed_inspiration, "12-25"); this->AddEvent(new PRS1ParsedSettingEvent(PRS1_SETTING_BACKUP_BREATH_MODE, PRS1Backup_Fixed)); this->AddEvent(new PRS1ParsedSettingEvent(PRS1_SETTING_BACKUP_BREATH_RATE, breath_rate)); // BPM this->AddEvent(new PRS1ScaledSettingEvent(PRS1_SETTING_BACKUP_TIMED_INSPIRATION, timed_inspiration, 0.1)); diff --git a/oscar/SleepLib/loader_plugins/prs1_parser_xpap.cpp b/oscar/SleepLib/loader_plugins/prs1_parser_xpap.cpp index c5643505..9f2e9b6f 100644 --- a/oscar/SleepLib/loader_plugins/prs1_parser_xpap.cpp +++ b/oscar/SleepLib/loader_plugins/prs1_parser_xpap.cpp @@ -1100,10 +1100,12 @@ bool PRS1DataChunk::ParseSettingsF0V45(const unsigned char* data, int size) // TODO: Where is altitude compensation set? We've seen it on 261CA. CHECK_VALUE(data[0x10], 0); + int autotrial_duration = data[0x11]; if (cpapmode == PRS1_MODE_AUTOTRIAL) { - CHECK_VALUE(data[0x11], 7); // 7-day duration? + CHECK_VALUES(autotrial_duration, 7, 30); + this->AddEvent(new PRS1ParsedSettingEvent(PRS1_SETTING_AUTO_TRIAL, autotrial_duration)); } else { - CHECK_VALUE(data[0x11], 0); + CHECK_VALUE(autotrial_duration, 0); } return true; 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/SleepLib/session.cpp b/oscar/SleepLib/session.cpp index 3ef97a20..6fd2e375 100644 --- a/oscar/SleepLib/session.cpp +++ b/oscar/SleepLib/session.cpp @@ -1635,6 +1635,7 @@ EventDataType Session::rangeCount(ChannelID id, qint64 first, qint64 last) if (id == AllAhiChannels) { for (int i = 0; i < ahiChannels.size(); i++) total += rangeCount(ahiChannels.at(i), first, last); + return (EventDataType)total; } QHash >::iterator j = eventlist.find(id); diff --git a/oscar/VERSION b/oscar/VERSION index 0873c54f..6883ccb0 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.4"