From 754b79b096e5c5e1cd05ca18cd957f25ec38bef5 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Tue, 5 Aug 2014 05:57:48 +1000 Subject: [PATCH] ResMed pressure storage fixes, Added Purge Machine feature back --- sleepyhead/SleepLib/day.cpp | 13 +- .../SleepLib/loader_plugins/prs1_loader.cpp | 130 ++++++++++++--- .../SleepLib/loader_plugins/resmed_loader.cpp | 153 +++++++++++++----- sleepyhead/SleepLib/machine_loader.cpp | 14 ++ sleepyhead/SleepLib/machine_loader.h | 2 + sleepyhead/SleepLib/profiles.cpp | 6 +- sleepyhead/SleepLib/schema.cpp | 17 +- sleepyhead/SleepLib/schema.h | 1 + sleepyhead/daily.cpp | 75 ++++++++- sleepyhead/docs/channels.xml | 43 ----- sleepyhead/mainwindow.cpp | 104 ++++++++---- sleepyhead/mainwindow.h | 2 + sleepyhead/mainwindow.ui | 41 +++-- 13 files changed, 422 insertions(+), 179 deletions(-) diff --git a/sleepyhead/SleepLib/day.cpp b/sleepyhead/SleepLib/day.cpp index 8273fb9c..fdaa8d1c 100644 --- a/sleepyhead/SleepLib/day.cpp +++ b/sleepyhead/SleepLib/day.cpp @@ -991,12 +991,15 @@ QString Day::getPressureRelief() ChannelID pr_level_chan = loader->PresReliefLevel(); ChannelID pr_mode_chan = loader->PresReliefMode(); - if ((pr_level_chan != NoChannel) && settingExists(pr_level_chan)) { - int pr_level = qRound(settings_wavg(pr_level_chan)); + if ((pr_mode_chan != NoChannel) && settingExists(pr_mode_chan)) { int pr_mode = qRound(settings_wavg(pr_mode_chan)); - pr_str = QObject::tr("%1%2").arg(loader->PresReliefLabel()). - arg(schema::channel[pr_mode_chan].option(pr_mode)); - if (pr_mode > 0) pr_str += QString(" %1").arg(schema::channel[pr_level_chan].option(pr_level)); + pr_str = QObject::tr("%1%2").arg(loader->PresReliefLabel()).arg(schema::channel[pr_mode_chan].option(pr_mode)); + + int pr_level = -1; + if (pr_level_chan != NoChannel && settingExists(pr_level_chan)) { + pr_level = qRound(settings_wavg(pr_level_chan)); + } + if (pr_level >= 0) pr_str += QString(" %1").arg(schema::channel[pr_level_chan].option(pr_level)); } else pr_str = STR_TR_None; return pr_str; } diff --git a/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp b/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp index d006783c..bef60844 100644 --- a/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp @@ -2000,7 +2000,7 @@ void PRS1Loader::Register() "PRS1FlexMode", QObject::tr("Flex Mode"), QObject::tr("PRS1 pressure relief mode."), QObject::tr("Flex Mode"), - "", DEFAULT, Qt::green)); + "", LOOKUP, Qt::green)); chan->addOption(FLEX_None, STR_TR_None); @@ -2015,35 +2015,121 @@ void PRS1Loader::Register() QObject::tr("Flex Level"), QObject::tr("PRS1 pressure relief setting."), QObject::tr("Flex Level"), - "", DEFAULT, Qt::blue)); + "", LOOKUP, Qt::blue)); chan->addOption(0, STR_TR_Off); chan->addOption(1, QObject::tr("x1")); chan->addOption(2, QObject::tr("x2")); chan->addOption(3, QObject::tr("x3")); - - channel.add(GRP_CPAP, chan = new Channel(PRS1_HumidStatus = 0xe101, SETTING, SESSION, - "PRS1HumidStat", - QObject::tr("Humidifier Status"), - QObject::tr("PRS1 humidifier connected?"), - QObject::tr("Humidifier Status"), - "", DEFAULT, Qt::green)); - chan->addOption(0, STR_TR_No); - chan->addOption(1, STR_TR_Yes); - - channel.add(GRP_CPAP, chan = new Channel(PRS1_HumidLevel = 0xe102, SETTING, SESSION, - "PRS1HumidLevel", - QObject::tr("Humidification Level"), - QObject::tr("PRS1 Humidification level"), - QObject::tr("Humid. Lvl."), - "", DEFAULT, Qt::green)); - chan->addOption(0, STR_TR_Off); - chan->addOption(1, QObject::tr("x1")); - chan->addOption(2, QObject::tr("x2")); - chan->addOption(3, QObject::tr("x3")); chan->addOption(4, QObject::tr("x4")); chan->addOption(5, QObject::tr("x5")); + channel.add(GRP_CPAP, chan = new Channel(PRS1_HumidStatus = 0xe101, SETTING, SESSION, + "PRS1HumidStat", + QObject::tr("Humidifier Status"), + QObject::tr("PRS1 humidifier connected?"), + QObject::tr("Humidifier Status"), + "", LOOKUP, Qt::green)); + chan->addOption(0, QObject::tr("Disconnected")); + chan->addOption(1, QObject::tr("Connected")); + + channel.add(GRP_CPAP, chan = new Channel(PRS1_HumidLevel = 0xe102, SETTING, SESSION, + "PRS1HumidLevel", + QObject::tr("Humidification Level"), + QObject::tr("PRS1 Humidification level"), + QObject::tr("Humid. Lvl."), + "", LOOKUP, Qt::green)); + chan->addOption(0, STR_TR_Off); + chan->addOption(1, QObject::tr("x1")); + chan->addOption(2, QObject::tr("x2")); + chan->addOption(3, QObject::tr("x3")); + chan->addOption(4, QObject::tr("x4")); + chan->addOption(5, QObject::tr("x5")); + + channel.add(GRP_CPAP, chan = new Channel(PRS1_SysOneResistStat = 0xe103, SETTING, SESSION, + "SysOneResistStat", + QObject::tr("System One Resistance Status"), + QObject::tr("System One Resistance Status"), + QObject::tr("Sys1 Resist. Status"), + "", LOOKUP, Qt::green)); + chan->addOption(0, STR_TR_Off); + chan->addOption(1, STR_TR_On); + + channel.add(GRP_CPAP, chan = new Channel(PRS1_SysOneResistSet = 0xe104, SETTING, SESSION, + "SysOneResistSet", + QObject::tr("System One Resistance Setting"), + QObject::tr("System One Mask Resistance Setting"), + QObject::tr("Sys1 Resist. Set"), + "", LOOKUP, Qt::green)); + chan->addOption(0, STR_TR_Off); + chan->addOption(1, QObject::tr("x1")); + chan->addOption(2, QObject::tr("x2")); + chan->addOption(3, QObject::tr("x3")); + chan->addOption(4, QObject::tr("x4")); + chan->addOption(5, QObject::tr("x5")); + + channel.add(GRP_CPAP, chan = new Channel(PRS1_HoseDiam = 0xe107, SETTING, SESSION, + "PRS1HoseDiam", + QObject::tr("Hose Diameter"), + QObject::tr("Diameter of primary CPAP hose"), + QObject::tr("Hose Diameter"), + "", LOOKUP, Qt::green)); + chan->addOption(0, QObject::tr("22mm")); + chan->addOption(1, QObject::tr("15mm")); + + channel.add(GRP_CPAP, chan = new Channel(PRS1_SysOneResistStat = 0xe108, SETTING, SESSION, + "SysOneLock", + QObject::tr("System One Resistance Lock"), + QObject::tr("Whether System One resistance settings are available to you."), + QObject::tr("Sys1 Resist. Lock"), + "", LOOKUP, Qt::green)); + chan->addOption(0, STR_TR_Off); + chan->addOption(1, STR_TR_On); + + channel.add(GRP_CPAP, chan = new Channel(PRS1_AutoOn = 0xe109, SETTING, SESSION, + "PRS1AutoOn", + QObject::tr("Auto On"), + QObject::tr("A few breaths automatically starts machine"), + QObject::tr("Auto On"), + "", LOOKUP, Qt::green)); + chan->addOption(0, STR_TR_Off); + chan->addOption(1, STR_TR_On); + + channel.add(GRP_CPAP, chan = new Channel(PRS1_AutoOff = 0xe10a, SETTING, SESSION, + "PRS1AutoOff", + QObject::tr("Auto Off"), + QObject::tr("Machine automatically switches off"), + QObject::tr("Auto Off"), + "", LOOKUP, Qt::green)); + chan->addOption(0, STR_TR_Off); + chan->addOption(1, STR_TR_On); + + channel.add(GRP_CPAP, chan = new Channel(PRS1_MaskAlert = 0xe10b, SETTING, SESSION, + "PRS1MaskAlert", + QObject::tr("Mask Alert"), + QObject::tr("Whether or not machine allows Mask checking."), + QObject::tr("Mask Alert"), + "", LOOKUP, Qt::green)); + chan->addOption(0, STR_TR_Off); + chan->addOption(1, STR_TR_On); + + channel.add(GRP_CPAP, chan = new Channel(PRS1_MaskAlert = 0xe10c, SETTING, SESSION, + "PRS1ShowAHI", + QObject::tr("Show AHI"), + QObject::tr("Whether or not machine shows AHI via LCD panel."), + QObject::tr("Show AHI"), + "", LOOKUP, Qt::green)); + chan->addOption(0, STR_TR_Off); + chan->addOption(1, STR_TR_On); + +// +// + + QString unknowndesc=QObject::tr("Unknown PRS1 Code %1"); QString unknownname=QObject::tr("PRS1_%1"); diff --git a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp index 067987d7..00c1bb93 100644 --- a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp @@ -718,26 +718,59 @@ void ResmedImport::run() // Save maskon time in session setting so we can use it later to avoid doubleups. sess->settings[RMS9_MaskOnTime] = R.maskon; - // Grab all the system settings - if (R.set_pressure >= 0) sess->settings[CPAP_Pressure] = R.set_pressure; - if (R.min_pressure >= 0) sess->settings[CPAP_PressureMin] = R.min_pressure; - if (R.max_pressure >= 0) sess->settings[CPAP_PressureMax] = R.max_pressure; - if (R.ps >= 0) sess->settings[CPAP_PS] = R.ps; - if (R.min_ps >= 0) sess->settings[CPAP_PSMin] = R.min_ps; - if (R.max_ps >= 0) sess->settings[CPAP_PSMax] = R.max_ps; - if (R.epap >= 0) sess->settings[CPAP_EPAP] = R.epap; - if (R.max_epap >= 0) sess->settings[CPAP_EPAPHi] = R.max_epap; - if (R.min_epap >= 0) sess->settings[CPAP_EPAPLo] = R.min_epap; - if (R.ipap >= 0) sess->settings[CPAP_IPAP] = R.ipap; - if (R.max_ipap >= 0) sess->settings[CPAP_IPAPHi] = R.max_ipap; - if (R.min_ipap >= 0) sess->settings[CPAP_IPAPLo] = R.min_ipap; - if (R.mode >= 0) sess->settings[CPAP_Mode] = R.mode; + if (R.mode >= 0) { + sess->settings[CPAP_Mode] = R.mode; + if (R.mode == MODE_CPAP) { + if (R.set_pressure >= 0) { + sess->settings[CPAP_Pressure] = R.set_pressure; + } + } else if (R.mode == MODE_APAP) { + if (R.min_pressure >= 0) sess->settings[CPAP_PressureMin] = R.min_pressure; + if (R.max_pressure >= 0) sess->settings[CPAP_PressureMax] = R.max_pressure; + } else if (R.mode == MODE_BILEVEL_FIXED) { + if (R.epap >= 0) sess->settings[CPAP_EPAP] = R.epap; + if (R.ipap >= 0) sess->settings[CPAP_IPAP] = R.ipap; + if (R.ps >= 0) sess->settings[CPAP_PS] = R.ps; + } else if (R.mode == MODE_BILEVEL_AUTO_FIXED_PS) { + if (R.min_epap >= 0) sess->settings[CPAP_EPAPLo] = R.min_epap; + if (R.max_ipap >= 0) sess->settings[CPAP_IPAPHi] = R.max_ipap; + if (R.ps >= 0) sess->settings[CPAP_PS] = R.ps; + } else if (R.mode == MODE_ASV) { + if (R.epap >= 0) sess->settings[CPAP_EPAP] = R.epap; + if (R.min_ps >= 0) sess->settings[CPAP_PSMin] = R.min_ps; + if (R.max_ps >= 0) sess->settings[CPAP_PSMax] = R.max_ps; + if (R.max_ipap >= 0) sess->settings[CPAP_IPAPHi] = R.max_ipap; + } else if (R.mode == MODE_ASV_VARIABLE_EPAP) { + if (R.max_epap >= 0) sess->settings[CPAP_EPAPHi] = R.max_epap; + if (R.min_epap >= 0) sess->settings[CPAP_EPAPLo] = R.min_epap; + if (R.max_ipap >= 0) sess->settings[CPAP_IPAPHi] = R.max_ipap; + if (R.min_ipap >= 0) sess->settings[CPAP_IPAPLo] = R.min_ipap; + if (R.min_ps >= 0) sess->settings[CPAP_PSMin] = R.min_ps; + if (R.max_ps >= 0) sess->settings[CPAP_PSMax] = R.max_ps; + } + } else { + if (R.set_pressure >= 0) sess->settings[CPAP_Pressure] = R.set_pressure; + if (R.min_pressure >= 0) sess->settings[CPAP_PressureMin] = R.min_pressure; + if (R.max_pressure >= 0) sess->settings[CPAP_PressureMax] = R.max_pressure; + if (R.max_epap >= 0) sess->settings[CPAP_EPAPHi] = R.max_epap; + if (R.min_epap >= 0) sess->settings[CPAP_EPAPLo] = R.min_epap; + if (R.max_ipap >= 0) sess->settings[CPAP_IPAPHi] = R.max_ipap; + if (R.min_ipap >= 0) sess->settings[CPAP_IPAPLo] = R.min_ipap; + if (R.min_ps >= 0) sess->settings[CPAP_PSMin] = R.min_ps; + if (R.max_ps >= 0) sess->settings[CPAP_PSMax] = R.max_ps; + if (R.ps >= 0) sess->settings[CPAP_PS] = R.ps; + if (R.epap >= 0) sess->settings[CPAP_EPAP] = R.epap; + if (R.ipap >= 0) sess->settings[CPAP_IPAP] = R.ipap; + } if (R.epr >= 0) { sess->settings[RMS9_EPR] = (int)R.epr; - } - if (R.epr_level >= 0) { - sess->settings[RMS9_EPRLevel] = (int)R.epr_level; + if (R.epr > 0) { + if (R.epr_level >= 0) { + sess->settings[RMS9_EPRLevel] = (int)R.epr_level; + } + } + } // Ignore all the rest of the sumary data, because there is enough available to calculate it with higher accuracy. @@ -784,25 +817,60 @@ void ResmedImportStage2::run() sess->SetChanged(true); // First take the settings - if (R.set_pressure >= 0) - sess->settings[CPAP_Pressure] = R.set_pressure; - if (R.min_pressure >= 0) sess->settings[CPAP_PressureMin] = R.min_pressure; - if (R.max_pressure >= 0) sess->settings[CPAP_PressureMax] = R.max_pressure; - if (R.ps >= 0) sess->settings[CPAP_PS] = R.ps; - if (R.min_ps >= 0) sess->settings[CPAP_PSMin] = R.min_ps; - if (R.max_ps >= 0) sess->settings[CPAP_PSMax] = R.max_ps; - if (R.epap >= 0) sess->settings[CPAP_EPAP] = R.epap; - if (R.max_epap >= 0) sess->settings[CPAP_EPAPHi] = R.max_epap; - if (R.min_epap >= 0) sess->settings[CPAP_EPAPLo] = R.min_epap; - if (R.ipap >= 0) sess->settings[CPAP_IPAP] = R.ipap; - if (R.max_ipap >= 0) sess->settings[CPAP_IPAPHi] = R.max_ipap; - if (R.min_ipap >= 0) sess->settings[CPAP_IPAPLo] = R.min_ipap; - if (R.mode >= 0) sess->settings[CPAP_Mode] = R.mode; + + if (R.mode >= 0) { + sess->settings[CPAP_Mode] = R.mode; + if (R.mode == MODE_CPAP) { + if (R.set_pressure >= 0) { + sess->settings[CPAP_Pressure] = R.set_pressure; + } + } else if (R.mode == MODE_APAP) { + if (R.min_pressure >= 0) sess->settings[CPAP_PressureMin] = R.min_pressure; + if (R.max_pressure >= 0) sess->settings[CPAP_PressureMax] = R.max_pressure; + } else if (R.mode == MODE_BILEVEL_FIXED) { + if (R.epap >= 0) sess->settings[CPAP_EPAP] = R.epap; + if (R.ipap >= 0) sess->settings[CPAP_IPAP] = R.ipap; + if (R.ps >= 0) sess->settings[CPAP_PS] = R.ps; + } else if (R.mode == MODE_BILEVEL_AUTO_FIXED_PS) { + if (R.min_epap >= 0) sess->settings[CPAP_EPAPLo] = R.min_epap; + if (R.max_ipap >= 0) sess->settings[CPAP_IPAPHi] = R.max_ipap; + if (R.ps >= 0) sess->settings[CPAP_PS] = R.ps; + } else if (R.mode == MODE_ASV) { + if (R.epap >= 0) sess->settings[CPAP_EPAP] = R.epap; + if (R.min_ps >= 0) sess->settings[CPAP_PSMin] = R.min_ps; + if (R.max_ps >= 0) sess->settings[CPAP_PSMax] = R.max_ps; + if (R.max_ipap >= 0) sess->settings[CPAP_IPAPHi] = R.max_ipap; + } else if (R.mode == MODE_ASV_VARIABLE_EPAP) { + if (R.max_epap >= 0) sess->settings[CPAP_EPAPHi] = R.max_epap; + if (R.min_epap >= 0) sess->settings[CPAP_EPAPLo] = R.min_epap; + if (R.max_ipap >= 0) sess->settings[CPAP_IPAPHi] = R.max_ipap; + if (R.min_ipap >= 0) sess->settings[CPAP_IPAPLo] = R.min_ipap; + if (R.min_ps >= 0) sess->settings[CPAP_PSMin] = R.min_ps; + if (R.max_ps >= 0) sess->settings[CPAP_PSMax] = R.max_ps; + } + } else { + if (R.set_pressure >= 0) sess->settings[CPAP_Pressure] = R.set_pressure; + if (R.min_pressure >= 0) sess->settings[CPAP_PressureMin] = R.min_pressure; + if (R.max_pressure >= 0) sess->settings[CPAP_PressureMax] = R.max_pressure; + if (R.max_epap >= 0) sess->settings[CPAP_EPAPHi] = R.max_epap; + if (R.min_epap >= 0) sess->settings[CPAP_EPAPLo] = R.min_epap; + if (R.max_ipap >= 0) sess->settings[CPAP_IPAPHi] = R.max_ipap; + if (R.min_ipap >= 0) sess->settings[CPAP_IPAPLo] = R.min_ipap; + if (R.min_ps >= 0) sess->settings[CPAP_PSMin] = R.min_ps; + if (R.max_ps >= 0) sess->settings[CPAP_PSMax] = R.max_ps; + if (R.ps >= 0) sess->settings[CPAP_PS] = R.ps; + if (R.epap >= 0) sess->settings[CPAP_EPAP] = R.epap; + if (R.ipap >= 0) sess->settings[CPAP_IPAP] = R.ipap; + } + + if (R.epr >= 0) { sess->settings[RMS9_EPR] = (int)R.epr; - } - if (R.epr_level >= 0) { - sess->settings[RMS9_EPRLevel] = (int)R.epr_level; + if (R.epr > 0) { + if (R.epr_level >= 0) { + sess->settings[RMS9_EPRLevel] = (int)R.epr_level; + } + } } if (R.leakmax >= 0) sess->setMax(CPAP_Leak, R.leakmax); if (R.leakmax >= 0) sess->setMin(CPAP_Leak, 0); @@ -2373,16 +2441,14 @@ void ResmedLoader::Register() qDebug() << "Registering ResmedLoader"; RegisterLoader(new ResmedLoader()); - ResInitModelMap(); - resmed_initialized = true; using namespace schema; Channel * chan = nullptr; channel.add(GRP_CPAP, chan = new Channel(RMS9_EPR = 0xe201, SETTING, SESSION, - "EPR", QObject::tr("EPR Mode"), - QObject::tr("ResMed Exhale Pressure Relief Mode."), - QObject::tr("EPR Mode"), - "", DEFAULT, Qt::green)); + "EPR", QObject::tr("EPR"), + QObject::tr("ResMed Exhale Pressure Relief"), + QObject::tr("EPR"), + "", LOOKUP, Qt::green)); chan->addOption(0, STR_TR_Off); @@ -2393,13 +2459,16 @@ void ResmedLoader::Register() "EPRLevel", QObject::tr("EPR Level"), QObject::tr("Exhale Pressure Relief Level"), QObject::tr("EPR Level"), - "", DEFAULT, Qt::blue)); + "", LOOKUP, Qt::blue)); chan->addOption(0, QObject::tr("0cmH2O")); chan->addOption(1, QObject::tr("1cmH2O")); chan->addOption(2, QObject::tr("2cmH2O")); chan->addOption(3, QObject::tr("3cmH2O")); - chan->addOption(4, QObject::tr("Patient")); + chan->addOption(4, QObject::tr("Patient")); // Think this isn't real.. + + ResInitModelMap(); + resmed_initialized = true; } //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/sleepyhead/SleepLib/machine_loader.cpp b/sleepyhead/SleepLib/machine_loader.cpp index 5de9034d..23d410ce 100644 --- a/sleepyhead/SleepLib/machine_loader.cpp +++ b/sleepyhead/SleepLib/machine_loader.cpp @@ -51,6 +51,20 @@ MachineLoader * lookupLoader(Machine * m) QHash > MachineList; +void MachineLoader::removeMachine(Machine * m) +{ + m_machlist.removeAll(m); + QHash >::iterator mlit = MachineList.find(m->loaderName()); + + if (mlit != MachineList.end()) { + QHash::iterator mit = mlit.value().find(m->serial()); + if (mit != mlit.value().end()) { + mlit.value().erase(mit); + } + } + +} + Machine * MachineLoader::CreateMachine(MachineInfo info, MachineID id) { Q_ASSERT(p_profile != nullptr); diff --git a/sleepyhead/SleepLib/machine_loader.h b/sleepyhead/SleepLib/machine_loader.h index ee96bde8..bfe520f5 100644 --- a/sleepyhead/SleepLib/machine_loader.h +++ b/sleepyhead/SleepLib/machine_loader.h @@ -84,6 +84,8 @@ class MachineLoader: public QObject QMutex sessionMutex; QMutex saveMutex; + void removeMachine(Machine * m); + signals: void updateProgress(int cnt, int total); diff --git a/sleepyhead/SleepLib/profiles.cpp b/sleepyhead/SleepLib/profiles.cpp index 5eb405cc..fe414d33 100644 --- a/sleepyhead/SleepLib/profiles.cpp +++ b/sleepyhead/SleepLib/profiles.cpp @@ -508,7 +508,8 @@ void Profile::AddMachine(Machine *m) } machlist[m->id()] = m; -}; +} + void Profile::DelMachine(Machine *m) { if (!m) { @@ -516,8 +517,9 @@ void Profile::DelMachine(Machine *m) return; } + m->loader()->removeMachine(m); machlist.erase(machlist.find(m->id())); -}; +} // Potential Memory Leak Here.. diff --git a/sleepyhead/SleepLib/schema.cpp b/sleepyhead/SleepLib/schema.cpp index ae0930f1..2bb8154c 100644 --- a/sleepyhead/SleepLib/schema.cpp +++ b/sleepyhead/SleepLib/schema.cpp @@ -118,11 +118,11 @@ void init() schema::channel.add(GRP_CPAP, new Channel(CPAP_PressureMin = 0x1020, SETTING, SESSION, "PressureMin", QObject::tr("Min Pressure") , QObject::tr("Minimum Therapy Pressure"), - QObject::tr("Pr. Min"), STR_UNIT_CMH2O, DEFAULT, QColor("black"))); + QObject::tr("Pressure Min"), STR_UNIT_CMH2O, DEFAULT, QColor("black"))); schema::channel.add(GRP_CPAP, new Channel(CPAP_PressureMax = 0x1021, SETTING, SESSION, "PressureMax", QObject::tr("Max Pressure"), QObject::tr("Maximum Therapy Pressure"), - QObject::tr("Pr. Max"), STR_UNIT_CMH2O, DEFAULT, QColor("black"))); + QObject::tr("Pressure Max"), STR_UNIT_CMH2O, DEFAULT, QColor("black"))); schema::channel.add(GRP_CPAP, new Channel(CPAP_RampTime = 0x1022, SETTING, SESSION, "RampTime", QObject::tr("Ramp Time") , QObject::tr("Ramp Delay Period"), @@ -130,7 +130,7 @@ void init() schema::channel.add(GRP_CPAP, new Channel(CPAP_RampPressure = 0x1023, SETTING, SESSION, "RampPressure", QObject::tr("Ramp Pressure"), QObject::tr("Starting Ramp Pressure"), - QObject::tr("Ramp Pr."), STR_UNIT_CMH2O, DEFAULT, QColor("black"))); + QObject::tr("Ramp Pressure"), STR_UNIT_CMH2O, DEFAULT, QColor("black"))); schema::channel.add(GRP_CPAP, new Channel(CPAP_Ramp = 0x1027, SPAN, SESSION, @@ -398,7 +398,8 @@ void init() Channel *ch; schema::channel.add(GRP_CPAP, ch = new Channel(CPAP_Mode = 0x1200, SETTING, SESSION, "PAPMode", QObject::tr("PAP Mode"), - QObject::tr("PAP Mode"), QObject::tr("PAP_Mode"), STR_UNIT_Unknown, + QObject::tr("PAP Device Mode"), + QObject::tr("PAP Mode"), QString(), LOOKUP, Qt::black)); ch->addOption(0, STR_TR_Unknown); @@ -478,14 +479,6 @@ void init() RMS9_E02 = schema::channel["RMS9_E02"].id(); RMS9_SetPressure = schema::channel["SetPressure"].id(); // TODO: this isn't needed anymore CPAP_HumidSetting = schema::channel["HumidSet"].id(); - PRS1_SysLock = schema::channel["SysLock"].id(); - PRS1_SysOneResistStat = schema::channel["SysOneResistStat"].id(); - PRS1_SysOneResistSet = schema::channel["SysOneResistSet"].id(); - PRS1_HoseDiam = schema::channel["HoseDiam"].id(); - PRS1_AutoOn = schema::channel["AutoOn"].id(); - PRS1_AutoOff = schema::channel["AutoOff"].id(); - PRS1_MaskAlert = schema::channel["MaskAlert"].id(); - PRS1_ShowAHI = schema::channel["ShowAHI"].id(); INTELLIPAP_Unknown1 = schema::channel["IntUnk1"].id(); INTELLIPAP_Unknown2 = schema::channel["IntUnk2"].id(); // OXI_Pulse=schema::channel["Pulse"].id(); diff --git a/sleepyhead/SleepLib/schema.h b/sleepyhead/SleepLib/schema.h index ec704216..77b5d2d4 100644 --- a/sleepyhead/SleepLib/schema.h +++ b/sleepyhead/SleepLib/schema.h @@ -61,6 +61,7 @@ class Channel const int &id() { return m_id; } const ChanType &type() { return m_type; } + const DataType &datatype() { return m_datatype; } const QString &code() { return m_code; } const QString &fullname() { return m_fullname; } const QString &description() { return m_description; } diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index b45c44e9..abf17260 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -65,8 +65,10 @@ Daily::Daily(QWidget *parent,gGraphView * shared) lastcpapday=nullptr; QList a; - a.push_back(300); - a.push_back(this->width()-300); + + int panel_width = 350; + a.push_back(panel_width); + a.push_back(this->width() - panel_width); ui->splitter_2->setStretchFactor(1,1); ui->splitter_2->setSizes(a); ui->splitter_2->setStretchFactor(1,1); @@ -933,7 +935,7 @@ QString Daily::getSessionInformation(Day * cpap, Day * oxi, Day * stage, Day * p sess->settings[SESSION_ENABLED]=true; } bool b=sess->settings[SESSION_ENABLED].toBool(); - html+=QString("" + html+=QString("" "" "" "%5" @@ -970,7 +972,64 @@ QString Daily::getMachineSettings(Day * cpap) { return html; } - ChannelID pr_level_chan = NoChannel; + QMap other; + QHash::iterator it = cpap->sessions.at(0)->settings.begin(); + QHash::iterator it_end = cpap->sessions.at(0)->settings.end(); + QMap first; + for (; it != it_end; ++it) { + ChannelID code = it.key(); + + if ((code <= 1) || (code == RMS9_MaskOnTime)) continue; + + schema::Channel & chan = schema::channel[code]; + + QString data; + + if (chan.datatype() == schema::LOOKUP) { + data = chan.option(it.value().toInt()); + } else if (chan.datatype() == schema::BOOL) { + data = (it.value().toBool() ? STR_TR_Yes : STR_TR_No); + } else if (chan.datatype() == schema::DOUBLE) { + data = QString().number(it.value().toDouble(),'f',1) + " "+chan.units(); + } else { + data = it.value().toString() + " "+ chan.units(); + } + QString tmp = QString("%1%2%3") + .arg(schema::channel[code].label()) + .arg(schema::channel[code].description()) + .arg(data); + + + if ((code == CPAP_Mode) + || (code == CPAP_IPAP) + || (code == CPAP_EPAP) + || (code == CPAP_IPAPHi) + || (code == CPAP_EPAPHi) + || (code == CPAP_IPAPLo) + || (code == CPAP_EPAPLo) + || (code == CPAP_PressureMin) + || (code == CPAP_PressureMax) + || (code == CPAP_Pressure) + || (code == CPAP_PSMin) + || (code == CPAP_PSMax) + || (code == CPAP_PS)) { + first[code] = tmp; + } else { + other[schema::channel[code].label()] = tmp; + } + } + + ChannelID order[] = { CPAP_Mode, CPAP_Pressure, CPAP_PressureMin, CPAP_PressureMax, CPAP_EPAP, CPAP_EPAPLo, CPAP_EPAPHi, CPAP_IPAP, CPAP_IPAPLo, CPAP_IPAPHi, CPAP_PS, CPAP_PSMin, CPAP_PSMax }; + int os = sizeof(order) / sizeof(ChannelID); + for (int i=0 ;i < os; ++i) { + if (first.contains(order[i])) html += first[order[i]]; + } + + for (QMap::iterator it = other.begin(); it != other.end(); ++it) { + html += it.value(); + } + + /* ChannelID pr_level_chan = NoChannel; ChannelID pr_mode_chan = NoChannel; ChannelID hum_stat_chan = NoChannel; ChannelID hum_level_chan = NoChannel; @@ -997,7 +1056,7 @@ QString Daily::getMachineSettings(Day * cpap) { html+=QString(""+schema::channel[hum_level_chan].label()+"%1%2") .arg(schema::channel[hum_level_chan].description()) .arg(humid == 0 ? STR_GEN_Off : "x"+QString::number(humid)); - } + } */ html+=""; html+="
\n"; } @@ -1150,7 +1209,7 @@ QString Daily::getStatisticsInfo(Day * cpap,Day * oxi,Day *pos) } } - html+=QString("%1%6%2%3%4%5") + html+=QString("%1%6%2%3%4%5") .arg(schema::channel[code].label()) .arg(mn,0,'f',2) .arg(med,0,'f',2) @@ -1282,6 +1341,10 @@ void Daily::Load(QDate date) QString html="" "" "